From e71c2726937e11229e7d1aeec5a3c3ab7ef21c3f Mon Sep 17 00:00:00 2001 From: czybjtu Date: Sun, 23 Apr 2023 13:27:29 +0800 Subject: [PATCH] style: format golang import package code style (#58) Co-authored-by: Kevin Yu --- Makefile | 2 ++ cmd/export.go | 1 + cmd/internal/su.go | 3 ++- cmd/reload.go | 5 ++-- cmd/run.go | 23 ++++++++++--------- cmd/suspend.go | 5 ++-- cmd/validate.go | 3 ++- common/assets/assets.go | 5 ++-- common/bitlist/bitlist.go | 5 ++-- common/consts/dialer.go | 3 ++- common/consts/ebpf.go | 3 ++- common/debug.go | 3 ++- common/json/fuzzy_decoder.go | 5 ++-- common/netutils/dns.go | 11 +++++---- common/netutils/ip46.go | 5 ++-- common/subscription/subscription.go | 5 ++-- common/utils.go | 9 ++++---- component/dns/dns.go | 7 +++--- component/dns/function_parser.go | 5 ++-- component/dns/request_routing.go | 3 ++- component/dns/response_routing.go | 7 +++--- component/dns/upstream.go | 7 +++--- component/outbound/dialer/alive_dialer_set.go | 7 +++--- component/outbound/dialer/block.go | 3 ++- .../outbound/dialer/connectivity_check.go | 15 ++++++------ component/outbound/dialer/dialer.go | 5 ++-- component/outbound/dialer/http/http.go | 9 ++++---- component/outbound/dialer/register.go | 3 ++- .../dialer/shadowsocks/shadowsocks.go | 15 ++++++------ .../dialer/shadowsocksr/shadowsocksr.go | 13 ++++++----- component/outbound/dialer/sockopt.go | 3 ++- component/outbound/dialer/socks/socks.go | 9 ++++---- component/outbound/dialer/trojan/trojan.go | 17 +++++++------- component/outbound/dialer/v2ray/v2ray.go | 9 ++++---- component/outbound/dialer_group.go | 3 ++- component/outbound/dialer_group_test.go | 5 ++-- component/outbound/dialer_selection_policy.go | 3 ++- component/outbound/filter.go | 5 ++-- component/outbound/outbound.go | 8 +++---- .../transport/simpleobfs/simpleobfs.go | 2 +- .../routing/domain_matcher/benchmark_test.go | 12 +++++----- component/routing/function_parser.go | 2 +- .../sniffing/internal/quicutils/cipher.go | 2 +- .../internal/quicutils/cipher_test.go | 3 ++- component/sniffing/quic.go | 5 ++-- component/sniffing/quic_bench_test.go | 3 ++- component/sniffing/sniffing_bench_test.go | 3 ++- component/sniffing/tls.go | 3 ++- component/sniffing/tls_test.go | 3 ++- config/config.go | 3 ++- config/config_merger.go | 5 ++-- config/marshal.go | 5 ++-- config/outline.go | 3 ++- config/parser.go | 5 ++-- config/patch.go | 3 ++- control/addr.go | 3 ++- control/bpf_utils.go | 11 +++++---- control/connectivity.go | 3 ++- control/control_plane.go | 19 +++++++-------- control/control_plane_core.go | 9 ++++---- control/dns_cache.go | 5 ++-- control/dns_control.go | 15 ++++++------ control/dns_utils.go | 3 ++- control/routing_matcher_builder.go | 5 ++-- control/routing_matcher_userspace.go | 3 ++- control/tcp.go | 9 ++++---- control/udp.go | 11 +++++---- control/udp_endpoint.go | 7 +++--- control/utils.go | 7 +++--- main.go | 7 +++--- pkg/anybuffer/anybuffer.go | 1 + pkg/config_parser/config_parser.go | 1 + pkg/config_parser/error.go | 5 ++-- pkg/config_parser/walker.go | 7 +++--- pkg/ebpf_internal/version.go | 3 ++- pkg/geodata/common.pb.go | 5 ++-- pkg/geodata/decode.go | 3 ++- pkg/geodata/geodata.go | 5 ++-- pkg/geodata/protoext/extensions.pb.go | 5 ++-- pkg/trie/trie.go | 5 ++-- 80 files changed, 276 insertions(+), 200 deletions(-) diff --git a/Makefile b/Makefile index 40b7bc8..ec52d70 100644 --- a/Makefile +++ b/Makefile @@ -43,6 +43,8 @@ dae: ebpf clean-ebpf: @rm -f control/bpf_bpf*.go && \ rm -f control/bpf_bpf*.o +fmt: + go fmt ./... # $BPF_CLANG is used in go:generate invocations. ebpf: export BPF_CLANG := $(CLANG) diff --git a/cmd/export.go b/cmd/export.go index 7c5b20b..ada1488 100644 --- a/cmd/export.go +++ b/cmd/export.go @@ -7,6 +7,7 @@ package cmd import ( "fmt" + "github.com/daeuniverse/dae/config" "github.com/spf13/cobra" ) diff --git a/cmd/internal/su.go b/cmd/internal/su.go index d1a694d..98a6dc2 100644 --- a/cmd/internal/su.go +++ b/cmd/internal/su.go @@ -2,10 +2,11 @@ package internal import ( "fmt" - "github.com/sirupsen/logrus" "os" "os/exec" "path/filepath" + + "github.com/sirupsen/logrus" ) func AutoSu() { diff --git a/cmd/reload.go b/cmd/reload.go index 2648c1b..5560353 100644 --- a/cmd/reload.go +++ b/cmd/reload.go @@ -7,12 +7,13 @@ package cmd import ( "fmt" - "github.com/spf13/cobra" - "github.com/daeuniverse/dae/cmd/internal" "os" "strconv" "strings" "syscall" + + "github.com/daeuniverse/dae/cmd/internal" + "github.com/spf13/cobra" ) var ( diff --git a/cmd/run.go b/cmd/run.go index bff8c5d..b3fdb1c 100644 --- a/cmd/run.go +++ b/cmd/run.go @@ -3,17 +3,6 @@ package cmd import ( "errors" "fmt" - "github.com/daeuniverse/dae/cmd/internal" - "github.com/daeuniverse/dae/common" - "github.com/daeuniverse/dae/common/subscription" - "github.com/daeuniverse/dae/config" - "github.com/daeuniverse/dae/control" - "github.com/daeuniverse/dae/pkg/config_parser" - "github.com/daeuniverse/dae/pkg/logger" - "github.com/mohae/deepcopy" - "github.com/okzk/sdnotify" - "github.com/sirupsen/logrus" - "github.com/spf13/cobra" "math/rand" "net" "net/http" @@ -25,6 +14,18 @@ import ( "strings" "syscall" "time" + + "github.com/daeuniverse/dae/cmd/internal" + "github.com/daeuniverse/dae/common" + "github.com/daeuniverse/dae/common/subscription" + "github.com/daeuniverse/dae/config" + "github.com/daeuniverse/dae/control" + "github.com/daeuniverse/dae/pkg/config_parser" + "github.com/daeuniverse/dae/pkg/logger" + "github.com/mohae/deepcopy" + "github.com/okzk/sdnotify" + "github.com/sirupsen/logrus" + "github.com/spf13/cobra" ) const ( diff --git a/cmd/suspend.go b/cmd/suspend.go index 461440b..9e8ef1f 100644 --- a/cmd/suspend.go +++ b/cmd/suspend.go @@ -7,12 +7,13 @@ package cmd import ( "fmt" - "github.com/daeuniverse/dae/cmd/internal" - "github.com/spf13/cobra" "os" "strconv" "strings" "syscall" + + "github.com/daeuniverse/dae/cmd/internal" + "github.com/spf13/cobra" ) var ( diff --git a/cmd/validate.go b/cmd/validate.go index 4b7dcc2..cbe173d 100644 --- a/cmd/validate.go +++ b/cmd/validate.go @@ -7,8 +7,9 @@ package cmd import ( "fmt" - "github.com/spf13/cobra" "os" + + "github.com/spf13/cobra" ) var ( diff --git a/common/assets/assets.go b/common/assets/assets.go index db47207..55ba5b2 100644 --- a/common/assets/assets.go +++ b/common/assets/assets.go @@ -8,8 +8,6 @@ package assets import ( "errors" "fmt" - "github.com/adrg/xdg" - "github.com/sirupsen/logrus" "io/fs" "os" "path/filepath" @@ -17,6 +15,9 @@ import ( "strings" "sync" "time" + + "github.com/adrg/xdg" + "github.com/sirupsen/logrus" ) const CacheTimeout = 5 * time.Second diff --git a/common/bitlist/bitlist.go b/common/bitlist/bitlist.go index 24fded1..84aacc4 100644 --- a/common/bitlist/bitlist.go +++ b/common/bitlist/bitlist.go @@ -7,9 +7,10 @@ package bitlist import ( "fmt" - "github.com/mzz2017/softwind/common" - "github.com/daeuniverse/dae/pkg/anybuffer" "math/bits" + + "github.com/daeuniverse/dae/pkg/anybuffer" + "github.com/mzz2017/softwind/common" ) // CompactBitList allows your units to be of arbitrary bit size. diff --git a/common/consts/dialer.go b/common/consts/dialer.go index a877243..ce27943 100644 --- a/common/consts/dialer.go +++ b/common/consts/dialer.go @@ -6,8 +6,9 @@ package consts import ( - "golang.org/x/sys/unix" "net/netip" + + "golang.org/x/sys/unix" ) type DialerSelectionPolicy string diff --git a/common/consts/ebpf.go b/common/consts/ebpf.go index b0dfc09..f532ccb 100644 --- a/common/consts/ebpf.go +++ b/common/consts/ebpf.go @@ -6,9 +6,10 @@ package consts import ( - internal "github.com/daeuniverse/dae/pkg/ebpf_internal" "strconv" "strings" + + internal "github.com/daeuniverse/dae/pkg/ebpf_internal" ) const ( diff --git a/common/debug.go b/common/debug.go index 7e91413..6cc5bb5 100644 --- a/common/debug.go +++ b/common/debug.go @@ -6,11 +6,12 @@ package common import ( - "github.com/sirupsen/logrus" "os" "path/filepath" "strconv" "strings" + + "github.com/sirupsen/logrus" ) func ReportMemory(tag string) { diff --git a/common/json/fuzzy_decoder.go b/common/json/fuzzy_decoder.go index 3dbc7e7..5867146 100644 --- a/common/json/fuzzy_decoder.go +++ b/common/json/fuzzy_decoder.go @@ -6,8 +6,9 @@ package json import ( - jsoniter "github.com/json-iterator/go" "unsafe" + + jsoniter "github.com/json-iterator/go" ) type FuzzyBoolDecoder struct { @@ -48,4 +49,4 @@ func (decoder *FuzzyBoolDecoder) Decode(ptr unsafe.Pointer, iter *jsoniter.Itera default: iter.ReportError("FuzzyBoolDecoder", "not number, string or bool") } -} \ No newline at end of file +} diff --git a/common/netutils/dns.go b/common/netutils/dns.go index 3103b37..6d12b0b 100644 --- a/common/netutils/dns.go +++ b/common/netutils/dns.go @@ -9,17 +9,18 @@ import ( "context" "encoding/binary" "fmt" - "github.com/mzz2017/softwind/netproxy" - "github.com/mzz2017/softwind/pkg/fastrand" - "github.com/mzz2017/softwind/pool" - "github.com/sirupsen/logrus" - "golang.org/x/net/dns/dnsmessage" "io" "math" "net/netip" "strings" "sync" "time" + + "github.com/mzz2017/softwind/netproxy" + "github.com/mzz2017/softwind/pkg/fastrand" + "github.com/mzz2017/softwind/pool" + "github.com/sirupsen/logrus" + "golang.org/x/net/dns/dnsmessage" ) var ( diff --git a/common/netutils/ip46.go b/common/netutils/ip46.go index a9498f0..f9a7504 100644 --- a/common/netutils/ip46.go +++ b/common/netutils/ip46.go @@ -9,11 +9,12 @@ import ( "context" "errors" "fmt" + "net/netip" + "sync" + "github.com/mzz2017/softwind/netproxy" "github.com/sirupsen/logrus" "golang.org/x/net/dns/dnsmessage" - "net/netip" - "sync" ) type Ip46 struct { diff --git a/common/subscription/subscription.go b/common/subscription/subscription.go index 7f64524..b187d99 100644 --- a/common/subscription/subscription.go +++ b/common/subscription/subscription.go @@ -10,8 +10,6 @@ import ( "bytes" "encoding/json" "fmt" - "github.com/sirupsen/logrus" - "github.com/daeuniverse/dae/common" "io" "net" "net/http" @@ -20,6 +18,9 @@ import ( "path/filepath" "strconv" "strings" + + "github.com/daeuniverse/dae/common" + "github.com/sirupsen/logrus" ) type sip008 struct { diff --git a/common/utils.go b/common/utils.go index 2f0ab22..a34e556 100644 --- a/common/utils.go +++ b/common/utils.go @@ -12,10 +12,6 @@ import ( "encoding/binary" "encoding/hex" "fmt" - internal "github.com/daeuniverse/dae/pkg/ebpf_internal" - "github.com/vishvananda/netlink" - "golang.org/x/net/dns/dnsmessage" - "golang.org/x/sys/unix" "net/netip" "net/url" "path/filepath" @@ -24,6 +20,11 @@ import ( "strings" "time" "unsafe" + + internal "github.com/daeuniverse/dae/pkg/ebpf_internal" + "github.com/vishvananda/netlink" + "golang.org/x/net/dns/dnsmessage" + "golang.org/x/sys/unix" ) var ( diff --git a/component/dns/dns.go b/component/dns/dns.go index 2df7691..5ff6153 100644 --- a/component/dns/dns.go +++ b/component/dns/dns.go @@ -7,6 +7,10 @@ package dns import ( "fmt" + "net/netip" + "net/url" + "sync" + "github.com/daeuniverse/dae/common" "github.com/daeuniverse/dae/common/assets" "github.com/daeuniverse/dae/common/consts" @@ -14,9 +18,6 @@ import ( "github.com/daeuniverse/dae/config" "github.com/sirupsen/logrus" "golang.org/x/net/dns/dnsmessage" - "net/netip" - "net/url" - "sync" ) var BadUpstreamFormatError = fmt.Errorf("bad upstream format") diff --git a/component/dns/function_parser.go b/component/dns/function_parser.go index 0a4c498..9a34364 100644 --- a/component/dns/function_parser.go +++ b/component/dns/function_parser.go @@ -7,11 +7,12 @@ package dns import ( "fmt" - "github.com/sirupsen/logrus" + "strings" + "github.com/daeuniverse/dae/component/routing" "github.com/daeuniverse/dae/pkg/config_parser" + "github.com/sirupsen/logrus" "golang.org/x/net/dns/dnsmessage" - "strings" ) var typeNames = map[string]dnsmessage.Type{ diff --git a/component/dns/request_routing.go b/component/dns/request_routing.go index e704afb..d89b598 100644 --- a/component/dns/request_routing.go +++ b/component/dns/request_routing.go @@ -7,6 +7,8 @@ package dns import ( "fmt" + "strconv" + "github.com/daeuniverse/dae/common/consts" "github.com/daeuniverse/dae/component/routing" "github.com/daeuniverse/dae/component/routing/domain_matcher" @@ -14,7 +16,6 @@ import ( "github.com/daeuniverse/dae/pkg/config_parser" "github.com/sirupsen/logrus" "golang.org/x/net/dns/dnsmessage" - "strconv" ) type RequestMatcherBuilder struct { diff --git a/component/dns/response_routing.go b/component/dns/response_routing.go index 9f21963..42c72ca 100644 --- a/component/dns/response_routing.go +++ b/component/dns/response_routing.go @@ -7,6 +7,10 @@ package dns import ( "fmt" + "net/netip" + "strconv" + "strings" + "github.com/daeuniverse/dae/common/consts" "github.com/daeuniverse/dae/component/routing" "github.com/daeuniverse/dae/component/routing/domain_matcher" @@ -16,9 +20,6 @@ import ( "github.com/mzz2017/softwind/pkg/zeroalloc/buffer" "github.com/sirupsen/logrus" "golang.org/x/net/dns/dnsmessage" - "net/netip" - "strconv" - "strings" ) var ValidCidrChars = trie.NewValidChars([]byte{'0', '1'}) diff --git a/component/dns/upstream.go b/component/dns/upstream.go index cfb7744..f8203fa 100644 --- a/component/dns/upstream.go +++ b/component/dns/upstream.go @@ -8,14 +8,15 @@ package dns import ( "context" "fmt" - "github.com/daeuniverse/dae/common/consts" - "github.com/daeuniverse/dae/common/netutils" - "github.com/mzz2017/softwind/protocol/direct" "net" "net/url" "strconv" "sync" "time" + + "github.com/daeuniverse/dae/common/consts" + "github.com/daeuniverse/dae/common/netutils" + "github.com/mzz2017/softwind/protocol/direct" ) var ( diff --git a/component/outbound/dialer/alive_dialer_set.go b/component/outbound/dialer/alive_dialer_set.go index e221ada..8a1452b 100644 --- a/component/outbound/dialer/alive_dialer_set.go +++ b/component/outbound/dialer/alive_dialer_set.go @@ -7,12 +7,13 @@ package dialer import ( "fmt" - "github.com/daeuniverse/dae/common/consts" - "github.com/mzz2017/softwind/pkg/fastrand" - "github.com/sirupsen/logrus" "strings" "sync" "time" + + "github.com/daeuniverse/dae/common/consts" + "github.com/mzz2017/softwind/pkg/fastrand" + "github.com/sirupsen/logrus" ) const ( diff --git a/component/outbound/dialer/block.go b/component/outbound/dialer/block.go index d527854..1c67b2d 100644 --- a/component/outbound/dialer/block.go +++ b/component/outbound/dialer/block.go @@ -7,8 +7,9 @@ package dialer import ( "fmt" - "github.com/mzz2017/softwind/netproxy" "net" + + "github.com/mzz2017/softwind/netproxy" ) type blockDialer struct { diff --git a/component/outbound/dialer/connectivity_check.go b/component/outbound/dialer/connectivity_check.go index 6f19b15..d2ef4d1 100644 --- a/component/outbound/dialer/connectivity_check.go +++ b/component/outbound/dialer/connectivity_check.go @@ -9,13 +9,6 @@ import ( "context" "errors" "fmt" - "github.com/daeuniverse/dae/common/consts" - "github.com/daeuniverse/dae/common/netutils" - "github.com/mzz2017/softwind/netproxy" - "github.com/mzz2017/softwind/pkg/fastrand" - "github.com/mzz2017/softwind/protocol/direct" - "github.com/sirupsen/logrus" - "golang.org/x/net/dns/dnsmessage" "net" "net/http" "net/netip" @@ -25,6 +18,14 @@ import ( "strings" "sync" "time" + + "github.com/daeuniverse/dae/common/consts" + "github.com/daeuniverse/dae/common/netutils" + "github.com/mzz2017/softwind/netproxy" + "github.com/mzz2017/softwind/pkg/fastrand" + "github.com/mzz2017/softwind/protocol/direct" + "github.com/sirupsen/logrus" + "golang.org/x/net/dns/dnsmessage" ) type NetworkType struct { diff --git a/component/outbound/dialer/dialer.go b/component/outbound/dialer/dialer.go index eac8600..a2c610f 100644 --- a/component/outbound/dialer/dialer.go +++ b/component/outbound/dialer/dialer.go @@ -3,10 +3,11 @@ package dialer import ( "context" "fmt" - "github.com/mzz2017/softwind/netproxy" - "github.com/sirupsen/logrus" "sync" "time" + + "github.com/mzz2017/softwind/netproxy" + "github.com/sirupsen/logrus" ) var ( diff --git a/component/outbound/dialer/http/http.go b/component/outbound/dialer/http/http.go index 7642970..188ab15 100644 --- a/component/outbound/dialer/http/http.go +++ b/component/outbound/dialer/http/http.go @@ -2,13 +2,14 @@ package http import ( "fmt" - "github.com/mzz2017/softwind/protocol/direct" - "github.com/mzz2017/softwind/protocol/http" - "github.com/daeuniverse/dae/common" - "github.com/daeuniverse/dae/component/outbound/dialer" "net" "net/url" "strconv" + + "github.com/daeuniverse/dae/common" + "github.com/daeuniverse/dae/component/outbound/dialer" + "github.com/mzz2017/softwind/protocol/direct" + "github.com/mzz2017/softwind/protocol/http" ) func init() { diff --git a/component/outbound/dialer/register.go b/component/outbound/dialer/register.go index d3869c1..4aebf6c 100644 --- a/component/outbound/dialer/register.go +++ b/component/outbound/dialer/register.go @@ -7,8 +7,9 @@ package dialer import ( "fmt" - "github.com/daeuniverse/dae/common" "net/url" + + "github.com/daeuniverse/dae/common" ) type FromLinkCreator func(gOption *GlobalOption, iOption InstanceOption, link string) (dialer *Dialer, err error) diff --git a/component/outbound/dialer/shadowsocks/shadowsocks.go b/component/outbound/dialer/shadowsocks/shadowsocks.go index 836874c..c960b34 100644 --- a/component/outbound/dialer/shadowsocks/shadowsocks.go +++ b/component/outbound/dialer/shadowsocks/shadowsocks.go @@ -3,17 +3,18 @@ package shadowsocks import ( "encoding/base64" "fmt" - "github.com/mzz2017/softwind/netproxy" - "github.com/mzz2017/softwind/protocol" - "github.com/mzz2017/softwind/protocol/direct" - "github.com/mzz2017/softwind/protocol/shadowsocks" - "github.com/daeuniverse/dae/common" - "github.com/daeuniverse/dae/component/outbound/dialer" - "github.com/daeuniverse/dae/component/outbound/transport/simpleobfs" "net" "net/url" "strconv" "strings" + + "github.com/daeuniverse/dae/common" + "github.com/daeuniverse/dae/component/outbound/dialer" + "github.com/daeuniverse/dae/component/outbound/transport/simpleobfs" + "github.com/mzz2017/softwind/netproxy" + "github.com/mzz2017/softwind/protocol" + "github.com/mzz2017/softwind/protocol/direct" + "github.com/mzz2017/softwind/protocol/shadowsocks" ) func init() { diff --git a/component/outbound/dialer/shadowsocksr/shadowsocksr.go b/component/outbound/dialer/shadowsocksr/shadowsocksr.go index 5d51459..fbbe572 100644 --- a/component/outbound/dialer/shadowsocksr/shadowsocksr.go +++ b/component/outbound/dialer/shadowsocksr/shadowsocksr.go @@ -3,17 +3,18 @@ package shadowsocksr import ( "encoding/base64" "fmt" + "net" + "net/url" + "strconv" + "strings" + + "github.com/daeuniverse/dae/common" + "github.com/daeuniverse/dae/component/outbound/dialer" "github.com/mzz2017/softwind/protocol" "github.com/mzz2017/softwind/protocol/direct" "github.com/mzz2017/softwind/protocol/shadowsocks_stream" "github.com/mzz2017/softwind/transport/shadowsocksr/obfs" "github.com/mzz2017/softwind/transport/shadowsocksr/proto" - "github.com/daeuniverse/dae/common" - "github.com/daeuniverse/dae/component/outbound/dialer" - "net" - "net/url" - "strconv" - "strings" ) func init() { diff --git a/component/outbound/dialer/sockopt.go b/component/outbound/dialer/sockopt.go index 9c662f9..bedd410 100644 --- a/component/outbound/dialer/sockopt.go +++ b/component/outbound/dialer/sockopt.go @@ -7,10 +7,11 @@ package dialer import ( "fmt" - "golang.org/x/sys/unix" "net/netip" "runtime" "syscall" + + "golang.org/x/sys/unix" ) var fwmarkIoctl int diff --git a/component/outbound/dialer/socks/socks.go b/component/outbound/dialer/socks/socks.go index 4ee0a89..a05a8da 100644 --- a/component/outbound/dialer/socks/socks.go +++ b/component/outbound/dialer/socks/socks.go @@ -2,13 +2,14 @@ package socks import ( "fmt" - "github.com/mzz2017/softwind/protocol/direct" - "github.com/daeuniverse/dae/component/outbound/dialer" - //"github.com/mzz2017/softwind/protocol/socks4" - "github.com/mzz2017/softwind/protocol/socks5" + "net" "net/url" "strconv" + + "github.com/daeuniverse/dae/component/outbound/dialer" + "github.com/mzz2017/softwind/protocol/direct" + "github.com/mzz2017/softwind/protocol/socks5" ) func init() { diff --git a/component/outbound/dialer/trojan/trojan.go b/component/outbound/dialer/trojan/trojan.go index 55e3497..4a5c53e 100644 --- a/component/outbound/dialer/trojan/trojan.go +++ b/component/outbound/dialer/trojan/trojan.go @@ -2,18 +2,19 @@ package trojan import ( "fmt" - "github.com/mzz2017/softwind/netproxy" - "github.com/mzz2017/softwind/protocol" - "github.com/mzz2017/softwind/protocol/direct" - "github.com/mzz2017/softwind/transport/grpc" - "github.com/daeuniverse/dae/common" - "github.com/daeuniverse/dae/component/outbound/dialer" - "github.com/daeuniverse/dae/component/outbound/transport/tls" - "github.com/daeuniverse/dae/component/outbound/transport/ws" "net" "net/url" "strconv" "strings" + + "github.com/daeuniverse/dae/common" + "github.com/daeuniverse/dae/component/outbound/dialer" + "github.com/daeuniverse/dae/component/outbound/transport/tls" + "github.com/daeuniverse/dae/component/outbound/transport/ws" + "github.com/mzz2017/softwind/netproxy" + "github.com/mzz2017/softwind/protocol" + "github.com/mzz2017/softwind/protocol/direct" + "github.com/mzz2017/softwind/transport/grpc" ) func init() { diff --git a/component/outbound/dialer/v2ray/v2ray.go b/component/outbound/dialer/v2ray/v2ray.go index 224c545..a3d4914 100644 --- a/component/outbound/dialer/v2ray/v2ray.go +++ b/component/outbound/dialer/v2ray/v2ray.go @@ -3,6 +3,11 @@ package v2ray import ( "encoding/base64" "fmt" + "net" + "net/url" + "regexp" + "strings" + "github.com/daeuniverse/dae/common" "github.com/daeuniverse/dae/component/outbound/dialer" "github.com/daeuniverse/dae/component/outbound/transport/tls" @@ -12,10 +17,6 @@ import ( "github.com/mzz2017/softwind/protocol" "github.com/mzz2017/softwind/protocol/direct" "github.com/mzz2017/softwind/transport/grpc" - "net" - "net/url" - "regexp" - "strings" ) func init() { diff --git a/component/outbound/dialer_group.go b/component/outbound/dialer_group.go index 9eaa645..e652b07 100644 --- a/component/outbound/dialer_group.go +++ b/component/outbound/dialer_group.go @@ -7,11 +7,12 @@ package outbound import ( "fmt" + "time" + "github.com/daeuniverse/dae/common/consts" "github.com/daeuniverse/dae/component/outbound/dialer" "github.com/mzz2017/softwind/netproxy" "github.com/sirupsen/logrus" - "time" ) var NoAliveDialerError = fmt.Errorf("no alive dialer") diff --git a/component/outbound/dialer_group_test.go b/component/outbound/dialer_group_test.go index e770b94..5ad5dfd 100644 --- a/component/outbound/dialer_group_test.go +++ b/component/outbound/dialer_group_test.go @@ -6,12 +6,13 @@ package outbound import ( + "testing" + "time" + "github.com/daeuniverse/dae/common/consts" "github.com/daeuniverse/dae/component/outbound/dialer" "github.com/daeuniverse/dae/pkg/logger" "github.com/mzz2017/softwind/pkg/fastrand" - "testing" - "time" ) const ( diff --git a/component/outbound/dialer_selection_policy.go b/component/outbound/dialer_selection_policy.go index 06235af..31e86eb 100644 --- a/component/outbound/dialer_selection_policy.go +++ b/component/outbound/dialer_selection_policy.go @@ -7,9 +7,10 @@ package outbound import ( "fmt" + "strconv" + "github.com/daeuniverse/dae/common/consts" "github.com/daeuniverse/dae/config" - "strconv" ) type DialerSelectionPolicy struct { diff --git a/component/outbound/filter.go b/component/outbound/filter.go index 7d9280b..6496000 100644 --- a/component/outbound/filter.go +++ b/component/outbound/filter.go @@ -7,10 +7,11 @@ package outbound import ( "fmt" - "github.com/daeuniverse/dae/component/outbound/dialer" - "github.com/daeuniverse/dae/pkg/config_parser" "regexp" "strings" + + "github.com/daeuniverse/dae/component/outbound/dialer" + "github.com/daeuniverse/dae/pkg/config_parser" ) const ( diff --git a/component/outbound/outbound.go b/component/outbound/outbound.go index 8b5b144..d45d926 100644 --- a/component/outbound/outbound.go +++ b/component/outbound/outbound.go @@ -6,14 +6,14 @@ package outbound import ( - _ "github.com/mzz2017/softwind/protocol/shadowsocks" - _ "github.com/mzz2017/softwind/protocol/trojanc" - _ "github.com/mzz2017/softwind/protocol/vless" - _ "github.com/mzz2017/softwind/protocol/vmess" _ "github.com/daeuniverse/dae/component/outbound/dialer/http" _ "github.com/daeuniverse/dae/component/outbound/dialer/shadowsocks" _ "github.com/daeuniverse/dae/component/outbound/dialer/shadowsocksr" _ "github.com/daeuniverse/dae/component/outbound/dialer/socks" _ "github.com/daeuniverse/dae/component/outbound/dialer/trojan" _ "github.com/daeuniverse/dae/component/outbound/dialer/v2ray" + _ "github.com/mzz2017/softwind/protocol/shadowsocks" + _ "github.com/mzz2017/softwind/protocol/trojanc" + _ "github.com/mzz2017/softwind/protocol/vless" + _ "github.com/mzz2017/softwind/protocol/vmess" ) diff --git a/component/outbound/transport/simpleobfs/simpleobfs.go b/component/outbound/transport/simpleobfs/simpleobfs.go index 2d60ddb..cbe3317 100644 --- a/component/outbound/transport/simpleobfs/simpleobfs.go +++ b/component/outbound/transport/simpleobfs/simpleobfs.go @@ -56,7 +56,6 @@ func NewSimpleObfs(s string, d netproxy.Dialer) (*SimpleObfs, error) { return t, nil } - func (s *SimpleObfs) Dial(network, addr string) (c netproxy.Conn, err error) { magicNetwork, err := netproxy.ParseMagicNetwork(network) if err != nil { @@ -75,6 +74,7 @@ func (s *SimpleObfs) Dial(network, addr string) (c netproxy.Conn, err error) { func (s *SimpleObfs) DialUdp(addr string) (conn netproxy.PacketConn, err error) { return nil, fmt.Errorf("%w: simpleobfs+udp", netproxy.UnsupportedTunnelTypeError) } + // DialTcp connects to the address addr on the network net via the proxy. func (s *SimpleObfs) DialTcp(addr string) (c netproxy.Conn, err error) { diff --git a/component/routing/domain_matcher/benchmark_test.go b/component/routing/domain_matcher/benchmark_test.go index 30b9c51..9ed9f7a 100644 --- a/component/routing/domain_matcher/benchmark_test.go +++ b/component/routing/domain_matcher/benchmark_test.go @@ -7,15 +7,16 @@ package domain_matcher import ( "fmt" + "hash/fnv" + "math/rand" + "reflect" + "testing" + "github.com/daeuniverse/dae/common/consts" "github.com/daeuniverse/dae/component/routing" "github.com/daeuniverse/dae/config" "github.com/daeuniverse/dae/pkg/config_parser" "github.com/sirupsen/logrus" - "hash/fnv" - "math/rand" - "reflect" - "testing" ) var TestSample = []string{ @@ -94,7 +95,6 @@ var TestSample = []string{ } type RoutingMatcherBuilder struct { - outboundName2Id map[string]uint8 simulatedDomainSet []routing.DomainSet Fallback string @@ -206,7 +206,7 @@ func BenchmarkAhocorasickSlimtrie(b *testing.B) { if err != nil { b.Fatal(err) } - ahocorasick := NewAhocorasickSlimtrie(consts.MaxMatchSetLen) + ahocorasick := NewAhocorasickSlimtrie(logrus.StandardLogger(), consts.MaxMatchSetLen) for _, domains := range simulatedDomainSet { ahocorasick.AddSet(domains.RuleIndex, domains.Domains, domains.Key) } diff --git a/component/routing/function_parser.go b/component/routing/function_parser.go index 121bb16..c125f10 100644 --- a/component/routing/function_parser.go +++ b/component/routing/function_parser.go @@ -7,10 +7,10 @@ package routing import ( "fmt" - "github.com/sirupsen/logrus" "github.com/daeuniverse/dae/common" "github.com/daeuniverse/dae/common/consts" "github.com/daeuniverse/dae/pkg/config_parser" + "github.com/sirupsen/logrus" "net/netip" "strings" ) diff --git a/component/sniffing/internal/quicutils/cipher.go b/component/sniffing/internal/quicutils/cipher.go index 06ef667..8de6248 100644 --- a/component/sniffing/internal/quicutils/cipher.go +++ b/component/sniffing/internal/quicutils/cipher.go @@ -10,8 +10,8 @@ import ( "crypto/cipher" "crypto/sha256" "encoding/binary" - "github.com/mzz2017/softwind/pool" "github.com/daeuniverse/dae/common" + "github.com/mzz2017/softwind/pool" "golang.org/x/crypto/hkdf" "io" ) diff --git a/component/sniffing/internal/quicutils/cipher_test.go b/component/sniffing/internal/quicutils/cipher_test.go index e60fec8..6ae2fea 100644 --- a/component/sniffing/internal/quicutils/cipher_test.go +++ b/component/sniffing/internal/quicutils/cipher_test.go @@ -8,8 +8,9 @@ package quicutils import ( "bytes" "encoding/hex" - "github.com/daeuniverse/dae/common" "testing" + + "github.com/daeuniverse/dae/common" ) var destConnId = []byte{0x83, 0x94, 0xc8, 0xf0, 0x3e, 0x51, 0x57, 0x08} diff --git a/component/sniffing/quic.go b/component/sniffing/quic.go index af2036d..1d3c176 100644 --- a/component/sniffing/quic.go +++ b/component/sniffing/quic.go @@ -7,9 +7,10 @@ package sniffing import ( "errors" - "github.com/mzz2017/softwind/pool" - "github.com/daeuniverse/dae/component/sniffing/internal/quicutils" "io/fs" + + "github.com/daeuniverse/dae/component/sniffing/internal/quicutils" + "github.com/mzz2017/softwind/pool" ) const ( diff --git a/component/sniffing/quic_bench_test.go b/component/sniffing/quic_bench_test.go index bcd432b..8be538f 100644 --- a/component/sniffing/quic_bench_test.go +++ b/component/sniffing/quic_bench_test.go @@ -7,8 +7,9 @@ package sniffing import ( "encoding/hex" - "github.com/sirupsen/logrus" "testing" + + "github.com/sirupsen/logrus" ) var QuicStream, _ = hex.DecodeString("c00000000108d60451e5cb0f7050000044bc9acdcae1f0bbb8b98bb6ce5371cec3db5d4212d08d370fd220bd92fd3f42b06d8b25feea28c190ce741b316d28d8be11bd5637db3b00bf945ee330066b5262e7cef82d1f1fcc19d1879e1a7e062d068217a7a62c2fc8dd5226e6988d605578f05bebe102825af36fdfd50514cc41de82acde9d10c3f6c0650273c6f750251925d730a558ec820c221665550b0d41e38494b884393197d38cf9e32dcd0d4cbe6a75be00069bdd04836c6e83a360ee072b9da44c9dfec05762bb0bea1585755e22fdb0b11c67166b3178207801847a8d079fb6600a8bc22860ffb98d49dd56fbdd0c16bbae54d219adbcda402e43fc524667b7f08171820958ddf5b111cf776555aa0b23d6820748a4bb9695d754a1a2ce30901d90cdd5ab8aecae5b9fce5b6cf0e993a7316ce8eded51b382587a5c31ed27c6e96808a7eab84ec168b1648c6c0218760d6304c718266df2ac5c73e1f34f1b57a025a8fe5fecfbf3ff90b51cd26f5b93ef47fe790324951cb347a85b3ed5ba3e04880f83041e13f142f72173a9cc79ff3303a7b981b133600e47852ea8a03b5414f9cc39f5401b187bb22373bd75c64b79bb4601e12283f7d4f0916509e8f0114574e1ac316b07b83887eb451f268a325b713fe2f53b9eda5db85eaef20c632bd839d8fe49318fc913192d107d5416bc57d619c0db700abc4db48a73abd32a3d98f06c90aa17924321774b2d8b073ca1e1062a6473eba613037deefd306962a5bc0b7843678f25fbf74cff6430ef1c324a12f0beadb2bbe861cb211b7114b55164fe00907d7b41bd0140bdbe9c405405030b58478803e1d76082583d7122ee8552b5f901ca924afdefe3a30f345793108f50a9d934077864d6533db956d5d424f0aeed1fd85a6292d2ae7bd392a8223e66f46d7ffd1ad16871774c133af6dec7a97e67987158738d40bb496e3e3d478a01e0b995c44e08e37f137d4885f382176d9f5f7b00b81c96e83f2b60b762c8ed89a1077bb860c317332af8595cbe9afc3dab1da1a62cbd721f8eca8ee8be4240356ed9918fb4beddcab654ed085112e6abfeb0680979a20edd9426719d0f97bff2031f2af40dc47f47b815665f28f920fe5ceef4481f5195811e9cdc23dcec251550ed17111ab45124498dfbaae87b2081814d3fdfdb581a651ea3929fede7e9e01f8475360a484478bcde90d463b76b0ff486aba41f9b7d043ad3dac35e50569bf007f12c08b433474c4aa085bf0ff1ebbb2ee6e7dbdc92c429f9b54b098a5d34b0448458919bbb13b0b4c0ba82a130e8d9f105d724729a22c9c31476bfa609eb53f2d7a1c7134e60ba365a3082775d601f7c96f52e915da5e7670aa33e6027bca2a99ec8871ea424febb741bf2ca0e1d911b7047b6ddfe17c03d9c1aedb106e0ec40b1a8c980bfdcce083a1769bbdd8fd149f86f6cae50ab9b8dc7c1306c03a4a9bb2dcf0c477ae7431fba5f1e7e999bccb7ad73df33d9931f9e7291a4f882b4065ac63d58d81746e48f5035074b90cac149210efabded7f6099df28959f74aeb8ab2b8c63cf85c2ca3e054d70d31d3b3d24f4f8d36dfb82c9371f31313fa7a5bb56b10ef75d8aa4b976d9196728e6ef4401f9e2cf33058cda0b1464c8f14d404c48e4c9258830985eecccbaddd06407605f1af40542c727ab80e460cb322613204a60fb135e890e1f3b95d9a64a45450815db1c741837bf4a") diff --git a/component/sniffing/sniffing_bench_test.go b/component/sniffing/sniffing_bench_test.go index 81e912d..cda2842 100644 --- a/component/sniffing/sniffing_bench_test.go +++ b/component/sniffing/sniffing_bench_test.go @@ -7,8 +7,9 @@ package sniffing import ( "fmt" - "github.com/mzz2017/softwind/pkg/fastrand" "testing" + + "github.com/mzz2017/softwind/pkg/fastrand" ) var ( diff --git a/component/sniffing/tls.go b/component/sniffing/tls.go index 75b87b5..0e64537 100644 --- a/component/sniffing/tls.go +++ b/component/sniffing/tls.go @@ -8,8 +8,9 @@ package sniffing import ( "bytes" "encoding/binary" - "github.com/daeuniverse/dae/component/sniffing/internal/quicutils" "strings" + + "github.com/daeuniverse/dae/component/sniffing/internal/quicutils" ) const ( diff --git a/component/sniffing/tls_test.go b/component/sniffing/tls_test.go index 63f0f95..9f0684f 100644 --- a/component/sniffing/tls_test.go +++ b/component/sniffing/tls_test.go @@ -7,8 +7,9 @@ package sniffing import ( "encoding/hex" - "github.com/sirupsen/logrus" "testing" + + "github.com/sirupsen/logrus" ) var tlsStream, _ = hex.DecodeString("1603010200010001fc0303d90fdf25b0c7a11c3eb968604a065157a149407c139c22ed32f5c6f486ed2c04206c51c32da7f83c3c19766be60d45d264e898c77504e34915c44caa69513c2221003e130213031301c02cc030009fcca9cca8ccaac02bc02f009ec024c028006bc023c0270067c00ac0140039c009c0130033009d009c003d003c0035002f00ff0100017500000013001100000e7777772e676f6f676c652e636f6d000b000403000102000a00160014001d0017001e00190018010001010102010301040010000e000c02683208687474702f312e31001600000017000000310000000d002a0028040305030603080708080809080a080b080408050806040105010601030303010302040205020602002b0009080304030303020301002d00020101003300260024001d00207fe08226bdc4fb1715e477506b6afe8f3abe2d20daa1f8c78c5483f1a90a9b19001500af00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000") diff --git a/config/config.go b/config/config.go index e0ee67f..1519d6a 100644 --- a/config/config.go +++ b/config/config.go @@ -7,9 +7,10 @@ package config import ( "fmt" - "github.com/daeuniverse/dae/pkg/config_parser" "reflect" "time" + + "github.com/daeuniverse/dae/pkg/config_parser" ) type Global struct { diff --git a/config/config_merger.go b/config/config_merger.go index e802466..80d9106 100644 --- a/config/config_merger.go +++ b/config/config_merger.go @@ -8,12 +8,13 @@ package config import ( "errors" "fmt" - "github.com/daeuniverse/dae/common" - "github.com/daeuniverse/dae/pkg/config_parser" "io" "os" "path/filepath" "strings" + + "github.com/daeuniverse/dae/common" + "github.com/daeuniverse/dae/pkg/config_parser" ) var ( diff --git a/config/marshal.go b/config/marshal.go index 0f06b78..914f2af 100644 --- a/config/marshal.go +++ b/config/marshal.go @@ -8,11 +8,12 @@ package config import ( "bytes" "fmt" - "github.com/daeuniverse/dae/common" - "github.com/daeuniverse/dae/pkg/config_parser" "reflect" "strconv" "strings" + + "github.com/daeuniverse/dae/common" + "github.com/daeuniverse/dae/pkg/config_parser" ) // Marshal assume all tokens should be legal, and does not prevent injection attacks. diff --git a/config/outline.go b/config/outline.go index abeaf75..9e4b878 100644 --- a/config/outline.go +++ b/config/outline.go @@ -6,9 +6,10 @@ package config import ( - jsoniter "github.com/json-iterator/go" "reflect" "sort" + + jsoniter "github.com/json-iterator/go" ) type Outline struct { diff --git a/config/parser.go b/config/parser.go index 8be8dc0..5b98806 100644 --- a/config/parser.go +++ b/config/parser.go @@ -7,10 +7,11 @@ package config import ( "fmt" - "github.com/daeuniverse/dae/common" - "github.com/daeuniverse/dae/pkg/config_parser" "reflect" "strings" + + "github.com/daeuniverse/dae/common" + "github.com/daeuniverse/dae/pkg/config_parser" ) func StringListParser(to reflect.Value, section *config_parser.Section) error { diff --git a/config/patch.go b/config/patch.go index 438f287..186b734 100644 --- a/config/patch.go +++ b/config/patch.go @@ -6,9 +6,10 @@ package config import ( + "strings" + "github.com/daeuniverse/dae/common/consts" "github.com/daeuniverse/dae/pkg/config_parser" - "strings" ) type patch func(params *Config) error diff --git a/control/addr.go b/control/addr.go index 8a22407..5561e7b 100644 --- a/control/addr.go +++ b/control/addr.go @@ -6,10 +6,11 @@ package control import ( - "github.com/daeuniverse/dae/common/consts" "net" "net/netip" "strconv" + + "github.com/daeuniverse/dae/common/consts" ) func RefineSourceToShow(src netip.AddrPort, dst netip.Addr, lanWanFlag consts.LanWanFlag) (srcToShow string) { diff --git a/control/bpf_utils.go b/control/bpf_utils.go index 85cf12d..65f5601 100644 --- a/control/bpf_utils.go +++ b/control/bpf_utils.go @@ -10,17 +10,18 @@ import ( "encoding/binary" "errors" "fmt" - "github.com/cilium/ebpf" - "github.com/daeuniverse/dae/common" - "github.com/daeuniverse/dae/common/consts" - "github.com/daeuniverse/dae/pkg/ebpf_internal" - "github.com/sirupsen/logrus" "net/netip" "os" "path/filepath" "reflect" "strings" "sync" + + "github.com/cilium/ebpf" + "github.com/daeuniverse/dae/common" + "github.com/daeuniverse/dae/common/consts" + internal "github.com/daeuniverse/dae/pkg/ebpf_internal" + "github.com/sirupsen/logrus" ) type _bpfTuples struct { diff --git a/control/connectivity.go b/control/connectivity.go index 14c2a75..199b942 100644 --- a/control/connectivity.go +++ b/control/connectivity.go @@ -6,11 +6,12 @@ package control import ( + "strconv" + "github.com/cilium/ebpf" "github.com/daeuniverse/dae/component/outbound/dialer" "github.com/sirupsen/logrus" "golang.org/x/sys/unix" - "strconv" ) func FormatL4Proto(l4proto uint8) string { diff --git a/control/control_plane.go b/control/control_plane.go index 9769dbe..1a907ec 100644 --- a/control/control_plane.go +++ b/control/control_plane.go @@ -8,6 +8,16 @@ package control import ( "context" "fmt" + "net" + "net/netip" + "os" + "path/filepath" + "strconv" + "strings" + "sync" + "syscall" + "time" + "github.com/bits-and-blooms/bloom/v3" "github.com/cilium/ebpf" "github.com/cilium/ebpf/rlimit" @@ -28,15 +38,6 @@ import ( "github.com/sirupsen/logrus" "golang.org/x/net/dns/dnsmessage" "golang.org/x/sys/unix" - "net" - "net/netip" - "os" - "path/filepath" - "strconv" - "strings" - "sync" - "syscall" - "time" ) type ControlPlane struct { diff --git a/control/control_plane_core.go b/control/control_plane_core.go index d18c42e..6435d11 100644 --- a/control/control_plane_core.go +++ b/control/control_plane_core.go @@ -8,6 +8,11 @@ package control import ( "context" "fmt" + "net" + "net/netip" + "os" + "regexp" + "github.com/cilium/ebpf" ciliumLink "github.com/cilium/ebpf/link" "github.com/daeuniverse/dae/common" @@ -19,10 +24,6 @@ import ( "github.com/vishvananda/netlink" "golang.org/x/net/dns/dnsmessage" "golang.org/x/sys/unix" - "net" - "net/netip" - "os" - "regexp" ) // coreFlip should be 0 or 1 diff --git a/control/dns_cache.go b/control/dns_cache.go index df69c2a..8660dfd 100644 --- a/control/dns_cache.go +++ b/control/dns_cache.go @@ -6,10 +6,11 @@ package control import ( - "github.com/mohae/deepcopy" - "golang.org/x/net/dns/dnsmessage" "net/netip" "time" + + "github.com/mohae/deepcopy" + "golang.org/x/net/dns/dnsmessage" ) type DnsCache struct { diff --git a/control/dns_control.go b/control/dns_control.go index 92bd1b4..2ace736 100644 --- a/control/dns_control.go +++ b/control/dns_control.go @@ -10,6 +10,14 @@ import ( "encoding/binary" "errors" "fmt" + "io" + "math" + "net" + "net/netip" + "strings" + "sync" + "time" + "github.com/daeuniverse/dae/common/consts" "github.com/daeuniverse/dae/common/netutils" "github.com/daeuniverse/dae/component/dns" @@ -21,13 +29,6 @@ import ( "github.com/mzz2017/softwind/pool" "github.com/sirupsen/logrus" "golang.org/x/net/dns/dnsmessage" - "io" - "math" - "net" - "net/netip" - "strings" - "sync" - "time" ) const ( diff --git a/control/dns_utils.go b/control/dns_utils.go index 85c8a7f..a53fbee 100644 --- a/control/dns_utils.go +++ b/control/dns_utils.go @@ -8,11 +8,12 @@ package control import ( "encoding/binary" "fmt" - "golang.org/x/net/dns/dnsmessage" "hash/fnv" "math/rand" "net/netip" "strings" + + "golang.org/x/net/dns/dnsmessage" ) // FlipDnsQuestionCase is used to reduce dns pollution. diff --git a/control/routing_matcher_builder.go b/control/routing_matcher_builder.go index 8aa6329..291a8b3 100644 --- a/control/routing_matcher_builder.go +++ b/control/routing_matcher_builder.go @@ -8,6 +8,9 @@ package control import ( "encoding/binary" "fmt" + "net/netip" + "strconv" + "github.com/cilium/ebpf" "github.com/daeuniverse/dae/common" "github.com/daeuniverse/dae/common/consts" @@ -16,8 +19,6 @@ import ( "github.com/daeuniverse/dae/config" "github.com/daeuniverse/dae/pkg/config_parser" "github.com/sirupsen/logrus" - "net/netip" - "strconv" ) type RoutingMatcherBuilder struct { diff --git a/control/routing_matcher_userspace.go b/control/routing_matcher_userspace.go index b371d60..9b56416 100644 --- a/control/routing_matcher_userspace.go +++ b/control/routing_matcher_userspace.go @@ -8,11 +8,12 @@ package control import ( "encoding/binary" "fmt" + "net" + "github.com/cilium/ebpf" "github.com/daeuniverse/dae/common" "github.com/daeuniverse/dae/common/consts" "github.com/daeuniverse/dae/component/routing" - "net" ) type RoutingMatcher struct { diff --git a/control/tcp.go b/control/tcp.go index b463b87..387b82f 100644 --- a/control/tcp.go +++ b/control/tcp.go @@ -7,6 +7,11 @@ package control import ( "fmt" + "net" + "net/netip" + "strings" + "time" + "github.com/daeuniverse/dae/common" "github.com/daeuniverse/dae/common/consts" "github.com/daeuniverse/dae/component/outbound/dialer" @@ -15,10 +20,6 @@ import ( "github.com/mzz2017/softwind/pkg/zeroalloc/io" "github.com/sirupsen/logrus" "golang.org/x/sys/unix" - "net" - "net/netip" - "strings" - "time" ) const ( diff --git a/control/udp.go b/control/udp.go index 8992a82..edab9be 100644 --- a/control/udp.go +++ b/control/udp.go @@ -9,6 +9,12 @@ import ( "encoding/binary" "errors" "fmt" + "net" + "net/netip" + "syscall" + "time" + "unsafe" + "github.com/daeuniverse/dae/common" "github.com/daeuniverse/dae/common/consts" "github.com/daeuniverse/dae/component/outbound/dialer" @@ -17,11 +23,6 @@ import ( "github.com/mzz2017/softwind/pkg/zeroalloc/buffer" "github.com/sirupsen/logrus" "golang.org/x/net/dns/dnsmessage" - "net" - "net/netip" - "syscall" - "time" - "unsafe" ) const ( diff --git a/control/udp_endpoint.go b/control/udp_endpoint.go index 4ddf9a7..2238926 100644 --- a/control/udp_endpoint.go +++ b/control/udp_endpoint.go @@ -8,12 +8,13 @@ package control import ( "errors" "fmt" - "github.com/daeuniverse/dae/component/outbound/dialer" - "github.com/mzz2017/softwind/netproxy" - "github.com/mzz2017/softwind/pool" "net/netip" "sync" "time" + + "github.com/daeuniverse/dae/component/outbound/dialer" + "github.com/mzz2017/softwind/netproxy" + "github.com/mzz2017/softwind/pool" ) const ( diff --git a/control/utils.go b/control/utils.go index 6c8d81b..2a8d463 100644 --- a/control/utils.go +++ b/control/utils.go @@ -10,13 +10,14 @@ import ( "encoding/binary" "encoding/hex" "fmt" + "net/netip" + "os" + "syscall" + "github.com/daeuniverse/dae/common" "github.com/daeuniverse/dae/common/consts" "github.com/mzz2017/softwind/netproxy" "golang.org/x/sys/unix" - "net/netip" - "os" - "syscall" ) func (c *ControlPlane) Route(src, dst netip.AddrPort, domain string, l4proto consts.L4ProtoType, routingResult *bpfRoutingResult) (outboundIndex consts.OutboundIndex, mark uint32, must bool, err error) { diff --git a/main.go b/main.go index 12d7d09..a01f09f 100644 --- a/main.go +++ b/main.go @@ -8,13 +8,14 @@ package main import ( + "net/http" + "os" + "time" + "github.com/daeuniverse/dae/cmd" "github.com/daeuniverse/dae/common/json" jsoniter "github.com/json-iterator/go" "github.com/json-iterator/go/extra" - "net/http" - "os" - "time" ) func main() { diff --git a/pkg/anybuffer/anybuffer.go b/pkg/anybuffer/anybuffer.go index 8111008..b69f5f1 100644 --- a/pkg/anybuffer/anybuffer.go +++ b/pkg/anybuffer/anybuffer.go @@ -7,6 +7,7 @@ package anybuffer import ( "errors" + "golang.org/x/exp/constraints" ) diff --git a/pkg/config_parser/config_parser.go b/pkg/config_parser/config_parser.go index c04b10c..c30bfc3 100644 --- a/pkg/config_parser/config_parser.go +++ b/pkg/config_parser/config_parser.go @@ -7,6 +7,7 @@ package config_parser import ( "fmt" + "github.com/antlr/antlr4/runtime/Go/antlr/v4" "github.com/daeuniverse/dae-config-dist/go/dae_config" ) diff --git a/pkg/config_parser/error.go b/pkg/config_parser/error.go index ccbf044..6377358 100644 --- a/pkg/config_parser/error.go +++ b/pkg/config_parser/error.go @@ -7,10 +7,11 @@ package config_parser import ( "fmt" - "github.com/antlr/antlr4/runtime/Go/antlr/v4" - "github.com/sirupsen/logrus" "reflect" "strings" + + "github.com/antlr/antlr4/runtime/Go/antlr/v4" + "github.com/sirupsen/logrus" ) type ErrorType string diff --git a/pkg/config_parser/walker.go b/pkg/config_parser/walker.go index ced7541..f5c6e3f 100644 --- a/pkg/config_parser/walker.go +++ b/pkg/config_parser/walker.go @@ -9,11 +9,12 @@ package config_parser import ( "fmt" - "github.com/antlr/antlr4/runtime/Go/antlr/v4" - "github.com/sirupsen/logrus" - "github.com/daeuniverse/dae-config-dist/go/dae_config" "strconv" "strings" + + "github.com/antlr/antlr4/runtime/Go/antlr/v4" + "github.com/daeuniverse/dae-config-dist/go/dae_config" + "github.com/sirupsen/logrus" ) type Walker struct { diff --git a/pkg/ebpf_internal/version.go b/pkg/ebpf_internal/version.go index 2e0233b..73ebd7c 100644 --- a/pkg/ebpf_internal/version.go +++ b/pkg/ebpf_internal/version.go @@ -4,8 +4,9 @@ package internal import ( "fmt" - "github.com/daeuniverse/dae/pkg/ebpf_internal/internal/unix" "sync" + + "github.com/daeuniverse/dae/pkg/ebpf_internal/internal/unix" ) const ( diff --git a/pkg/geodata/common.pb.go b/pkg/geodata/common.pb.go index adbfd17..f8d1ed3 100644 --- a/pkg/geodata/common.pb.go +++ b/pkg/geodata/common.pb.go @@ -3,11 +3,12 @@ package geodata import ( + "reflect" + "sync" + _ "github.com/daeuniverse/dae/pkg/geodata/protoext" "google.golang.org/protobuf/reflect/protoreflect" "google.golang.org/protobuf/runtime/protoimpl" - "reflect" - "sync" ) const ( diff --git a/pkg/geodata/decode.go b/pkg/geodata/decode.go index 2226371..1bdbeca 100644 --- a/pkg/geodata/decode.go +++ b/pkg/geodata/decode.go @@ -10,10 +10,11 @@ package geodata import ( "errors" "fmt" - "google.golang.org/protobuf/encoding/protowire" "io" "os" "strings" + + "google.golang.org/protobuf/encoding/protowire" ) var ( diff --git a/pkg/geodata/geodata.go b/pkg/geodata/geodata.go index 1428aea..490410f 100644 --- a/pkg/geodata/geodata.go +++ b/pkg/geodata/geodata.go @@ -9,10 +9,11 @@ package geodata import ( "fmt" - "github.com/sirupsen/logrus" - "google.golang.org/protobuf/proto" "os" "strings" + + "github.com/sirupsen/logrus" + "google.golang.org/protobuf/proto" ) func UnmarshalGeoIp(log *logrus.Logger, filepath, code string) (*GeoIP, error) { diff --git a/pkg/geodata/protoext/extensions.pb.go b/pkg/geodata/protoext/extensions.pb.go index 54f273e..1097ba5 100644 --- a/pkg/geodata/protoext/extensions.pb.go +++ b/pkg/geodata/protoext/extensions.pb.go @@ -3,11 +3,12 @@ package protoext import ( + reflect "reflect" + sync "sync" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" descriptorpb "google.golang.org/protobuf/types/descriptorpb" - reflect "reflect" - sync "sync" ) const ( diff --git a/pkg/trie/trie.go b/pkg/trie/trie.go index 31560df..b76784c 100644 --- a/pkg/trie/trie.go +++ b/pkg/trie/trie.go @@ -5,10 +5,11 @@ package trie import ( "fmt" - "github.com/daeuniverse/dae/common" - "github.com/daeuniverse/dae/common/bitlist" "math/bits" "sort" + + "github.com/daeuniverse/dae/common" + "github.com/daeuniverse/dae/common/bitlist" ) type ValidChars struct {