all: imp code
This commit is contained in:
parent
27e5181200
commit
c82b18f140
|
@ -22,14 +22,11 @@ func GenerateHostname(ip netip.Addr) (hostname string) {
|
|||
}
|
||||
|
||||
ip = ip.Unmap()
|
||||
hostname = ip.StringExpanded()
|
||||
|
||||
if ip.Is4() {
|
||||
hostname = ip.String()
|
||||
|
||||
return strings.Replace(hostname, ".", "-", -1)
|
||||
}
|
||||
|
||||
hostname = ip.StringExpanded()
|
||||
|
||||
return strings.Replace(hostname, ":", "-", -1)
|
||||
}
|
||||
|
|
|
@ -36,18 +36,6 @@ func TestGenerateHostName(t *testing.T) {
|
|||
})
|
||||
|
||||
t.Run("invalid", func(t *testing.T) {
|
||||
testCases := []struct {
|
||||
name string
|
||||
ip netip.Addr
|
||||
}{{
|
||||
name: "nil",
|
||||
ip: netip.Addr{},
|
||||
}}
|
||||
|
||||
for _, tc := range testCases {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
assert.Panics(t, func() { GenerateHostname(tc.ip) })
|
||||
})
|
||||
}
|
||||
assert.Panics(t, func() { GenerateHostname(netip.Addr{}) })
|
||||
})
|
||||
}
|
||||
|
|
|
@ -309,9 +309,7 @@ func (s *v6Server) reserveLease(mac net.HardwareAddr) *Lease {
|
|||
s.leasesLock.Lock()
|
||||
defer s.leasesLock.Unlock()
|
||||
|
||||
var ip net.IP
|
||||
copy(ip, s.conf.ipStart)
|
||||
ip = s.findFreeIP()
|
||||
ip := s.findFreeIP()
|
||||
if ip == nil {
|
||||
i := s.findExpiredLease()
|
||||
if i < 0 {
|
||||
|
|
Loading…
Reference in New Issue