diff --git a/adapter/outbound/vless.go b/adapter/outbound/vless.go index 0712d14..4aa45f8 100644 --- a/adapter/outbound/vless.go +++ b/adapter/outbound/vless.go @@ -210,7 +210,8 @@ func NewVless(option VlessOption) (*Vless, error) { } func newVlessPacketConn(c net.Conn, addr net.Addr) *vlessPacketConn { - return &vlessPacketConn{Conn: c, + return &vlessPacketConn{ + Conn: c, rAddr: addr, cache: make([]byte, 0, maxLength+2), } diff --git a/component/trie/ipcidr_node.go b/component/trie/ipcidr_node.go index acaf9a8..0ab5f6f 100644 --- a/component/trie/ipcidr_node.go +++ b/component/trie/ipcidr_node.go @@ -2,9 +2,7 @@ package trie import "errors" -var ( - ErrorOverMaxValue = errors.New("the value don't over max value") -) +var ErrorOverMaxValue = errors.New("the value don't over max value") type IpCidrNode struct { Mark bool diff --git a/component/trie/ipcidr_trie.go b/component/trie/ipcidr_trie.go index 8b931c2..82c603d 100644 --- a/component/trie/ipcidr_trie.go +++ b/component/trie/ipcidr_trie.go @@ -1,8 +1,9 @@ package trie import ( - "github.com/Dreamacro/clash/log" "net" + + "github.com/Dreamacro/clash/log" ) type IPV6 bool diff --git a/constant/adapters.go b/constant/adapters.go index 3b89f6f..5493855 100644 --- a/constant/adapters.go +++ b/constant/adapters.go @@ -95,7 +95,6 @@ type ProxyAdapter interface { // DialContext return a C.Conn with protocol which // contains multiplexing-related reuse logic (if any) DialContext(ctx context.Context, metadata *Metadata, opts ...dialer.Option) (Conn, error) - ListenPacketContext(ctx context.Context, metadata *Metadata, opts ...dialer.Option) (PacketConn, error) // Unwrap extracts the proxy from a proxy-group. It returns nil when nothing to extract. diff --git a/hub/route/provider.go b/hub/route/provider.go index 459fc91..4eec68d 100644 --- a/hub/route/provider.go +++ b/hub/route/provider.go @@ -2,9 +2,10 @@ package route import ( "context" - ruleProvider "github.com/Dreamacro/clash/rule/provider" "net/http" + ruleProvider "github.com/Dreamacro/clash/rule/provider" + "github.com/Dreamacro/clash/constant/provider" "github.com/Dreamacro/clash/tunnel" diff --git a/rule/process.go b/rule/process.go index 53bb3e8..8142ef1 100644 --- a/rule/process.go +++ b/rule/process.go @@ -15,8 +15,8 @@ import ( var processCache = cache.NewLRUCache(cache.WithAge(2), cache.WithSize(64)) type Process struct { - adapter string - process string + adapter string + process string fullMatch bool } @@ -70,8 +70,8 @@ func NewProcess(process string, adapter string, fullMatch bool) (*Process, error } return &Process{ - adapter: adapter, - process: process, + adapter: adapter, + process: process, fullMatch: fullMatch, }, nil } diff --git a/rule/provider/fetcher.go b/rule/provider/fetcher.go index dfa4ed0..bf738f6 100644 --- a/rule/provider/fetcher.go +++ b/rule/provider/fetcher.go @@ -3,17 +3,18 @@ package provider import ( "bytes" "crypto/md5" - providerType "github.com/Dreamacro/clash/constant/provider" - "github.com/Dreamacro/clash/log" "io/ioutil" "os" "path/filepath" "time" + + providerType "github.com/Dreamacro/clash/constant/provider" + "github.com/Dreamacro/clash/log" ) var ( - fileMode os.FileMode = 0666 - dirMode os.FileMode = 0755 + fileMode os.FileMode = 0o666 + dirMode os.FileMode = 0o755 ) type parser = func([]byte) (interface{}, error) diff --git a/rule/provider/parser.go b/rule/provider/parser.go index 8279fab..5f6f414 100644 --- a/rule/provider/parser.go +++ b/rule/provider/parser.go @@ -2,11 +2,12 @@ package provider import ( "fmt" + "time" + "github.com/Dreamacro/clash/adapter/provider" "github.com/Dreamacro/clash/common/structure" C "github.com/Dreamacro/clash/constant" providerType "github.com/Dreamacro/clash/constant/provider" - "time" ) type ruleProviderSchema struct { diff --git a/rule/provider/provider.go b/rule/provider/provider.go index 1d5f4b5..3ea8dc2 100644 --- a/rule/provider/provider.go +++ b/rule/provider/provider.go @@ -3,13 +3,14 @@ package provider import ( "encoding/json" "errors" + "runtime" + "strings" + "time" + "github.com/Dreamacro/clash/component/trie" C "github.com/Dreamacro/clash/constant" providerType "github.com/Dreamacro/clash/constant/provider" "gopkg.in/yaml.v2" - "runtime" - "strings" - "time" ) type Behavior int diff --git a/rule/provider_test/provider_test.go b/rule/provider_test/provider_test.go index 4111109..be287e3 100644 --- a/rule/provider_test/provider_test.go +++ b/rule/provider_test/provider_test.go @@ -1,14 +1,15 @@ package provider_test import ( + "net" + "testing" + "time" + "github.com/Dreamacro/clash/adapter/provider" "github.com/Dreamacro/clash/constant" "github.com/Dreamacro/clash/rule" ruleProvider "github.com/Dreamacro/clash/rule/provider" "github.com/stretchr/testify/assert" - "net" - "testing" - "time" ) func setup() { diff --git a/rule/rule_set.go b/rule/rule_set.go index 7a37a9b..69dd512 100644 --- a/rule/rule_set.go +++ b/rule/rule_set.go @@ -2,6 +2,7 @@ package rules import ( "fmt" + C "github.com/Dreamacro/clash/constant" "github.com/Dreamacro/clash/rule/provider" ) @@ -31,6 +32,7 @@ func (rs *RuleSet) Payload() string { func (rs *RuleSet) ShouldResolveIP() bool { return rs.getProviders().Behavior() != provider.Domain } + func (rs *RuleSet) getProviders() provider.RuleProvider { if rs.ruleProvider == nil { rp := provider.RuleProviders()[rs.ruleProviderName] diff --git a/tunnel/tunnel.go b/tunnel/tunnel.go index 0c90184..f69b3ea 100644 --- a/tunnel/tunnel.go +++ b/tunnel/tunnel.go @@ -3,12 +3,13 @@ package tunnel import ( "context" "fmt" - ruleProvider "github.com/Dreamacro/clash/rule/provider" "net" "runtime" "sync" "time" + ruleProvider "github.com/Dreamacro/clash/rule/provider" + "github.com/Dreamacro/clash/adapter/inbound" "github.com/Dreamacro/clash/component/nat" "github.com/Dreamacro/clash/component/resolver" diff --git a/tunnel/util.go b/tunnel/util.go index 4a3418a..6571ea1 100644 --- a/tunnel/util.go +++ b/tunnel/util.go @@ -17,4 +17,3 @@ func safeAssertProxyType(adapter C.Proxy, metadata *C.Metadata, proxyType C.Adap return false } } -