server

package
v1.3.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 21, 2023 License: AGPL-3.0 Imports: 21 Imported by: 2

Documentation

Index

Constants

View Source
const (
	DefaultNatTimeout = 3 * time.Minute
	DnsQueryTimeout   = 17 * time.Second // RFC 5452
)
View Source
const LostThreshold = 5 * time.Minute

Variables

View Source
var ErrDialPrivateAddress = fmt.Errorf("request to dial a private address")
View Source
var (
	ErrPassageAbuse = fmt.Errorf("passage abuse")
)
View Source
var FullconePrivateLimitedDialer netproxy.Dialer
View Source
var Mapper = make(map[string]Creator)
View Source
var (
	// ProtectTime is the cooling time of a client IP changing for the same passage
	ProtectTime = map[PassageUse]time.Duration{
		PassageUseUser:    0,
		PassageUseRelay:   90 * time.Second,
		PassageUseManager: 90 * time.Second,
	}
)
View Source
var SymmetricPrivateLimitedDialer netproxy.Dialer

Functions

func GenerateBandwidthLimit added in v0.1.15

func GenerateBandwidthLimit() (l model.BandwidthLimit, err error)

func InitLimitedDialer added in v1.3.0

func InitLimitedDialer()

func Register

func Register(name string, c Creator)

func RelayTCP added in v1.1.0

func RelayTCP(lConn, rConn netproxy.Conn) (err error)

func RelayUDP added in v1.1.0

func RelayUDP(dst *net.UDPConn, laddr net.Addr, src net.PacketConn, timeout time.Duration) (err error)

func RelayUDPToConn added in v1.1.0

func RelayUDPToConn(dst netproxy.Conn, src net.PacketConn, timeout time.Duration) (err error)

func SelectTimeout added in v1.1.0

func SelectTimeout(packet []byte) time.Duration

SelectTimeout selects an appropriate timeout for UDP packet.

func SyncPassages

func SyncPassages(s Server, passages []Passage) (err error)

Types

type Argument

type Argument struct {
	Ticket string

	ServerName string
	Hostnames  string
	Port       int

	NoRelay bool
}

type ContentionCache

type ContentionCache struct {
	// contains filtered or unexported fields
}

func NewContentionCache

func NewContentionCache() *ContentionCache

func (*ContentionCache) Check

func (c *ContentionCache) Check(key string, protectTime time.Duration, ip net.IP) (accept bool, conflictIP net.IP)

Check return if the IP should be allowed for the key.

type ContentionCountdown

type ContentionCountdown struct {
	// contains filtered or unexported fields
}

type Creator

type Creator func(valueCtx context.Context, dialer netproxy.Dialer, sweetLisaHost config.Lisa, arg Argument) (Server, error)

type ForceNetworkType added in v1.3.0

type ForceNetworkType int
const (
	Force4 ForceNetworkType = iota
	Force6
	KeepOrigin
)

type LimitedDNSConn added in v1.0.0

type LimitedDNSConn struct {
	net.Conn
	// contains filtered or unexported fields
}

LimitedDNSConn adheres to RFC 7766 section 5, "Transport Protocol Selection".

func (*LimitedDNSConn) Read added in v1.0.0

func (c *LimitedDNSConn) Read(b []byte) (int, error)

func (*LimitedDNSConn) Write added in v1.0.0

func (c *LimitedDNSConn) Write(b []byte) (int, error)

type Passage

type Passage struct {
	Manager bool
	model.Passage
}

func (*Passage) Use added in v1.1.3

func (p *Passage) Use() (use PassageUse)

type PassageUse

type PassageUse string
const (
	PassageUseUser    PassageUse = "user"
	PassageUseRelay   PassageUse = "relay"
	PassageUseManager PassageUse = "manager"
)

type PrivateLimitedDialer added in v1.1.3

type PrivateLimitedDialer struct {
	// contains filtered or unexported fields
}

func NewLimitedDialer added in v1.1.3

func NewLimitedDialer(fullCone bool, forceNetwork ForceNetworkType) *PrivateLimitedDialer

func (*PrivateLimitedDialer) Dial added in v1.1.3

func (d *PrivateLimitedDialer) Dial(network, addr string) (c netproxy.Conn, err error)

func (*PrivateLimitedDialer) DialTcp added in v1.3.2

func (d *PrivateLimitedDialer) DialTcp(addr string) (c netproxy.Conn, err error)

func (*PrivateLimitedDialer) DialUdp added in v1.3.2

func (d *PrivateLimitedDialer) DialUdp(addr string) (netproxy.PacketConn, error)

type PrivateLimitedUDPConn added in v1.1.3

type PrivateLimitedUDPConn struct {
	*net.UDPConn
	FullCone bool
}

func (*PrivateLimitedUDPConn) ReadFrom added in v1.3.2

func (c *PrivateLimitedUDPConn) ReadFrom(p []byte) (n int, addr netip.AddrPort, err error)

func (*PrivateLimitedUDPConn) WriteMsgUDP added in v1.1.3

func (c *PrivateLimitedUDPConn) WriteMsgUDP(b, oob []byte, addr *net.UDPAddr) (n, oobn int, err error)

func (*PrivateLimitedUDPConn) WriteTo added in v1.1.3

func (c *PrivateLimitedUDPConn) WriteTo(b []byte, addr string) (int, error)

func (*PrivateLimitedUDPConn) WriteToUDP added in v1.1.3

func (c *PrivateLimitedUDPConn) WriteToUDP(b []byte, addr *net.UDPAddr) (int, error)

type Server

type Server interface {
	Listen(addr string) (err error)
	AddPassages(passages []Passage) (err error)
	RemovePassages(passages []Passage, alsoManager bool) (err error)
	SyncPassages(passages []Passage) (err error)
	Passages() (passages []Passage)
	io.Closer
}

func NewServer

func NewServer(valueCtx context.Context, dialer netproxy.Dialer, protocol string, sweetLisaHost config.Lisa, arg Argument) (Server, error)

type WriteCloser added in v1.1.0

type WriteCloser interface {
	CloseWrite() error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL