@@ -101,7 +101,6 @@ type wgtun struct {
101
101
ep * channel.Endpoint // reads and writes packets to/from stack
102
102
ingress chan * buffer.View // pipes ep writes to wg
103
103
events chan tun.Event // wg specific tun (interface) events
104
- amnezia * wg.Amnezia // amnezia config, if any
105
104
finalize chan struct {} // close signal for incomingPacket
106
105
once sync.Once // closer fn; exec exactly once
107
106
preferOffload bool // UDP GRO/GSO offloads
@@ -120,10 +119,12 @@ type wgtun struct {
120
119
desiredmtu atomic.Uint32 // desired mtu
121
120
netmtu atomic.Uint32 // underlay network mtu
122
121
123
- peers * core.Volatile [map [string ]device.NoisePublicKey ] // peer (remote endpoint) public keys
124
- dns * core.Volatile [* multihost.MH ] // dns resolver for this interface
125
- remote * core.Volatile [* multihost.MHMap ] // peer (remote endpoint) addrs
126
- rt x.IpTree // route table for this interface
122
+ peers * core.Volatile [map [string ]device.NoisePublicKey ] // peer (remote endpoint) public keys
123
+ dns * core.Volatile [* multihost.MH ] // dns resolver for this interface
124
+ remote * core.Volatile [* multihost.MHMap ] // peer (remote endpoint) addrs
125
+ amnezia * core.Volatile [* wg.Amnezia ] // amnezia/warp config, if any
126
+
127
+ rt x.IpTree // route table for this interface
127
128
128
129
refreshBa * core.Barrier [bool , string ] // 2mins refresh barrier
129
130
@@ -385,8 +386,9 @@ func (w *wgproxy) update(id, txt string) bool {
385
386
}
386
387
387
388
if settings .Debug {
388
- if ! w .amnezia .Same (opts .amnezia ) {
389
- log .D ("proxy: wg: update(%s): failed; amnezia %v != %v" , w .id , opts .amnezia , w .amnezia )
389
+ if ! w .amnezia .Load ().Same (opts .amnezia ) {
390
+ log .D ("proxy: wg: update(%s): failed; amnezia %v != %v" ,
391
+ w .id , opts .amnezia , w .amnezia .Load ())
390
392
}
391
393
if opts .dns != nil && ! opts .dns .EqualAddrs (w .dns .Load ()) {
392
394
log .D ("proxy: wg: update(%s): failed; new/mismatched dns" , w .id )
@@ -403,10 +405,10 @@ func (w *wgproxy) update(id, txt string) bool {
403
405
404
406
w .peers .Store (opts .peers ) // re-assignment is okay (map entry modification is not)
405
407
w .allowedIPs (opts .allowed )
406
- w .remote .Store (opts .eps ) // requires refresh
407
- w .dns .Store (opts .dns ) // requires refresh
408
+ w .remote .Store (opts .eps ) // requires refresh (wg.Conn:ParseEndpoint must be re-called)
409
+ w .dns .Store (opts .dns ) // requires refresh (client must also re-add via intra.AddDNSProxy)
408
410
w .desiredmtu .Store (uint32 (opts .mtu )) // requires reset; [NOMTU, MAXMTU)
409
- w .amnezia = opts .amnezia // TODO: core.Volatile?
411
+ w .amnezia . Store ( opts .amnezia )
410
412
w .resetMtu (w .getVia ())
411
413
412
414
return reuse
@@ -651,9 +653,11 @@ func NewWgProxy(id string, ctl protect.Controller, px ProxyProvider, lp LinkProp
651
653
var wgep wgconn
652
654
if wgtun .preferOffload {
653
655
// todo: use wgtun.serve fn instead of ctl
656
+ // todo: wgtun.remote instead of opts.eps
657
+ // todo: amnezia/warp config
654
658
wgep = wg .NewEndpoint2 (id , ctl , opts .eps , wgtun .listener )
655
659
} else {
656
- wgep = wg .NewEndpoint (id , wgtun .serve , opts . eps , wgtun .listener , wgtun .amnezia )
660
+ wgep = wg .NewEndpoint (id , wgtun .serve , wgtun . remote , wgtun .listener , wgtun .amnezia )
657
661
}
658
662
659
663
wgdev := device .NewDevice (wgtun , wgep , wglogger (id ))
@@ -786,7 +790,7 @@ func makeWgTun(id, cfg string, ctl protect.Controller, px ProxyProvider, lp Link
786
790
remote : core .NewVolatile (ifopts .eps ), // may be nil
787
791
peers : core .NewVolatile (ifopts .peers ), // its entries must never be modified
788
792
rt : x .NewIpTree (), // must be set to allowedaddrs
789
- amnezia : ifopts .amnezia ,
793
+ amnezia : core . NewVolatile ( ifopts .amnezia ) ,
790
794
status : core .NewVolatile (TUP ),
791
795
preferOffload : preferOffload (id ),
792
796
refreshBa : core.NewBarrier [bool ](refreshInterval ),
0 commit comments