fix: ignore DHCP lease if not in DHCP mode

This commit is contained in:
Siyuan 2025-10-14 15:07:05 +00:00
parent c1f1da2640
commit 6a2a33b00a
1 changed files with 5 additions and 0 deletions

View File

@ -90,6 +90,11 @@ func NewInterfaceManager(ctx context.Context, ifaceName string, config *types.Ne
// Set up DHCP client callbacks // Set up DHCP client callbacks
im.dhcpClient.SetOnLeaseChange(func(lease *types.DHCPLease) { im.dhcpClient.SetOnLeaseChange(func(lease *types.DHCPLease) {
if im.config.IPv4Mode.String != "dhcp" {
im.logger.Warn().Str("mode", im.config.IPv4Mode.String).Msg("ignoring DHCP lease, current mode is not DHCP")
return
}
if err := im.applyDHCPLease(lease); err != nil { if err := im.applyDHCPLease(lease); err != nil {
im.logger.Error().Err(err).Msg("failed to apply DHCP lease") im.logger.Error().Err(err).Msg("failed to apply DHCP lease")
} }