Documentation
¶
Index ¶
- Variables
- func Get[T any](ctx context.Context, k any) (t T, _ bool)
- func NewBlockError(network statistic.Type, hostname string) error
- func NewStore(ctx context.Context) context.Context
- func PaseNetwork(s string) statistic.Type
- 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 ParseIPAddr(ad *net.IPAddr) 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
- type CurrentKey
- type DNSHandler
- type DestinationKey
- type Discard
- type DiscardConn
- func (*DiscardConn) Close() error
- func (*DiscardConn) LocalAddr() net.Addr
- func (*DiscardConn) Read(b []byte) (n int, err error)
- func (*DiscardConn) RemoteAddr() net.Addr
- func (*DiscardConn) SetDeadline(t time.Time) error
- func (*DiscardConn) SetReadDeadline(t time.Time) error
- func (*DiscardConn) SetWriteDeadline(t time.Time) error
- func (*DiscardConn) Write(b []byte) (n int, err error)
- type DiscardPacketConn
- func (*DiscardPacketConn) Close() error
- func (*DiscardPacketConn) LocalAddr() net.Addr
- func (*DiscardPacketConn) ReadFrom(p []byte) (n int, addr net.Addr, err error)
- func (*DiscardPacketConn) SetDeadline(t time.Time) error
- func (*DiscardPacketConn) SetReadDeadline(t time.Time) error
- func (*DiscardPacketConn) SetWriteDeadline(t time.Time) error
- func (*DiscardPacketConn) WriteTo(p []byte, addr net.Addr) (n int, err error)
- type DomainAddr
- func (d *DomainAddr) AddrPort(ctx context.Context) (netip.AddrPort, error)
- func (d *DomainAddr) Hostname() string
- func (d *DomainAddr) IP(ctx context.Context) (net.IP, error)
- 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) PreferIPv6(b bool)
- func (d DomainAddr) Resolver() Resolver
- func (d *DomainAddr) String() string
- func (d *DomainAddr) TCPAddr(ctx context.Context) (*net.TCPAddr, error)
- func (d *DomainAddr) Type() Type
- func (d *DomainAddr) UDPAddr(ctx context.Context) (*net.UDPAddr, error)
- func (d DomainAddr) WithResolver(resolver Resolver, canCover bool) bool
- type EmptyDispatch
- type ErrorResolver
- func (e ErrorResolver) Close() error
- func (e ErrorResolver) Do(context.Context, string, []byte) ([]byte, error)
- func (e ErrorResolver) LookupIP(_ context.Context, domain string) ([]net.IP, error)
- func (e ErrorResolver) Record(_ context.Context, domain string, _ dnsmessage.Type) ([]net.IP, uint32, error)
- type FakeIPKey
- type Handler
- type IPAddrPort
- func (d *IPAddrPort) AddrPort(context.Context) (netip.AddrPort, error)
- func (d *IPAddrPort) Hostname() string
- func (d *IPAddrPort) IP(context.Context) (net.IP, error)
- 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) PreferIPv6(b bool)
- func (d IPAddrPort) Resolver() Resolver
- func (d *IPAddrPort) String() string
- func (d *IPAddrPort) TCPAddr(context.Context) (*net.TCPAddr, error)
- func (d *IPAddrPort) Type() Type
- func (d *IPAddrPort) UDPAddr(context.Context) (*net.UDPAddr, error)
- func (d IPAddrPort) WithResolver(resolver Resolver, canCover bool) bool
- type InboundKey
- type Packet
- type PacketHandler
- type PacketProxy
- type Port
- type PortUint16
- type PreferIPv6
- type Proxy
- type Resolver
- type Server
- type SourceKey
- type Store
- type StreamHandler
- type StreamMeta
- type StreamProxy
- type System
- type Type
Constants ¶
This section is empty.
Variables ¶
View Source
var DiscardNetConn net.Conn = &DiscardConn{}
View Source
var DiscardNetPacketConn net.PacketConn = &DiscardPacketConn{}
View Source
var ErrBlocked = errors.New("BLOCK")
Functions ¶
func PaseNetwork ¶
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(context.Context) (net.IP, error) AddrPort(context.Context) (netip.AddrPort, error) UDPAddr(context.Context) (*net.UDPAddr, error) TCPAddr(context.Context) (*net.TCPAddr, error) // Port return port of address Port() Port // Type return type of address, domain or ip Type() Type NetworkType() statistic.Type net.Addr // WithResolver will use call IP(), IPHost(), UDPAddr(), TCPAddr() // return the current resolver is applied, if can't apply return false WithResolver(_ Resolver, canCover bool) bool PreferIPv6(b bool) // OverrideHostname clone address(exclude Values) and change hostname OverrideHostname(string) Address OverridePort(Port) Address }
var EmptyAddr Address = &emptyAddr{}
func ParseAddressPort ¶
func ParseIPAddr ¶
func ParseTCPAddress ¶
func ParseUDPAddr ¶
func ParseUnixAddr ¶
type CurrentKey ¶
type CurrentKey struct{}
type DNSHandler ¶
type DNSHandler 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 DNSHandler = &emptyHandler{}
type DestinationKey ¶
type DestinationKey struct{}
func (DestinationKey) String ¶
func (DestinationKey) String() string
type DiscardConn ¶
type DiscardConn struct{}
func (*DiscardConn) Close ¶
func (*DiscardConn) Close() error
func (*DiscardConn) LocalAddr ¶
func (*DiscardConn) LocalAddr() net.Addr
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
type DiscardPacketConn ¶
type DiscardPacketConn struct{}
func (*DiscardPacketConn) Close ¶
func (*DiscardPacketConn) Close() error
func (*DiscardPacketConn) LocalAddr ¶
func (*DiscardPacketConn) LocalAddr() net.Addr
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
type DomainAddr ¶
type DomainAddr struct {
// contains filtered or unexported fields
}
func (*DomainAddr) Hostname ¶
func (d *DomainAddr) Hostname() string
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) PreferIPv6 ¶
func (d DomainAddr) PreferIPv6(b bool)
func (*DomainAddr) String ¶
func (d *DomainAddr) String() string
func (*DomainAddr) Type ¶
func (d *DomainAddr) Type() Type
func (DomainAddr) WithResolver ¶
type EmptyDispatch ¶
type EmptyDispatch struct{}
type ErrorResolver ¶
func (ErrorResolver) Close ¶
func (e ErrorResolver) Close() error
type Handler ¶
type Handler interface { StreamHandler PacketHandler }
type IPAddrPort ¶
type IPAddrPort struct {
// contains filtered or unexported fields
}
func (*IPAddrPort) Hostname ¶
func (d *IPAddrPort) Hostname() string
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) PreferIPv6 ¶
func (d IPAddrPort) PreferIPv6(b bool)
func (*IPAddrPort) String ¶
func (d *IPAddrPort) String() string
func (*IPAddrPort) Type ¶
func (d *IPAddrPort) Type() Type
func (IPAddrPort) WithResolver ¶
type InboundKey ¶
type InboundKey struct{}
func (InboundKey) String ¶
func (InboundKey) String() string
type PacketHandler ¶
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 Proxy ¶
type Proxy interface { StreamProxy PacketProxy Dispatch(context.Context, Address) (Address, error) }
func NewErrProxy ¶
type Resolver ¶
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 StreamHandler ¶
type StreamHandler interface {
Stream(ctx context.Context, _ *StreamMeta)
}
type StreamMeta ¶
Click to show internal directories.
Click to hide internal directories.