Versions in this module Expand all Collapse all v1 v1.31.1 Nov 1, 2023 v1.31.0 Oct 20, 2023 Changes in this version + const BpfFSPath + const ClashTrafficMark + const DefaultTCPTimeout + const DefaultTLSTimeout + const DefaultUDPTimeout + const Name + const ScriptRuleGeoSiteTarget + const TcpAutoRedirPort + var BuildTime = "unknown time" + var DNSModeMapping = map[string]DNSMode + var ErrInvalidResponse = errors.New("invalid response") + var ErrInvalidURL = errors.New("invalid URL") + var GetScriptProxyProviders = defaultProxyProvidersGetter + var MetadataTypeMapping = map[string]Type + var Path = func() *path { ... }() + var RewriteTypeMapping = map[string]RewriteType + var StackTypeMapping = map[string]TUNStack + var Version = "unknown version" + func BackupScriptState() + func DecodeLatin1(reader io.Reader) (string, error) + func EncodeLatin1(str string) ([]byte, error) + func GetScriptRuleProviders() map[string]Rule + func NewErrorResponse(req *http.Request, err error) *http.Response + func NewResponse(code int, body io.Reader, req *http.Request) *http.Response + func ProxyURL(auth auth.Authenticator) func(*http.Request) (*url.URL, error) + func ReadDecompressedBody(res *http.Response) ([]byte, error) + func RestoreScriptState() + func SetConfig(file string) + func SetHomeDir(root string) + func SetLastTunConf(conf *Tun) + func SetProxyInbound(tcpInbounds map[string]Inbound) + func SetScriptRuleProviders(rp map[string]Rule) + type AdapterType int + const Direct + const Fallback + const Http + const LoadBalance + const Mitm + const Reject + const Relay + const Selector + const Shadowsocks + const ShadowsocksR + const Snell + const Socks5 + const Trojan + const URLTest + const Vless + const Vmess + const WireGuard + func (at AdapterType) String() string + type AuthenticatorListener interface + SetAuthenticator func([]auth.AuthUser) + type Chain []string + func (c Chain) Last() string + func (c Chain) String() string + type Conn interface + type ConnContext interface + Conn func() net.Conn + Metadata func() *Metadata + type Connection interface + AppendToChains func(adapter ProxyAdapter) + Chains func() Chain + MarshalObject func(e *log.Entry) + SetChains func(chains []string) + type DNSAddrPort struct + func (p *DNSAddrPort) UnmarshalText(text []byte) error + func (p DNSAddrPort) String() string + type DNSMode int + const DNSFakeIP + const DNSMapping + const DNSNormal + func (e *DNSMode) UnmarshalJSON(data []byte) error + func (e *DNSMode) UnmarshalYAML(unmarshal func(any) error) error + func (e DNSMode) MarshalJSON() ([]byte, error) + func (e DNSMode) MarshalYAML() (any, error) + func (e DNSMode) String() string + type DNSUrl struct + AddrPort DNSAddrPort + Network string + func (d *DNSUrl) UnmarshalJSON(data []byte) error + func (d *DNSUrl) UnmarshalYAML(unmarshal func(any) error) error + func (d DNSUrl) MarshalJSON() ([]byte, error) + func (d DNSUrl) MarshalYAML() (any, error) + func (d DNSUrl) String() string + type DelayHistory struct + AvgDelay uint16 + Delay uint16 + Time time.Time + type EBpf interface + Close func() + Lookup func(srcAddrPort netip.AddrPort) (socks5.Addr, error) + Start func() error + type Inbound inbound + func (i *Inbound) Key() string + func (i *Inbound) MarshalJSON() ([]byte, error) + func (i *Inbound) ToAlias() string + func (i *Inbound) UnmarshalJSON(data []byte) error + func (i *Inbound) UnmarshalYAML(unmarshal func(any) error) error + type InboundType string + const InboundTypeHTTP + const InboundTypeMitm + const InboundTypeMixed + const InboundTypeRedir + const InboundTypeSocks + const InboundTypeSocks4 + const InboundTypeSocks5 + const InboundTypeTproxy + type Listener interface + Address func() string + Close func() error + RawAddress func() string + type Matcher interface + Eval func(metadata *Metadata) (string, error) + Match func(metadata *Metadata) (bool, error) + Name func() string + type Metadata struct + DNSMode DNSMode + DstIP netip.Addr + DstPort Port + Host string + NetWork NetWork + OriginDst netip.AddrPort + Process string + ProcessPath string + SpecialProxy string + SrcIP netip.Addr + SrcPort Port + Type Type + UserAgent string + func (m *Metadata) AddrType() int + func (m *Metadata) MarshalObject(e *log.Entry) + func (m *Metadata) NetworkFromString(s string) + func (m *Metadata) RemoteAddress() string + func (m *Metadata) Resolved() bool + func (m *Metadata) SourceAddress() string + func (m *Metadata) String() string + func (m *Metadata) TypeFromString(s string) + func (m *Metadata) UDPAddr() *net.UDPAddr + func (m *Metadata) Valid() bool + type MitmOption struct + ApiHost string + CertConfig *cert.Config + Handler RewriteHandler + TLSConfig *tls.Config + type MitmSession struct + Conn net.Conn + Request *http.Request + Response *http.Response + func NewMitmSession(conn net.Conn, request *http.Request, response *http.Response) *MitmSession + func (s *MitmSession) GetProperties(key string) (any, bool) + func (s *MitmSession) NewErrorResponse(err error) *http.Response + func (s *MitmSession) NewResponse(code int, body io.Reader) *http.Response + func (s *MitmSession) SetProperties(key string, val any) + func (s *MitmSession) WriteResponse() (err error) + type NetWork int + const ALLNet + const TCP + const UDP + func (n NetWork) MarshalJSON() ([]byte, error) + func (n NetWork) String() string + type PacketConn interface + type PacketConnContext interface + Metadata func() *Metadata + PacketConn func() net.PacketConn + type PlainContext interface + ID func() uuid.UUID + type Port uint16 + func (n Port) MarshalJSON() ([]byte, error) + func (n Port) String() string + type Proxy interface + Alive func() bool + DelayHistory func() []DelayHistory + HasV6 func() bool + LastDelay func() uint16 + URLTest func(ctx context.Context, url string) (uint16, uint16, error) + type ProxyAdapter interface + Addr func() string + Cleanup func() + DialContext func(ctx context.Context, metadata *Metadata, opts ...dialer.Option) (Conn, error) + DisableDnsResolve func() bool + ListenPacketContext func(ctx context.Context, metadata *Metadata, opts ...dialer.Option) (PacketConn, error) + MarshalJSON func() ([]byte, error) + Name func() string + StreamConn func(c net.Conn, metadata *Metadata) (net.Conn, error) + StreamPacketConn func(c net.Conn, metadata *Metadata) (net.Conn, error) + SupportUDP func() bool + Type func() AdapterType + Unwrap func(metadata *Metadata) Proxy + type RawProxy struct + M map[string]any + Name string + Password string + Server string + Type string + UUID string + func (m *RawProxy) Init() + type Rewrite interface + ID func() string + ReplaceSubPayload func(string) string + ReplaceURLPayload func([]string) string + RulePayload func() string + RuleRegx func() *regexp.Regexp + RuleType func() RewriteType + URLRegx func() *regexp.Regexp + type RewriteHandler interface + HandleApiRequest func(*MitmSession) bool + HandleError func(*MitmSession, error) + HandleRequest func(*MitmSession) (*http.Request, *http.Response) + HandleResponse func(*MitmSession) *http.Response + type RewriteRule interface + SearchInRequest func(func(Rewrite) bool) bool + SearchInResponse func(func(Rewrite) bool) bool + type RewriteType int + const Mitm302 + const Mitm307 + const MitmReject + const MitmReject200 + const MitmRejectArray + const MitmRejectDict + const MitmRejectImg + const MitmRequestBody + const MitmRequestHeader + const MitmResponseBody + const MitmResponseHeader + func (rt RewriteType) String() string + type Rule interface + Adapter func() string + AppendGroup func(group string) + Match func(metadata *Metadata) bool + Payload func() string + RuleExtra func() *RuleExtra + RuleGroups func() RuleGroup + RuleType func() RuleType + SetRuleExtra func(re *RuleExtra) + ShouldFindProcess func() bool + ShouldResolveIP func() bool + SubRules func() []Rule + type RuleExtra struct + Network NetWork + ProcessNames []string + SourceIPs []*netip.Prefix + func (re *RuleExtra) NotMatchNetwork(network NetWork) bool + func (re *RuleExtra) NotMatchProcessName(processName string) bool + func (re *RuleExtra) NotMatchSourceIP(srcIP netip.Addr) bool + type RuleGeoSite interface + GetDomainMatcher func() *router.DomainMatcher + type RuleGroup []string + func (rg RuleGroup) String() string + type RuleType int + const Domain + const DomainKeyword + const DomainSuffix + const DstPort + const GEOIP + const GEOSITE + const Group + const IPCIDR + const IPSet + const InboundPort + const MATCH + const Process + const ProcessPath + const Script + const SrcIPCIDR + const SrcPort + const UserAgent + func (rt RuleType) String() string + type TUNChangeCallback interface + Pause func() + Resume func() + type TUNStack int + const TunGvisor + const TunSystem + func (e *TUNStack) UnmarshalJSON(data []byte) error + func (e *TUNStack) UnmarshalYAML(unmarshal func(any) error) error + func (e TUNStack) MarshalJSON() ([]byte, error) + func (e TUNStack) MarshalYAML() (any, error) + func (e TUNStack) String() string + type TUNState int + const TunDisabled + const TunEnabled + const TunPaused + type Tun struct + AutoDetectInterface bool + AutoRoute bool + DNSHijack []DNSUrl + Device string + Enable bool + RedirectToTun []string + Stack TUNStack + StopRouteListener bool + TunAddressPrefix *netip.Prefix + func GetLastTunConf() *Tun + func GetTunConf() Tun + type Type int + const HTTP + const HTTPCONNECT + const MITM + const REDIR + const SOCKS4 + const SOCKS5 + const TPROXY + const TUN + const TUNNEL + func (t Type) MarshalJSON() ([]byte, error) + func (t Type) String() string + type UDPPacket interface + Data func() []byte + Drop func() + LocalAddr func() net.Addr + WriteBack func(b []byte, addr net.Addr) (n int, err error)