@@ -101,7 +101,6 @@ type wgtun struct {
101101 ep * channel.Endpoint // reads and writes packets to/from stack
102102 ingress chan * buffer.View // pipes ep writes to wg
103103 events chan tun.Event // wg specific tun (interface) events
104- amnezia * wg.Amnezia // amnezia config, if any
105104 finalize chan struct {} // close signal for incomingPacket
106105 once sync.Once // closer fn; exec exactly once
107106 preferOffload bool // UDP GRO/GSO offloads
@@ -120,10 +119,12 @@ type wgtun struct {
120119 desiredmtu atomic.Uint32 // desired mtu
121120 netmtu atomic.Uint32 // underlay network mtu
122121
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
127128
128129 refreshBa * core.Barrier [bool , string ] // 2mins refresh barrier
129130
@@ -385,8 +386,9 @@ func (w *wgproxy) update(id, txt string) bool {
385386 }
386387
387388 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 ())
390392 }
391393 if opts .dns != nil && ! opts .dns .EqualAddrs (w .dns .Load ()) {
392394 log .D ("proxy: wg: update(%s): failed; new/mismatched dns" , w .id )
@@ -403,10 +405,10 @@ func (w *wgproxy) update(id, txt string) bool {
403405
404406 w .peers .Store (opts .peers ) // re-assignment is okay (map entry modification is not)
405407 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)
408410 w .desiredmtu .Store (uint32 (opts .mtu )) // requires reset; [NOMTU, MAXMTU)
409- w .amnezia = opts .amnezia // TODO: core.Volatile?
411+ w .amnezia . Store ( opts .amnezia )
410412 w .resetMtu (w .getVia ())
411413
412414 return reuse
@@ -651,9 +653,11 @@ func NewWgProxy(id string, ctl protect.Controller, px ProxyProvider, lp LinkProp
651653 var wgep wgconn
652654 if wgtun .preferOffload {
653655 // todo: use wgtun.serve fn instead of ctl
656+ // todo: wgtun.remote instead of opts.eps
657+ // todo: amnezia/warp config
654658 wgep = wg .NewEndpoint2 (id , ctl , opts .eps , wgtun .listener )
655659 } 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 )
657661 }
658662
659663 wgdev := device .NewDevice (wgtun , wgep , wglogger (id ))
@@ -786,7 +790,7 @@ func makeWgTun(id, cfg string, ctl protect.Controller, px ProxyProvider, lp Link
786790 remote : core .NewVolatile (ifopts .eps ), // may be nil
787791 peers : core .NewVolatile (ifopts .peers ), // its entries must never be modified
788792 rt : x .NewIpTree (), // must be set to allowedaddrs
789- amnezia : ifopts .amnezia ,
793+ amnezia : core . NewVolatile ( ifopts .amnezia ) ,
790794 status : core .NewVolatile (TUP ),
791795 preferOffload : preferOffload (id ),
792796 refreshBa : core.NewBarrier [bool ](refreshInterval ),
0 commit comments