mirror of
https://github.com/juanfont/headscale.git
synced 2024-11-29 18:33:05 +00:00
Migrate ACLs to net/netip
This commit is contained in:
parent
cdf48b1216
commit
290ec8bb19
2 changed files with 59 additions and 59 deletions
110
acls_test.go
110
acls_test.go
|
@ -2,11 +2,11 @@ package headscale
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
"net/netip"
|
||||||
"reflect"
|
"reflect"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"gopkg.in/check.v1"
|
"gopkg.in/check.v1"
|
||||||
"inet.af/netaddr"
|
|
||||||
"tailscale.com/tailcfg"
|
"tailscale.com/tailcfg"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -131,7 +131,7 @@ func (s *Suite) TestValidExpandTagOwnersInSources(c *check.C) {
|
||||||
NodeKey: "bar",
|
NodeKey: "bar",
|
||||||
DiscoKey: "faa",
|
DiscoKey: "faa",
|
||||||
Hostname: "testmachine",
|
Hostname: "testmachine",
|
||||||
IPAddresses: MachineAddresses{netaddr.MustParseIP("100.64.0.1")},
|
IPAddresses: MachineAddresses{netip.MustParseAddr("100.64.0.1")},
|
||||||
NamespaceID: namespace.ID,
|
NamespaceID: namespace.ID,
|
||||||
RegisterMethod: RegisterMethodAuthKey,
|
RegisterMethod: RegisterMethodAuthKey,
|
||||||
AuthKeyID: uint(pak.ID),
|
AuthKeyID: uint(pak.ID),
|
||||||
|
@ -181,7 +181,7 @@ func (s *Suite) TestValidExpandTagOwnersInDestinations(c *check.C) {
|
||||||
NodeKey: "bar",
|
NodeKey: "bar",
|
||||||
DiscoKey: "faa",
|
DiscoKey: "faa",
|
||||||
Hostname: "testmachine",
|
Hostname: "testmachine",
|
||||||
IPAddresses: MachineAddresses{netaddr.MustParseIP("100.64.0.1")},
|
IPAddresses: MachineAddresses{netip.MustParseAddr("100.64.0.1")},
|
||||||
NamespaceID: namespace.ID,
|
NamespaceID: namespace.ID,
|
||||||
RegisterMethod: RegisterMethodAuthKey,
|
RegisterMethod: RegisterMethodAuthKey,
|
||||||
AuthKeyID: uint(pak.ID),
|
AuthKeyID: uint(pak.ID),
|
||||||
|
@ -231,7 +231,7 @@ func (s *Suite) TestInvalidTagValidNamespace(c *check.C) {
|
||||||
NodeKey: "bar",
|
NodeKey: "bar",
|
||||||
DiscoKey: "faa",
|
DiscoKey: "faa",
|
||||||
Hostname: "testmachine",
|
Hostname: "testmachine",
|
||||||
IPAddresses: MachineAddresses{netaddr.MustParseIP("100.64.0.1")},
|
IPAddresses: MachineAddresses{netip.MustParseAddr("100.64.0.1")},
|
||||||
NamespaceID: namespace.ID,
|
NamespaceID: namespace.ID,
|
||||||
RegisterMethod: RegisterMethodAuthKey,
|
RegisterMethod: RegisterMethodAuthKey,
|
||||||
AuthKeyID: uint(pak.ID),
|
AuthKeyID: uint(pak.ID),
|
||||||
|
@ -280,7 +280,7 @@ func (s *Suite) TestValidTagInvalidNamespace(c *check.C) {
|
||||||
NodeKey: "bar",
|
NodeKey: "bar",
|
||||||
DiscoKey: "faa",
|
DiscoKey: "faa",
|
||||||
Hostname: "webserver",
|
Hostname: "webserver",
|
||||||
IPAddresses: MachineAddresses{netaddr.MustParseIP("100.64.0.1")},
|
IPAddresses: MachineAddresses{netip.MustParseAddr("100.64.0.1")},
|
||||||
NamespaceID: namespace.ID,
|
NamespaceID: namespace.ID,
|
||||||
RegisterMethod: RegisterMethodAuthKey,
|
RegisterMethod: RegisterMethodAuthKey,
|
||||||
AuthKeyID: uint(pak.ID),
|
AuthKeyID: uint(pak.ID),
|
||||||
|
@ -299,7 +299,7 @@ func (s *Suite) TestValidTagInvalidNamespace(c *check.C) {
|
||||||
NodeKey: "bar2",
|
NodeKey: "bar2",
|
||||||
DiscoKey: "faab",
|
DiscoKey: "faab",
|
||||||
Hostname: "user",
|
Hostname: "user",
|
||||||
IPAddresses: MachineAddresses{netaddr.MustParseIP("100.64.0.2")},
|
IPAddresses: MachineAddresses{netip.MustParseAddr("100.64.0.2")},
|
||||||
NamespaceID: namespace.ID,
|
NamespaceID: namespace.ID,
|
||||||
RegisterMethod: RegisterMethodAuthKey,
|
RegisterMethod: RegisterMethodAuthKey,
|
||||||
AuthKeyID: uint(pak.ID),
|
AuthKeyID: uint(pak.ID),
|
||||||
|
@ -844,10 +844,10 @@ func Test_expandAlias(t *testing.T) {
|
||||||
args: args{
|
args: args{
|
||||||
alias: "*",
|
alias: "*",
|
||||||
machines: []Machine{
|
machines: []Machine{
|
||||||
{IPAddresses: MachineAddresses{netaddr.MustParseIP("100.64.0.1")}},
|
{IPAddresses: MachineAddresses{netip.MustParseAddr("100.64.0.1")}},
|
||||||
{
|
{
|
||||||
IPAddresses: MachineAddresses{
|
IPAddresses: MachineAddresses{
|
||||||
netaddr.MustParseIP("100.78.84.227"),
|
netip.MustParseAddr("100.78.84.227"),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -864,25 +864,25 @@ func Test_expandAlias(t *testing.T) {
|
||||||
machines: []Machine{
|
machines: []Machine{
|
||||||
{
|
{
|
||||||
IPAddresses: MachineAddresses{
|
IPAddresses: MachineAddresses{
|
||||||
netaddr.MustParseIP("100.64.0.1"),
|
netip.MustParseAddr("100.64.0.1"),
|
||||||
},
|
},
|
||||||
Namespace: Namespace{Name: "joe"},
|
Namespace: Namespace{Name: "joe"},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
IPAddresses: MachineAddresses{
|
IPAddresses: MachineAddresses{
|
||||||
netaddr.MustParseIP("100.64.0.2"),
|
netip.MustParseAddr("100.64.0.2"),
|
||||||
},
|
},
|
||||||
Namespace: Namespace{Name: "joe"},
|
Namespace: Namespace{Name: "joe"},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
IPAddresses: MachineAddresses{
|
IPAddresses: MachineAddresses{
|
||||||
netaddr.MustParseIP("100.64.0.3"),
|
netip.MustParseAddr("100.64.0.3"),
|
||||||
},
|
},
|
||||||
Namespace: Namespace{Name: "marc"},
|
Namespace: Namespace{Name: "marc"},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
IPAddresses: MachineAddresses{
|
IPAddresses: MachineAddresses{
|
||||||
netaddr.MustParseIP("100.64.0.4"),
|
netip.MustParseAddr("100.64.0.4"),
|
||||||
},
|
},
|
||||||
Namespace: Namespace{Name: "mickael"},
|
Namespace: Namespace{Name: "mickael"},
|
||||||
},
|
},
|
||||||
|
@ -902,25 +902,25 @@ func Test_expandAlias(t *testing.T) {
|
||||||
machines: []Machine{
|
machines: []Machine{
|
||||||
{
|
{
|
||||||
IPAddresses: MachineAddresses{
|
IPAddresses: MachineAddresses{
|
||||||
netaddr.MustParseIP("100.64.0.1"),
|
netip.MustParseAddr("100.64.0.1"),
|
||||||
},
|
},
|
||||||
Namespace: Namespace{Name: "joe"},
|
Namespace: Namespace{Name: "joe"},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
IPAddresses: MachineAddresses{
|
IPAddresses: MachineAddresses{
|
||||||
netaddr.MustParseIP("100.64.0.2"),
|
netip.MustParseAddr("100.64.0.2"),
|
||||||
},
|
},
|
||||||
Namespace: Namespace{Name: "joe"},
|
Namespace: Namespace{Name: "joe"},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
IPAddresses: MachineAddresses{
|
IPAddresses: MachineAddresses{
|
||||||
netaddr.MustParseIP("100.64.0.3"),
|
netip.MustParseAddr("100.64.0.3"),
|
||||||
},
|
},
|
||||||
Namespace: Namespace{Name: "marc"},
|
Namespace: Namespace{Name: "marc"},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
IPAddresses: MachineAddresses{
|
IPAddresses: MachineAddresses{
|
||||||
netaddr.MustParseIP("100.64.0.4"),
|
netip.MustParseAddr("100.64.0.4"),
|
||||||
},
|
},
|
||||||
Namespace: Namespace{Name: "mickael"},
|
Namespace: Namespace{Name: "mickael"},
|
||||||
},
|
},
|
||||||
|
@ -951,7 +951,7 @@ func Test_expandAlias(t *testing.T) {
|
||||||
machines: []Machine{},
|
machines: []Machine{},
|
||||||
aclPolicy: ACLPolicy{
|
aclPolicy: ACLPolicy{
|
||||||
Hosts: Hosts{
|
Hosts: Hosts{
|
||||||
"homeNetwork": netaddr.MustParseIPPrefix("192.168.1.0/24"),
|
"homeNetwork": netip.MustParsePrefix("192.168.1.0/24"),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
stripEmailDomain: true,
|
stripEmailDomain: true,
|
||||||
|
@ -988,7 +988,7 @@ func Test_expandAlias(t *testing.T) {
|
||||||
machines: []Machine{
|
machines: []Machine{
|
||||||
{
|
{
|
||||||
IPAddresses: MachineAddresses{
|
IPAddresses: MachineAddresses{
|
||||||
netaddr.MustParseIP("100.64.0.1"),
|
netip.MustParseAddr("100.64.0.1"),
|
||||||
},
|
},
|
||||||
Namespace: Namespace{Name: "joe"},
|
Namespace: Namespace{Name: "joe"},
|
||||||
HostInfo: HostInfo{
|
HostInfo: HostInfo{
|
||||||
|
@ -999,7 +999,7 @@ func Test_expandAlias(t *testing.T) {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
IPAddresses: MachineAddresses{
|
IPAddresses: MachineAddresses{
|
||||||
netaddr.MustParseIP("100.64.0.2"),
|
netip.MustParseAddr("100.64.0.2"),
|
||||||
},
|
},
|
||||||
Namespace: Namespace{Name: "joe"},
|
Namespace: Namespace{Name: "joe"},
|
||||||
HostInfo: HostInfo{
|
HostInfo: HostInfo{
|
||||||
|
@ -1010,13 +1010,13 @@ func Test_expandAlias(t *testing.T) {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
IPAddresses: MachineAddresses{
|
IPAddresses: MachineAddresses{
|
||||||
netaddr.MustParseIP("100.64.0.3"),
|
netip.MustParseAddr("100.64.0.3"),
|
||||||
},
|
},
|
||||||
Namespace: Namespace{Name: "marc"},
|
Namespace: Namespace{Name: "marc"},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
IPAddresses: MachineAddresses{
|
IPAddresses: MachineAddresses{
|
||||||
netaddr.MustParseIP("100.64.0.4"),
|
netip.MustParseAddr("100.64.0.4"),
|
||||||
},
|
},
|
||||||
Namespace: Namespace{Name: "joe"},
|
Namespace: Namespace{Name: "joe"},
|
||||||
},
|
},
|
||||||
|
@ -1036,25 +1036,25 @@ func Test_expandAlias(t *testing.T) {
|
||||||
machines: []Machine{
|
machines: []Machine{
|
||||||
{
|
{
|
||||||
IPAddresses: MachineAddresses{
|
IPAddresses: MachineAddresses{
|
||||||
netaddr.MustParseIP("100.64.0.1"),
|
netip.MustParseAddr("100.64.0.1"),
|
||||||
},
|
},
|
||||||
Namespace: Namespace{Name: "joe"},
|
Namespace: Namespace{Name: "joe"},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
IPAddresses: MachineAddresses{
|
IPAddresses: MachineAddresses{
|
||||||
netaddr.MustParseIP("100.64.0.2"),
|
netip.MustParseAddr("100.64.0.2"),
|
||||||
},
|
},
|
||||||
Namespace: Namespace{Name: "joe"},
|
Namespace: Namespace{Name: "joe"},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
IPAddresses: MachineAddresses{
|
IPAddresses: MachineAddresses{
|
||||||
netaddr.MustParseIP("100.64.0.3"),
|
netip.MustParseAddr("100.64.0.3"),
|
||||||
},
|
},
|
||||||
Namespace: Namespace{Name: "marc"},
|
Namespace: Namespace{Name: "marc"},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
IPAddresses: MachineAddresses{
|
IPAddresses: MachineAddresses{
|
||||||
netaddr.MustParseIP("100.64.0.4"),
|
netip.MustParseAddr("100.64.0.4"),
|
||||||
},
|
},
|
||||||
Namespace: Namespace{Name: "mickael"},
|
Namespace: Namespace{Name: "mickael"},
|
||||||
},
|
},
|
||||||
|
@ -1077,27 +1077,27 @@ func Test_expandAlias(t *testing.T) {
|
||||||
machines: []Machine{
|
machines: []Machine{
|
||||||
{
|
{
|
||||||
IPAddresses: MachineAddresses{
|
IPAddresses: MachineAddresses{
|
||||||
netaddr.MustParseIP("100.64.0.1"),
|
netip.MustParseAddr("100.64.0.1"),
|
||||||
},
|
},
|
||||||
Namespace: Namespace{Name: "joe"},
|
Namespace: Namespace{Name: "joe"},
|
||||||
ForcedTags: []string{"tag:hr-webserver"},
|
ForcedTags: []string{"tag:hr-webserver"},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
IPAddresses: MachineAddresses{
|
IPAddresses: MachineAddresses{
|
||||||
netaddr.MustParseIP("100.64.0.2"),
|
netip.MustParseAddr("100.64.0.2"),
|
||||||
},
|
},
|
||||||
Namespace: Namespace{Name: "joe"},
|
Namespace: Namespace{Name: "joe"},
|
||||||
ForcedTags: []string{"tag:hr-webserver"},
|
ForcedTags: []string{"tag:hr-webserver"},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
IPAddresses: MachineAddresses{
|
IPAddresses: MachineAddresses{
|
||||||
netaddr.MustParseIP("100.64.0.3"),
|
netip.MustParseAddr("100.64.0.3"),
|
||||||
},
|
},
|
||||||
Namespace: Namespace{Name: "marc"},
|
Namespace: Namespace{Name: "marc"},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
IPAddresses: MachineAddresses{
|
IPAddresses: MachineAddresses{
|
||||||
netaddr.MustParseIP("100.64.0.4"),
|
netip.MustParseAddr("100.64.0.4"),
|
||||||
},
|
},
|
||||||
Namespace: Namespace{Name: "mickael"},
|
Namespace: Namespace{Name: "mickael"},
|
||||||
},
|
},
|
||||||
|
@ -1115,14 +1115,14 @@ func Test_expandAlias(t *testing.T) {
|
||||||
machines: []Machine{
|
machines: []Machine{
|
||||||
{
|
{
|
||||||
IPAddresses: MachineAddresses{
|
IPAddresses: MachineAddresses{
|
||||||
netaddr.MustParseIP("100.64.0.1"),
|
netip.MustParseAddr("100.64.0.1"),
|
||||||
},
|
},
|
||||||
Namespace: Namespace{Name: "joe"},
|
Namespace: Namespace{Name: "joe"},
|
||||||
ForcedTags: []string{"tag:hr-webserver"},
|
ForcedTags: []string{"tag:hr-webserver"},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
IPAddresses: MachineAddresses{
|
IPAddresses: MachineAddresses{
|
||||||
netaddr.MustParseIP("100.64.0.2"),
|
netip.MustParseAddr("100.64.0.2"),
|
||||||
},
|
},
|
||||||
Namespace: Namespace{Name: "joe"},
|
Namespace: Namespace{Name: "joe"},
|
||||||
HostInfo: HostInfo{
|
HostInfo: HostInfo{
|
||||||
|
@ -1133,13 +1133,13 @@ func Test_expandAlias(t *testing.T) {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
IPAddresses: MachineAddresses{
|
IPAddresses: MachineAddresses{
|
||||||
netaddr.MustParseIP("100.64.0.3"),
|
netip.MustParseAddr("100.64.0.3"),
|
||||||
},
|
},
|
||||||
Namespace: Namespace{Name: "marc"},
|
Namespace: Namespace{Name: "marc"},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
IPAddresses: MachineAddresses{
|
IPAddresses: MachineAddresses{
|
||||||
netaddr.MustParseIP("100.64.0.4"),
|
netip.MustParseAddr("100.64.0.4"),
|
||||||
},
|
},
|
||||||
Namespace: Namespace{Name: "mickael"},
|
Namespace: Namespace{Name: "mickael"},
|
||||||
},
|
},
|
||||||
|
@ -1161,7 +1161,7 @@ func Test_expandAlias(t *testing.T) {
|
||||||
machines: []Machine{
|
machines: []Machine{
|
||||||
{
|
{
|
||||||
IPAddresses: MachineAddresses{
|
IPAddresses: MachineAddresses{
|
||||||
netaddr.MustParseIP("100.64.0.1"),
|
netip.MustParseAddr("100.64.0.1"),
|
||||||
},
|
},
|
||||||
Namespace: Namespace{Name: "joe"},
|
Namespace: Namespace{Name: "joe"},
|
||||||
HostInfo: HostInfo{
|
HostInfo: HostInfo{
|
||||||
|
@ -1172,7 +1172,7 @@ func Test_expandAlias(t *testing.T) {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
IPAddresses: MachineAddresses{
|
IPAddresses: MachineAddresses{
|
||||||
netaddr.MustParseIP("100.64.0.2"),
|
netip.MustParseAddr("100.64.0.2"),
|
||||||
},
|
},
|
||||||
Namespace: Namespace{Name: "joe"},
|
Namespace: Namespace{Name: "joe"},
|
||||||
HostInfo: HostInfo{
|
HostInfo: HostInfo{
|
||||||
|
@ -1183,13 +1183,13 @@ func Test_expandAlias(t *testing.T) {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
IPAddresses: MachineAddresses{
|
IPAddresses: MachineAddresses{
|
||||||
netaddr.MustParseIP("100.64.0.3"),
|
netip.MustParseAddr("100.64.0.3"),
|
||||||
},
|
},
|
||||||
Namespace: Namespace{Name: "marc"},
|
Namespace: Namespace{Name: "marc"},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
IPAddresses: MachineAddresses{
|
IPAddresses: MachineAddresses{
|
||||||
netaddr.MustParseIP("100.64.0.4"),
|
netip.MustParseAddr("100.64.0.4"),
|
||||||
},
|
},
|
||||||
Namespace: Namespace{Name: "joe"},
|
Namespace: Namespace{Name: "joe"},
|
||||||
},
|
},
|
||||||
|
@ -1245,7 +1245,7 @@ func Test_excludeCorrectlyTaggedNodes(t *testing.T) {
|
||||||
nodes: []Machine{
|
nodes: []Machine{
|
||||||
{
|
{
|
||||||
IPAddresses: MachineAddresses{
|
IPAddresses: MachineAddresses{
|
||||||
netaddr.MustParseIP("100.64.0.1"),
|
netip.MustParseAddr("100.64.0.1"),
|
||||||
},
|
},
|
||||||
Namespace: Namespace{Name: "joe"},
|
Namespace: Namespace{Name: "joe"},
|
||||||
HostInfo: HostInfo{
|
HostInfo: HostInfo{
|
||||||
|
@ -1256,7 +1256,7 @@ func Test_excludeCorrectlyTaggedNodes(t *testing.T) {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
IPAddresses: MachineAddresses{
|
IPAddresses: MachineAddresses{
|
||||||
netaddr.MustParseIP("100.64.0.2"),
|
netip.MustParseAddr("100.64.0.2"),
|
||||||
},
|
},
|
||||||
Namespace: Namespace{Name: "joe"},
|
Namespace: Namespace{Name: "joe"},
|
||||||
HostInfo: HostInfo{
|
HostInfo: HostInfo{
|
||||||
|
@ -1267,7 +1267,7 @@ func Test_excludeCorrectlyTaggedNodes(t *testing.T) {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
IPAddresses: MachineAddresses{
|
IPAddresses: MachineAddresses{
|
||||||
netaddr.MustParseIP("100.64.0.4"),
|
netip.MustParseAddr("100.64.0.4"),
|
||||||
},
|
},
|
||||||
Namespace: Namespace{Name: "joe"},
|
Namespace: Namespace{Name: "joe"},
|
||||||
},
|
},
|
||||||
|
@ -1277,7 +1277,7 @@ func Test_excludeCorrectlyTaggedNodes(t *testing.T) {
|
||||||
},
|
},
|
||||||
want: []Machine{
|
want: []Machine{
|
||||||
{
|
{
|
||||||
IPAddresses: MachineAddresses{netaddr.MustParseIP("100.64.0.4")},
|
IPAddresses: MachineAddresses{netip.MustParseAddr("100.64.0.4")},
|
||||||
Namespace: Namespace{Name: "joe"},
|
Namespace: Namespace{Name: "joe"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -1296,7 +1296,7 @@ func Test_excludeCorrectlyTaggedNodes(t *testing.T) {
|
||||||
nodes: []Machine{
|
nodes: []Machine{
|
||||||
{
|
{
|
||||||
IPAddresses: MachineAddresses{
|
IPAddresses: MachineAddresses{
|
||||||
netaddr.MustParseIP("100.64.0.1"),
|
netip.MustParseAddr("100.64.0.1"),
|
||||||
},
|
},
|
||||||
Namespace: Namespace{Name: "joe"},
|
Namespace: Namespace{Name: "joe"},
|
||||||
HostInfo: HostInfo{
|
HostInfo: HostInfo{
|
||||||
|
@ -1307,7 +1307,7 @@ func Test_excludeCorrectlyTaggedNodes(t *testing.T) {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
IPAddresses: MachineAddresses{
|
IPAddresses: MachineAddresses{
|
||||||
netaddr.MustParseIP("100.64.0.2"),
|
netip.MustParseAddr("100.64.0.2"),
|
||||||
},
|
},
|
||||||
Namespace: Namespace{Name: "joe"},
|
Namespace: Namespace{Name: "joe"},
|
||||||
HostInfo: HostInfo{
|
HostInfo: HostInfo{
|
||||||
|
@ -1318,7 +1318,7 @@ func Test_excludeCorrectlyTaggedNodes(t *testing.T) {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
IPAddresses: MachineAddresses{
|
IPAddresses: MachineAddresses{
|
||||||
netaddr.MustParseIP("100.64.0.4"),
|
netip.MustParseAddr("100.64.0.4"),
|
||||||
},
|
},
|
||||||
Namespace: Namespace{Name: "joe"},
|
Namespace: Namespace{Name: "joe"},
|
||||||
},
|
},
|
||||||
|
@ -1328,7 +1328,7 @@ func Test_excludeCorrectlyTaggedNodes(t *testing.T) {
|
||||||
},
|
},
|
||||||
want: []Machine{
|
want: []Machine{
|
||||||
{
|
{
|
||||||
IPAddresses: MachineAddresses{netaddr.MustParseIP("100.64.0.4")},
|
IPAddresses: MachineAddresses{netip.MustParseAddr("100.64.0.4")},
|
||||||
Namespace: Namespace{Name: "joe"},
|
Namespace: Namespace{Name: "joe"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -1342,7 +1342,7 @@ func Test_excludeCorrectlyTaggedNodes(t *testing.T) {
|
||||||
nodes: []Machine{
|
nodes: []Machine{
|
||||||
{
|
{
|
||||||
IPAddresses: MachineAddresses{
|
IPAddresses: MachineAddresses{
|
||||||
netaddr.MustParseIP("100.64.0.1"),
|
netip.MustParseAddr("100.64.0.1"),
|
||||||
},
|
},
|
||||||
Namespace: Namespace{Name: "joe"},
|
Namespace: Namespace{Name: "joe"},
|
||||||
HostInfo: HostInfo{
|
HostInfo: HostInfo{
|
||||||
|
@ -1353,14 +1353,14 @@ func Test_excludeCorrectlyTaggedNodes(t *testing.T) {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
IPAddresses: MachineAddresses{
|
IPAddresses: MachineAddresses{
|
||||||
netaddr.MustParseIP("100.64.0.2"),
|
netip.MustParseAddr("100.64.0.2"),
|
||||||
},
|
},
|
||||||
Namespace: Namespace{Name: "joe"},
|
Namespace: Namespace{Name: "joe"},
|
||||||
ForcedTags: []string{"tag:accountant-webserver"},
|
ForcedTags: []string{"tag:accountant-webserver"},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
IPAddresses: MachineAddresses{
|
IPAddresses: MachineAddresses{
|
||||||
netaddr.MustParseIP("100.64.0.4"),
|
netip.MustParseAddr("100.64.0.4"),
|
||||||
},
|
},
|
||||||
Namespace: Namespace{Name: "joe"},
|
Namespace: Namespace{Name: "joe"},
|
||||||
},
|
},
|
||||||
|
@ -1370,7 +1370,7 @@ func Test_excludeCorrectlyTaggedNodes(t *testing.T) {
|
||||||
},
|
},
|
||||||
want: []Machine{
|
want: []Machine{
|
||||||
{
|
{
|
||||||
IPAddresses: MachineAddresses{netaddr.MustParseIP("100.64.0.4")},
|
IPAddresses: MachineAddresses{netip.MustParseAddr("100.64.0.4")},
|
||||||
Namespace: Namespace{Name: "joe"},
|
Namespace: Namespace{Name: "joe"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -1384,7 +1384,7 @@ func Test_excludeCorrectlyTaggedNodes(t *testing.T) {
|
||||||
nodes: []Machine{
|
nodes: []Machine{
|
||||||
{
|
{
|
||||||
IPAddresses: MachineAddresses{
|
IPAddresses: MachineAddresses{
|
||||||
netaddr.MustParseIP("100.64.0.1"),
|
netip.MustParseAddr("100.64.0.1"),
|
||||||
},
|
},
|
||||||
Namespace: Namespace{Name: "joe"},
|
Namespace: Namespace{Name: "joe"},
|
||||||
HostInfo: HostInfo{
|
HostInfo: HostInfo{
|
||||||
|
@ -1395,7 +1395,7 @@ func Test_excludeCorrectlyTaggedNodes(t *testing.T) {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
IPAddresses: MachineAddresses{
|
IPAddresses: MachineAddresses{
|
||||||
netaddr.MustParseIP("100.64.0.2"),
|
netip.MustParseAddr("100.64.0.2"),
|
||||||
},
|
},
|
||||||
Namespace: Namespace{Name: "joe"},
|
Namespace: Namespace{Name: "joe"},
|
||||||
HostInfo: HostInfo{
|
HostInfo: HostInfo{
|
||||||
|
@ -1406,7 +1406,7 @@ func Test_excludeCorrectlyTaggedNodes(t *testing.T) {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
IPAddresses: MachineAddresses{
|
IPAddresses: MachineAddresses{
|
||||||
netaddr.MustParseIP("100.64.0.4"),
|
netip.MustParseAddr("100.64.0.4"),
|
||||||
},
|
},
|
||||||
Namespace: Namespace{Name: "joe"},
|
Namespace: Namespace{Name: "joe"},
|
||||||
},
|
},
|
||||||
|
@ -1417,7 +1417,7 @@ func Test_excludeCorrectlyTaggedNodes(t *testing.T) {
|
||||||
want: []Machine{
|
want: []Machine{
|
||||||
{
|
{
|
||||||
IPAddresses: MachineAddresses{
|
IPAddresses: MachineAddresses{
|
||||||
netaddr.MustParseIP("100.64.0.1"),
|
netip.MustParseAddr("100.64.0.1"),
|
||||||
},
|
},
|
||||||
Namespace: Namespace{Name: "joe"},
|
Namespace: Namespace{Name: "joe"},
|
||||||
HostInfo: HostInfo{
|
HostInfo: HostInfo{
|
||||||
|
@ -1428,7 +1428,7 @@ func Test_excludeCorrectlyTaggedNodes(t *testing.T) {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
IPAddresses: MachineAddresses{
|
IPAddresses: MachineAddresses{
|
||||||
netaddr.MustParseIP("100.64.0.2"),
|
netip.MustParseAddr("100.64.0.2"),
|
||||||
},
|
},
|
||||||
Namespace: Namespace{Name: "joe"},
|
Namespace: Namespace{Name: "joe"},
|
||||||
HostInfo: HostInfo{
|
HostInfo: HostInfo{
|
||||||
|
@ -1439,7 +1439,7 @@ func Test_excludeCorrectlyTaggedNodes(t *testing.T) {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
IPAddresses: MachineAddresses{
|
IPAddresses: MachineAddresses{
|
||||||
netaddr.MustParseIP("100.64.0.4"),
|
netip.MustParseAddr("100.64.0.4"),
|
||||||
},
|
},
|
||||||
Namespace: Namespace{Name: "joe"},
|
Namespace: Namespace{Name: "joe"},
|
||||||
},
|
},
|
||||||
|
|
|
@ -2,11 +2,11 @@ package headscale
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"net/netip"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/tailscale/hujson"
|
"github.com/tailscale/hujson"
|
||||||
"gopkg.in/yaml.v3"
|
"gopkg.in/yaml.v3"
|
||||||
"inet.af/netaddr"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// ACLPolicy represents a Tailscale ACL Policy.
|
// ACLPolicy represents a Tailscale ACL Policy.
|
||||||
|
@ -30,7 +30,7 @@ type ACL struct {
|
||||||
type Groups map[string][]string
|
type Groups map[string][]string
|
||||||
|
|
||||||
// Hosts are alias for IP addresses or subnets.
|
// Hosts are alias for IP addresses or subnets.
|
||||||
type Hosts map[string]netaddr.IPPrefix
|
type Hosts map[string]netip.Prefix
|
||||||
|
|
||||||
// TagOwners specify what users (namespaces?) are allow to use certain tags.
|
// TagOwners specify what users (namespaces?) are allow to use certain tags.
|
||||||
type TagOwners map[string][]string
|
type TagOwners map[string][]string
|
||||||
|
@ -60,7 +60,7 @@ func (hosts *Hosts) UnmarshalJSON(data []byte) error {
|
||||||
if !strings.Contains(prefixStr, "/") {
|
if !strings.Contains(prefixStr, "/") {
|
||||||
prefixStr += "/32"
|
prefixStr += "/32"
|
||||||
}
|
}
|
||||||
prefix, err := netaddr.ParseIPPrefix(prefixStr)
|
prefix, err := netip.ParsePrefix(prefixStr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -81,7 +81,7 @@ func (hosts *Hosts) UnmarshalYAML(data []byte) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
for host, prefixStr := range hostIPPrefixMap {
|
for host, prefixStr := range hostIPPrefixMap {
|
||||||
prefix, err := netaddr.ParseIPPrefix(prefixStr)
|
prefix, err := netip.ParsePrefix(prefixStr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue