diff --git a/adapter/adapter.go b/adapter/adapter.go index b1867998..22860811 100644 --- a/adapter/adapter.go +++ b/adapter/adapter.go @@ -4,9 +4,6 @@ import ( "context" "encoding/json" "fmt" - "github.com/Dreamacro/clash/common/queue" - "github.com/Dreamacro/clash/component/dialer" - C "github.com/Dreamacro/clash/constant" "net" "net/http" "net/netip" @@ -14,6 +11,9 @@ import ( "strings" "time" + "github.com/Dreamacro/clash/common/queue" + "github.com/Dreamacro/clash/component/dialer" + C "github.com/Dreamacro/clash/constant" "go.uber.org/atomic" ) diff --git a/adapter/outbound/base.go b/adapter/outbound/base.go index 0666d306..6d7f6a8d 100644 --- a/adapter/outbound/base.go +++ b/adapter/outbound/base.go @@ -4,12 +4,12 @@ import ( "context" "encoding/json" "errors" - "github.com/gofrs/uuid" "net" "strings" "github.com/Dreamacro/clash/component/dialer" C "github.com/Dreamacro/clash/constant" + "github.com/gofrs/uuid" ) type Base struct { diff --git a/adapter/outbound/http.go b/adapter/outbound/http.go index 81bf2e57..d4612acd 100644 --- a/adapter/outbound/http.go +++ b/adapter/outbound/http.go @@ -86,7 +86,7 @@ func (h *Http) shakeHand(metadata *C.Metadata, rw io.ReadWriter) error { }, } - //增加headers + // 增加headers if len(h.option.Headers) != 0 { for key, value := range h.option.Headers { req.Header.Add(key, value) diff --git a/adapter/outbound/util.go b/adapter/outbound/util.go index 071052a6..2d1c85ef 100644 --- a/adapter/outbound/util.go +++ b/adapter/outbound/util.go @@ -3,7 +3,6 @@ package outbound import ( "bytes" "crypto/tls" - xtls "github.com/xtls/go" "net" "strconv" "sync" @@ -12,6 +11,7 @@ import ( "github.com/Dreamacro/clash/component/resolver" C "github.com/Dreamacro/clash/constant" "github.com/Dreamacro/clash/transport/socks5" + xtls "github.com/xtls/go" ) var ( diff --git a/adapter/outbound/vless.go b/adapter/outbound/vless.go index 2d5c51bb..34875d4d 100644 --- a/adapter/outbound/vless.go +++ b/adapter/outbound/vless.go @@ -6,13 +6,13 @@ import ( "encoding/binary" "errors" "fmt" - "github.com/Dreamacro/clash/common/convert" "io" "net" "net/http" "strconv" "sync" + "github.com/Dreamacro/clash/common/convert" "github.com/Dreamacro/clash/component/dialer" "github.com/Dreamacro/clash/component/resolver" C "github.com/Dreamacro/clash/constant" diff --git a/adapter/outbound/vmess.go b/adapter/outbound/vmess.go index 0d65b31e..aaadd850 100644 --- a/adapter/outbound/vmess.go +++ b/adapter/outbound/vmess.go @@ -5,12 +5,12 @@ import ( "crypto/tls" "errors" "fmt" - "github.com/Dreamacro/clash/common/convert" "net" "net/http" "strconv" "strings" + "github.com/Dreamacro/clash/common/convert" "github.com/Dreamacro/clash/component/dialer" "github.com/Dreamacro/clash/component/resolver" C "github.com/Dreamacro/clash/constant" diff --git a/adapter/outboundgroup/fallback.go b/adapter/outboundgroup/fallback.go index 8f5f539b..fa205420 100644 --- a/adapter/outboundgroup/fallback.go +++ b/adapter/outboundgroup/fallback.go @@ -4,11 +4,12 @@ import ( "context" "encoding/json" "errors" + "time" + "github.com/Dreamacro/clash/adapter/outbound" "github.com/Dreamacro/clash/component/dialer" C "github.com/Dreamacro/clash/constant" "github.com/Dreamacro/clash/constant/provider" - "time" ) type Fallback struct { diff --git a/adapter/outboundgroup/groupbase.go b/adapter/outboundgroup/groupbase.go index 42b61dd4..83a369ce 100644 --- a/adapter/outboundgroup/groupbase.go +++ b/adapter/outboundgroup/groupbase.go @@ -3,16 +3,17 @@ package outboundgroup import ( "context" "fmt" + "sync" + "time" + "github.com/Dreamacro/clash/adapter/outbound" C "github.com/Dreamacro/clash/constant" - "github.com/Dreamacro/clash/constant/provider" types "github.com/Dreamacro/clash/constant/provider" + "github.com/Dreamacro/clash/constant/provider" "github.com/Dreamacro/clash/log" "github.com/Dreamacro/clash/tunnel" "github.com/dlclark/regexp2" "go.uber.org/atomic" - "sync" - "time" ) type GroupBase struct { diff --git a/adapter/outboundgroup/loadbalance.go b/adapter/outboundgroup/loadbalance.go index 5b962983..4214a3ef 100644 --- a/adapter/outboundgroup/loadbalance.go +++ b/adapter/outboundgroup/loadbalance.go @@ -5,16 +5,15 @@ import ( "encoding/json" "errors" "fmt" - "github.com/Dreamacro/clash/common/cache" "net" "time" "github.com/Dreamacro/clash/adapter/outbound" + "github.com/Dreamacro/clash/common/cache" "github.com/Dreamacro/clash/common/murmur3" "github.com/Dreamacro/clash/component/dialer" C "github.com/Dreamacro/clash/constant" "github.com/Dreamacro/clash/constant/provider" - "golang.org/x/net/publicsuffix" ) diff --git a/adapter/provider/healthcheck.go b/adapter/provider/healthcheck.go index cc664c9e..cb4329e5 100644 --- a/adapter/provider/healthcheck.go +++ b/adapter/provider/healthcheck.go @@ -6,7 +6,6 @@ import ( "github.com/Dreamacro/clash/common/batch" C "github.com/Dreamacro/clash/constant" - "go.uber.org/atomic" ) diff --git a/adapter/provider/provider.go b/adapter/provider/provider.go index a38718a9..2caf3494 100644 --- a/adapter/provider/provider.go +++ b/adapter/provider/provider.go @@ -4,16 +4,15 @@ import ( "encoding/json" "errors" "fmt" - "github.com/Dreamacro/clash/common/convert" - "github.com/dlclark/regexp2" "math" "runtime" "time" "github.com/Dreamacro/clash/adapter" + "github.com/Dreamacro/clash/common/convert" C "github.com/Dreamacro/clash/constant" types "github.com/Dreamacro/clash/constant/provider" - + "github.com/dlclark/regexp2" "gopkg.in/yaml.v3" ) diff --git a/adapter/provider/vehicle.go b/adapter/provider/vehicle.go index 1eb5df83..bcb20d40 100644 --- a/adapter/provider/vehicle.go +++ b/adapter/provider/vehicle.go @@ -2,12 +2,13 @@ package provider import ( "context" - netHttp "github.com/Dreamacro/clash/component/http" - types "github.com/Dreamacro/clash/constant/provider" "io" "net/http" "os" "time" + + netHttp "github.com/Dreamacro/clash/component/http" + types "github.com/Dreamacro/clash/constant/provider" ) type FileVehicle struct { diff --git a/common/cmd/cmd.go b/common/cmd/cmd.go index e015dd2e..44a869e1 100644 --- a/common/cmd/cmd.go +++ b/common/cmd/cmd.go @@ -14,7 +14,6 @@ func ExecCmd(cmdStr string) (string, error) { cmd = exec.Command(args[0]) } else { cmd = exec.Command(args[0], args[1:]...) - } prepareBackgroundCommand(cmd) out, err := cmd.CombinedOutput() diff --git a/common/cmd/cmd_other.go b/common/cmd/cmd_other.go index c6bc4ac4..8adcfc43 100644 --- a/common/cmd/cmd_other.go +++ b/common/cmd/cmd_other.go @@ -7,5 +7,4 @@ import ( ) func prepareBackgroundCommand(cmd *exec.Cmd) { - } diff --git a/common/convert/converter.go b/common/convert/converter.go index 7a96743e..46f0bbbf 100644 --- a/common/convert/converter.go +++ b/common/convert/converter.go @@ -116,7 +116,7 @@ func ConvertsV2Ray(buf []byte) ([]map[string]any, error) { headers := make(map[string]any) wsOpts := make(map[string]any) - //headers["Host"] = RandHost() + // headers["Host"] = RandHost() headers["User-Agent"] = RandUserAgent() wsOpts["path"] = query.Get("path") @@ -203,7 +203,7 @@ func ConvertsV2Ray(buf []byte) ([]map[string]any, error) { headers := make(map[string]any) wsOpts := make(map[string]any) - //headers["Host"] = RandHost() + // headers["Host"] = RandHost() headers["User-Agent"] = RandUserAgent() wsOpts["path"] = query.Get("path") wsOpts["headers"] = headers @@ -267,7 +267,7 @@ func ConvertsV2Ray(buf []byte) ([]map[string]any, error) { headers := make(map[string]any) httpOpts := make(map[string]any) - //headers["Host"] = RandHost() + // headers["Host"] = RandHost() headers["User-Agent"] = RandUserAgent() httpOpts["method"] = values["method"] httpOpts["path"] = values["path"] @@ -279,7 +279,7 @@ func ConvertsV2Ray(buf []byte) ([]map[string]any, error) { headers := make(map[string]any) h2Opts := make(map[string]any) - //headers["Host"] = RandHost() + // headers["Host"] = RandHost() headers["User-Agent"] = RandUserAgent() h2Opts["path"] = values["path"] h2Opts["headers"] = headers diff --git a/common/utils/uuid_test.go b/common/utils/uuid_test.go index ba00ea08..ebd04f84 100644 --- a/common/utils/uuid_test.go +++ b/common/utils/uuid_test.go @@ -1,9 +1,10 @@ package utils import ( - "github.com/gofrs/uuid" "reflect" "testing" + + "github.com/gofrs/uuid" ) func TestUUIDMap(t *testing.T) { diff --git a/component/dhcp/dhcp.go b/component/dhcp/dhcp.go index be2c578a..750be75f 100644 --- a/component/dhcp/dhcp.go +++ b/component/dhcp/dhcp.go @@ -8,7 +8,6 @@ import ( "github.com/Dreamacro/clash/common/nnip" "github.com/Dreamacro/clash/component/iface" - "github.com/insomniacslk/dhcp/dhcpv4" ) diff --git a/component/dialer/bind_darwin.go b/component/dialer/bind_darwin.go index 91d74987..2b9c83ee 100644 --- a/component/dialer/bind_darwin.go +++ b/component/dialer/bind_darwin.go @@ -6,7 +6,6 @@ import ( "syscall" "github.com/Dreamacro/clash/component/iface" - "golang.org/x/sys/unix" ) diff --git a/component/fakeip/pool_test.go b/component/fakeip/pool_test.go index 1f6b3f09..20d1f6fa 100644 --- a/component/fakeip/pool_test.go +++ b/component/fakeip/pool_test.go @@ -9,7 +9,6 @@ import ( "github.com/Dreamacro/clash/component/profile/cachefile" "github.com/Dreamacro/clash/component/trie" - "github.com/stretchr/testify/assert" "go.etcd.io/bbolt" ) diff --git a/component/geodata/geodata.go b/component/geodata/geodata.go index ac0f820e..ba6132dc 100644 --- a/component/geodata/geodata.go +++ b/component/geodata/geodata.go @@ -3,10 +3,10 @@ package geodata import ( "errors" "fmt" - C "github.com/Dreamacro/clash/constant" "strings" "github.com/Dreamacro/clash/component/geodata/router" + C "github.com/Dreamacro/clash/constant" "github.com/Dreamacro/clash/log" ) diff --git a/component/geodata/router/condition.go b/component/geodata/router/condition.go index 4e0ad46c..75b581c8 100644 --- a/component/geodata/router/condition.go +++ b/component/geodata/router/condition.go @@ -329,7 +329,6 @@ func NewGeoIPMatcher(geoip *GeoIP) (*GeoIPMatcher, error) { } func (m *MultiGeoIPMatcher) ApplyIp(ip net.IP) bool { - for _, matcher := range m.matchers { if matcher.Match(ip) { return true diff --git a/component/geodata/router/config.pb.go b/component/geodata/router/config.pb.go index 7c3af22a..38e401c3 100644 --- a/component/geodata/router/config.pb.go +++ b/component/geodata/router/config.pb.go @@ -7,10 +7,11 @@ package router import ( - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" sync "sync" + + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" ) const ( diff --git a/component/geodata/standard/standard.go b/component/geodata/standard/standard.go index 355cbf34..918c559f 100644 --- a/component/geodata/standard/standard.go +++ b/component/geodata/standard/standard.go @@ -9,7 +9,6 @@ import ( "github.com/Dreamacro/clash/component/geodata" "github.com/Dreamacro/clash/component/geodata/router" C "github.com/Dreamacro/clash/constant" - "google.golang.org/protobuf/proto" ) diff --git a/component/geodata/utils.go b/component/geodata/utils.go index 9e7e50b1..a9eb3a9c 100644 --- a/component/geodata/utils.go +++ b/component/geodata/utils.go @@ -2,6 +2,7 @@ package geodata import ( "fmt" + "github.com/Dreamacro/clash/component/geodata/router" C "github.com/Dreamacro/clash/constant" ) diff --git a/component/http/http.go b/component/http/http.go index c534b2ee..30aac4e6 100644 --- a/component/http/http.go +++ b/component/http/http.go @@ -2,14 +2,15 @@ package http import ( "context" - "github.com/Dreamacro/clash/listener/inner" - "github.com/Dreamacro/clash/log" "io" "net" "net/http" URL "net/url" "strings" "time" + + "github.com/Dreamacro/clash/listener/inner" + "github.com/Dreamacro/clash/log" ) const ( @@ -60,5 +61,4 @@ func HttpRequest(ctx context.Context, url, method string, header map[string][]st client := http.Client{Transport: transport} return client.Do(req) - } diff --git a/component/mmdb/mmdb.go b/component/mmdb/mmdb.go index 58f3fe00..469b00c2 100644 --- a/component/mmdb/mmdb.go +++ b/component/mmdb/mmdb.go @@ -1,11 +1,11 @@ package mmdb import ( - "github.com/oschwald/geoip2-golang" "sync" C "github.com/Dreamacro/clash/constant" "github.com/Dreamacro/clash/log" + "github.com/oschwald/geoip2-golang" ) var ( diff --git a/component/process/process.go b/component/process/process.go index 32c992c4..34e85c6d 100644 --- a/component/process/process.go +++ b/component/process/process.go @@ -2,10 +2,11 @@ package process import ( "errors" - "github.com/Dreamacro/clash/common/nnip" - C "github.com/Dreamacro/clash/constant" "net" "net/netip" + + "github.com/Dreamacro/clash/common/nnip" + C "github.com/Dreamacro/clash/constant" ) var ( diff --git a/component/process/process_darwin.go b/component/process/process_darwin.go index ef8f6e0e..53c889e0 100644 --- a/component/process/process_darwin.go +++ b/component/process/process_darwin.go @@ -7,7 +7,6 @@ import ( "unsafe" "github.com/Dreamacro/clash/common/nnip" - "golang.org/x/sys/unix" ) diff --git a/component/process/process_windows.go b/component/process/process_windows.go index 03935c37..9c9f3e4f 100644 --- a/component/process/process_windows.go +++ b/component/process/process_windows.go @@ -9,7 +9,6 @@ import ( "github.com/Dreamacro/clash/common/nnip" "github.com/Dreamacro/clash/log" - "golang.org/x/sys/windows" ) diff --git a/component/profile/cachefile/cache.go b/component/profile/cachefile/cache.go index 3d2dd1de..cf418fb4 100644 --- a/component/profile/cachefile/cache.go +++ b/component/profile/cachefile/cache.go @@ -8,7 +8,6 @@ import ( "github.com/Dreamacro/clash/component/profile" C "github.com/Dreamacro/clash/constant" "github.com/Dreamacro/clash/log" - "go.etcd.io/bbolt" ) diff --git a/component/sniffer/dispatcher.go b/component/sniffer/dispatcher.go index cfcc58fb..3a187e74 100644 --- a/component/sniffer/dispatcher.go +++ b/component/sniffer/dispatcher.go @@ -2,18 +2,17 @@ package sniffer import ( "errors" - "github.com/Dreamacro/clash/constant/sniffer" "net" "net/netip" "strconv" "time" - "github.com/Dreamacro/clash/component/trie" - CN "github.com/Dreamacro/clash/common/net" "github.com/Dreamacro/clash/common/utils" "github.com/Dreamacro/clash/component/resolver" + "github.com/Dreamacro/clash/component/trie" C "github.com/Dreamacro/clash/constant" + "github.com/Dreamacro/clash/constant/sniffer" "github.com/Dreamacro/clash/log" ) @@ -117,13 +116,13 @@ func (sd *SnifferDispatcher) sniffDomain(conn *CN.BufferedConn, metadata *C.Meta host, err := sniffer.SniffTCP(bytes) if err != nil { - //log.Debugln("[Sniffer] [%s] Sniff data failed %s", sniffer.Protocol(), metadata.DstIP) + // log.Debugln("[Sniffer] [%s] Sniff data failed %s", sniffer.Protocol(), metadata.DstIP) continue } _, err = netip.ParseAddr(host) if err == nil { - //log.Debugln("[Sniffer] [%s] Sniff data failed %s", sniffer.Protocol(), metadata.DstIP) + // log.Debugln("[Sniffer] [%s] Sniff data failed %s", sniffer.Protocol(), metadata.DstIP) continue } @@ -143,7 +142,8 @@ func NewCloseSnifferDispatcher() (*SnifferDispatcher, error) { } func NewSnifferDispatcher(needSniffer []sniffer.Type, forceDomain *trie.DomainTrie[bool], - skipSNI *trie.DomainTrie[bool], ports *[]utils.Range[uint16]) (*SnifferDispatcher, error) { + skipSNI *trie.DomainTrie[bool], ports *[]utils.Range[uint16], +) (*SnifferDispatcher, error) { dispatcher := SnifferDispatcher{ enable: true, foreDomain: forceDomain, diff --git a/component/sniffer/http_sniffer.go b/component/sniffer/http_sniffer.go index 97ae607b..386d8627 100644 --- a/component/sniffer/http_sniffer.go +++ b/component/sniffer/http_sniffer.go @@ -3,9 +3,10 @@ package sniffer import ( "bytes" "errors" - C "github.com/Dreamacro/clash/constant" "net" "strings" + + C "github.com/Dreamacro/clash/constant" ) var ( diff --git a/component/sniffer/quic_sniffer.go b/component/sniffer/quic_sniffer.go index de78cf82..24570dcb 100644 --- a/component/sniffer/quic_sniffer.go +++ b/component/sniffer/quic_sniffer.go @@ -1,3 +1,3 @@ package sniffer -//TODO +// TODO diff --git a/component/sniffer/tls_sniffer.go b/component/sniffer/tls_sniffer.go index f5a8fd99..71b16ce3 100644 --- a/component/sniffer/tls_sniffer.go +++ b/component/sniffer/tls_sniffer.go @@ -13,8 +13,7 @@ var ( errNotClientHello = errors.New("not client hello") ) -type TLSSniffer struct { -} +type TLSSniffer struct{} func (tls *TLSSniffer) Protocol() string { return "tls" diff --git a/component/trie/ipcidr_node.go b/component/trie/ipcidr_node.go index acaf9a8f..0ab5f6f3 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 a3a63f95..ec8e313e 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/component/trie/trie_test.go b/component/trie/trie_test.go index dca77c05..2b83ba39 100644 --- a/component/trie/trie_test.go +++ b/component/trie/trie_test.go @@ -49,7 +49,6 @@ func TestIpv4Search(t *testing.T) { assert.Equal(t, false, trie.IsContain(net.ParseIP("22"))) assert.Equal(t, false, trie.IsContain(net.ParseIP(""))) - } func TestIpv6AddSuccess(t *testing.T) { @@ -96,5 +95,4 @@ func TestIpv6Search(t *testing.T) { assert.Equal(t, true, trie.IsContainForString("2001:67c:4e8:9666::1213")) assert.Equal(t, false, trie.IsContain(net.ParseIP("22233:22"))) - } diff --git a/config/config.go b/config/config.go index 5f7eff65..c1999a08 100644 --- a/config/config.go +++ b/config/config.go @@ -4,8 +4,6 @@ import ( "container/list" "errors" "fmt" - "github.com/Dreamacro/clash/constant/sniffer" - "github.com/Dreamacro/clash/listener/tun/ipstack/commons" "net" "net/netip" "net/url" @@ -15,14 +13,11 @@ import ( "strings" "time" - "github.com/Dreamacro/clash/common/utils" - R "github.com/Dreamacro/clash/rules" - RP "github.com/Dreamacro/clash/rules/provider" - "github.com/Dreamacro/clash/adapter" "github.com/Dreamacro/clash/adapter/outbound" "github.com/Dreamacro/clash/adapter/outboundgroup" "github.com/Dreamacro/clash/adapter/provider" + "github.com/Dreamacro/clash/common/utils" "github.com/Dreamacro/clash/component/auth" "github.com/Dreamacro/clash/component/dialer" "github.com/Dreamacro/clash/component/fakeip" @@ -31,11 +26,14 @@ import ( "github.com/Dreamacro/clash/component/trie" C "github.com/Dreamacro/clash/constant" providerTypes "github.com/Dreamacro/clash/constant/provider" + "github.com/Dreamacro/clash/constant/sniffer" snifferTypes "github.com/Dreamacro/clash/constant/sniffer" "github.com/Dreamacro/clash/dns" + "github.com/Dreamacro/clash/listener/tun/ipstack/commons" "github.com/Dreamacro/clash/log" + R "github.com/Dreamacro/clash/rules" + RP "github.com/Dreamacro/clash/rules/provider" T "github.com/Dreamacro/clash/tunnel" - "gopkg.in/yaml.v3" ) @@ -332,7 +330,7 @@ func UnmarshalRawConfig(buf []byte) (*RawConfig, error) { func ParseRawConfig(rawCfg *RawConfig) (*Config, error) { config := &Config{} - log.Infoln("Start initial configuration in progress") //Segment finished in xxm + log.Infoln("Start initial configuration in progress") // Segment finished in xxm startTime := time.Now() config.Experimental = &rawCfg.Experimental config.Profile = &rawCfg.Profile @@ -386,7 +384,7 @@ func ParseRawConfig(rawCfg *RawConfig) (*Config, error) { } elapsedTime := time.Since(startTime) / time.Millisecond // duration in ms - log.Infoln("Initial configuration complete, total time: %dms", elapsedTime) //Segment finished in xxm + log.Infoln("Initial configuration complete, total time: %dms", elapsedTime) // Segment finished in xxm return config, nil } diff --git a/config/initial.go b/config/initial.go index b41fdd1a..0c1e69ac 100644 --- a/config/initial.go +++ b/config/initial.go @@ -2,12 +2,12 @@ package config import ( "fmt" - "github.com/Dreamacro/clash/component/geodata" - "github.com/Dreamacro/clash/component/mmdb" "io" "net/http" "os" + "github.com/Dreamacro/clash/component/geodata" + "github.com/Dreamacro/clash/component/mmdb" C "github.com/Dreamacro/clash/constant" "github.com/Dreamacro/clash/log" ) diff --git a/config/updateGeo.go b/config/updateGeo.go index e865f807..68a7a974 100644 --- a/config/updateGeo.go +++ b/config/updateGeo.go @@ -2,13 +2,14 @@ package config import ( "fmt" + "io/ioutil" + "net/http" + "runtime" + "github.com/Dreamacro/clash/component/geodata" _ "github.com/Dreamacro/clash/component/geodata/standard" C "github.com/Dreamacro/clash/constant" "github.com/oschwald/geoip2-golang" - "io/ioutil" - "net/http" - "runtime" ) func UpdateGeoDatabases() error { diff --git a/constant/sniffer/sniffer.go b/constant/sniffer/sniffer.go index 8ab2d496..37064799 100644 --- a/constant/sniffer/sniffer.go +++ b/constant/sniffer/sniffer.go @@ -13,9 +13,7 @@ const ( HTTP ) -var ( - List = []Type{TLS, HTTP} -) +var List = []Type{TLS, HTTP} type Type int diff --git a/context/packetconn.go b/context/packetconn.go index 3b005141..acf883f7 100644 --- a/context/packetconn.go +++ b/context/packetconn.go @@ -4,7 +4,6 @@ import ( "net" C "github.com/Dreamacro/clash/constant" - "github.com/gofrs/uuid" ) diff --git a/dns/client.go b/dns/client.go index 0bbe671f..438ba86e 100644 --- a/dns/client.go +++ b/dns/client.go @@ -4,15 +4,14 @@ import ( "context" "crypto/tls" "fmt" - "go.uber.org/atomic" "net" "net/netip" "strings" "github.com/Dreamacro/clash/component/dialer" "github.com/Dreamacro/clash/component/resolver" - D "github.com/miekg/dns" + "go.uber.org/atomic" ) type client struct { diff --git a/dns/dhcp.go b/dns/dhcp.go index a4ad70a5..b0e1bc9f 100644 --- a/dns/dhcp.go +++ b/dns/dhcp.go @@ -2,7 +2,6 @@ package dns import ( "context" - "go.uber.org/atomic" "net" "net/netip" "sync" @@ -11,8 +10,8 @@ import ( "github.com/Dreamacro/clash/component/dhcp" "github.com/Dreamacro/clash/component/iface" "github.com/Dreamacro/clash/component/resolver" - D "github.com/miekg/dns" + "go.uber.org/atomic" ) const ( diff --git a/dns/doh.go b/dns/doh.go index 36f5d21c..c6ae1c3d 100644 --- a/dns/doh.go +++ b/dns/doh.go @@ -9,7 +9,6 @@ import ( "github.com/Dreamacro/clash/component/dialer" "github.com/Dreamacro/clash/component/resolver" - D "github.com/miekg/dns" ) diff --git a/dns/doq.go b/dns/doq.go index 04d80d13..17bd6e43 100644 --- a/dns/doq.go +++ b/dns/doq.go @@ -5,15 +5,15 @@ import ( "context" "crypto/tls" "fmt" - "github.com/Dreamacro/clash/component/dialer" - "github.com/Dreamacro/clash/component/resolver" - "github.com/lucas-clemente/quic-go" "net" "strconv" "sync" "time" + "github.com/Dreamacro/clash/component/dialer" + "github.com/Dreamacro/clash/component/resolver" "github.com/Dreamacro/clash/log" + "github.com/lucas-clemente/quic-go" D "github.com/miekg/dns" ) diff --git a/dns/filters.go b/dns/filters.go index 80b656c9..ba3fa2bf 100644 --- a/dns/filters.go +++ b/dns/filters.go @@ -2,6 +2,7 @@ package dns import ( "net/netip" + "strings" "github.com/Dreamacro/clash/component/geodata" "github.com/Dreamacro/clash/component/geodata/router" @@ -9,7 +10,6 @@ import ( "github.com/Dreamacro/clash/component/trie" C "github.com/Dreamacro/clash/constant" "github.com/Dreamacro/clash/log" - "strings" ) type fallbackIPFilter interface { diff --git a/dns/middleware.go b/dns/middleware.go index 415bcd1b..dd12cd30 100644 --- a/dns/middleware.go +++ b/dns/middleware.go @@ -12,7 +12,6 @@ import ( C "github.com/Dreamacro/clash/constant" "github.com/Dreamacro/clash/context" "github.com/Dreamacro/clash/log" - D "github.com/miekg/dns" ) diff --git a/dns/resolver.go b/dns/resolver.go index 4d788c18..5e8f6945 100644 --- a/dns/resolver.go +++ b/dns/resolver.go @@ -4,7 +4,6 @@ import ( "context" "errors" "fmt" - "go.uber.org/atomic" "math/rand" "net/netip" "time" @@ -16,8 +15,8 @@ import ( "github.com/Dreamacro/clash/component/resolver" "github.com/Dreamacro/clash/component/trie" C "github.com/Dreamacro/clash/constant" - D "github.com/miekg/dns" + "go.uber.org/atomic" "golang.org/x/sync/singleflight" ) diff --git a/dns/server.go b/dns/server.go index 1fbde824..53480963 100644 --- a/dns/server.go +++ b/dns/server.go @@ -7,7 +7,6 @@ import ( "github.com/Dreamacro/clash/common/sockopt" "github.com/Dreamacro/clash/context" "github.com/Dreamacro/clash/log" - D "github.com/miekg/dns" ) diff --git a/dns/util.go b/dns/util.go index 4ea511a9..ed153bf4 100644 --- a/dns/util.go +++ b/dns/util.go @@ -15,7 +15,6 @@ import ( C "github.com/Dreamacro/clash/constant" "github.com/Dreamacro/clash/log" "github.com/Dreamacro/clash/tunnel" - D "github.com/miekg/dns" ) diff --git a/hub/executor/executor.go b/hub/executor/executor.go index 1dd21c10..5f10169e 100644 --- a/hub/executor/executor.go +++ b/hub/executor/executor.go @@ -2,8 +2,6 @@ package executor import ( "fmt" - "github.com/Dreamacro/clash/component/process" - "github.com/Dreamacro/clash/listener/inner" "net/netip" "os" "runtime" @@ -15,6 +13,7 @@ import ( "github.com/Dreamacro/clash/component/dialer" G "github.com/Dreamacro/clash/component/geodata" "github.com/Dreamacro/clash/component/iface" + "github.com/Dreamacro/clash/component/process" "github.com/Dreamacro/clash/component/profile" "github.com/Dreamacro/clash/component/profile/cachefile" "github.com/Dreamacro/clash/component/resolver" @@ -26,6 +25,7 @@ import ( "github.com/Dreamacro/clash/dns" P "github.com/Dreamacro/clash/listener" authStore "github.com/Dreamacro/clash/listener/auth" + "github.com/Dreamacro/clash/listener/inner" "github.com/Dreamacro/clash/listener/tproxy" "github.com/Dreamacro/clash/log" "github.com/Dreamacro/clash/tunnel" @@ -224,7 +224,6 @@ func loadRuleProvider(ruleProviders map[string]provider.RuleProvider) { go func() { defer func() { <-ch; wg.Done() }() loadProvider(ruleProvider) - }() } diff --git a/hub/route/cache.go b/hub/route/cache.go index bdfd2e35..3101ba75 100644 --- a/hub/route/cache.go +++ b/hub/route/cache.go @@ -4,7 +4,6 @@ import ( "net/http" "github.com/Dreamacro/clash/component/resolver" - "github.com/go-chi/chi/v5" "github.com/go-chi/render" ) diff --git a/hub/route/configs.go b/hub/route/configs.go index f87fa5ce..4a2ed163 100644 --- a/hub/route/configs.go +++ b/hub/route/configs.go @@ -1,11 +1,11 @@ package route import ( - "github.com/Dreamacro/clash/component/dialer" "net/http" "path/filepath" "sync" + "github.com/Dreamacro/clash/component/dialer" "github.com/Dreamacro/clash/component/resolver" "github.com/Dreamacro/clash/config" "github.com/Dreamacro/clash/constant" @@ -13,7 +13,6 @@ import ( P "github.com/Dreamacro/clash/listener" "github.com/Dreamacro/clash/log" "github.com/Dreamacro/clash/tunnel" - "github.com/go-chi/chi/v5" "github.com/go-chi/render" ) diff --git a/hub/route/connections.go b/hub/route/connections.go index bfe3b42d..387822df 100644 --- a/hub/route/connections.go +++ b/hub/route/connections.go @@ -8,7 +8,6 @@ import ( "time" "github.com/Dreamacro/clash/tunnel/statistic" - "github.com/go-chi/chi/v5" "github.com/go-chi/render" "github.com/gorilla/websocket" diff --git a/hub/route/groups.go b/hub/route/groups.go index e877bfd0..c94f8fde 100644 --- a/hub/route/groups.go +++ b/hub/route/groups.go @@ -2,14 +2,15 @@ package route import ( "context" + "net/http" + "strconv" + "time" + "github.com/Dreamacro/clash/adapter" C "github.com/Dreamacro/clash/constant" "github.com/Dreamacro/clash/tunnel" "github.com/go-chi/chi/v5" "github.com/go-chi/render" - "net/http" - "strconv" - "time" ) func GroupRouter() http.Handler { @@ -68,7 +69,6 @@ func getGroupDelay(w http.ResponseWriter, r *http.Request) { defer cancel() dm, err := group.URLTest(ctx, url) - if err != nil { render.Status(r, http.StatusGatewayTimeout) render.JSON(w, r, newError(err.Error())) diff --git a/hub/route/provider.go b/hub/route/provider.go index e8c985a8..0dac5d32 100644 --- a/hub/route/provider.go +++ b/hub/route/provider.go @@ -6,7 +6,6 @@ import ( "github.com/Dreamacro/clash/constant/provider" "github.com/Dreamacro/clash/tunnel" - "github.com/go-chi/chi/v5" "github.com/go-chi/render" ) diff --git a/hub/route/proxies.go b/hub/route/proxies.go index baffb1f5..e2fd1bed 100644 --- a/hub/route/proxies.go +++ b/hub/route/proxies.go @@ -12,14 +12,11 @@ import ( "github.com/Dreamacro/clash/component/profile/cachefile" C "github.com/Dreamacro/clash/constant" "github.com/Dreamacro/clash/tunnel" - "github.com/go-chi/chi/v5" "github.com/go-chi/render" ) -var ( - SwitchProxiesCallback func(sGroup string, sProxy string) -) +var SwitchProxiesCallback func(sGroup string, sProxy string) func proxyRouter() http.Handler { r := chi.NewRouter() diff --git a/hub/route/rules.go b/hub/route/rules.go index 51f8f01c..5cb7f807 100644 --- a/hub/route/rules.go +++ b/hub/route/rules.go @@ -1,11 +1,10 @@ package route import ( - "github.com/Dreamacro/clash/constant" "net/http" + "github.com/Dreamacro/clash/constant" "github.com/Dreamacro/clash/tunnel" - "github.com/go-chi/chi/v5" "github.com/go-chi/render" ) diff --git a/hub/route/server.go b/hub/route/server.go index 7ebc4ceb..b987dbd8 100644 --- a/hub/route/server.go +++ b/hub/route/server.go @@ -12,7 +12,6 @@ import ( _ "github.com/Dreamacro/clash/constant/mime" "github.com/Dreamacro/clash/log" "github.com/Dreamacro/clash/tunnel/statistic" - "github.com/go-chi/chi/v5" "github.com/go-chi/cors" "github.com/go-chi/render" diff --git a/listener/inner/tcp.go b/listener/inner/tcp.go index a7e38588..4a46c955 100644 --- a/listener/inner/tcp.go +++ b/listener/inner/tcp.go @@ -1,9 +1,10 @@ package inner import ( + "net" + "github.com/Dreamacro/clash/adapter/inbound" C "github.com/Dreamacro/clash/constant" - "net" ) var tcpIn chan<- C.ConnContext diff --git a/listener/listener.go b/listener/listener.go index 29f6d441..22515ba7 100644 --- a/listener/listener.go +++ b/listener/listener.go @@ -2,8 +2,6 @@ package proxy import ( "fmt" - "github.com/Dreamacro/clash/listener/inner" - "github.com/Dreamacro/clash/listener/tun/ipstack/commons" "net" "sort" "strconv" @@ -13,12 +11,14 @@ import ( "github.com/Dreamacro/clash/config" C "github.com/Dreamacro/clash/constant" "github.com/Dreamacro/clash/listener/http" + "github.com/Dreamacro/clash/listener/inner" "github.com/Dreamacro/clash/listener/mixed" "github.com/Dreamacro/clash/listener/redir" "github.com/Dreamacro/clash/listener/socks" "github.com/Dreamacro/clash/listener/tproxy" "github.com/Dreamacro/clash/listener/tun" "github.com/Dreamacro/clash/listener/tun/ipstack" + "github.com/Dreamacro/clash/listener/tun/ipstack/commons" "github.com/Dreamacro/clash/log" ) diff --git a/listener/tun/device/device_no_gvisor.go b/listener/tun/device/device_no_gvisor.go index b2d7225d..bef7036b 100644 --- a/listener/tun/device/device_no_gvisor.go +++ b/listener/tun/device/device_no_gvisor.go @@ -5,7 +5,6 @@ package device // Device is the interface that implemented by network layer devices (e.g. tun), // and easy to use as stack.LinkEndpoint. type Device interface { - // Name returns the current name of the device. Name() string diff --git a/listener/tun/device/fdbased/fd_unix.go b/listener/tun/device/fdbased/fd_unix.go index 63f6e839..4f7d23d7 100644 --- a/listener/tun/device/fdbased/fd_unix.go +++ b/listener/tun/device/fdbased/fd_unix.go @@ -7,7 +7,6 @@ import ( "strconv" "github.com/Dreamacro/clash/listener/tun/device" - "golang.org/x/sys/unix" ) diff --git a/listener/tun/device/fdbased/fd_unix_gvisor.go b/listener/tun/device/fdbased/fd_unix_gvisor.go index cc327c77..7f8d81c2 100644 --- a/listener/tun/device/fdbased/fd_unix_gvisor.go +++ b/listener/tun/device/fdbased/fd_unix_gvisor.go @@ -3,8 +3,9 @@ package fdbased import ( - "gvisor.dev/gvisor/pkg/tcpip/stack" "os" + + "gvisor.dev/gvisor/pkg/tcpip/stack" ) type FD struct { diff --git a/listener/tun/device/fdbased/open_linux.go b/listener/tun/device/fdbased/open_linux.go index c19b1491..f350ccfa 100644 --- a/listener/tun/device/fdbased/open_linux.go +++ b/listener/tun/device/fdbased/open_linux.go @@ -4,7 +4,6 @@ import ( "fmt" "github.com/Dreamacro/clash/listener/tun/device" - "gvisor.dev/gvisor/pkg/tcpip/link/fdbased" "gvisor.dev/gvisor/pkg/tcpip/link/rawfile" ) diff --git a/listener/tun/device/tun/driver/dll_windows.go b/listener/tun/device/tun/driver/dll_windows.go index 5f4a5dae..ee86f8e5 100644 --- a/listener/tun/device/tun/driver/dll_windows.go +++ b/listener/tun/device/tun/driver/dll_windows.go @@ -14,7 +14,6 @@ import ( "unsafe" "github.com/Dreamacro/clash/log" - "golang.org/x/sys/windows" "golang.zx2c4.com/wireguard/windows/driver/memmod" ) diff --git a/listener/tun/device/tun/tun_netstack.go b/listener/tun/device/tun/tun_netstack.go index 89dab248..40f4b0c2 100644 --- a/listener/tun/device/tun/tun_netstack.go +++ b/listener/tun/device/tun/tun_netstack.go @@ -7,7 +7,6 @@ import ( "unsafe" "github.com/Dreamacro/clash/listener/tun/device" - "golang.org/x/sys/unix" "gvisor.dev/gvisor/pkg/tcpip/link/fdbased" "gvisor.dev/gvisor/pkg/tcpip/link/rawfile" diff --git a/listener/tun/device/tun/tun_wireguard.go b/listener/tun/device/tun/tun_wireguard.go index 828dd56d..4550c048 100644 --- a/listener/tun/device/tun/tun_wireguard.go +++ b/listener/tun/device/tun/tun_wireguard.go @@ -8,7 +8,6 @@ import ( "runtime" "github.com/Dreamacro/clash/listener/tun/device" - "golang.zx2c4.com/wireguard/tun" ) diff --git a/listener/tun/device/tun/tun_wireguard_gvisor.go b/listener/tun/device/tun/tun_wireguard_gvisor.go index 400b4219..f02d9062 100644 --- a/listener/tun/device/tun/tun_wireguard_gvisor.go +++ b/listener/tun/device/tun/tun_wireguard_gvisor.go @@ -4,6 +4,7 @@ package tun import ( "fmt" + "github.com/Dreamacro/clash/listener/tun/device/iobased" "golang.zx2c4.com/wireguard/tun" ) diff --git a/listener/tun/device/tun/tun_wireguard_no_gvisor.go b/listener/tun/device/tun/tun_wireguard_no_gvisor.go index c55487c7..9451dea7 100644 --- a/listener/tun/device/tun/tun_wireguard_no_gvisor.go +++ b/listener/tun/device/tun/tun_wireguard_no_gvisor.go @@ -16,7 +16,6 @@ type TUN struct { } func closeIO(t *TUN) { - } func newEq(t *TUN) error { diff --git a/listener/tun/device/tun/tun_wireguard_windows.go b/listener/tun/device/tun/tun_wireguard_windows.go index c5c16a1d..4018932c 100644 --- a/listener/tun/device/tun/tun_wireguard_windows.go +++ b/listener/tun/device/tun/tun_wireguard_windows.go @@ -2,7 +2,6 @@ package tun import ( "github.com/Dreamacro/clash/listener/tun/device/tun/driver" - "golang.org/x/sys/windows" "golang.zx2c4.com/wireguard/tun" ) diff --git a/listener/tun/ipstack/commons/auto_linux.go b/listener/tun/ipstack/commons/auto_linux.go index 36be5a66..17587c40 100644 --- a/listener/tun/ipstack/commons/auto_linux.go +++ b/listener/tun/ipstack/commons/auto_linux.go @@ -1,12 +1,13 @@ package commons import ( + "time" + "github.com/Dreamacro/clash/component/dialer" "github.com/Dreamacro/clash/component/iface" "github.com/Dreamacro/clash/log" "github.com/vishvananda/netlink" "go.uber.org/atomic" - "time" ) var ( diff --git a/listener/tun/ipstack/commons/auto_others.go b/listener/tun/ipstack/commons/auto_others.go index 23772c5e..5922ef4f 100644 --- a/listener/tun/ipstack/commons/auto_others.go +++ b/listener/tun/ipstack/commons/auto_others.go @@ -3,11 +3,12 @@ package commons import ( + "time" + "github.com/Dreamacro/clash/component/dialer" "github.com/Dreamacro/clash/component/iface" "github.com/Dreamacro/clash/log" "go.uber.org/atomic" - "time" ) var ( diff --git a/listener/tun/ipstack/commons/router.go b/listener/tun/ipstack/commons/router.go index 57c99502..a4b0c29d 100644 --- a/listener/tun/ipstack/commons/router.go +++ b/listener/tun/ipstack/commons/router.go @@ -2,14 +2,13 @@ package commons import ( "fmt" - "github.com/Dreamacro/clash/log" "net" "time" + + "github.com/Dreamacro/clash/log" ) -var ( - defaultRoutes = []string{"1.0.0.0/8", "2.0.0.0/7", "4.0.0.0/6", "8.0.0.0/5", "16.0.0.0/4", "32.0.0.0/3", "64.0.0.0/2", "128.0.0.0/1"} -) +var defaultRoutes = []string{"1.0.0.0/8", "2.0.0.0/7", "4.0.0.0/6", "8.0.0.0/5", "16.0.0.0/4", "32.0.0.0/3", "64.0.0.0/2", "128.0.0.0/1"} func ipv4MaskString(bits int) string { m := net.CIDRMask(bits, 32) diff --git a/listener/tun/ipstack/commons/router_android.go b/listener/tun/ipstack/commons/router_android.go index 139dbca9..8d6d8be9 100644 --- a/listener/tun/ipstack/commons/router_android.go +++ b/listener/tun/ipstack/commons/router_android.go @@ -2,11 +2,12 @@ package commons import ( "fmt" + "net" + "net/netip" + "github.com/Dreamacro/clash/listener/tun/device" "github.com/Dreamacro/clash/log" "github.com/vishvananda/netlink" - "net" - "net/netip" ) func GetAutoDetectInterface() (ifn string, err error) { @@ -60,7 +61,7 @@ func ConfigInterfaceAddress(dev device.Device, addr netip.Prefix, forceMTU int, func configInterfaceRouting(index int, interfaceName string, ip netip.Addr) error { const tableId = 1981801 - var pref = 9000 + pref := 9000 for _, route := range defaultRoutes { _, ipn, err := net.ParseCIDR(route) diff --git a/listener/tun/ipstack/commons/router_linux.go b/listener/tun/ipstack/commons/router_linux.go index 37a92d2e..f4d22284 100644 --- a/listener/tun/ipstack/commons/router_linux.go +++ b/listener/tun/ipstack/commons/router_linux.go @@ -4,10 +4,11 @@ package commons import ( "fmt" - "github.com/Dreamacro/clash/listener/tun/device" - "github.com/vishvananda/netlink" "net" "net/netip" + + "github.com/Dreamacro/clash/listener/tun/device" + "github.com/vishvananda/netlink" ) func GetAutoDetectInterface() (string, error) { diff --git a/listener/tun/ipstack/commons/router_windows.go b/listener/tun/ipstack/commons/router_windows.go index 2abfa0ff..e0a14f96 100644 --- a/listener/tun/ipstack/commons/router_windows.go +++ b/listener/tun/ipstack/commons/router_windows.go @@ -10,7 +10,6 @@ import ( "github.com/Dreamacro/clash/listener/tun/device" "github.com/Dreamacro/clash/listener/tun/device/tun" "github.com/Dreamacro/clash/log" - "golang.org/x/sys/windows" "golang.zx2c4.com/wireguard/windows/services" "golang.zx2c4.com/wireguard/windows/tunnel/winipcfg" diff --git a/listener/tun/ipstack/gvisor/nic.go b/listener/tun/ipstack/gvisor/nic.go index 77a1a349..577bc30d 100644 --- a/listener/tun/ipstack/gvisor/nic.go +++ b/listener/tun/ipstack/gvisor/nic.go @@ -6,7 +6,6 @@ import ( "fmt" "github.com/Dreamacro/clash/listener/tun/ipstack/gvisor/option" - "gvisor.dev/gvisor/pkg/tcpip" "gvisor.dev/gvisor/pkg/tcpip/stack" ) diff --git a/listener/tun/ipstack/gvisor/route.go b/listener/tun/ipstack/gvisor/route.go index 8e1ae94e..4197fd6e 100644 --- a/listener/tun/ipstack/gvisor/route.go +++ b/listener/tun/ipstack/gvisor/route.go @@ -4,7 +4,6 @@ package gvisor import ( "github.com/Dreamacro/clash/listener/tun/ipstack/gvisor/option" - "gvisor.dev/gvisor/pkg/tcpip" "gvisor.dev/gvisor/pkg/tcpip/header" "gvisor.dev/gvisor/pkg/tcpip/stack" diff --git a/listener/tun/ipstack/gvisor/stack.go b/listener/tun/ipstack/gvisor/stack.go index c79bd0df..46431c17 100644 --- a/listener/tun/ipstack/gvisor/stack.go +++ b/listener/tun/ipstack/gvisor/stack.go @@ -11,7 +11,6 @@ import ( "github.com/Dreamacro/clash/listener/tun/device" "github.com/Dreamacro/clash/listener/tun/ipstack" "github.com/Dreamacro/clash/listener/tun/ipstack/gvisor/option" - "gvisor.dev/gvisor/pkg/tcpip" "gvisor.dev/gvisor/pkg/tcpip/network/ipv4" "gvisor.dev/gvisor/pkg/tcpip/network/ipv6" diff --git a/listener/tun/ipstack/gvisor/stack_no_gvisor.go b/listener/tun/ipstack/gvisor/stack_no_gvisor.go index 7a424e74..1f49430a 100644 --- a/listener/tun/ipstack/gvisor/stack_no_gvisor.go +++ b/listener/tun/ipstack/gvisor/stack_no_gvisor.go @@ -4,12 +4,13 @@ package gvisor import ( "fmt" + "net/netip" + "github.com/Dreamacro/clash/adapter/inbound" C "github.com/Dreamacro/clash/constant" "github.com/Dreamacro/clash/listener/tun/device" "github.com/Dreamacro/clash/listener/tun/ipstack" "github.com/Dreamacro/clash/log" - "net/netip" ) // New allocates a new *gvStack with given options. diff --git a/listener/tun/ipstack/gvisor/tcp.go b/listener/tun/ipstack/gvisor/tcp.go index 660912cb..2db87eed 100644 --- a/listener/tun/ipstack/gvisor/tcp.go +++ b/listener/tun/ipstack/gvisor/tcp.go @@ -8,7 +8,6 @@ import ( "github.com/Dreamacro/clash/listener/tun/ipstack/gvisor/adapter" "github.com/Dreamacro/clash/listener/tun/ipstack/gvisor/option" "github.com/Dreamacro/clash/log" - "gvisor.dev/gvisor/pkg/tcpip" "gvisor.dev/gvisor/pkg/tcpip/adapters/gonet" "gvisor.dev/gvisor/pkg/tcpip/header" diff --git a/listener/tun/ipstack/gvisor/udp.go b/listener/tun/ipstack/gvisor/udp.go index f010ed8a..80098887 100644 --- a/listener/tun/ipstack/gvisor/udp.go +++ b/listener/tun/ipstack/gvisor/udp.go @@ -9,7 +9,6 @@ import ( "github.com/Dreamacro/clash/listener/tun/ipstack/gvisor/adapter" "github.com/Dreamacro/clash/listener/tun/ipstack/gvisor/option" "github.com/Dreamacro/clash/log" - "gvisor.dev/gvisor/pkg/tcpip/adapters/gonet" "gvisor.dev/gvisor/pkg/tcpip/stack" "gvisor.dev/gvisor/pkg/tcpip/transport/udp" diff --git a/listener/tun/ipstack/system/mars/nat/nat.go b/listener/tun/ipstack/system/mars/nat/nat.go index 7954ace1..d06978c7 100644 --- a/listener/tun/ipstack/system/mars/nat/nat.go +++ b/listener/tun/ipstack/system/mars/nat/nat.go @@ -1,13 +1,13 @@ package nat import ( - log "github.com/sirupsen/logrus" "io" "net" "net/netip" "github.com/Dreamacro/clash/common/pool" "github.com/Dreamacro/clash/listener/tun/ipstack/system/mars/tcpip" + log "github.com/sirupsen/logrus" ) func Start(device io.ReadWriter, gateway, portal, broadcast netip.Addr) (*TCP, *UDP, error) { diff --git a/listener/tun/tun_adapter.go b/listener/tun/tun_adapter.go index 7b69c5f3..ad5df9c3 100644 --- a/listener/tun/tun_adapter.go +++ b/listener/tun/tun_adapter.go @@ -2,6 +2,11 @@ package tun import ( "fmt" + "net/netip" + "net/url" + "runtime" + "strings" + "github.com/Dreamacro/clash/adapter/inbound" "github.com/Dreamacro/clash/common/cmd" "github.com/Dreamacro/clash/component/process" @@ -15,15 +20,10 @@ import ( "github.com/Dreamacro/clash/listener/tun/ipstack/gvisor" "github.com/Dreamacro/clash/listener/tun/ipstack/system" "github.com/Dreamacro/clash/log" - "net/netip" - "net/url" - "runtime" - "strings" ) // New TunAdapter func New(tunConf *config.Tun, tcpIn chan<- C.ConnContext, udpIn chan<- *inbound.PacketAdapter) (ipstack.Stack, error) { - var ( tunAddress = tunConf.TunAddressPrefix devName = tunConf.Device diff --git a/log/log.go b/log/log.go index f1053f44..f4640e26 100644 --- a/log/log.go +++ b/log/log.go @@ -5,7 +5,6 @@ import ( "os" "github.com/Dreamacro/clash/common/observable" - log "github.com/sirupsen/logrus" ) diff --git a/main.go b/main.go index e13b8dc8..b18faab2 100644 --- a/main.go +++ b/main.go @@ -3,7 +3,6 @@ package main import ( "flag" "fmt" - "github.com/Dreamacro/clash/constant/features" "os" "os/signal" "path/filepath" @@ -13,10 +12,10 @@ import ( "github.com/Dreamacro/clash/config" C "github.com/Dreamacro/clash/constant" + "github.com/Dreamacro/clash/constant/features" "github.com/Dreamacro/clash/hub" "github.com/Dreamacro/clash/hub/executor" "github.com/Dreamacro/clash/log" - "go.uber.org/automaxprocs/maxprocs" ) diff --git a/rules/common/geoip.go b/rules/common/geoip.go index aeddcbdb..05fc186d 100644 --- a/rules/common/geoip.go +++ b/rules/common/geoip.go @@ -2,10 +2,10 @@ package common import ( "fmt" - "github.com/Dreamacro/clash/component/geodata" - "github.com/Dreamacro/clash/component/geodata/router" "strings" + "github.com/Dreamacro/clash/component/geodata" + "github.com/Dreamacro/clash/component/geodata/router" "github.com/Dreamacro/clash/component/mmdb" "github.com/Dreamacro/clash/component/resolver" C "github.com/Dreamacro/clash/constant" diff --git a/rules/common/geosite.go b/rules/common/geosite.go index 10fe3152..7cbe3192 100644 --- a/rules/common/geosite.go +++ b/rules/common/geosite.go @@ -2,13 +2,14 @@ package common import ( "fmt" + _ "unsafe" + "github.com/Dreamacro/clash/component/geodata" _ "github.com/Dreamacro/clash/component/geodata/memconservative" "github.com/Dreamacro/clash/component/geodata/router" _ "github.com/Dreamacro/clash/component/geodata/standard" C "github.com/Dreamacro/clash/constant" "github.com/Dreamacro/clash/log" - _ "unsafe" ) //go:linkname initGeoSite github.com/Dreamacro/clash/config.initGeoSite diff --git a/rules/common/in_type.go b/rules/common/in_type.go index c577c843..77eccdc5 100644 --- a/rules/common/in_type.go +++ b/rules/common/in_type.go @@ -2,8 +2,9 @@ package common import ( "fmt" - C "github.com/Dreamacro/clash/constant" "strings" + + C "github.com/Dreamacro/clash/constant" ) type InType struct { diff --git a/rules/common/ipsuffix.go b/rules/common/ipsuffix.go index 18271244..9e986a8a 100644 --- a/rules/common/ipsuffix.go +++ b/rules/common/ipsuffix.go @@ -1,8 +1,9 @@ package common import ( - C "github.com/Dreamacro/clash/constant" "net/netip" + + C "github.com/Dreamacro/clash/constant" ) type IPSuffix struct { diff --git a/rules/common/network_type.go b/rules/common/network_type.go index 107df91e..5ffa9c98 100644 --- a/rules/common/network_type.go +++ b/rules/common/network_type.go @@ -2,8 +2,9 @@ package common import ( "fmt" - C "github.com/Dreamacro/clash/constant" "strings" + + C "github.com/Dreamacro/clash/constant" ) type NetworkType struct { diff --git a/rules/common/uid.go b/rules/common/uid.go index f7ea4875..581d14cf 100644 --- a/rules/common/uid.go +++ b/rules/common/uid.go @@ -2,13 +2,14 @@ package common import ( "fmt" + "runtime" + "strconv" + "strings" + "github.com/Dreamacro/clash/common/utils" "github.com/Dreamacro/clash/component/process" C "github.com/Dreamacro/clash/constant" "github.com/Dreamacro/clash/log" - "runtime" - "strconv" - "strings" ) type Uid struct { diff --git a/rules/logic/and.go b/rules/logic/and.go index edcb0e04..651beda0 100644 --- a/rules/logic/and.go +++ b/rules/logic/and.go @@ -2,9 +2,10 @@ package logic import ( "fmt" + "strings" + C "github.com/Dreamacro/clash/constant" "github.com/Dreamacro/clash/rules/common" - "strings" ) type AND struct { diff --git a/rules/logic/common.go b/rules/logic/common.go index d3d68100..9b534d31 100644 --- a/rules/logic/common.go +++ b/rules/logic/common.go @@ -2,11 +2,12 @@ package logic import ( "fmt" - "github.com/Dreamacro/clash/common/collections" - C "github.com/Dreamacro/clash/constant" "regexp" "strings" _ "unsafe" + + "github.com/Dreamacro/clash/common/collections" + C "github.com/Dreamacro/clash/constant" ) //go:linkname parseRule github.com/Dreamacro/clash/rules.ParseRule diff --git a/rules/logic/logic_test.go b/rules/logic/logic_test.go index c279995b..e30377df 100644 --- a/rules/logic/logic_test.go +++ b/rules/logic/logic_test.go @@ -1,9 +1,10 @@ package logic import ( + "testing" + "github.com/Dreamacro/clash/constant" "github.com/stretchr/testify/assert" - "testing" ) func TestAND(t *testing.T) { diff --git a/rules/logic/not.go b/rules/logic/not.go index d72076fc..4d4492e9 100644 --- a/rules/logic/not.go +++ b/rules/logic/not.go @@ -2,6 +2,7 @@ package logic import ( "fmt" + C "github.com/Dreamacro/clash/constant" "github.com/Dreamacro/clash/rules/common" ) diff --git a/rules/logic/or.go b/rules/logic/or.go index f8295552..1d01baed 100644 --- a/rules/logic/or.go +++ b/rules/logic/or.go @@ -2,9 +2,10 @@ package logic import ( "fmt" + "strings" + C "github.com/Dreamacro/clash/constant" "github.com/Dreamacro/clash/rules/common" - "strings" ) type OR struct { diff --git a/rules/provider/domain_strategy.go b/rules/provider/domain_strategy.go index d78bb44c..bc2aa390 100644 --- a/rules/provider/domain_strategy.go +++ b/rules/provider/domain_strategy.go @@ -1,10 +1,11 @@ package provider import ( + "strings" + "github.com/Dreamacro/clash/component/trie" C "github.com/Dreamacro/clash/constant" "github.com/Dreamacro/clash/log" - "strings" ) type domainStrategy struct { diff --git a/rules/provider/fetcher.go b/rules/provider/fetcher.go index 89dfd5db..681e6a3d 100644 --- a/rules/provider/fetcher.go +++ b/rules/provider/fetcher.go @@ -3,17 +3,18 @@ package provider import ( "bytes" "crypto/md5" - P "github.com/Dreamacro/clash/constant/provider" - "github.com/Dreamacro/clash/log" "io/ioutil" "os" "path/filepath" "time" + + P "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/rules/provider/parse.go b/rules/provider/parse.go index 51452d09..73cc0415 100644 --- a/rules/provider/parse.go +++ b/rules/provider/parse.go @@ -2,13 +2,14 @@ package provider import ( "fmt" + "time" + "github.com/Dreamacro/clash/adapter/provider" "github.com/Dreamacro/clash/common/structure" C "github.com/Dreamacro/clash/constant" P "github.com/Dreamacro/clash/constant/provider" RC "github.com/Dreamacro/clash/rules/common" "github.com/Dreamacro/clash/rules/ruleparser" - "time" ) type ruleProviderSchema struct { diff --git a/rules/provider/provider.go b/rules/provider/provider.go index a92df718..479125dc 100644 --- a/rules/provider/provider.go +++ b/rules/provider/provider.go @@ -2,16 +2,15 @@ package provider import ( "encoding/json" + "runtime" + "time" + C "github.com/Dreamacro/clash/constant" P "github.com/Dreamacro/clash/constant/provider" "gopkg.in/yaml.v3" - "runtime" - "time" ) -var ( - ruleProviders = map[string]P.RuleProvider{} -) +var ruleProviders = map[string]P.RuleProvider{} type ruleSetProvider struct { *fetcher diff --git a/rules/provider/rule_set.go b/rules/provider/rule_set.go index 81419818..1c33d40e 100644 --- a/rules/provider/rule_set.go +++ b/rules/provider/rule_set.go @@ -2,6 +2,7 @@ package provider import ( "fmt" + C "github.com/Dreamacro/clash/constant" P "github.com/Dreamacro/clash/constant/provider" "github.com/Dreamacro/clash/rules/common" @@ -38,6 +39,7 @@ func (rs *RuleSet) Payload() string { func (rs *RuleSet) ShouldResolveIP() bool { return !rs.noResolveIP && rs.getProviders().ShouldResolveIP() } + func (rs *RuleSet) getProviders() P.RuleProvider { if rs.ruleProvider == nil { rp := RuleProviders()[rs.ruleProviderName] diff --git a/rules/ruleparser/ruleparser.go b/rules/ruleparser/ruleparser.go index 64294374..eb540370 100644 --- a/rules/ruleparser/ruleparser.go +++ b/rules/ruleparser/ruleparser.go @@ -2,6 +2,7 @@ package ruleparser import ( "fmt" + C "github.com/Dreamacro/clash/constant" RC "github.com/Dreamacro/clash/rules/common" ) diff --git a/transport/gun/gun.go b/transport/gun/gun.go index f65a1929..38bbd430 100644 --- a/transport/gun/gun.go +++ b/transport/gun/gun.go @@ -19,7 +19,6 @@ import ( "github.com/Dreamacro/clash/common/pool" C "github.com/Dreamacro/clash/constant" - "go.uber.org/atomic" "golang.org/x/net/http2" ) diff --git a/transport/gun/transport.go b/transport/gun/transport.go index 12ccfd5c..4d543b7b 100644 --- a/transport/gun/transport.go +++ b/transport/gun/transport.go @@ -1,8 +1,9 @@ package gun import ( - "golang.org/x/net/http2" "net" + + "golang.org/x/net/http2" ) type TransportWrap struct { diff --git a/transport/snell/cipher.go b/transport/snell/cipher.go index 24999e28..c615a0f9 100644 --- a/transport/snell/cipher.go +++ b/transport/snell/cipher.go @@ -5,7 +5,6 @@ import ( "crypto/cipher" "github.com/Dreamacro/clash/transport/shadowsocks/shadowaead" - "golang.org/x/crypto/argon2" "golang.org/x/crypto/chacha20poly1305" ) diff --git a/transport/trojan/trojan.go b/transport/trojan/trojan.go index d6ee7285..7c9dca00 100644 --- a/transport/trojan/trojan.go +++ b/transport/trojan/trojan.go @@ -18,7 +18,6 @@ import ( "github.com/Dreamacro/clash/transport/socks5" "github.com/Dreamacro/clash/transport/vless" "github.com/Dreamacro/clash/transport/vmess" - xtls "github.com/xtls/go" ) diff --git a/transport/vless/config.pb.go b/transport/vless/config.pb.go index 1407e4d7..191bc5c7 100644 --- a/transport/vless/config.pb.go +++ b/transport/vless/config.pb.go @@ -7,10 +7,11 @@ package vless import ( - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" sync "sync" + + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" ) const ( diff --git a/transport/vless/vless.go b/transport/vless/vless.go index 5afe2c3e..7acaeea7 100644 --- a/transport/vless/vless.go +++ b/transport/vless/vless.go @@ -1,9 +1,9 @@ package vless import ( - "github.com/Dreamacro/clash/common/utils" "net" + "github.com/Dreamacro/clash/common/utils" "github.com/gofrs/uuid" ) diff --git a/transport/vmess/vmess.go b/transport/vmess/vmess.go index d7c8edb4..3c63251b 100644 --- a/transport/vmess/vmess.go +++ b/transport/vmess/vmess.go @@ -2,11 +2,11 @@ package vmess import ( "fmt" - "github.com/Dreamacro/clash/common/utils" "math/rand" "net" "runtime" + "github.com/Dreamacro/clash/common/utils" "github.com/gofrs/uuid" ) diff --git a/tunnel/statistic/tracker.go b/tunnel/statistic/tracker.go index fc627297..2a7ab028 100644 --- a/tunnel/statistic/tracker.go +++ b/tunnel/statistic/tracker.go @@ -5,7 +5,6 @@ import ( "time" C "github.com/Dreamacro/clash/constant" - "github.com/gofrs/uuid" "go.uber.org/atomic" ) diff --git a/tunnel/tunnel.go b/tunnel/tunnel.go index b8038520..f304c05b 100644 --- a/tunnel/tunnel.go +++ b/tunnel/tunnel.go @@ -3,7 +3,6 @@ package tunnel import ( "context" "fmt" - P "github.com/Dreamacro/clash/component/process" "net" "net/netip" "path/filepath" @@ -14,6 +13,7 @@ import ( "github.com/Dreamacro/clash/adapter/inbound" "github.com/Dreamacro/clash/component/nat" + P "github.com/Dreamacro/clash/component/process" "github.com/Dreamacro/clash/component/resolver" "github.com/Dreamacro/clash/component/sniffer" C "github.com/Dreamacro/clash/constant"