server

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: May 12, 2022 License: AGPL-3.0 Imports: 20 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 = NewLimitedDialer(true)
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 = NewLimitedDialer(false)

Functions

func GenerateBandwidthLimit added in v0.1.15

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

func Register

func Register(name string, c Creator)

func RelayTCP added in v1.1.0

func RelayTCP(lConn, rConn net.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 net.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 proxy.Dialer, sweetLisaHost config.Lisa, arg Argument) (Server, error)

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 {
	proxy.Dialer
	// contains filtered or unexported fields
}

func NewLimitedDialer added in v1.1.3

func NewLimitedDialer(fullCone bool) *PrivateLimitedDialer

func (*PrivateLimitedDialer) Dial added in v1.1.3

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

type PrivateLimitedUDPConn added in v1.1.3

type PrivateLimitedUDPConn struct {
	*net.UDPConn
	FullCone bool
}

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 net.Addr) (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 proxy.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