proxy

package
v0.2.18 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2023 License: AGPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

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

Variables

View Source
var ReservedPrefix = netip.MustParsePrefix("198.18.0.0/15")

Functions

func RelayTCP

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

func SelectTimeout

func SelectTimeout(packet []byte) time.Duration

SelectTimeout selects an appropriate timeout for UDP packet.

Types

type HijackResp

type HijackResp struct {
	Resp   []byte
	Domain string
	Type   dnsmessage.Type
	AnsIP  netip.Addr
}

type IPMapper

type IPMapper interface {
	Alloc(target string) (loopback netip.Addr)
	Get(loopback netip.Addr) (target string)
}

type LoopbackMapper

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

LoopbackMapper projects something to a loopback IP. It is not thread-safe.

func NewLoopbackMapper

func NewLoopbackMapper() *LoopbackMapper

func (*LoopbackMapper) Alloc

func (m *LoopbackMapper) Alloc(target string) (loopback netip.Addr)

func (*LoopbackMapper) Get

func (m *LoopbackMapper) Get(loopback netip.Addr) (target string)

type Proxy

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

func New

func New(logger *logrus.Logger, dialer proxy.Dialer) *Proxy

func (*Proxy) AllocProjection

func (p *Proxy) AllocProjection(target string) (loopback netip.Addr)

func (*Proxy) Close

func (p *Proxy) Close() error

func (*Proxy) GetOrBuildUDPConn

func (p *Proxy) GetOrBuildUDPConn(lAddr net.Addr, target string, data []byte) (rc net.PacketConn, err error)

GetOrBuildUDPConn get a UDP conn from the mapping.

func (*Proxy) GetProjection

func (p *Proxy) GetProjection(ip netip.Addr) (target string)

func (*Proxy) GetRealIP

func (p *Proxy) GetRealIP(fakeIP netip.Addr) (realIP netip.Addr, ok bool)

func (*Proxy) ListenAndServe

func (p *Proxy) ListenAndServe(port int) error

ListenAndServe will block the goroutine.

func (*Proxy) ListenTCP

func (p *Proxy) ListenTCP(addr string) (err error)

func (*Proxy) ListenUDP

func (p *Proxy) ListenUDP(addr string) (err error)

func (*Proxy) TCPPort

func (p *Proxy) TCPPort() int

func (*Proxy) UDPPort

func (p *Proxy) UDPPort() int

type RealIPMapper

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

func NewRealIPMapper

func NewRealIPMapper() *RealIPMapper

func (*RealIPMapper) Get

func (m *RealIPMapper) Get(fakeIP netip.Addr) (realIP netip.Addr, ok bool)

func (*RealIPMapper) Set

func (m *RealIPMapper) Set(fakeIP netip.Addr, realIP netip.Addr)

type ReservedMapper

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

ReservedMapper projects something to a reserved IP. It is not thread-safe.

func NewReservedMapper

func NewReservedMapper() *ReservedMapper

func (*ReservedMapper) Alloc

func (m *ReservedMapper) Alloc(target string) (loopback netip.Addr)

func (*ReservedMapper) Get

func (m *ReservedMapper) Get(loopback netip.Addr) (target string)

type UDPConn

type UDPConn struct {
	Establishing chan struct{}
	Timeout      time.Duration
	net.PacketConn
}

func NewUDPConn

func NewUDPConn(conn net.PacketConn) *UDPConn

type UDPConnMapping

type UDPConnMapping struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func NewUDPConnMapping

func NewUDPConnMapping() *UDPConnMapping

func (*UDPConnMapping) Get

func (m *UDPConnMapping) Get(key string) (conn *UDPConn, ok bool)

func (*UDPConnMapping) Insert

func (m *UDPConnMapping) Insert(key string, val net.PacketConn) *UDPConn

pass val=nil for stating it is establishing

func (*UDPConnMapping) Remove

func (m *UDPConnMapping) Remove(key string)

type WriteCloser

type WriteCloser interface {
	CloseWrite() error
}

Jump to

Keyboard shortcuts

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