From 37791acb5947e9b978f0494f3aa91eaadb2bdf46 Mon Sep 17 00:00:00 2001 From: wwqgtxx Date: Thu, 23 Nov 2023 10:24:01 +0800 Subject: [PATCH] chore: upgrade xsync to v3 --- adapter/adapter.go | 4 ++-- component/nat/table.go | 10 +++++----- go.mod | 2 +- go.sum | 4 ++-- transport/tuic/v4/client.go | 4 ++-- transport/tuic/v4/server.go | 4 ++-- transport/tuic/v5/client.go | 4 ++-- transport/tuic/v5/server.go | 4 ++-- tunnel/statistic/manager.go | 4 ++-- 9 files changed, 20 insertions(+), 20 deletions(-) diff --git a/adapter/adapter.go b/adapter/adapter.go index 74b11bd9..33f567c5 100644 --- a/adapter/adapter.go +++ b/adapter/adapter.go @@ -19,7 +19,7 @@ import ( C "github.com/metacubex/mihomo/constant" "github.com/metacubex/mihomo/log" - "github.com/puzpuzpuz/xsync/v2" + "github.com/puzpuzpuz/xsync/v3" ) var UnifiedDelay = atomic.NewBool(false) @@ -316,7 +316,7 @@ func NewProxy(adapter C.ProxyAdapter) *Proxy { history: queue.New[C.DelayHistory](defaultHistoriesNum), alive: atomic.NewBool(true), url: "", - extra: xsync.NewMapOf[*extraProxyState]()} + extra: xsync.NewMapOf[string, *extraProxyState]()} } func urlToMetadata(rawURL string) (addr C.Metadata, err error) { diff --git a/component/nat/table.go b/component/nat/table.go index b2908c94..bb5ab755 100644 --- a/component/nat/table.go +++ b/component/nat/table.go @@ -6,7 +6,7 @@ import ( C "github.com/metacubex/mihomo/constant" - "github.com/puzpuzpuz/xsync/v2" + "github.com/puzpuzpuz/xsync/v3" ) type Table struct { @@ -25,8 +25,8 @@ func (t *Table) Set(key string, e C.PacketConn, w C.WriteBackProxy) { t.mapping.Store(key, &Entry{ PacketConn: e, WriteBackProxy: w, - LocalUDPConnMap: xsync.NewMapOf[*net.UDPConn](), - LocalLockMap: xsync.NewMapOf[*sync.Cond](), + LocalUDPConnMap: xsync.NewMapOf[string, *net.UDPConn](), + LocalLockMap: xsync.NewMapOf[string, *sync.Cond](), }) } @@ -116,7 +116,7 @@ func makeLock() *sync.Cond { // New return *Cache func New() *Table { return &Table{ - mapping: xsync.NewMapOf[*Entry](), - lockMap: xsync.NewMapOf[*sync.Cond](), + mapping: xsync.NewMapOf[string, *Entry](), + lockMap: xsync.NewMapOf[string, *sync.Cond](), } } diff --git a/go.mod b/go.mod index 8e86bb85..5bd66cd0 100644 --- a/go.mod +++ b/go.mod @@ -31,7 +31,7 @@ require ( github.com/mroth/weightedrand/v2 v2.1.0 github.com/openacid/low v0.1.21 github.com/oschwald/maxminddb-golang v1.12.0 - github.com/puzpuzpuz/xsync/v2 v2.5.1 + github.com/puzpuzpuz/xsync/v3 v3.0.2 github.com/sagernet/bbolt v0.0.0-20231014093535-ea5cb2fe9f0a github.com/sagernet/netlink v0.0.0-20220905062125-8043b4a9aa97 github.com/sagernet/sing v0.2.18-0.20231108041402-4fbbd193203c diff --git a/go.sum b/go.sum index 7fddd84e..3a606050 100644 --- a/go.sum +++ b/go.sum @@ -145,8 +145,8 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c h1:ncq/mPwQF4JjgDlrVEn3C11VoGHZN7m8qihwgMEtzYw= github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c/go.mod h1:OmDBASR4679mdNQnz2pUhc2G8CO2JrUAVFDRBDP/hJE= github.com/prashantv/gostub v1.1.0 h1:BTyx3RfQjRHnUWaGF9oQos79AlQ5k8WNktv7VGvVH4g= -github.com/puzpuzpuz/xsync/v2 v2.5.1 h1:mVGYAvzDSu52+zaGyNjC+24Xw2bQi3kTr4QJ6N9pIIU= -github.com/puzpuzpuz/xsync/v2 v2.5.1/go.mod h1:gD2H2krq/w52MfPLE+Uy64TzJDVY7lP2znR9qmR35kU= +github.com/puzpuzpuz/xsync/v3 v3.0.2 h1:3yESHrRFYr6xzkz61LLkvNiPFXxJEAABanTQpKbAaew= +github.com/puzpuzpuz/xsync/v3 v3.0.2/go.mod h1:VjzYrABPabuM4KyBh1Ftq6u8nhwY5tBPKP9jpmh0nnA= github.com/quic-go/qpack v0.4.0 h1:Cr9BXA1sQS2SmDUWjSofMPNKmvF6IiIfDRmgU0w1ZCo= github.com/quic-go/qpack v0.4.0/go.mod h1:UZVnYIfi5GRk+zI9UMaCPsmZ2xKJP7XBUvVyT1Knj9A= github.com/quic-go/qtls-go1-20 v0.3.4 h1:MfFAPULvst4yoMgY9QmtpYmfij/em7O8UUi+bNVm7Cg= diff --git a/transport/tuic/v4/client.go b/transport/tuic/v4/client.go index 0bc8f9bb..a553db82 100644 --- a/transport/tuic/v4/client.go +++ b/transport/tuic/v4/client.go @@ -22,7 +22,7 @@ import ( "github.com/metacubex/mihomo/transport/tuic/common" "github.com/metacubex/quic-go" - "github.com/puzpuzpuz/xsync/v2" + "github.com/puzpuzpuz/xsync/v3" "github.com/zhangyunhao116/fastrand" ) @@ -469,7 +469,7 @@ func NewClient(clientOption *ClientOption, udp bool, dialerRef C.Dialer) *Client ClientOption: clientOption, udp: udp, dialerRef: dialerRef, - udpInputMap: xsync.NewIntegerMapOf[uint32, net.Conn](), + udpInputMap: xsync.NewMapOf[uint32, net.Conn](), } c := &Client{ci} runtime.SetFinalizer(c, closeClient) diff --git a/transport/tuic/v4/server.go b/transport/tuic/v4/server.go index c4e4d735..2430866f 100644 --- a/transport/tuic/v4/server.go +++ b/transport/tuic/v4/server.go @@ -17,7 +17,7 @@ import ( "github.com/gofrs/uuid/v5" "github.com/metacubex/quic-go" - "github.com/puzpuzpuz/xsync/v2" + "github.com/puzpuzpuz/xsync/v3" ) type ServerOption struct { @@ -34,7 +34,7 @@ func NewServerHandler(option *ServerOption, quicConn quic.EarlyConnection, uuid quicConn: quicConn, uuid: uuid, authCh: make(chan struct{}), - udpInputMap: xsync.NewIntegerMapOf[uint32, *atomic.Bool](), + udpInputMap: xsync.NewMapOf[uint32, *atomic.Bool](), } } diff --git a/transport/tuic/v5/client.go b/transport/tuic/v5/client.go index e37d60fc..81da80e7 100644 --- a/transport/tuic/v5/client.go +++ b/transport/tuic/v5/client.go @@ -20,7 +20,7 @@ import ( "github.com/metacubex/mihomo/transport/tuic/common" "github.com/metacubex/quic-go" - "github.com/puzpuzpuz/xsync/v2" + "github.com/puzpuzpuz/xsync/v3" "github.com/zhangyunhao116/fastrand" ) @@ -406,7 +406,7 @@ func NewClient(clientOption *ClientOption, udp bool, dialerRef C.Dialer) *Client ClientOption: clientOption, udp: udp, dialerRef: dialerRef, - udpInputMap: *xsync.NewIntegerMapOf[uint16, net.Conn](), + udpInputMap: *xsync.NewMapOf[uint16, net.Conn](), } c := &Client{ci} runtime.SetFinalizer(c, closeClient) diff --git a/transport/tuic/v5/server.go b/transport/tuic/v5/server.go index c8170f62..8454b64c 100644 --- a/transport/tuic/v5/server.go +++ b/transport/tuic/v5/server.go @@ -16,7 +16,7 @@ import ( "github.com/gofrs/uuid/v5" "github.com/metacubex/quic-go" - "github.com/puzpuzpuz/xsync/v2" + "github.com/puzpuzpuz/xsync/v3" ) type ServerOption struct { @@ -33,7 +33,7 @@ func NewServerHandler(option *ServerOption, quicConn quic.EarlyConnection, uuid quicConn: quicConn, uuid: uuid, authCh: make(chan struct{}), - udpInputMap: xsync.NewIntegerMapOf[uint16, *serverUDPInput](), + udpInputMap: xsync.NewMapOf[uint16, *serverUDPInput](), } } diff --git a/tunnel/statistic/manager.go b/tunnel/statistic/manager.go index 8e962dae..08747118 100644 --- a/tunnel/statistic/manager.go +++ b/tunnel/statistic/manager.go @@ -6,7 +6,7 @@ import ( "github.com/metacubex/mihomo/common/atomic" - "github.com/puzpuzpuz/xsync/v2" + "github.com/puzpuzpuz/xsync/v3" "github.com/shirou/gopsutil/v3/process" ) @@ -14,7 +14,7 @@ var DefaultManager *Manager func init() { DefaultManager = &Manager{ - connections: xsync.NewMapOf[Tracker](), + connections: xsync.NewMapOf[string, Tracker](), uploadTemp: atomic.NewInt64(0), downloadTemp: atomic.NewInt64(0), uploadBlip: atomic.NewInt64(0),