From 031f25c1c108e68820fbf292a0d10d637ef7d202 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=96=E7=95=8C?= Date: Mon, 25 Aug 2025 19:49:12 +0800 Subject: [PATCH] Deprecate common/atomic --- common/dialer/default.go | 3 +-- common/dialer/tfo.go | 2 +- experimental/clashapi/trafficontrol/manager.go | 2 +- experimental/clashapi/trafficontrol/tracker.go | 2 +- experimental/v2rayapi/stats.go | 2 +- go.mod | 2 +- go.sum | 4 ++-- protocol/group/selector.go | 4 ++-- protocol/group/urltest.go | 4 ++-- route/network.go | 3 +-- route/rule/rule_set_local.go | 2 +- route/rule/rule_set_remote.go | 2 +- service/ssmapi/cache.go | 2 +- service/ssmapi/traffic.go | 2 +- transport/v2rayquic/client.go | 3 +-- 15 files changed, 18 insertions(+), 21 deletions(-) diff --git a/common/dialer/default.go b/common/dialer/default.go index 4afa0091..dd1e90e5 100644 --- a/common/dialer/default.go +++ b/common/dialer/default.go @@ -15,7 +15,6 @@ import ( "github.com/sagernet/sing-box/experimental/libbox/platform" "github.com/sagernet/sing-box/option" "github.com/sagernet/sing/common" - "github.com/sagernet/sing/common/atomic" "github.com/sagernet/sing/common/control" E "github.com/sagernet/sing/common/exceptions" M "github.com/sagernet/sing/common/metadata" @@ -43,7 +42,7 @@ type DefaultDialer struct { networkType []C.InterfaceType fallbackNetworkType []C.InterfaceType networkFallbackDelay time.Duration - networkLastFallback atomic.TypedValue[time.Time] + networkLastFallback common.TypedValue[time.Time] } func NewDefault(ctx context.Context, options option.DialerOptions) (*DefaultDialer, error) { diff --git a/common/dialer/tfo.go b/common/dialer/tfo.go index cd1a2a22..4832c12d 100644 --- a/common/dialer/tfo.go +++ b/common/dialer/tfo.go @@ -8,10 +8,10 @@ import ( "net" "os" "sync" + "sync/atomic" "time" "github.com/sagernet/sing/common" - "github.com/sagernet/sing/common/atomic" "github.com/sagernet/sing/common/bufio" M "github.com/sagernet/sing/common/metadata" N "github.com/sagernet/sing/common/network" diff --git a/experimental/clashapi/trafficontrol/manager.go b/experimental/clashapi/trafficontrol/manager.go index 757ffdf9..7b69b93d 100644 --- a/experimental/clashapi/trafficontrol/manager.go +++ b/experimental/clashapi/trafficontrol/manager.go @@ -3,12 +3,12 @@ package trafficontrol import ( "runtime" "sync" + "sync/atomic" "time" C "github.com/sagernet/sing-box/constant" "github.com/sagernet/sing-box/experimental/clashapi/compatible" "github.com/sagernet/sing/common" - "github.com/sagernet/sing/common/atomic" "github.com/sagernet/sing/common/json" "github.com/sagernet/sing/common/x/list" diff --git a/experimental/clashapi/trafficontrol/tracker.go b/experimental/clashapi/trafficontrol/tracker.go index e324be20..48d54b25 100644 --- a/experimental/clashapi/trafficontrol/tracker.go +++ b/experimental/clashapi/trafficontrol/tracker.go @@ -2,11 +2,11 @@ package trafficontrol import ( "net" + "sync/atomic" "time" "github.com/sagernet/sing-box/adapter" "github.com/sagernet/sing/common" - "github.com/sagernet/sing/common/atomic" "github.com/sagernet/sing/common/bufio" F "github.com/sagernet/sing/common/format" "github.com/sagernet/sing/common/json" diff --git a/experimental/v2rayapi/stats.go b/experimental/v2rayapi/stats.go index 16d44114..c7b2b49f 100644 --- a/experimental/v2rayapi/stats.go +++ b/experimental/v2rayapi/stats.go @@ -7,11 +7,11 @@ import ( "runtime" "strings" "sync" + "sync/atomic" "time" "github.com/sagernet/sing-box/adapter" "github.com/sagernet/sing-box/option" - "github.com/sagernet/sing/common/atomic" "github.com/sagernet/sing/common/bufio" E "github.com/sagernet/sing/common/exceptions" N "github.com/sagernet/sing/common/network" diff --git a/go.mod b/go.mod index 452694c6..dccba18f 100644 --- a/go.mod +++ b/go.mod @@ -27,7 +27,7 @@ require ( github.com/sagernet/gomobile v0.1.8 github.com/sagernet/gvisor v0.0.0-20250325023245-7a9c0f5725fb github.com/sagernet/quic-go v0.52.0-beta.1 - github.com/sagernet/sing v0.7.6-0.20250815070458-d33ece7a184f + github.com/sagernet/sing v0.7.6-0.20250825114712-2aeec120ce28 github.com/sagernet/sing-mux v0.3.3 github.com/sagernet/sing-quic v0.5.0 github.com/sagernet/sing-shadowsocks v0.2.8 diff --git a/go.sum b/go.sum index d0f21c8c..86e4b287 100644 --- a/go.sum +++ b/go.sum @@ -167,8 +167,8 @@ github.com/sagernet/nftables v0.3.0-beta.4/go.mod h1:OQXAjvjNGGFxaTgVCSTRIhYB5/l github.com/sagernet/quic-go v0.52.0-beta.1 h1:hWkojLg64zjV+MJOvJU/kOeWndm3tiEfBLx5foisszs= github.com/sagernet/quic-go v0.52.0-beta.1/go.mod h1:OV+V5kEBb8kJS7k29MzDu6oj9GyMc7HA07sE1tedxz4= github.com/sagernet/sing v0.6.9/go.mod h1:ARkL0gM13/Iv5VCZmci/NuoOlePoIsW0m7BWfln/Hak= -github.com/sagernet/sing v0.7.6-0.20250815070458-d33ece7a184f h1:HIBo8l+tsS3wLwuI1E56uRTQw46QytXSUpZTP3vwG/U= -github.com/sagernet/sing v0.7.6-0.20250815070458-d33ece7a184f/go.mod h1:ARkL0gM13/Iv5VCZmci/NuoOlePoIsW0m7BWfln/Hak= +github.com/sagernet/sing v0.7.6-0.20250825114712-2aeec120ce28 h1:C8Lnqd0Q+C15kwaMiDsfq5S45rhhaQMBG91TT+6oFVo= +github.com/sagernet/sing v0.7.6-0.20250825114712-2aeec120ce28/go.mod h1:ARkL0gM13/Iv5VCZmci/NuoOlePoIsW0m7BWfln/Hak= github.com/sagernet/sing-mux v0.3.3 h1:YFgt9plMWzH994BMZLmyKL37PdIVaIilwP0Jg+EcLfw= github.com/sagernet/sing-mux v0.3.3/go.mod h1:pht8iFY4c9Xltj7rhVd208npkNaeCxzyXCgulDPLUDA= github.com/sagernet/sing-quic v0.5.0 h1:jNLIyVk24lFPvu8A4x+ZNEnZdI+Tg1rp7eCJ6v0Csak= diff --git a/protocol/group/selector.go b/protocol/group/selector.go index 9806e033..439283bd 100644 --- a/protocol/group/selector.go +++ b/protocol/group/selector.go @@ -10,7 +10,7 @@ import ( C "github.com/sagernet/sing-box/constant" "github.com/sagernet/sing-box/log" "github.com/sagernet/sing-box/option" - "github.com/sagernet/sing/common/atomic" + "github.com/sagernet/sing/common" E "github.com/sagernet/sing/common/exceptions" "github.com/sagernet/sing/common/logger" M "github.com/sagernet/sing/common/metadata" @@ -37,7 +37,7 @@ type Selector struct { tags []string defaultTag string outbounds map[string]adapter.Outbound - selected atomic.TypedValue[adapter.Outbound] + selected common.TypedValue[adapter.Outbound] interruptGroup *interrupt.Group interruptExternalConnections bool } diff --git a/protocol/group/urltest.go b/protocol/group/urltest.go index 719f4a2c..4bdef9fb 100644 --- a/protocol/group/urltest.go +++ b/protocol/group/urltest.go @@ -4,6 +4,7 @@ import ( "context" "net" "sync" + "sync/atomic" "time" "github.com/sagernet/sing-box/adapter" @@ -14,7 +15,6 @@ import ( "github.com/sagernet/sing-box/log" "github.com/sagernet/sing-box/option" "github.com/sagernet/sing/common" - "github.com/sagernet/sing/common/atomic" "github.com/sagernet/sing/common/batch" E "github.com/sagernet/sing/common/exceptions" M "github.com/sagernet/sing/common/metadata" @@ -192,7 +192,7 @@ type URLTestGroup struct { ticker *time.Ticker close chan struct{} started bool - lastActive atomic.TypedValue[time.Time] + lastActive common.TypedValue[time.Time] } func NewURLTestGroup(ctx context.Context, outboundManager adapter.OutboundManager, logger log.Logger, outbounds []adapter.Outbound, link string, interval time.Duration, tolerance uint16, idleTimeout time.Duration, interruptExternalConnections bool) (*URLTestGroup, error) { diff --git a/route/network.go b/route/network.go index 6a45abc6..5009ec0b 100644 --- a/route/network.go +++ b/route/network.go @@ -19,7 +19,6 @@ import ( "github.com/sagernet/sing-box/option" "github.com/sagernet/sing-tun" "github.com/sagernet/sing/common" - "github.com/sagernet/sing/common/atomic" "github.com/sagernet/sing/common/control" E "github.com/sagernet/sing/common/exceptions" F "github.com/sagernet/sing/common/format" @@ -37,7 +36,7 @@ var _ adapter.NetworkManager = (*NetworkManager)(nil) type NetworkManager struct { logger logger.ContextLogger interfaceFinder *control.DefaultInterfaceFinder - networkInterfaces atomic.TypedValue[[]adapter.NetworkInterface] + networkInterfaces common.TypedValue[[]adapter.NetworkInterface] autoDetectInterface bool defaultOptions adapter.NetworkOptions diff --git a/route/rule/rule_set_local.go b/route/rule/rule_set_local.go index 4f2fabcc..0ef15fc7 100644 --- a/route/rule/rule_set_local.go +++ b/route/rule/rule_set_local.go @@ -6,6 +6,7 @@ import ( "path/filepath" "strings" "sync" + "sync/atomic" "github.com/sagernet/fswatch" "github.com/sagernet/sing-box/adapter" @@ -13,7 +14,6 @@ import ( C "github.com/sagernet/sing-box/constant" "github.com/sagernet/sing-box/option" "github.com/sagernet/sing/common" - "github.com/sagernet/sing/common/atomic" E "github.com/sagernet/sing/common/exceptions" F "github.com/sagernet/sing/common/format" "github.com/sagernet/sing/common/json" diff --git a/route/rule/rule_set_remote.go b/route/rule/rule_set_remote.go index 16a95bb6..133e575a 100644 --- a/route/rule/rule_set_remote.go +++ b/route/rule/rule_set_remote.go @@ -10,6 +10,7 @@ import ( "runtime" "strings" "sync" + "sync/atomic" "time" "github.com/sagernet/sing-box/adapter" @@ -17,7 +18,6 @@ import ( C "github.com/sagernet/sing-box/constant" "github.com/sagernet/sing-box/option" "github.com/sagernet/sing/common" - "github.com/sagernet/sing/common/atomic" E "github.com/sagernet/sing/common/exceptions" F "github.com/sagernet/sing/common/format" "github.com/sagernet/sing/common/json" diff --git a/service/ssmapi/cache.go b/service/ssmapi/cache.go index 4c82c9d0..03cc8c3f 100644 --- a/service/ssmapi/cache.go +++ b/service/ssmapi/cache.go @@ -5,8 +5,8 @@ import ( "os" "path/filepath" "sort" + "sync/atomic" - "github.com/sagernet/sing/common/atomic" "github.com/sagernet/sing/common/json" "github.com/sagernet/sing/common/json/badjson" "github.com/sagernet/sing/service/filemanager" diff --git a/service/ssmapi/traffic.go b/service/ssmapi/traffic.go index f39d56d8..4a669adb 100644 --- a/service/ssmapi/traffic.go +++ b/service/ssmapi/traffic.go @@ -3,9 +3,9 @@ package ssmapi import ( "net" "sync" + "sync/atomic" "github.com/sagernet/sing-box/adapter" - "github.com/sagernet/sing/common/atomic" "github.com/sagernet/sing/common/bufio" N "github.com/sagernet/sing/common/network" ) diff --git a/transport/v2rayquic/client.go b/transport/v2rayquic/client.go index 3d1d916e..803d58c5 100644 --- a/transport/v2rayquic/client.go +++ b/transport/v2rayquic/client.go @@ -15,7 +15,6 @@ import ( "github.com/sagernet/sing-box/option" "github.com/sagernet/sing-quic" "github.com/sagernet/sing/common" - "github.com/sagernet/sing/common/atomic" "github.com/sagernet/sing/common/bufio" M "github.com/sagernet/sing/common/metadata" N "github.com/sagernet/sing/common/network" @@ -30,7 +29,7 @@ type Client struct { tlsConfig tls.Config quicConfig *quic.Config connAccess sync.Mutex - conn atomic.TypedValue[quic.Connection] + conn common.TypedValue[quic.Connection] rawConn net.Conn }