@@ -34,7 +34,7 @@ func NewEndpointUpdater(log *logrus.Entry, wgConfig WgConfig, initiator bool) *E
3434 }
3535}
3636
37- func (e * EndpointUpdater ) ConfigureWGEndpoint (addr * net.UDPAddr , presharedKey * wgtypes.Key , setEndpointNow bool ) error {
37+ func (e * EndpointUpdater ) ConfigureWGEndpoint (addr * net.UDPAddr , presharedKey * wgtypes.Key ) error {
3838 e .mu .Lock ()
3939 defer e .mu .Unlock ()
4040
@@ -44,7 +44,7 @@ func (e *EndpointUpdater) ConfigureWGEndpoint(addr *net.UDPAddr, presharedKey *w
4444 }
4545
4646 e .log .Debugf ("configure up WireGuard as responder" )
47- return e .configureAsResponder (addr , presharedKey , setEndpointNow )
47+ return e .configureAsResponder (addr , presharedKey )
4848}
4949
5050func (e * EndpointUpdater ) SwitchWGEndpoint (addr * net.UDPAddr , presharedKey * wgtypes.Key ) error {
@@ -80,25 +80,19 @@ func (e *EndpointUpdater) configureAsInitiator(addr *net.UDPAddr, presharedKey *
8080 return nil
8181}
8282
83- func (e * EndpointUpdater ) configureAsResponder (addr * net.UDPAddr , presharedKey * wgtypes.Key , setEndpointNow bool ) error {
83+ func (e * EndpointUpdater ) configureAsResponder (addr * net.UDPAddr , presharedKey * wgtypes.Key ) error {
8484 // prevent to run new update while cancel the previous update
8585 e .waitForCloseTheDelayedUpdate ()
8686
8787 e .log .Debugf ("configure up WireGuard and wait for handshake" )
88- if setEndpointNow {
89- if err := e .updateWireGuardPeer (addr , presharedKey ); err != nil {
90- return err
91- }
92- } else {
93- var ctx context.Context
94- ctx , e .cancelFunc = context .WithCancel (context .Background ())
95- e .updateWg .Add (1 )
96- go e .scheduleDelayedUpdate (ctx , addr , presharedKey )
97-
98- if err := e .updateWireGuardPeer (nil , presharedKey ); err != nil {
99- e .waitForCloseTheDelayedUpdate ()
100- return err
101- }
88+ var ctx context.Context
89+ ctx , e .cancelFunc = context .WithCancel (context .Background ())
90+ e .updateWg .Add (1 )
91+ go e .scheduleDelayedUpdate (ctx , addr , presharedKey )
92+
93+ if err := e .updateWireGuardPeer (nil , presharedKey ); err != nil {
94+ e .waitForCloseTheDelayedUpdate ()
95+ return err
10296 }
10397 return nil
10498}
0 commit comments