Pull request: 5035-slices-clone
Updates #5035. Squashed commit of the following: commit 9a5be90a347d4da08649927731b20fd5ecb90be2 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Fri Oct 21 20:11:54 2022 +0300 all: use slices.Clone, netip.AddrPort
This commit is contained in:
@@ -9,8 +9,8 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/AdguardTeam/golibs/log"
|
||||
"github.com/AdguardTeam/golibs/netutil"
|
||||
"github.com/AdguardTeam/golibs/timeutil"
|
||||
"golang.org/x/exp/slices"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -54,8 +54,8 @@ func (l *Lease) Clone() (clone *Lease) {
|
||||
return &Lease{
|
||||
Expiry: l.Expiry,
|
||||
Hostname: l.Hostname,
|
||||
HWAddr: netutil.CloneMAC(l.HWAddr),
|
||||
IP: netutil.CloneIP(l.IP),
|
||||
HWAddr: slices.Clone(l.HWAddr),
|
||||
IP: slices.Clone(l.IP),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,10 +10,10 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/AdguardTeam/AdGuardHome/internal/aghtest"
|
||||
"github.com/AdguardTeam/golibs/netutil"
|
||||
"github.com/AdguardTeam/golibs/testutil"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"golang.org/x/exp/slices"
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
@@ -157,7 +157,7 @@ func TestV4Server_badRange(t *testing.T) {
|
||||
// cloneUDPAddr returns a deep copy of a.
|
||||
func cloneUDPAddr(a *net.UDPAddr) (clone *net.UDPAddr) {
|
||||
return &net.UDPAddr{
|
||||
IP: netutil.CloneIP(a.IP),
|
||||
IP: slices.Clone(a.IP),
|
||||
Port: a.Port,
|
||||
Zone: a.Zone,
|
||||
}
|
||||
|
||||
@@ -1018,7 +1018,7 @@ func (s *v4Server) handle(req, resp *dhcpv4.DHCPv4) int {
|
||||
}
|
||||
|
||||
if l != nil {
|
||||
resp.YourIPAddr = netutil.CloneIP(l.IP)
|
||||
resp.YourIPAddr = slices.Clone(l.IP)
|
||||
}
|
||||
|
||||
s.updateOptions(req, resp)
|
||||
|
||||
Reference in New Issue
Block a user