Documentation
¶
Index ¶
- func ComputeAddressHash[t comparable](tt t) uint64
- func IsBlockError(err error) bool
- func LogLevel(err error) slog.Level
- func NewDnsConn(ctx context.Context, resolver Resolver) *dnsConn
- type Accepter
- type AddrInfo
- type Address
- func ParseAddress(network string, addr string) (ad Address, _ error)
- func ParseAddressPort(network string, addr string, port uint16) (ad Address)
- func ParseDomainPort(network string, addr string, port uint16) (ad Address)
- func ParseIPAddr(net string, ip net.IP, port uint16) Address
- func ParseNetipAddr(net string, ip netip.Addr, port uint16) Address
- func ParseSysAddr(ad net.Addr) (Address, error)
- type AddressNetwork
- type ChannelHandler
- type ChannelStreamListener
- type Context
- func (c *Context) AddMatchHistory(s string)
- func (s *Context) GetComponent() string
- func (s *Context) GetDomainString() string
- func (c *Context) GetFakeIP() net.Addr
- func (c *Context) GetHTTPHost() string
- func (c *Context) GetHosts() net.Addr
- func (s *Context) GetIPString() string
- func (c *Context) GetInbound() net.Addr
- func (c *Context) GetInboundName() string
- func (c *Context) GetProcess() (string, uint, uint)
- func (c *Context) GetProcessName() string
- func (c *Context) GetProcessPid() uint
- func (c *Context) GetProcessUid() uint
- func (c *Context) GetProtocol() string
- func (c *Context) GetTLSServerName() string
- func (s *Context) GetTag() string
- func (s *Context) GetUDPMigrateID() uint64
- func (c *Context) MatchHistory() string
- func (c *Context) NewMatch()
- func (s *Context) SetComponent(str string)
- func (s *Context) SetDomainString(str string)
- func (c *Context) SetFakeIP(addr net.Addr)
- func (c *Context) SetHTTPHost(str string)
- func (c *Context) SetHosts(addr net.Addr)
- func (s *Context) SetIPString(str string)
- func (c *Context) SetInbound(addr net.Addr)
- func (c *Context) SetInboundName(name string)
- func (c *Context) SetProcess(p string, pid, uid uint)
- func (c *Context) SetProtocol(p string)
- func (c *Context) SetTLSServerName(str string)
- func (s *Context) SetTag(str string)
- func (s *Context) SetUDPMigrateID(id uint64)
- func (c *Context) SniffHost() string
- func (c *Context) Value(key any) any
- type ContextResolver
- type DNSRawRequest
- type DNSServer
- type DNSStreamRequest
- type DialError
- type DomainAddr
- type DomainAddress
- type DynamicProxy
- func (d *DynamicProxy) Close() error
- func (d *DynamicProxy) Conn(ctx context.Context, a Address) (net.Conn, error)
- func (d *DynamicProxy) Dispatch(ctx context.Context, a Address) (Address, error)
- func (d *DynamicProxy) PacketConn(ctx context.Context, a Address) (net.PacketConn, error)
- func (d *DynamicProxy) Set(p Proxy)
- type EmptyDispatch
- type ErrorResolver
- type ForceFakeIPKey
- type Handler
- type IPAddr
- type IPAddress
- type IPs
- type Listener
- type LogConn
- type LookupIPOption
- type MatchHistory
- type Packet
- type PacketListener
- type PacketProxy
- type PacketSniffer
- type Process
- type ProcessDumper
- type Proxy
- type Resolver
- type ResolverMode
- type Server
- type SkipRouteKey
- type Sniff
- type StreamListener
- type StreamMeta
- type StreamProxy
- type WriteBack
- type WriteBackFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ComputeAddressHash ¶
func ComputeAddressHash[t comparable](tt t) uint64
ComputeAddressHash compute hash of address
func IsBlockError ¶ added in v0.3.6
func NewDnsConn ¶
Types ¶
type Address ¶
type Address interface {
// Hostname return hostname of address, eg: www.example.com, 127.0.0.1, ff::ff
Hostname() string
// Port return port of address
Port() uint16
// IsFqdn return true if address is FQDN
// fqdn must impl [DomainAddress]
// otherwise must impl [IPAddress]
IsFqdn() bool
// Comparable return hash of address, compute by [ComputeAddressHash]
Comparable() uint64
net.Addr
}
var EmptyAddr Address = DomainAddr{}
func ParseAddressPort ¶
func ParseDomainPort ¶ added in v0.3.5
func ParseNetipAddr ¶ added in v0.3.7
type AddressNetwork ¶ added in v0.3.7
type AddressNetwork byte
const ( Unknown AddressNetwork = iota TCP UDP IP )
func ParseAddressNetwork ¶ added in v0.3.7
func ParseAddressNetwork(network string) AddressNetwork
func (AddressNetwork) Network ¶ added in v0.3.7
func (n AddressNetwork) Network() string
type ChannelHandler ¶
type ChannelHandler struct {
// contains filtered or unexported fields
}
func NewChannelHandler ¶
func NewChannelHandler(ctx context.Context) *ChannelHandler
func (*ChannelHandler) HandlePacket ¶
func (h *ChannelHandler) HandlePacket(p *Packet)
func (*ChannelHandler) HandleStream ¶
func (h *ChannelHandler) HandleStream(s *StreamMeta)
func (*ChannelHandler) Packet ¶
func (h *ChannelHandler) Packet() <-chan *Packet
func (*ChannelHandler) Stream ¶
func (h *ChannelHandler) Stream() <-chan *StreamMeta
type ChannelStreamListener ¶ added in v0.3.6
type ChannelStreamListener struct {
// contains filtered or unexported fields
}
func NewChannelStreamListener ¶ added in v0.3.6
func NewChannelStreamListener(addr net.Addr) *ChannelStreamListener
func (*ChannelStreamListener) Accept ¶ added in v0.3.6
func (c *ChannelStreamListener) Accept() (net.Conn, error)
func (*ChannelStreamListener) Addr ¶ added in v0.3.6
func (c *ChannelStreamListener) Addr() net.Addr
func (*ChannelStreamListener) Close ¶ added in v0.3.6
func (c *ChannelStreamListener) Close() error
func (*ChannelStreamListener) NewConn ¶ added in v0.3.6
func (c *ChannelStreamListener) NewConn(conn net.Conn)
type Context ¶ added in v0.3.6
type Context struct {
Source net.Addr `metrics:"Source"`
Destination net.Addr `metrics:"Destination"`
context.Context
Hash string `metrics:"Hash"`
NodeName string `metrics:"NodeName"`
ModeReason string `metrics:"MODE Reason"`
Resolver ContextResolver `metrics:"-"`
ForceMode bypass.Mode `metrics:"-"`
SniffMode bypass.Mode `metrics:"-"`
Mode bypass.Mode `metrics:"MODE"`
SystemDialer bool `metrics:"-"`
// contains filtered or unexported fields
}
func GetContext ¶ added in v0.3.6
func GetContextOrNil ¶
func WithContext ¶ added in v0.3.6
func (*Context) AddMatchHistory ¶
func (*Context) GetComponent ¶
func (*Context) GetDomainString ¶
func (*Context) GetHTTPHost ¶
func (*Context) GetIPString ¶
func (*Context) GetInbound ¶
func (*Context) GetInboundName ¶
func (*Context) GetProcessName ¶
func (*Context) GetProcessPid ¶
func (*Context) GetProcessUid ¶
func (*Context) GetProtocol ¶
func (*Context) GetTLSServerName ¶
func (*Context) GetUDPMigrateID ¶
func (*Context) MatchHistory ¶
func (*Context) SetComponent ¶
func (*Context) SetDomainString ¶
func (*Context) SetHTTPHost ¶
func (*Context) SetIPString ¶
func (*Context) SetInbound ¶
func (*Context) SetInboundName ¶
func (*Context) SetProcess ¶
func (*Context) SetProtocol ¶
func (*Context) SetTLSServerName ¶
func (*Context) SetUDPMigrateID ¶
type ContextResolver ¶ added in v0.3.6
type ContextResolver struct {
Resolver Resolver
Mode ResolverMode
SkipResolve bool `metrics:"-"`
// contains filtered or unexported fields
}
func (ContextResolver) Opts ¶ added in v0.3.6
func (r ContextResolver) Opts(reverse bool) []func(*LookupIPOption)
func (*ContextResolver) ResolverResolver ¶
func (r *ContextResolver) ResolverResolver() Resolver
func (*ContextResolver) SetResolverResolver ¶
func (r *ContextResolver) SetResolverResolver(resolver Resolver)
type DNSRawRequest ¶ added in v0.3.6
type DNSServer ¶ added in v0.3.5
type DNSServer interface {
Server
DoStream(context.Context, *DNSStreamRequest) error
Do(context.Context, *DNSRawRequest) error
}
type DNSStreamRequest ¶ added in v0.3.8
type DialError ¶ added in v0.3.7
type DialError struct {
// Addr is the network address for which this error occurred.
// For local operations, like Listen or SetDeadline, Addr is
// the address of the local endpoint being manipulated.
// For operations involving a remote network connection, like
// Dial, Read, or Write, Addr is the remote address of that
// connection.
Addr net.Addr
// Err is the error that occurred during the operation.
// The Error method panics if the error is nil.
Err error
// Op is the operation which caused the error, such as
// "read" or "write".
Op string
// Net is the network type on which this error occurred,
// such as "tcp" or "udp6".
Net string
Sniff string
}
OpError is the error type usually returned by functions in the net package. It describes the operation, network type, and address of an error.
func NewDialError ¶ added in v0.3.7
type DomainAddr ¶
type DomainAddr struct {
HostnameX string `json:"hostname,omitempty"`
AddressNetwork `json:"network,omitempty"`
PortX uint16 `json:"port,omitempty"`
}
func (DomainAddr) Comparable ¶
func (d DomainAddr) Comparable() uint64
func (DomainAddr) Hostname ¶
func (d DomainAddr) Hostname() string
func (DomainAddr) IsFqdn ¶ added in v0.3.4
func (d DomainAddr) IsFqdn() bool
func (DomainAddr) Port ¶
func (d DomainAddr) Port() uint16
func (DomainAddr) String ¶
func (d DomainAddr) String() string
type DomainAddress ¶ added in v0.3.7
type DomainAddress interface{ Address }
type DynamicProxy ¶
type DynamicProxy struct {
// contains filtered or unexported fields
}
func NewDynamicProxy ¶
func NewDynamicProxy(p Proxy) *DynamicProxy
func (*DynamicProxy) Close ¶
func (d *DynamicProxy) Close() error
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)) (*IPs, error)
func (ErrorResolver) Raw ¶
func (e ErrorResolver) Raw(_ context.Context, req dnsmessage.Question) (dnsmessage.Message, error)
type ForceFakeIPKey ¶ added in v0.3.8
type ForceFakeIPKey struct{}
type Handler ¶
type Handler interface {
HandleStream(*StreamMeta)
HandlePacket(*Packet)
}
type IPAddr ¶ added in v0.3.5
type IPAddr struct {
AddrPortX netip.AddrPort `json:"addr_port"`
AddressNetwork `json:"network,omitempty"`
}
func (IPAddr) Comparable ¶
type Listener ¶ added in v0.3.3
type Listener interface {
PacketListener
StreamListener
Server
}
func NewListener ¶ added in v0.3.6
func NewListener(s net.Listener, p PacketListener) Listener
type LookupIPOption ¶ added in v0.3.4
type LookupIPOption struct {
Mode ResolverMode
}
type MatchHistory ¶
type MatchHistory struct {
// contains filtered or unexported fields
}
func (*MatchHistory) Add ¶
func (r *MatchHistory) Add(s string)
func (*MatchHistory) New ¶
func (r *MatchHistory) New()
func (*MatchHistory) String ¶
func (r *MatchHistory) String() string
type Packet ¶
type Packet struct {
Src net.Addr
Dst Address
WriteBack WriteBack
// Payload will set to nil when ref count is negative, get it by [Packet.GetPayload]
// ! DON'T use Payload directly
Payload []byte
MigrateID uint64
InboundName string
// contains filtered or unexported fields
}
func (*Packet) GetPayload ¶
type PacketListener ¶ added in v0.3.6
type PacketProxy ¶
type PacketSniffer ¶ added in v0.3.8
type ProcessDumper ¶ added in v0.3.5
type Proxy ¶
type Proxy interface {
StreamProxy
PacketProxy
Dispatch(context.Context, Address) (Address, error)
io.Closer
}
func NewErrProxy ¶
type Resolver ¶
type Resolver interface {
// LookupIP returns a list of ip addresses
LookupIP(ctx context.Context, domain string, opts ...func(*LookupIPOption)) (*IPs, error)
// Raw returns a dns message
//
// ! The returned message may be cached, so it should not be modified
// ! Please clone the message if you need to modify it
Raw(ctx context.Context, req dnsmessage.Question) (dnsmessage.Message, error)
io.Closer
}
Resolver is a dns resolver
TODO merge LookupIP and Raw, new interface for Resolver
type ResolverMode ¶ added in v0.3.6
type ResolverMode int
const ( ResolverModeNoSpecified ResolverMode = iota ResolverModePreferIPv6 ResolverModePreferIPv4 )
type SkipRouteKey ¶ added in v0.3.8
type SkipRouteKey struct{}
type StreamListener ¶ added in v0.3.6
type StreamMeta ¶
Click to show internal directories.
Click to hide internal directories.