chore: using atomic.Pointer in anytls
Some checks are pending
Test / test (1.20, macos-13) (push) Waiting to run
Test / test (1.20, macos-latest) (push) Waiting to run
Test / test (1.20, ubuntu-24.04-arm) (push) Waiting to run
Test / test (1.20, ubuntu-latest) (push) Waiting to run
Test / test (1.20, windows-latest) (push) Waiting to run
Test / test (1.21, macos-13) (push) Waiting to run
Test / test (1.21, macos-latest) (push) Waiting to run
Test / test (1.21, ubuntu-24.04-arm) (push) Waiting to run
Test / test (1.21, ubuntu-latest) (push) Waiting to run
Test / test (1.21, windows-latest) (push) Waiting to run
Test / test (1.22, macos-13) (push) Waiting to run
Test / test (1.22, macos-latest) (push) Waiting to run
Test / test (1.22, ubuntu-24.04-arm) (push) Waiting to run
Test / test (1.22, ubuntu-latest) (push) Waiting to run
Test / test (1.22, windows-latest) (push) Waiting to run
Test / test (1.23, macos-13) (push) Waiting to run
Test / test (1.23, macos-latest) (push) Waiting to run
Test / test (1.23, ubuntu-24.04-arm) (push) Waiting to run
Test / test (1.23, ubuntu-latest) (push) Waiting to run
Test / test (1.23, windows-latest) (push) Waiting to run
Test / test (1.24, macos-13) (push) Waiting to run
Test / test (1.24, macos-latest) (push) Waiting to run
Test / test (1.24, ubuntu-24.04-arm) (push) Waiting to run
Test / test (1.24, ubuntu-latest) (push) Waiting to run
Test / test (1.24, windows-latest) (push) Waiting to run
Test / test (1.25, macos-13) (push) Waiting to run
Test / test (1.25, macos-latest) (push) Waiting to run
Test / test (1.25, ubuntu-24.04-arm) (push) Waiting to run
Test / test (1.25, ubuntu-latest) (push) Waiting to run
Test / test (1.25, windows-latest) (push) Waiting to run
Trigger CMFA Update / trigger-CMFA-update (push) Waiting to run

This commit is contained in:
wwqgtxx 2025-08-14 00:51:55 +08:00
parent 0408da2aee
commit f90d0b954c
5 changed files with 13 additions and 13 deletions

View File

@ -7,9 +7,9 @@ import (
"errors" "errors"
"net" "net"
"strings" "strings"
"sync/atomic"
"github.com/metacubex/mihomo/adapter/inbound" "github.com/metacubex/mihomo/adapter/inbound"
"github.com/metacubex/mihomo/common/atomic"
"github.com/metacubex/mihomo/common/buf" "github.com/metacubex/mihomo/common/buf"
"github.com/metacubex/mihomo/component/ca" "github.com/metacubex/mihomo/component/ca"
"github.com/metacubex/mihomo/component/ech" "github.com/metacubex/mihomo/component/ech"
@ -31,7 +31,7 @@ type Listener struct {
listeners []net.Listener listeners []net.Listener
tlsConfig *tlsC.Config tlsConfig *tlsC.Config
userMap map[[32]byte]string userMap map[[32]byte]string
padding atomic.TypedValue[*padding.PaddingFactory] padding atomic.Pointer[padding.PaddingFactory]
} }
func New(config LC.AnyTLSServer, tunnel C.Tunnel, additions ...inbound.Addition) (sl *Listener, err error) { func New(config LC.AnyTLSServer, tunnel C.Tunnel, additions ...inbound.Addition) (sl *Listener, err error) {

View File

@ -5,9 +5,9 @@ import (
"crypto/sha256" "crypto/sha256"
"encoding/binary" "encoding/binary"
"net" "net"
"sync/atomic"
"time" "time"
"github.com/metacubex/mihomo/common/atomic"
"github.com/metacubex/mihomo/common/buf" "github.com/metacubex/mihomo/common/buf"
"github.com/metacubex/mihomo/transport/anytls/padding" "github.com/metacubex/mihomo/transport/anytls/padding"
"github.com/metacubex/mihomo/transport/anytls/session" "github.com/metacubex/mihomo/transport/anytls/session"
@ -33,7 +33,7 @@ type Client struct {
dialer N.Dialer dialer N.Dialer
server M.Socksaddr server M.Socksaddr
sessionClient *session.Client sessionClient *session.Client
padding atomic.TypedValue[*padding.PaddingFactory] padding atomic.Pointer[padding.PaddingFactory]
} }
func NewClient(ctx context.Context, config ClientConfig) *Client { func NewClient(ctx context.Context, config ClientConfig) *Client {

View File

@ -7,8 +7,8 @@ import (
"math/big" "math/big"
"strconv" "strconv"
"strings" "strings"
"sync/atomic"
"github.com/metacubex/mihomo/common/atomic"
"github.com/metacubex/mihomo/transport/anytls/util" "github.com/metacubex/mihomo/transport/anytls/util"
) )
@ -31,7 +31,7 @@ type PaddingFactory struct {
Md5 string Md5 string
} }
func UpdatePaddingScheme(rawScheme []byte, to *atomic.TypedValue[*PaddingFactory]) bool { func UpdatePaddingScheme(rawScheme []byte, to *atomic.Pointer[PaddingFactory]) bool {
if p := NewPaddingFactory(rawScheme); p != nil { if p := NewPaddingFactory(rawScheme); p != nil {
to.Store(p) to.Store(p)
return true return true

View File

@ -7,9 +7,9 @@ import (
"math" "math"
"net" "net"
"sync" "sync"
"sync/atomic"
"time" "time"
"github.com/metacubex/mihomo/common/atomic"
"github.com/metacubex/mihomo/transport/anytls/padding" "github.com/metacubex/mihomo/transport/anytls/padding"
"github.com/metacubex/mihomo/transport/anytls/skiplist" "github.com/metacubex/mihomo/transport/anytls/skiplist"
"github.com/metacubex/mihomo/transport/anytls/util" "github.com/metacubex/mihomo/transport/anytls/util"
@ -29,13 +29,13 @@ type Client struct {
sessions map[uint64]*Session sessions map[uint64]*Session
sessionsLock sync.Mutex sessionsLock sync.Mutex
padding *atomic.TypedValue[*padding.PaddingFactory] padding *atomic.Pointer[padding.PaddingFactory]
idleSessionTimeout time.Duration idleSessionTimeout time.Duration
minIdleSession int minIdleSession int
} }
func NewClient(ctx context.Context, dialOut util.DialOutFunc, _padding *atomic.TypedValue[*padding.PaddingFactory], idleSessionCheckInterval, idleSessionTimeout time.Duration, minIdleSession int) *Client { func NewClient(ctx context.Context, dialOut util.DialOutFunc, _padding *atomic.Pointer[padding.PaddingFactory], idleSessionCheckInterval, idleSessionTimeout time.Duration, minIdleSession int) *Client {
c := &Client{ c := &Client{
sessions: make(map[uint64]*Session), sessions: make(map[uint64]*Session),
dialOut: dialOut, dialOut: dialOut,

View File

@ -9,9 +9,9 @@ import (
"runtime/debug" "runtime/debug"
"strconv" "strconv"
"sync" "sync"
"sync/atomic"
"time" "time"
"github.com/metacubex/mihomo/common/atomic"
"github.com/metacubex/mihomo/common/buf" "github.com/metacubex/mihomo/common/buf"
"github.com/metacubex/mihomo/common/pool" "github.com/metacubex/mihomo/common/pool"
"github.com/metacubex/mihomo/constant" "github.com/metacubex/mihomo/constant"
@ -38,7 +38,7 @@ type Session struct {
// pool // pool
seq uint64 seq uint64
idleSince time.Time idleSince time.Time
padding *atomic.TypedValue[*padding.PaddingFactory] padding *atomic.Pointer[padding.PaddingFactory]
peerVersion byte peerVersion byte
@ -53,7 +53,7 @@ type Session struct {
onNewStream func(stream *Stream) onNewStream func(stream *Stream)
} }
func NewClientSession(conn net.Conn, _padding *atomic.TypedValue[*padding.PaddingFactory]) *Session { func NewClientSession(conn net.Conn, _padding *atomic.Pointer[padding.PaddingFactory]) *Session {
s := &Session{ s := &Session{
conn: conn, conn: conn,
isClient: true, isClient: true,
@ -65,7 +65,7 @@ func NewClientSession(conn net.Conn, _padding *atomic.TypedValue[*padding.Paddin
return s return s
} }
func NewServerSession(conn net.Conn, onNewStream func(stream *Stream), _padding *atomic.TypedValue[*padding.PaddingFactory]) *Session { func NewServerSession(conn net.Conn, onNewStream func(stream *Stream), _padding *atomic.Pointer[padding.PaddingFactory]) *Session {
s := &Session{ s := &Session{
conn: conn, conn: conn,
onNewStream: onNewStream, onNewStream: onNewStream,