chore(wireguard): use netip.AddrPort instead of *net.UDPAddr
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"net"
|
||||
"net/netip"
|
||||
|
||||
"github.com/qdm12/gluetun/internal/configuration/settings"
|
||||
@@ -21,9 +20,7 @@ func BuildWireguardSettings(connection models.Connection,
|
||||
const rulePriority = 101 // 100 is to receive external connections
|
||||
settings.RulePriority = rulePriority
|
||||
|
||||
settings.Endpoint = new(net.UDPAddr)
|
||||
settings.Endpoint.IP = connection.IP.AsSlice()
|
||||
settings.Endpoint.Port = int(connection.Port)
|
||||
settings.Endpoint = netip.AddrPortFrom(connection.IP, connection.Port)
|
||||
|
||||
settings.Addresses = make([]netip.Prefix, 0, len(userSettings.Addresses))
|
||||
for _, address := range userSettings.Addresses {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"net"
|
||||
"net/netip"
|
||||
"testing"
|
||||
|
||||
@@ -43,10 +42,7 @@ func Test_BuildWireguardSettings(t *testing.T) {
|
||||
PrivateKey: "private",
|
||||
PublicKey: "public",
|
||||
PreSharedKey: "pre-shared",
|
||||
Endpoint: &net.UDPAddr{
|
||||
IP: net.IP{1, 2, 3, 4},
|
||||
Port: 51821,
|
||||
},
|
||||
Endpoint: netip.AddrPortFrom(netip.AddrFrom4([4]byte{1, 2, 3, 4}), 51821),
|
||||
Addresses: []netip.Prefix{
|
||||
netip.PrefixFrom(netip.AddrFrom4([4]byte{1, 1, 1, 1}), 32),
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user