Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions internal/dhcpd/dhcpd_unix_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,14 @@ func TestV4Server_badRange(t *testing.T) {
}
}

func TestV4Server_Create_disabled(t *testing.T) {
s, err := v4Create(&V4ServerConf{})

require.NoError(t, err)
assert.NotNil(t, s)
assert.False(t, s.enabled())
}

// cloneUDPAddr returns a deep copy of a.
func cloneUDPAddr(a *net.UDPAddr) (clone *net.UDPAddr) {
return &net.UDPAddr{
Expand Down
9 changes: 9 additions & 0 deletions internal/dhcpd/v4_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -1417,6 +1417,15 @@ func v4Create(conf *V4ServerConf) (srv *v4Server, err error) {
ipIndex: map[netip.Addr]*dhcpsvc.Lease{},
}

if conf != nil &&
!conf.Enabled &&
!conf.GatewayIP.IsValid() &&
!conf.SubnetMask.IsValid() &&
!conf.RangeStart.IsValid() &&
!conf.RangeEnd.IsValid() {
return s, nil
}

err = conf.Validate()
if err != nil {
// TODO(a.garipov): Don't use a disabled server in other places or just
Expand Down