chore: better atomic using

This commit is contained in:
wwqgtxx
2023-10-10 16:34:33 +08:00
parent ae557c30d3
commit 7ed25ddc74
10 changed files with 48 additions and 57 deletions

View File

@ -23,7 +23,7 @@ type client struct {
r *Resolver
port string
host string
iface *atomic.TypedValue[string]
iface atomic.TypedValue[string]
proxyAdapter C.ProxyAdapter
proxyName string
addr string
@ -77,8 +77,8 @@ func (c *client) ExchangeContext(ctx context.Context, m *D.Msg) (*D.Msg, error)
network = "tcp"
}
options := []dialer.Option{}
if c.iface != nil && c.iface.Load() != "" {
var options []dialer.Option
if c.iface.Load() != "" {
options = append(options, dialer.WithInterface(c.iface.Load()))
}

View File

@ -398,7 +398,7 @@ func (r *Resolver) Invalid() bool {
type NameServer struct {
Net string
Addr string
Interface *atomic.TypedValue[string]
Interface atomic.TypedValue[string]
ProxyAdapter C.ProxyAdapter
ProxyName string
Params map[string]string