From e19e9ef5a4a323a118b3597f066f6b52cfbc71f5 Mon Sep 17 00:00:00 2001 From: Dreamacro <8615343+Dreamacro@users.noreply.github.com> Date: Thu, 29 Apr 2021 11:23:14 +0800 Subject: [PATCH] Style: code style --- adapters/inbound/http.go | 2 +- adapters/inbound/https.go | 2 +- adapters/inbound/socket.go | 2 +- adapters/outbound/base.go | 19 +++++++++++++++++++ adapters/outbound/direct.go | 2 ++ adapters/outbound/http.go | 2 ++ adapters/outbound/reject.go | 2 ++ adapters/outbound/shadowsocks.go | 4 ++++ adapters/outbound/shadowsocksr.go | 4 ++++ adapters/outbound/snell.go | 2 ++ adapters/outbound/socks5.go | 3 +++ adapters/outbound/trojan.go | 3 +++ adapters/outbound/vmess.go | 3 +++ adapters/outboundgroup/fallback.go | 5 +++++ adapters/outboundgroup/loadbalance.go | 5 +++++ adapters/outboundgroup/relay.go | 2 ++ adapters/outboundgroup/selector.go | 5 +++++ adapters/outboundgroup/urltest.go | 5 +++++ 18 files changed, 69 insertions(+), 3 deletions(-) diff --git a/adapters/inbound/http.go b/adapters/inbound/http.go index 72e8bb3d..b01c62bf 100644 --- a/adapters/inbound/http.go +++ b/adapters/inbound/http.go @@ -9,7 +9,7 @@ import ( "github.com/Dreamacro/clash/context" ) -// NewHTTP recieve normal http request and return HTTPContext +// NewHTTP receive normal http request and return HTTPContext func NewHTTP(request *http.Request, conn net.Conn) *context.HTTPContext { metadata := parseHTTPAddr(request) metadata.Type = C.HTTP diff --git a/adapters/inbound/https.go b/adapters/inbound/https.go index bb2bd97d..e7e92211 100644 --- a/adapters/inbound/https.go +++ b/adapters/inbound/https.go @@ -8,7 +8,7 @@ import ( "github.com/Dreamacro/clash/context" ) -// NewHTTPS recieve CONNECT request and return ConnContext +// NewHTTPS receive CONNECT request and return ConnContext func NewHTTPS(request *http.Request, conn net.Conn) *context.ConnContext { metadata := parseHTTPAddr(request) metadata.Type = C.HTTPCONNECT diff --git a/adapters/inbound/socket.go b/adapters/inbound/socket.go index 1370b701..be772b7b 100644 --- a/adapters/inbound/socket.go +++ b/adapters/inbound/socket.go @@ -8,7 +8,7 @@ import ( "github.com/Dreamacro/clash/context" ) -// NewSocket recieve TCP inbound and return ConnContext +// NewSocket receive TCP inbound and return ConnContext func NewSocket(target socks5.Addr, conn net.Conn, source C.Type) *context.ConnContext { metadata := parseSocksAddr(target) metadata.NetWork = C.TCP diff --git a/adapters/outbound/base.go b/adapters/outbound/base.go index f4da21ce..6e16bbae 100644 --- a/adapters/outbound/base.go +++ b/adapters/outbound/base.go @@ -21,36 +21,44 @@ type Base struct { udp bool } +// Name implements C.ProxyAdapter func (b *Base) Name() string { return b.name } +// Type implements C.ProxyAdapter func (b *Base) Type() C.AdapterType { return b.tp } +// StreamConn implements C.ProxyAdapter func (b *Base) StreamConn(c net.Conn, metadata *C.Metadata) (net.Conn, error) { return c, errors.New("no support") } +// DialUDP implements C.ProxyAdapter func (b *Base) DialUDP(metadata *C.Metadata) (C.PacketConn, error) { return nil, errors.New("no support") } +// SupportUDP implements C.ProxyAdapter func (b *Base) SupportUDP() bool { return b.udp } +// MarshalJSON implements C.ProxyAdapter func (b *Base) MarshalJSON() ([]byte, error) { return json.Marshal(map[string]string{ "type": b.Type().String(), }) } +// Addr implements C.ProxyAdapter func (b *Base) Addr() string { return b.addr } +// Unwrap implements C.ProxyAdapter func (b *Base) Unwrap(metadata *C.Metadata) C.Proxy { return nil } @@ -64,10 +72,12 @@ type conn struct { chain C.Chain } +// Chains implements C.Connection func (c *conn) Chains() C.Chain { return c.chain } +// AppendToChains implements C.Connection func (c *conn) AppendToChains(a C.ProxyAdapter) { c.chain = append(c.chain, a.Name()) } @@ -81,10 +91,12 @@ type packetConn struct { chain C.Chain } +// Chains implements C.Connection func (c *packetConn) Chains() C.Chain { return c.chain } +// AppendToChains implements C.Connection func (c *packetConn) AppendToChains(a C.ProxyAdapter) { c.chain = append(c.chain, a.Name()) } @@ -99,16 +111,19 @@ type Proxy struct { alive *atomic.Bool } +// Alive implements C.Proxy func (p *Proxy) Alive() bool { return p.alive.Load() } +// Dial implements C.Proxy func (p *Proxy) Dial(metadata *C.Metadata) (C.Conn, error) { ctx, cancel := context.WithTimeout(context.Background(), tcpTimeout) defer cancel() return p.DialContext(ctx, metadata) } +// DialContext implements C.ProxyAdapter func (p *Proxy) DialContext(ctx context.Context, metadata *C.Metadata) (C.Conn, error) { conn, err := p.ProxyAdapter.DialContext(ctx, metadata) if err != nil { @@ -117,6 +132,7 @@ func (p *Proxy) DialContext(ctx context.Context, metadata *C.Metadata) (C.Conn, return conn, err } +// DelayHistory implements C.Proxy func (p *Proxy) DelayHistory() []C.DelayHistory { queue := p.history.Copy() histories := []C.DelayHistory{} @@ -127,6 +143,7 @@ func (p *Proxy) DelayHistory() []C.DelayHistory { } // LastDelay return last history record. if proxy is not alive, return the max value of uint16. +// implements C.Proxy func (p *Proxy) LastDelay() (delay uint16) { var max uint16 = 0xffff if !p.alive.Load() { @@ -144,6 +161,7 @@ func (p *Proxy) LastDelay() (delay uint16) { return history.Delay } +// MarshalJSON implements C.ProxyAdapter func (p *Proxy) MarshalJSON() ([]byte, error) { inner, err := p.ProxyAdapter.MarshalJSON() if err != nil { @@ -158,6 +176,7 @@ func (p *Proxy) MarshalJSON() ([]byte, error) { } // URLTest get the delay for the specified URL +// implements C.Proxy func (p *Proxy) URLTest(ctx context.Context, url string) (t uint16, err error) { defer func() { p.alive.Store(err == nil) diff --git a/adapters/outbound/direct.go b/adapters/outbound/direct.go index 5273a593..5b4a710f 100644 --- a/adapters/outbound/direct.go +++ b/adapters/outbound/direct.go @@ -12,6 +12,7 @@ type Direct struct { *Base } +// DialContext implements C.ProxyAdapter func (d *Direct) DialContext(ctx context.Context, metadata *C.Metadata) (C.Conn, error) { address := net.JoinHostPort(metadata.String(), metadata.DstPort) @@ -23,6 +24,7 @@ func (d *Direct) DialContext(ctx context.Context, metadata *C.Metadata) (C.Conn, return NewConn(c, d), nil } +// DialUDP implements C.ProxyAdapter func (d *Direct) DialUDP(metadata *C.Metadata) (C.PacketConn, error) { pc, err := dialer.ListenPacket("udp", "") if err != nil { diff --git a/adapters/outbound/http.go b/adapters/outbound/http.go index 3c445cd4..43ca1204 100644 --- a/adapters/outbound/http.go +++ b/adapters/outbound/http.go @@ -35,6 +35,7 @@ type HttpOption struct { SkipCertVerify bool `proxy:"skip-cert-verify,omitempty"` } +// StreamConn implements C.ProxyAdapter func (h *Http) StreamConn(c net.Conn, metadata *C.Metadata) (net.Conn, error) { if h.tlsConfig != nil { cc := tls.Client(c, h.tlsConfig) @@ -51,6 +52,7 @@ func (h *Http) StreamConn(c net.Conn, metadata *C.Metadata) (net.Conn, error) { return c, nil } +// DialContext implements C.ProxyAdapter func (h *Http) DialContext(ctx context.Context, metadata *C.Metadata) (_ C.Conn, err error) { c, err := dialer.DialContext(ctx, "tcp", h.addr) if err != nil { diff --git a/adapters/outbound/reject.go b/adapters/outbound/reject.go index a403ce94..36750496 100644 --- a/adapters/outbound/reject.go +++ b/adapters/outbound/reject.go @@ -14,10 +14,12 @@ type Reject struct { *Base } +// DialContext implements C.ProxyAdapter func (r *Reject) DialContext(ctx context.Context, metadata *C.Metadata) (C.Conn, error) { return NewConn(&NopConn{}, r), nil } +// DialUDP implements C.ProxyAdapter func (r *Reject) DialUDP(metadata *C.Metadata) (C.PacketConn, error) { return nil, errors.New("match reject rule") } diff --git a/adapters/outbound/shadowsocks.go b/adapters/outbound/shadowsocks.go index bc2e1fe6..edcd60ab 100644 --- a/adapters/outbound/shadowsocks.go +++ b/adapters/outbound/shadowsocks.go @@ -54,6 +54,7 @@ type v2rayObfsOption struct { Mux bool `obfs:"mux,omitempty"` } +// StreamConn implements C.ProxyAdapter func (ss *ShadowSocks) StreamConn(c net.Conn, metadata *C.Metadata) (net.Conn, error) { switch ss.obfsMode { case "tls": @@ -73,6 +74,7 @@ func (ss *ShadowSocks) StreamConn(c net.Conn, metadata *C.Metadata) (net.Conn, e return c, err } +// DialContext implements C.ProxyAdapter func (ss *ShadowSocks) DialContext(ctx context.Context, metadata *C.Metadata) (_ C.Conn, err error) { c, err := dialer.DialContext(ctx, "tcp", ss.addr) if err != nil { @@ -86,6 +88,7 @@ func (ss *ShadowSocks) DialContext(ctx context.Context, metadata *C.Metadata) (_ return NewConn(c, ss), err } +// DialUDP implements C.ProxyAdapter func (ss *ShadowSocks) DialUDP(metadata *C.Metadata) (C.PacketConn, error) { pc, err := dialer.ListenPacket("udp", "") if err != nil { @@ -102,6 +105,7 @@ func (ss *ShadowSocks) DialUDP(metadata *C.Metadata) (C.PacketConn, error) { return newPacketConn(&ssPacketConn{PacketConn: pc, rAddr: addr}, ss), nil } +// MarshalJSON implements C.ProxyAdapter func (ss *ShadowSocks) MarshalJSON() ([]byte, error) { return json.Marshal(map[string]string{ "type": ss.Type().String(), diff --git a/adapters/outbound/shadowsocksr.go b/adapters/outbound/shadowsocksr.go index 36ab8048..6636d5ff 100644 --- a/adapters/outbound/shadowsocksr.go +++ b/adapters/outbound/shadowsocksr.go @@ -37,6 +37,7 @@ type ShadowSocksROption struct { UDP bool `proxy:"udp,omitempty"` } +// StreamConn implements C.ProxyAdapter func (ssr *ShadowSocksR) StreamConn(c net.Conn, metadata *C.Metadata) (net.Conn, error) { c = ssr.obfs.StreamConn(c) c = ssr.cipher.StreamConn(c) @@ -58,6 +59,7 @@ func (ssr *ShadowSocksR) StreamConn(c net.Conn, metadata *C.Metadata) (net.Conn, return c, err } +// DialContext implements C.ProxyAdapter func (ssr *ShadowSocksR) DialContext(ctx context.Context, metadata *C.Metadata) (_ C.Conn, err error) { c, err := dialer.DialContext(ctx, "tcp", ssr.addr) if err != nil { @@ -71,6 +73,7 @@ func (ssr *ShadowSocksR) DialContext(ctx context.Context, metadata *C.Metadata) return NewConn(c, ssr), err } +// DialUDP implements C.ProxyAdapter func (ssr *ShadowSocksR) DialUDP(metadata *C.Metadata) (C.PacketConn, error) { pc, err := dialer.ListenPacket("udp", "") if err != nil { @@ -88,6 +91,7 @@ func (ssr *ShadowSocksR) DialUDP(metadata *C.Metadata) (C.PacketConn, error) { return newPacketConn(&ssPacketConn{PacketConn: pc, rAddr: addr}, ssr), nil } +// MarshalJSON implements C.ProxyAdapter func (ssr *ShadowSocksR) MarshalJSON() ([]byte, error) { return json.Marshal(map[string]string{ "type": ssr.Type().String(), diff --git a/adapters/outbound/snell.go b/adapters/outbound/snell.go index 820c789f..0b65b272 100644 --- a/adapters/outbound/snell.go +++ b/adapters/outbound/snell.go @@ -48,6 +48,7 @@ func streamConn(c net.Conn, option streamOption) *snell.Snell { return snell.StreamConn(c, option.psk, option.version) } +// StreamConn implements C.ProxyAdapter func (s *Snell) StreamConn(c net.Conn, metadata *C.Metadata) (net.Conn, error) { c = streamConn(c, streamOption{s.psk, s.version, s.addr, s.obfsOption}) port, _ := strconv.Atoi(metadata.DstPort) @@ -55,6 +56,7 @@ func (s *Snell) StreamConn(c net.Conn, metadata *C.Metadata) (net.Conn, error) { return c, err } +// DialContext implements C.ProxyAdapter func (s *Snell) DialContext(ctx context.Context, metadata *C.Metadata) (_ C.Conn, err error) { if s.version == snell.Version2 { c, err := s.pool.Get() diff --git a/adapters/outbound/socks5.go b/adapters/outbound/socks5.go index 84acdd6d..377d7d17 100644 --- a/adapters/outbound/socks5.go +++ b/adapters/outbound/socks5.go @@ -35,6 +35,7 @@ type Socks5Option struct { SkipCertVerify bool `proxy:"skip-cert-verify,omitempty"` } +// StreamConn implements C.ProxyAdapter func (ss *Socks5) StreamConn(c net.Conn, metadata *C.Metadata) (net.Conn, error) { if ss.tls { cc := tls.Client(c, ss.tlsConfig) @@ -58,6 +59,7 @@ func (ss *Socks5) StreamConn(c net.Conn, metadata *C.Metadata) (net.Conn, error) return c, nil } +// DialContext implements C.ProxyAdapter func (ss *Socks5) DialContext(ctx context.Context, metadata *C.Metadata) (_ C.Conn, err error) { c, err := dialer.DialContext(ctx, "tcp", ss.addr) if err != nil { @@ -75,6 +77,7 @@ func (ss *Socks5) DialContext(ctx context.Context, metadata *C.Metadata) (_ C.Co return NewConn(c, ss), nil } +// DialUDP implements C.ProxyAdapter func (ss *Socks5) DialUDP(metadata *C.Metadata) (_ C.PacketConn, err error) { ctx, cancel := context.WithTimeout(context.Background(), tcpTimeout) defer cancel() diff --git a/adapters/outbound/trojan.go b/adapters/outbound/trojan.go index 92fcbeeb..cfd73449 100644 --- a/adapters/outbound/trojan.go +++ b/adapters/outbound/trojan.go @@ -39,6 +39,7 @@ type TrojanOption struct { GrpcOpts GrpcOptions `proxy:"grpc-opts,omitempty"` } +// StreamConn implements C.ProxyAdapter func (t *Trojan) StreamConn(c net.Conn, metadata *C.Metadata) (net.Conn, error) { var err error if t.transport != nil { @@ -55,6 +56,7 @@ func (t *Trojan) StreamConn(c net.Conn, metadata *C.Metadata) (net.Conn, error) return c, err } +// DialContext implements C.ProxyAdapter func (t *Trojan) DialContext(ctx context.Context, metadata *C.Metadata) (_ C.Conn, err error) { // gun transport if t.transport != nil { @@ -87,6 +89,7 @@ func (t *Trojan) DialContext(ctx context.Context, metadata *C.Metadata) (_ C.Con return NewConn(c, t), err } +// DialUDP implements C.ProxyAdapter func (t *Trojan) DialUDP(metadata *C.Metadata) (_ C.PacketConn, err error) { var c net.Conn diff --git a/adapters/outbound/vmess.go b/adapters/outbound/vmess.go index ecdcb8ed..528db7f5 100644 --- a/adapters/outbound/vmess.go +++ b/adapters/outbound/vmess.go @@ -64,6 +64,7 @@ type GrpcOptions struct { GrpcServiceName string `proxy:"grpc-service-name,omitempty"` } +// StreamConn implements C.ProxyAdapter func (v *Vmess) StreamConn(c net.Conn, metadata *C.Metadata) (net.Conn, error) { var err error switch v.option.Network { @@ -170,6 +171,7 @@ func (v *Vmess) StreamConn(c net.Conn, metadata *C.Metadata) (net.Conn, error) { return v.client.StreamConn(c, parseVmessAddr(metadata)) } +// DialContext implements C.ProxyAdapter func (v *Vmess) DialContext(ctx context.Context, metadata *C.Metadata) (_ C.Conn, err error) { // gun transport if v.transport != nil { @@ -198,6 +200,7 @@ func (v *Vmess) DialContext(ctx context.Context, metadata *C.Metadata) (_ C.Conn return NewConn(c, v), err } +// DialUDP implements C.ProxyAdapter func (v *Vmess) DialUDP(metadata *C.Metadata) (_ C.PacketConn, err error) { // vmess use stream-oriented udp with a special address, so we needs a net.UDPAddr if !metadata.Resolved() { diff --git a/adapters/outboundgroup/fallback.go b/adapters/outboundgroup/fallback.go index 756c4e81..b3dbe0cb 100644 --- a/adapters/outboundgroup/fallback.go +++ b/adapters/outboundgroup/fallback.go @@ -22,6 +22,7 @@ func (f *Fallback) Now() string { return proxy.Name() } +// DialContext implements C.ProxyAdapter func (f *Fallback) DialContext(ctx context.Context, metadata *C.Metadata) (C.Conn, error) { proxy := f.findAliveProxy(true) c, err := proxy.DialContext(ctx, metadata) @@ -31,6 +32,7 @@ func (f *Fallback) DialContext(ctx context.Context, metadata *C.Metadata) (C.Con return c, err } +// DialUDP implements C.ProxyAdapter func (f *Fallback) DialUDP(metadata *C.Metadata) (C.PacketConn, error) { proxy := f.findAliveProxy(true) pc, err := proxy.DialUDP(metadata) @@ -40,6 +42,7 @@ func (f *Fallback) DialUDP(metadata *C.Metadata) (C.PacketConn, error) { return pc, err } +// SupportUDP implements C.ProxyAdapter func (f *Fallback) SupportUDP() bool { if f.disableUDP { return false @@ -49,6 +52,7 @@ func (f *Fallback) SupportUDP() bool { return proxy.SupportUDP() } +// MarshalJSON implements C.ProxyAdapter func (f *Fallback) MarshalJSON() ([]byte, error) { var all []string for _, proxy := range f.proxies(false) { @@ -61,6 +65,7 @@ func (f *Fallback) MarshalJSON() ([]byte, error) { }) } +// Unwrap implements C.ProxyAdapter func (f *Fallback) Unwrap(metadata *C.Metadata) C.Proxy { proxy := f.findAliveProxy(true) return proxy diff --git a/adapters/outboundgroup/loadbalance.go b/adapters/outboundgroup/loadbalance.go index 289d0b46..b44fade1 100644 --- a/adapters/outboundgroup/loadbalance.go +++ b/adapters/outboundgroup/loadbalance.go @@ -68,6 +68,7 @@ func jumpHash(key uint64, buckets int32) int32 { return int32(b) } +// DialContext implements C.ProxyAdapter func (lb *LoadBalance) DialContext(ctx context.Context, metadata *C.Metadata) (c C.Conn, err error) { defer func() { if err == nil { @@ -81,6 +82,7 @@ func (lb *LoadBalance) DialContext(ctx context.Context, metadata *C.Metadata) (c return } +// DialUDP implements C.ProxyAdapter func (lb *LoadBalance) DialUDP(metadata *C.Metadata) (pc C.PacketConn, err error) { defer func() { if err == nil { @@ -93,6 +95,7 @@ func (lb *LoadBalance) DialUDP(metadata *C.Metadata) (pc C.PacketConn, err error return proxy.DialUDP(metadata) } +// SupportUDP implements C.ProxyAdapter func (lb *LoadBalance) SupportUDP() bool { return !lb.disableUDP } @@ -130,6 +133,7 @@ func strategyConsistentHashing() strategyFn { } } +// Unwrap implements C.ProxyAdapter func (lb *LoadBalance) Unwrap(metadata *C.Metadata) C.Proxy { proxies := lb.proxies(true) return lb.strategyFn(proxies, metadata) @@ -143,6 +147,7 @@ func (lb *LoadBalance) proxies(touch bool) []C.Proxy { return elm.([]C.Proxy) } +// MarshalJSON implements C.ProxyAdapter func (lb *LoadBalance) MarshalJSON() ([]byte, error) { var all []string for _, proxy := range lb.proxies(false) { diff --git a/adapters/outboundgroup/relay.go b/adapters/outboundgroup/relay.go index d2eeba66..6583d390 100644 --- a/adapters/outboundgroup/relay.go +++ b/adapters/outboundgroup/relay.go @@ -19,6 +19,7 @@ type Relay struct { providers []provider.ProxyProvider } +// DialContext implements C.ProxyAdapter func (r *Relay) DialContext(ctx context.Context, metadata *C.Metadata) (C.Conn, error) { proxies := r.proxies(metadata, true) if len(proxies) == 0 { @@ -56,6 +57,7 @@ func (r *Relay) DialContext(ctx context.Context, metadata *C.Metadata) (C.Conn, return outbound.NewConn(c, r), nil } +// MarshalJSON implements C.ProxyAdapter func (r *Relay) MarshalJSON() ([]byte, error) { var all []string for _, proxy := range r.rawProxies(false) { diff --git a/adapters/outboundgroup/selector.go b/adapters/outboundgroup/selector.go index 99640745..67afaaab 100644 --- a/adapters/outboundgroup/selector.go +++ b/adapters/outboundgroup/selector.go @@ -19,6 +19,7 @@ type Selector struct { providers []provider.ProxyProvider } +// DialContext implements C.ProxyAdapter func (s *Selector) DialContext(ctx context.Context, metadata *C.Metadata) (C.Conn, error) { c, err := s.selectedProxy(true).DialContext(ctx, metadata) if err == nil { @@ -27,6 +28,7 @@ func (s *Selector) DialContext(ctx context.Context, metadata *C.Metadata) (C.Con return c, err } +// DialUDP implements C.ProxyAdapter func (s *Selector) DialUDP(metadata *C.Metadata) (C.PacketConn, error) { pc, err := s.selectedProxy(true).DialUDP(metadata) if err == nil { @@ -35,6 +37,7 @@ func (s *Selector) DialUDP(metadata *C.Metadata) (C.PacketConn, error) { return pc, err } +// SupportUDP implements C.ProxyAdapter func (s *Selector) SupportUDP() bool { if s.disableUDP { return false @@ -43,6 +46,7 @@ func (s *Selector) SupportUDP() bool { return s.selectedProxy(false).SupportUDP() } +// MarshalJSON implements C.ProxyAdapter func (s *Selector) MarshalJSON() ([]byte, error) { var all []string for _, proxy := range getProvidersProxies(s.providers, false) { @@ -72,6 +76,7 @@ func (s *Selector) Set(name string) error { return errors.New("proxy not exist") } +// Unwrap implements C.ProxyAdapter func (s *Selector) Unwrap(metadata *C.Metadata) C.Proxy { return s.selectedProxy(true) } diff --git a/adapters/outboundgroup/urltest.go b/adapters/outboundgroup/urltest.go index b5c102c3..bc0d4068 100644 --- a/adapters/outboundgroup/urltest.go +++ b/adapters/outboundgroup/urltest.go @@ -33,6 +33,7 @@ func (u *URLTest) Now() string { return u.fast(false).Name() } +// DialContext implements C.ProxyAdapter func (u *URLTest) DialContext(ctx context.Context, metadata *C.Metadata) (c C.Conn, err error) { c, err = u.fast(true).DialContext(ctx, metadata) if err == nil { @@ -41,6 +42,7 @@ func (u *URLTest) DialContext(ctx context.Context, metadata *C.Metadata) (c C.Co return c, err } +// DialUDP implements C.ProxyAdapter func (u *URLTest) DialUDP(metadata *C.Metadata) (C.PacketConn, error) { pc, err := u.fast(true).DialUDP(metadata) if err == nil { @@ -49,6 +51,7 @@ func (u *URLTest) DialUDP(metadata *C.Metadata) (C.PacketConn, error) { return pc, err } +// Unwrap implements C.ProxyAdapter func (u *URLTest) Unwrap(metadata *C.Metadata) C.Proxy { return u.fast(true) } @@ -89,6 +92,7 @@ func (u *URLTest) fast(touch bool) C.Proxy { return elm.(C.Proxy) } +// SupportUDP implements C.ProxyAdapter func (u *URLTest) SupportUDP() bool { if u.disableUDP { return false @@ -97,6 +101,7 @@ func (u *URLTest) SupportUDP() bool { return u.fast(false).SupportUDP() } +// MarshalJSON implements C.ProxyAdapter func (u *URLTest) MarshalJSON() ([]byte, error) { var all []string for _, proxy := range u.proxies(false) {