[client] Restart engine when peer IP address changes (#5614)

This commit is contained in:
Viktor Liu
2026-03-18 00:00:24 +08:00
committed by GitHub
parent f0eed50678
commit af8eaa23e2

View File

@@ -989,10 +989,11 @@ func (e *Engine) updateConfig(conf *mgmProto.PeerConfig) error {
return errors.New("wireguard interface is not initialized") return errors.New("wireguard interface is not initialized")
} }
// Cannot update the IP address without restarting the engine because
// the firewall, route manager, and other components cache the old address
if e.wgInterface.Address().String() != conf.Address { if e.wgInterface.Address().String() != conf.Address {
log.Infof("peer IP address has changed from %s to %s", e.wgInterface.Address().String(), conf.Address) log.Infof("peer IP address changed from %s to %s, restarting client", e.wgInterface.Address().String(), conf.Address)
_ = CtxGetState(e.ctx).Wrap(ErrResetConnection)
e.clientCancel()
return ErrResetConnection
} }
if conf.GetSshConfig() != nil { if conf.GetSshConfig() != nil {