chore: using sync/atomic replace uber/atomic

This commit is contained in:
wwqgtxx
2023-04-22 15:37:57 +08:00
parent c6ecbb25dc
commit 40da1911d9
17 changed files with 288 additions and 31 deletions

View File

@ -8,6 +8,7 @@ import (
"net/netip"
"strings"
"github.com/Dreamacro/clash/common/atomic"
"github.com/Dreamacro/clash/component/dialer"
"github.com/Dreamacro/clash/component/resolver"
tlsC "github.com/Dreamacro/clash/component/tls"
@ -15,7 +16,6 @@ import (
D "github.com/miekg/dns"
"github.com/zhangyunhao116/fastrand"
"go.uber.org/atomic"
)
type client struct {
@ -23,7 +23,7 @@ type client struct {
r *Resolver
port string
host string
iface *atomic.String
iface *atomic.TypedValue[string]
proxyAdapter C.ProxyAdapter
proxyName string
addr string

View File

@ -8,8 +8,7 @@ import (
"sync"
"time"
"go.uber.org/atomic"
"github.com/Dreamacro/clash/common/atomic"
"github.com/Dreamacro/clash/component/dhcp"
"github.com/Dreamacro/clash/component/iface"
"github.com/Dreamacro/clash/component/resolver"
@ -86,7 +85,7 @@ func (d *dhcpClient) resolve(ctx context.Context) ([]dnsClient, error) {
for _, item := range dns {
nameserver = append(nameserver, NameServer{
Addr: net.JoinHostPort(item.String(), "53"),
Interface: atomic.NewString(d.ifaceName),
Interface: atomic.NewTypedValue(d.ifaceName),
})
}

View File

@ -7,8 +7,7 @@ import (
"strings"
"time"
"go.uber.org/atomic"
"github.com/Dreamacro/clash/common/atomic"
"github.com/Dreamacro/clash/common/cache"
"github.com/Dreamacro/clash/component/fakeip"
"github.com/Dreamacro/clash/component/geodata/router"
@ -388,7 +387,7 @@ func (r *Resolver) Invalid() bool {
type NameServer struct {
Net string
Addr string
Interface *atomic.String
Interface *atomic.TypedValue[string]
ProxyAdapter C.ProxyAdapter
ProxyName string
Params map[string]string