Documentation ¶
Index ¶
- Variables
- func DialHappyEyeballs(ctx context.Context, addr Address) (net.Conn, error)
- func Get[T any](ctx context.Context, k any) (t T, _ bool)
- func GetDefault[T any](ctx context.Context, k any, Default T) T
- func MergeBufioReaderConn(c net.Conn, r *bufio.Reader) (net.Conn, error)
- func NewBlockError(network statistic.Type, hostname string) error
- func NewMultipleReaderConn(c net.Conn, r io.Reader) net.Conn
- func NewPrefixBytesConn(c net.Conn, prefix ...*pool.Bytes) net.Conn
- func NewStore(ctx context.Context) context.Context
- func PaseNetwork(s string) statistic.Type
- type Accepter
- type Address
- func ParseAddrPort(net statistic.Type, addrPort netip.AddrPort) Address
- func ParseAddress(network statistic.Type, addr string) (ad Address, _ error)
- func ParseAddressPort(network statistic.Type, addr string, port Port) (ad Address)
- func ParseDomainPort(network statistic.Type, addr string, port Port) (ad Address)
- func ParseIPAddr(ad *net.IPAddr) Address
- func ParseIPAddrPort(net statistic.Type, ip net.IP, port int) Address
- func ParseSysAddr(ad net.Addr) (Address, error)
- func ParseTCPAddress(ad *net.TCPAddr) Address
- func ParseUDPAddr(ad *net.UDPAddr) Address
- func ParseUnixAddr(ad *net.UnixAddr) Address
- func ReadFrom(pc net.PacketConn) (*pool.Bytes, Address, error)
- type AddressSrc
- type ChannelListener
- type ChannelServer
- func (s *ChannelServer) AcceptPacket() (*Packet, error)
- func (s *ChannelServer) AcceptStream() (*StreamMeta, error)
- func (s *ChannelServer) Close() error
- func (s *ChannelServer) Context() context.Context
- func (s *ChannelServer) SendPacket(packet *Packet) error
- func (s *ChannelServer) SendStream(stream *StreamMeta) error
- type CurrentKey
- type DNSErrCode
- type DNSServer
- type DestinationKey
- type DomainAddr
- func (d *DomainAddr) AddrPort(ctx context.Context) Result[netip.AddrPort]
- func (d *DomainAddr) Hostname() string
- func (d *DomainAddr) IP(ctx context.Context) (net.IP, error)
- func (d *DomainAddr) IPs(ctx context.Context) ([]net.IP, error)
- func (d *DomainAddr) IsFqdn() bool
- func (d DomainAddr) Network() string
- func (d DomainAddr) NetworkType() statistic.Type
- func (d *DomainAddr) OverrideHostname(s string) Address
- func (d *DomainAddr) OverridePort(p Port) Address
- func (d *DomainAddr) Port() Port
- func (d DomainAddr) PreferIPv4(b bool)
- func (d DomainAddr) PreferIPv6(b bool)
- func (d DomainAddr) Resolver() Resolver
- func (d DomainAddr) SetResolver(resolver Resolver)
- func (d DomainAddr) SetSrc(src AddressSrc)
- func (d *DomainAddr) String() string
- func (d *DomainAddr) TCPAddr(ctx context.Context) Result[*net.TCPAddr]
- func (d *DomainAddr) Type() Type
- func (d *DomainAddr) UDPAddr(ctx context.Context) Result[*net.UDPAddr]
- type DynamicProxy
- type EmptyDispatch
- type ErrorResolver
- type FakeIPKey
- type ForceFakeIP
- type IPAddr
- func (d *IPAddr) AddrPort(context.Context) Result[netip.AddrPort]
- func (d *IPAddr) Hostname() string
- func (d *IPAddr) IP(context.Context) (net.IP, error)
- func (d *IPAddr) IPs(context.Context) ([]net.IP, error)
- func (d *IPAddr) IsFqdn() bool
- func (d IPAddr) Network() string
- func (d IPAddr) NetworkType() statistic.Type
- func (d *IPAddr) OverrideHostname(s string) Address
- func (d *IPAddr) OverridePort(p Port) Address
- func (d *IPAddr) Port() Port
- func (d IPAddr) PreferIPv4(b bool)
- func (d IPAddr) PreferIPv6(b bool)
- func (d IPAddr) Resolver() Resolver
- func (d IPAddr) SetResolver(resolver Resolver)
- func (d IPAddr) SetSrc(src AddressSrc)
- func (d *IPAddr) String() string
- func (d *IPAddr) TCPAddr(context.Context) Result[*net.TCPAddr]
- func (d *IPAddr) Type() Type
- func (d *IPAddr) UDPAddr(context.Context) Result[*net.UDPAddr]
- type IPAddrPort
- func (d *IPAddrPort) AddrPort(context.Context) Result[netip.AddrPort]
- func (d *IPAddrPort) Hostname() string
- func (d *IPAddrPort) IP(context.Context) (net.IP, error)
- func (d *IPAddrPort) IPs(context.Context) ([]net.IP, error)
- func (d *IPAddrPort) IsFqdn() bool
- func (d IPAddrPort) Network() string
- func (d IPAddrPort) NetworkType() statistic.Type
- func (d *IPAddrPort) OverrideHostname(s string) Address
- func (d *IPAddrPort) OverridePort(p Port) Address
- func (d *IPAddrPort) Port() Port
- func (d IPAddrPort) PreferIPv4(b bool)
- func (d IPAddrPort) PreferIPv6(b bool)
- func (d IPAddrPort) Resolver() Resolver
- func (d IPAddrPort) SetResolver(resolver Resolver)
- func (d IPAddrPort) SetSrc(src AddressSrc)
- func (d *IPAddrPort) String() string
- func (d *IPAddrPort) TCPAddr(context.Context) Result[*net.TCPAddr]
- func (d *IPAddrPort) Type() Type
- func (d *IPAddrPort) UDPAddr(context.Context) Result[*net.UDPAddr]
- type InboundKey
- type Listener
- type ListenerPatch
- type LogConn
- type LookupIPOption
- type Packet
- type PacketProxy
- type Port
- type PortUint16
- type PreferIPv6
- type ProcessDumper
- type Proxy
- type Reader
- type Resolver
- type Result
- type Server
- type SourceKey
- type Store
- type StreamMeta
- type StreamProxy
- type SystemResolver
- type Type
- type WriteBack
- type Writer
Constants ¶
This section is empty.
Variables ¶
View Source
var EmptyStore = &emptyStore{}
View Source
var ErrBlocked = errors.New("BLOCK")
Functions ¶
func DialHappyEyeballs ¶ added in v0.3.5
func MergeBufioReaderConn ¶ added in v0.3.3
func PaseNetwork ¶
Types ¶
type Accepter ¶ added in v0.3.5
type Accepter interface { Server AcceptStream() (*StreamMeta, error) AcceptPacket() (*Packet, error) }
type Address ¶
type Address interface { // Hostname return hostname of address, eg: www.example.com, 127.0.0.1, ff::ff Hostname() string IPs(context.Context) ([]net.IP, error) // IP return net.IP, if address is ip else resolve the domain and return one of ips IP(context.Context) (net.IP, error) AddrPort(context.Context) Result[netip.AddrPort] UDPAddr(context.Context) Result[*net.UDPAddr] TCPAddr(context.Context) Result[*net.TCPAddr] // Port return port of address Port() Port // Type return type of address, domain or ip Type() Type NetworkType() statistic.Type net.Addr SetSrc(AddressSrc) // SetResolver will use call IP(), IPHost(), UDPAddr(), TCPAddr() SetResolver(_ Resolver) PreferIPv6(b bool) PreferIPv4(b bool) // OverrideHostname clone address(exclude Values) and change hostname OverrideHostname(string) Address OverridePort(Port) Address IsFqdn() bool }
var EmptyAddr Address = &emptyAddr{}
func ParseAddressPort ¶
func ParseDomainPort ¶ added in v0.3.5
func ParseIPAddr ¶
func ParseIPAddrPort ¶ added in v0.3.5
func ParseTCPAddress ¶
func ParseUDPAddr ¶
func ParseUnixAddr ¶
type AddressSrc ¶ added in v0.3.4
type AddressSrc int32
const ( AddressSrcEmpty AddressSrc = 0 AddressSrcDNS AddressSrc = 1 )
type ChannelListener ¶
type ChannelListener struct {
// contains filtered or unexported fields
}
func NewChannelListener ¶
func NewChannelListener(addr net.Addr) *ChannelListener
func (*ChannelListener) Addr ¶
func (c *ChannelListener) Addr() net.Addr
func (*ChannelListener) Close ¶
func (c *ChannelListener) Close() error
func (*ChannelListener) NewConn ¶
func (c *ChannelListener) NewConn(conn net.Conn)
type ChannelServer ¶ added in v0.3.5
type ChannelServer struct {
// contains filtered or unexported fields
}
func NewChannelServer ¶ added in v0.3.5
func NewChannelServer() *ChannelServer
func (*ChannelServer) AcceptPacket ¶ added in v0.3.5
func (s *ChannelServer) AcceptPacket() (*Packet, error)
func (*ChannelServer) AcceptStream ¶ added in v0.3.5
func (s *ChannelServer) AcceptStream() (*StreamMeta, error)
func (*ChannelServer) Close ¶ added in v0.3.5
func (s *ChannelServer) Close() error
func (*ChannelServer) Context ¶ added in v0.3.5
func (s *ChannelServer) Context() context.Context
func (*ChannelServer) SendPacket ¶ added in v0.3.5
func (s *ChannelServer) SendPacket(packet *Packet) error
func (*ChannelServer) SendStream ¶ added in v0.3.5
func (s *ChannelServer) SendStream(stream *StreamMeta) error
type CurrentKey ¶
type CurrentKey struct{}
type DNSErrCode ¶ added in v0.3.3
type DNSErrCode struct {
// contains filtered or unexported fields
}
func NewDNSErrCode ¶ added in v0.3.3
func NewDNSErrCode(code dnsmessage.RCode) *DNSErrCode
func (*DNSErrCode) As ¶ added in v0.3.3
func (d *DNSErrCode) As(err any) bool
func (*DNSErrCode) Code ¶ added in v0.3.3
func (d *DNSErrCode) Code() dnsmessage.RCode
func (DNSErrCode) Error ¶ added in v0.3.3
func (d DNSErrCode) Error() string
type DNSServer ¶ added in v0.3.5
type DNSServer interface { Server HandleUDP(context.Context, net.PacketConn) error HandleTCP(context.Context, net.Conn) error Do(context.Context, *pool.Bytes, func([]byte) error) error }
var EmptyDNSServer DNSServer = &emptyHandler{}
type DestinationKey ¶
type DestinationKey struct{}
func (DestinationKey) String ¶
func (DestinationKey) String() string
type DomainAddr ¶
type DomainAddr struct {
// contains filtered or unexported fields
}
func (*DomainAddr) Hostname ¶
func (d *DomainAddr) Hostname() string
func (*DomainAddr) IsFqdn ¶ added in v0.3.4
func (d *DomainAddr) IsFqdn() bool
func (DomainAddr) NetworkType ¶
func (*DomainAddr) OverrideHostname ¶
func (d *DomainAddr) OverrideHostname(s string) Address
func (*DomainAddr) OverridePort ¶
func (d *DomainAddr) OverridePort(p Port) Address
func (*DomainAddr) Port ¶
func (d *DomainAddr) Port() Port
func (DomainAddr) PreferIPv4 ¶ added in v0.3.5
func (d DomainAddr) PreferIPv4(b bool)
func (DomainAddr) PreferIPv6 ¶
func (d DomainAddr) PreferIPv6(b bool)
func (DomainAddr) SetResolver ¶ added in v0.3.4
func (d DomainAddr) SetResolver(resolver Resolver)
func (DomainAddr) SetSrc ¶ added in v0.3.4
func (d DomainAddr) SetSrc(src AddressSrc)
func (*DomainAddr) String ¶
func (d *DomainAddr) String() string
func (*DomainAddr) Type ¶
func (d *DomainAddr) Type() Type
type DynamicProxy ¶
type DynamicProxy struct {
// contains filtered or unexported fields
}
func NewDynamicProxy ¶
func NewDynamicProxy(p Proxy) *DynamicProxy
func (*DynamicProxy) PacketConn ¶
func (d *DynamicProxy) PacketConn(ctx context.Context, a Address) (net.PacketConn, error)
func (*DynamicProxy) Set ¶
func (d *DynamicProxy) Set(p Proxy)
type EmptyDispatch ¶
type EmptyDispatch struct{}
type ErrorResolver ¶
func (ErrorResolver) Close ¶
func (e ErrorResolver) Close() error
func (ErrorResolver) LookupIP ¶
func (e ErrorResolver) LookupIP(_ context.Context, domain string, opts ...func(*LookupIPOption)) ([]net.IP, error)
func (ErrorResolver) Raw ¶
func (e ErrorResolver) Raw(_ context.Context, req dnsmessage.Question) (dnsmessage.Message, error)
type ForceFakeIP ¶
type ForceFakeIP struct{}
type IPAddr ¶ added in v0.3.5
type IPAddr struct {
// contains filtered or unexported fields
}
func (IPAddr) NetworkType ¶ added in v0.3.5
func (*IPAddr) OverrideHostname ¶ added in v0.3.5
func (*IPAddr) OverridePort ¶ added in v0.3.5
func (IPAddr) PreferIPv4 ¶ added in v0.3.5
func (d IPAddr) PreferIPv4(b bool)
func (IPAddr) PreferIPv6 ¶ added in v0.3.5
func (d IPAddr) PreferIPv6(b bool)
func (IPAddr) SetResolver ¶ added in v0.3.5
func (d IPAddr) SetResolver(resolver Resolver)
func (IPAddr) SetSrc ¶ added in v0.3.5
func (d IPAddr) SetSrc(src AddressSrc)
type IPAddrPort ¶
type IPAddrPort struct {
// contains filtered or unexported fields
}
func (*IPAddrPort) Hostname ¶
func (d *IPAddrPort) Hostname() string
func (*IPAddrPort) IsFqdn ¶ added in v0.3.4
func (d *IPAddrPort) IsFqdn() bool
func (IPAddrPort) NetworkType ¶
func (*IPAddrPort) OverrideHostname ¶
func (d *IPAddrPort) OverrideHostname(s string) Address
func (*IPAddrPort) OverridePort ¶
func (d *IPAddrPort) OverridePort(p Port) Address
func (*IPAddrPort) Port ¶
func (d *IPAddrPort) Port() Port
func (IPAddrPort) PreferIPv4 ¶ added in v0.3.5
func (d IPAddrPort) PreferIPv4(b bool)
func (IPAddrPort) PreferIPv6 ¶
func (d IPAddrPort) PreferIPv6(b bool)
func (IPAddrPort) SetResolver ¶ added in v0.3.4
func (d IPAddrPort) SetResolver(resolver Resolver)
func (IPAddrPort) SetSrc ¶ added in v0.3.4
func (d IPAddrPort) SetSrc(src AddressSrc)
func (*IPAddrPort) String ¶
func (d *IPAddrPort) String() string
func (*IPAddrPort) Type ¶
func (d *IPAddrPort) Type() Type
type InboundKey ¶
type InboundKey struct{}
func (InboundKey) String ¶
func (InboundKey) String() string
type ListenerPatch ¶ added in v0.3.5
type ListenerPatch struct { Listener // contains filtered or unexported fields }
func PatchStream ¶ added in v0.3.5
func PatchStream(lis net.Listener, inbound Listener) *ListenerPatch
func (*ListenerPatch) Close ¶ added in v0.3.5
func (w *ListenerPatch) Close() error
type LookupIPOption ¶ added in v0.3.4
type PacketProxy ¶
type Port ¶
var EmptyPort Port = PortUint16(0)
func ParsePort ¶
func ParsePort[T constraints.Integer](p T) Port
func ParsePortStr ¶
type PortUint16 ¶
type PortUint16 uint16
func (PortUint16) Port ¶
func (p PortUint16) Port() uint16
func (PortUint16) String ¶
func (p PortUint16) String() string
type PreferIPv6 ¶
type PreferIPv6 struct{}
type ProcessDumper ¶ added in v0.3.5
type Proxy ¶
type Proxy interface { StreamProxy PacketProxy Dispatch(context.Context, Address) (Address, error) }
func NewErrProxy ¶
type Resolver ¶
type Resolver interface { LookupIP(ctx context.Context, domain string, opts ...func(*LookupIPOption)) ([]net.IP, error) Raw(ctx context.Context, req dnsmessage.Question) (dnsmessage.Message, error) io.Closer }
var Bootstrap Resolver = InternetResolver
var InternetResolver Resolver = NewSystemResolver("8.8.8.8:53", "1.1.1.1:53", "223.5.5.5:53", "114.114.114.114:53")
type Result ¶ added in v0.3.4
func NewErrResult ¶ added in v0.3.4
type Store ¶
type Store interface { Add(k, v any) Store Get(k any) (any, bool) Range(func(k, v any) bool) Map() map[any]any }
func StoreFromContext ¶
type StreamMeta ¶
type SystemResolver ¶ added in v0.3.4
type SystemResolver struct {
// contains filtered or unexported fields
}
func NewSystemResolver ¶ added in v0.3.4
func NewSystemResolver(host ...string) *SystemResolver
func (*SystemResolver) Close ¶ added in v0.3.4
func (d *SystemResolver) Close() error
func (*SystemResolver) LookupIP ¶ added in v0.3.4
func (d *SystemResolver) LookupIP(ctx context.Context, domain string, opts ...func(*LookupIPOption)) ([]net.IP, error)
func (*SystemResolver) Raw ¶ added in v0.3.4
func (d *SystemResolver) Raw(context.Context, dnsmessage.Question) (dnsmessage.Message, error)
Click to show internal directories.
Click to hide internal directories.