proxy

package
v0.3.1-beta.5 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2022 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DiscardNetConn net.Conn = &DiscardConn{}
View Source
var DiscardNetPacketConn net.PacketConn = &DiscardPacketConn{}

Functions

func ParseIPZone

func ParseIPZone(s string) (net.IP, string)

Types

type Address

type Address interface {
	// Hostname return hostname of address, eg: www.example.com, 127.0.0.1, ff::ff
	Hostname() string
	// IP return net.IP, if address is ip else resolve the domain and return one of ips
	IP() (net.IP, error)
	// Port return port of address
	Port() Port
	// Type return type of address, domain or ip
	Type() Type

	net.Addr

	WithResolver(dns.DNS)

	Zone() string // IPv6 scoped addressing zone
	UDPAddr() (*net.UDPAddr, error)
	TCPAddr() (*net.TCPAddr, error)
	// IPHost if address is ip, return host, else resolve domain to ip and return JoinHostPort(ip,port)
	IPHost() (string, error)

	AddMark(key, value any)
	GetMark(key any) (any, bool)
	RangeMark(func(k, v any) bool)
}
var EmptyAddr Address = &emptyAddr{}

func ConvertFakeDNS

func ConvertFakeDNS(src Address, real string) Address

func ParseAddress

func ParseAddress(network, addr string) (ad Address, _ error)

func ParseAddressSplit

func ParseAddressSplit(network, addr string, por uint16) (ad Address)

func ParseIPAddr

func ParseIPAddr(ad *net.IPAddr) Address

func ParseSysAddr

func ParseSysAddr(ad net.Addr) (Address, error)

func ParseTCPAddress

func ParseTCPAddress(ad *net.TCPAddr) Address

func ParseUDPAddr

func ParseUDPAddr(ad *net.UDPAddr) Address

func ParseUnixAddr

func ParseUnixAddr(ad *net.UnixAddr) Address

type Discard

type Discard struct{}

func (*Discard) Conn

func (*Discard) Conn(Address) (net.Conn, error)

func (*Discard) PacketConn

func (*Discard) PacketConn(Address) (net.PacketConn, error)

type DiscardConn

type DiscardConn struct{}

func (*DiscardConn) Close

func (*DiscardConn) Close() error

func (*DiscardConn) LocalAddr

func (*DiscardConn) LocalAddr() net.Addr

func (*DiscardConn) Read

func (*DiscardConn) Read(b []byte) (n int, err error)

func (*DiscardConn) RemoteAddr

func (*DiscardConn) RemoteAddr() net.Addr

func (*DiscardConn) SetDeadline

func (*DiscardConn) SetDeadline(t time.Time) error

func (*DiscardConn) SetReadDeadline

func (*DiscardConn) SetReadDeadline(t time.Time) error

func (*DiscardConn) SetWriteDeadline

func (*DiscardConn) SetWriteDeadline(t time.Time) error

func (*DiscardConn) Write

func (*DiscardConn) Write(b []byte) (n int, err error)

type DiscardPacketConn

type DiscardPacketConn struct{}

func (*DiscardPacketConn) Close

func (*DiscardPacketConn) Close() error

func (*DiscardPacketConn) LocalAddr

func (*DiscardPacketConn) LocalAddr() net.Addr

func (*DiscardPacketConn) ReadFrom

func (*DiscardPacketConn) ReadFrom(p []byte) (n int, addr net.Addr, err error)

func (*DiscardPacketConn) SetDeadline

func (*DiscardPacketConn) SetDeadline(t time.Time) error

func (*DiscardPacketConn) SetReadDeadline

func (*DiscardPacketConn) SetReadDeadline(t time.Time) error

func (*DiscardPacketConn) SetWriteDeadline

func (*DiscardPacketConn) SetWriteDeadline(t time.Time) error

func (*DiscardPacketConn) WriteTo

func (*DiscardPacketConn) WriteTo(p []byte, addr net.Addr) (n int, err error)

type DomainAddr

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

func (*DomainAddr) AddMark

func (s *DomainAddr) AddMark(key, value any)

func (*DomainAddr) GetMark

func (s *DomainAddr) GetMark(key any) (any, bool)

func (*DomainAddr) Hostname

func (d *DomainAddr) Hostname() string

func (*DomainAddr) IP

func (d *DomainAddr) IP() (net.IP, error)

func (*DomainAddr) IPHost

func (d *DomainAddr) IPHost() (string, error)

func (*DomainAddr) Network

func (d *DomainAddr) Network() string

func (*DomainAddr) Port

func (d *DomainAddr) Port() Port

func (*DomainAddr) RangeMark

func (s *DomainAddr) RangeMark(f func(k, v any) bool)

func (*DomainAddr) String

func (d *DomainAddr) String() string

func (*DomainAddr) TCPAddr

func (d *DomainAddr) TCPAddr() (*net.TCPAddr, error)

func (*DomainAddr) Type

func (d *DomainAddr) Type() Type

func (*DomainAddr) UDPAddr

func (d *DomainAddr) UDPAddr() (*net.UDPAddr, error)

func (*DomainAddr) WithResolver

func (d *DomainAddr) WithResolver(resolver dns.DNS)

func (*DomainAddr) Zone

func (d *DomainAddr) Zone() string

type IPAddr

type IPAddr struct {
	Address
	// contains filtered or unexported fields
}

func (IPAddr) IP

func (i IPAddr) IP() (net.IP, error)

func (IPAddr) IPHost

func (i IPAddr) IPHost() (string, error)

func (IPAddr) TCPAddr

func (i IPAddr) TCPAddr() (*net.TCPAddr, error)

func (IPAddr) Type

func (i IPAddr) Type() Type

func (IPAddr) UDPAddr

func (i IPAddr) UDPAddr() (*net.UDPAddr, error)

func (IPAddr) Zone

func (i IPAddr) Zone() string

type PacketProxy

type PacketProxy interface {
	PacketConn(Address) (net.PacketConn, error)
}

type Port

type Port interface {
	Port() uint16
	String() string
}

type Proxy

type Proxy interface {
	StreamProxy
	PacketProxy
}
var DiscardProxy Proxy = &Discard{}

func NewErrProxy

func NewErrProxy(err error) Proxy

type ResolverProxy

type ResolverProxy interface {
	Resolver(Address) dns.DNS
}

func WrapDNS

func WrapDNS(d dns.DNS) ResolverProxy

type StreamProxy

type StreamProxy interface {
	Conn(Address) (net.Conn, error)
}

type Type

type Type string
const (
	DOMAIN Type = "DOMAIN"
	IP     Type = "IP"
	UNIX   Type = "UNIX"
	EMPTY  Type = "EMPTY"
)

Jump to

Keyboard shortcuts

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