Signed-off-by: Kristoffer Dalby <kristoffer@tailscale.com>
This commit is contained in:
Kristoffer Dalby 2023-07-26 11:53:42 +02:00 committed by Kristoffer Dalby
parent e55fe0671a
commit 13a7285658
8 changed files with 118 additions and 114 deletions

View file

@ -51,7 +51,7 @@ func initConfig() {
cfg, err := types.GetHeadscaleConfig()
if err != nil {
log.Fatal().Caller().Err(err)
log.Fatal().Caller().Err(err).Msg("Failed to get headscale configuration")
}
machineOutput := HasMachineOutputFlag()

View file

@ -154,17 +154,17 @@ func SuccessOutput(result interface{}, override string, outputFormat string) {
case "json":
jsonBytes, err = json.MarshalIndent(result, "", "\t")
if err != nil {
log.Fatal().Err(err)
log.Fatal().Err(err).Msg("failed to unmarshal output")
}
case "json-line":
jsonBytes, err = json.Marshal(result)
if err != nil {
log.Fatal().Err(err)
log.Fatal().Err(err).Msg("failed to unmarshal output")
}
case "yaml":
jsonBytes, err = yaml.Marshal(result)
if err != nil {
log.Fatal().Err(err)
log.Fatal().Err(err).Msg("failed to unmarshal output")
}
default:
//nolint

View file

@ -86,7 +86,8 @@ func (h *Headscale) handleRegister(
Caller().
Str("func", "RegistrationHandler").
Str("hostinfo.name", registerRequest.Hostinfo.Hostname).
Err(err)
Err(err).
Msg("Failed to generate given name for node")
return
}
@ -348,7 +349,8 @@ func (h *Headscale) handleAuthKey(
Bool("noise", isNoise).
Str("func", "RegistrationHandler").
Str("hostinfo.name", registerRequest.Hostinfo.Hostname).
Err(err)
Err(err).
Msg("Failed to generate given name for node")
return
}

View file

@ -241,14 +241,14 @@ func (hsdb *HSDatabase) getPrimaryRoute(prefix netip.Prefix) (*types.Route, erro
// getMachinePrimaryRoutes returns the routes that are enabled and marked as primary (for subnet failover)
// Exit nodes are not considered for this, as they are never marked as Primary.
func (hsdb *HSDatabase) GetMachinePrimaryRoutes(m *types.Machine) (types.Routes, error) {
func (hsdb *HSDatabase) GetMachinePrimaryRoutes(machine *types.Machine) (types.Routes, error) {
hsdb.mu.RLock()
defer hsdb.mu.RUnlock()
var routes types.Routes
err := hsdb.db.
Preload("Machine").
Where("machine_id = ? AND advertised = ? AND enabled = ? AND is_primary = ?", m.ID, true, true, true).
Where("machine_id = ? AND advertised = ? AND enabled = ? AND is_primary = ?", machine.ID, true, true, true).
Find(&routes).Error
if err != nil {
return nil, err

View file

@ -39,7 +39,7 @@ func NewDERPServer(
cfg *types.DERPConfig,
) (*DERPServer, error) {
log.Trace().Caller().Msg("Creating new embedded DERP server")
server := derp.NewServer(derpKey, log.Debug().Msgf)
server := derp.NewServer(derpKey, log.Debug().Msgf) // nolint // zerolinter complains
return &DERPServer{
serverURL: serverURL,

View file

@ -32,6 +32,8 @@ import (
const (
nextDNSDoHPrefix = "https://dns.nextdns.io"
reservedResponseHeaderSize = 4
mapperIDLength = 8
debugMapResponsePerm = 0o755
)
var debugDumpMapResponsePath = envknob.String("HEADSCALE_DEBUG_DUMP_MAPRESPONSE_PATH")
@ -72,7 +74,7 @@ func NewMapper(
Str("machine", machine.Hostname).
Msg("creating new mapper")
uid, _ := util.GenerateRandomStringDNSSafe(8)
uid, _ := util.GenerateRandomStringDNSSafe(mapperIDLength)
return &Mapper{
db: db,
@ -579,7 +581,7 @@ var zstdEncoderPool = &sync.Pool{
},
}
func (m *Mapper) baseMapResponse(machine *types.Machine) tailcfg.MapResponse {
func (m *Mapper) baseMapResponse(_ *types.Machine) tailcfg.MapResponse {
now := time.Now()
resp := tailcfg.MapResponse{

View file

@ -909,38 +909,38 @@ func Test_listMachinesInUser(t *testing.T) {
name: "1 machine in user",
args: args{
machines: types.Machines{
{User: types.User{Name: "joe"}},
types.Machine{User: types.User{Name: "joe"}},
},
user: "joe",
},
want: types.Machines{
{User: types.User{Name: "joe"}},
types.Machine{User: types.User{Name: "joe"}},
},
},
{
name: "3 machines, 2 in user",
args: args{
machines: types.Machines{
{ID: 1, User: types.User{Name: "joe"}},
{ID: 2, User: types.User{Name: "marc"}},
{ID: 3, User: types.User{Name: "marc"}},
types.Machine{ID: 1, User: types.User{Name: "joe"}},
types.Machine{ID: 2, User: types.User{Name: "marc"}},
types.Machine{ID: 3, User: types.User{Name: "marc"}},
},
user: "marc",
},
want: types.Machines{
{ID: 2, User: types.User{Name: "marc"}},
{ID: 3, User: types.User{Name: "marc"}},
types.Machine{ID: 2, User: types.User{Name: "marc"}},
types.Machine{ID: 3, User: types.User{Name: "marc"}},
},
},
{
name: "5 machines, 0 in user",
args: args{
machines: types.Machines{
{ID: 1, User: types.User{Name: "joe"}},
{ID: 2, User: types.User{Name: "marc"}},
{ID: 3, User: types.User{Name: "marc"}},
{ID: 4, User: types.User{Name: "marc"}},
{ID: 5, User: types.User{Name: "marc"}},
types.Machine{ID: 1, User: types.User{Name: "joe"}},
types.Machine{ID: 2, User: types.User{Name: "marc"}},
types.Machine{ID: 3, User: types.User{Name: "marc"}},
types.Machine{ID: 4, User: types.User{Name: "marc"}},
types.Machine{ID: 5, User: types.User{Name: "marc"}},
},
user: "mickael",
},
@ -998,8 +998,10 @@ func Test_expandAlias(t *testing.T) {
args: args{
alias: "*",
machines: types.Machines{
{IPAddresses: types.MachineAddresses{netip.MustParseAddr("100.64.0.1")}},
{
types.Machine{
IPAddresses: types.MachineAddresses{netip.MustParseAddr("100.64.0.1")},
},
types.Machine{
IPAddresses: types.MachineAddresses{
netip.MustParseAddr("100.78.84.227"),
},
@ -1022,25 +1024,25 @@ func Test_expandAlias(t *testing.T) {
args: args{
alias: "group:accountant",
machines: types.Machines{
{
types.Machine{
IPAddresses: types.MachineAddresses{
netip.MustParseAddr("100.64.0.1"),
},
User: types.User{Name: "joe"},
},
{
types.Machine{
IPAddresses: types.MachineAddresses{
netip.MustParseAddr("100.64.0.2"),
},
User: types.User{Name: "joe"},
},
{
types.Machine{
IPAddresses: types.MachineAddresses{
netip.MustParseAddr("100.64.0.3"),
},
User: types.User{Name: "marc"},
},
{
types.Machine{
IPAddresses: types.MachineAddresses{
netip.MustParseAddr("100.64.0.4"),
},
@ -1063,25 +1065,25 @@ func Test_expandAlias(t *testing.T) {
args: args{
alias: "group:hr",
machines: types.Machines{
{
types.Machine{
IPAddresses: types.MachineAddresses{
netip.MustParseAddr("100.64.0.1"),
},
User: types.User{Name: "joe"},
},
{
types.Machine{
IPAddresses: types.MachineAddresses{
netip.MustParseAddr("100.64.0.2"),
},
User: types.User{Name: "joe"},
},
{
types.Machine{
IPAddresses: types.MachineAddresses{
netip.MustParseAddr("100.64.0.3"),
},
User: types.User{Name: "marc"},
},
{
types.Machine{
IPAddresses: types.MachineAddresses{
netip.MustParseAddr("100.64.0.4"),
},
@ -1128,7 +1130,7 @@ func Test_expandAlias(t *testing.T) {
args: args{
alias: "10.0.0.1",
machines: types.Machines{
{
types.Machine{
IPAddresses: types.MachineAddresses{
netip.MustParseAddr("10.0.0.1"),
},
@ -1149,7 +1151,7 @@ func Test_expandAlias(t *testing.T) {
args: args{
alias: "10.0.0.1",
machines: types.Machines{
{
types.Machine{
IPAddresses: types.MachineAddresses{
netip.MustParseAddr("10.0.0.1"),
netip.MustParseAddr("fd7a:115c:a1e0:ab12:4843:2222:6273:2222"),
@ -1171,7 +1173,7 @@ func Test_expandAlias(t *testing.T) {
args: args{
alias: "fd7a:115c:a1e0:ab12:4843:2222:6273:2222",
machines: types.Machines{
{
types.Machine{
IPAddresses: types.MachineAddresses{
netip.MustParseAddr("10.0.0.1"),
netip.MustParseAddr("fd7a:115c:a1e0:ab12:4843:2222:6273:2222"),
@ -1240,7 +1242,7 @@ func Test_expandAlias(t *testing.T) {
args: args{
alias: "tag:hr-webserver",
machines: types.Machines{
{
types.Machine{
IPAddresses: types.MachineAddresses{
netip.MustParseAddr("100.64.0.1"),
},
@ -1251,7 +1253,7 @@ func Test_expandAlias(t *testing.T) {
RequestTags: []string{"tag:hr-webserver"},
},
},
{
types.Machine{
IPAddresses: types.MachineAddresses{
netip.MustParseAddr("100.64.0.2"),
},
@ -1262,13 +1264,13 @@ func Test_expandAlias(t *testing.T) {
RequestTags: []string{"tag:hr-webserver"},
},
},
{
types.Machine{
IPAddresses: types.MachineAddresses{
netip.MustParseAddr("100.64.0.3"),
},
User: types.User{Name: "marc"},
},
{
types.Machine{
IPAddresses: types.MachineAddresses{
netip.MustParseAddr("100.64.0.4"),
},
@ -1294,25 +1296,25 @@ func Test_expandAlias(t *testing.T) {
args: args{
alias: "tag:hr-webserver",
machines: types.Machines{
{
types.Machine{
IPAddresses: types.MachineAddresses{
netip.MustParseAddr("100.64.0.1"),
},
User: types.User{Name: "joe"},
},
{
types.Machine{
IPAddresses: types.MachineAddresses{
netip.MustParseAddr("100.64.0.2"),
},
User: types.User{Name: "joe"},
},
{
types.Machine{
IPAddresses: types.MachineAddresses{
netip.MustParseAddr("100.64.0.3"),
},
User: types.User{Name: "marc"},
},
{
types.Machine{
IPAddresses: types.MachineAddresses{
netip.MustParseAddr("100.64.0.4"),
},
@ -1331,27 +1333,27 @@ func Test_expandAlias(t *testing.T) {
args: args{
alias: "tag:hr-webserver",
machines: types.Machines{
{
types.Machine{
IPAddresses: types.MachineAddresses{
netip.MustParseAddr("100.64.0.1"),
},
User: types.User{Name: "joe"},
ForcedTags: []string{"tag:hr-webserver"},
},
{
types.Machine{
IPAddresses: types.MachineAddresses{
netip.MustParseAddr("100.64.0.2"),
},
User: types.User{Name: "joe"},
ForcedTags: []string{"tag:hr-webserver"},
},
{
types.Machine{
IPAddresses: types.MachineAddresses{
netip.MustParseAddr("100.64.0.3"),
},
User: types.User{Name: "marc"},
},
{
types.Machine{
IPAddresses: types.MachineAddresses{
netip.MustParseAddr("100.64.0.4"),
},
@ -1374,14 +1376,14 @@ func Test_expandAlias(t *testing.T) {
args: args{
alias: "tag:hr-webserver",
machines: types.Machines{
{
types.Machine{
IPAddresses: types.MachineAddresses{
netip.MustParseAddr("100.64.0.1"),
},
User: types.User{Name: "joe"},
ForcedTags: []string{"tag:hr-webserver"},
},
{
types.Machine{
IPAddresses: types.MachineAddresses{
netip.MustParseAddr("100.64.0.2"),
},
@ -1392,13 +1394,13 @@ func Test_expandAlias(t *testing.T) {
RequestTags: []string{"tag:hr-webserver"},
},
},
{
types.Machine{
IPAddresses: types.MachineAddresses{
netip.MustParseAddr("100.64.0.3"),
},
User: types.User{Name: "marc"},
},
{
types.Machine{
IPAddresses: types.MachineAddresses{
netip.MustParseAddr("100.64.0.4"),
},
@ -1419,7 +1421,7 @@ func Test_expandAlias(t *testing.T) {
args: args{
alias: "joe",
machines: types.Machines{
{
types.Machine{
IPAddresses: types.MachineAddresses{
netip.MustParseAddr("100.64.0.1"),
},
@ -1430,7 +1432,7 @@ func Test_expandAlias(t *testing.T) {
RequestTags: []string{"tag:accountant-webserver"},
},
},
{
types.Machine{
IPAddresses: types.MachineAddresses{
netip.MustParseAddr("100.64.0.2"),
},
@ -1441,13 +1443,13 @@ func Test_expandAlias(t *testing.T) {
RequestTags: []string{"tag:accountant-webserver"},
},
},
{
types.Machine{
IPAddresses: types.MachineAddresses{
netip.MustParseAddr("100.64.0.3"),
},
User: types.User{Name: "marc"},
},
{
types.Machine{
IPAddresses: types.MachineAddresses{
netip.MustParseAddr("100.64.0.4"),
},
@ -1496,7 +1498,7 @@ func Test_excludeCorrectlyTaggedNodes(t *testing.T) {
TagOwners: TagOwners{"tag:accountant-webserver": []string{"joe"}},
},
nodes: types.Machines{
{
types.Machine{
IPAddresses: types.MachineAddresses{
netip.MustParseAddr("100.64.0.1"),
},
@ -1507,7 +1509,7 @@ func Test_excludeCorrectlyTaggedNodes(t *testing.T) {
RequestTags: []string{"tag:accountant-webserver"},
},
},
{
types.Machine{
IPAddresses: types.MachineAddresses{
netip.MustParseAddr("100.64.0.2"),
},
@ -1518,7 +1520,7 @@ func Test_excludeCorrectlyTaggedNodes(t *testing.T) {
RequestTags: []string{"tag:accountant-webserver"},
},
},
{
types.Machine{
IPAddresses: types.MachineAddresses{
netip.MustParseAddr("100.64.0.4"),
},
@ -1528,7 +1530,7 @@ func Test_excludeCorrectlyTaggedNodes(t *testing.T) {
user: "joe",
},
want: types.Machines{
{
types.Machine{
IPAddresses: types.MachineAddresses{netip.MustParseAddr("100.64.0.4")},
User: types.User{Name: "joe"},
},
@ -1546,7 +1548,7 @@ func Test_excludeCorrectlyTaggedNodes(t *testing.T) {
},
},
nodes: types.Machines{
{
types.Machine{
IPAddresses: types.MachineAddresses{
netip.MustParseAddr("100.64.0.1"),
},
@ -1557,7 +1559,7 @@ func Test_excludeCorrectlyTaggedNodes(t *testing.T) {
RequestTags: []string{"tag:accountant-webserver"},
},
},
{
types.Machine{
IPAddresses: types.MachineAddresses{
netip.MustParseAddr("100.64.0.2"),
},
@ -1568,7 +1570,7 @@ func Test_excludeCorrectlyTaggedNodes(t *testing.T) {
RequestTags: []string{"tag:accountant-webserver"},
},
},
{
types.Machine{
IPAddresses: types.MachineAddresses{
netip.MustParseAddr("100.64.0.4"),
},
@ -1578,7 +1580,7 @@ func Test_excludeCorrectlyTaggedNodes(t *testing.T) {
user: "joe",
},
want: types.Machines{
{
types.Machine{
IPAddresses: types.MachineAddresses{netip.MustParseAddr("100.64.0.4")},
User: types.User{Name: "joe"},
},
@ -1591,7 +1593,7 @@ func Test_excludeCorrectlyTaggedNodes(t *testing.T) {
TagOwners: TagOwners{"tag:accountant-webserver": []string{"joe"}},
},
nodes: types.Machines{
{
types.Machine{
IPAddresses: types.MachineAddresses{
netip.MustParseAddr("100.64.0.1"),
},
@ -1602,14 +1604,14 @@ func Test_excludeCorrectlyTaggedNodes(t *testing.T) {
RequestTags: []string{"tag:accountant-webserver"},
},
},
{
types.Machine{
IPAddresses: types.MachineAddresses{
netip.MustParseAddr("100.64.0.2"),
},
User: types.User{Name: "joe"},
ForcedTags: []string{"tag:accountant-webserver"},
},
{
types.Machine{
IPAddresses: types.MachineAddresses{
netip.MustParseAddr("100.64.0.4"),
},
@ -1619,7 +1621,7 @@ func Test_excludeCorrectlyTaggedNodes(t *testing.T) {
user: "joe",
},
want: types.Machines{
{
types.Machine{
IPAddresses: types.MachineAddresses{netip.MustParseAddr("100.64.0.4")},
User: types.User{Name: "joe"},
},
@ -1632,7 +1634,7 @@ func Test_excludeCorrectlyTaggedNodes(t *testing.T) {
TagOwners: TagOwners{"tag:accountant-webserver": []string{"joe"}},
},
nodes: types.Machines{
{
types.Machine{
IPAddresses: types.MachineAddresses{
netip.MustParseAddr("100.64.0.1"),
},
@ -1643,7 +1645,7 @@ func Test_excludeCorrectlyTaggedNodes(t *testing.T) {
RequestTags: []string{"tag:hr-webserver"},
},
},
{
types.Machine{
IPAddresses: types.MachineAddresses{
netip.MustParseAddr("100.64.0.2"),
},
@ -1654,7 +1656,7 @@ func Test_excludeCorrectlyTaggedNodes(t *testing.T) {
RequestTags: []string{"tag:hr-webserver"},
},
},
{
types.Machine{
IPAddresses: types.MachineAddresses{
netip.MustParseAddr("100.64.0.4"),
},
@ -1664,7 +1666,7 @@ func Test_excludeCorrectlyTaggedNodes(t *testing.T) {
user: "joe",
},
want: types.Machines{
{
types.Machine{
IPAddresses: types.MachineAddresses{
netip.MustParseAddr("100.64.0.1"),
},
@ -1675,7 +1677,7 @@ func Test_excludeCorrectlyTaggedNodes(t *testing.T) {
RequestTags: []string{"tag:hr-webserver"},
},
},
{
types.Machine{
IPAddresses: types.MachineAddresses{
netip.MustParseAddr("100.64.0.2"),
},
@ -1686,7 +1688,7 @@ func Test_excludeCorrectlyTaggedNodes(t *testing.T) {
RequestTags: []string{"tag:hr-webserver"},
},
},
{
types.Machine{
IPAddresses: types.MachineAddresses{
netip.MustParseAddr("100.64.0.4"),
},
@ -1798,7 +1800,7 @@ func TestACLPolicy_generateFilterRules(t *testing.T) {
User: types.User{Name: "mickael"},
},
peers: types.Machines{
{
types.Machine{
IPAddresses: types.MachineAddresses{
netip.MustParseAddr("100.64.0.2"),
netip.MustParseAddr("fd7a:115c:a1e0:ab12:4843:2222:6273:2222"),
@ -1881,7 +1883,7 @@ func TestReduceFilterRules(t *testing.T) {
User: types.User{Name: "mickael"},
},
peers: types.Machines{
{
types.Machine{
IPAddresses: types.MachineAddresses{
netip.MustParseAddr("100.64.0.2"),
netip.MustParseAddr("fd7a:115c:a1e0:ab12:4843:2222:6273:2222"),
@ -2072,21 +2074,21 @@ func Test_getFilteredByACLPeers(t *testing.T) {
name: "all hosts can talk to each other",
args: args{
machines: types.Machines{ // list of all machines in the database
{
types.Machine{
ID: 1,
IPAddresses: types.MachineAddresses{
netip.MustParseAddr("100.64.0.1"),
},
User: types.User{Name: "joe"},
},
{
types.Machine{
ID: 2,
IPAddresses: types.MachineAddresses{
netip.MustParseAddr("100.64.0.2"),
},
User: types.User{Name: "marc"},
},
{
types.Machine{
ID: 3,
IPAddresses: types.MachineAddresses{
netip.MustParseAddr("100.64.0.3"),
@ -2109,12 +2111,12 @@ func Test_getFilteredByACLPeers(t *testing.T) {
},
},
want: types.Machines{
{
types.Machine{
ID: 2,
IPAddresses: types.MachineAddresses{netip.MustParseAddr("100.64.0.2")},
User: types.User{Name: "marc"},
},
{
types.Machine{
ID: 3,
IPAddresses: types.MachineAddresses{netip.MustParseAddr("100.64.0.3")},
User: types.User{Name: "mickael"},
@ -2125,21 +2127,21 @@ func Test_getFilteredByACLPeers(t *testing.T) {
name: "One host can talk to another, but not all hosts",
args: args{
machines: types.Machines{ // list of all machines in the database
{
types.Machine{
ID: 1,
IPAddresses: types.MachineAddresses{
netip.MustParseAddr("100.64.0.1"),
},
User: types.User{Name: "joe"},
},
{
types.Machine{
ID: 2,
IPAddresses: types.MachineAddresses{
netip.MustParseAddr("100.64.0.2"),
},
User: types.User{Name: "marc"},
},
{
types.Machine{
ID: 3,
IPAddresses: types.MachineAddresses{
netip.MustParseAddr("100.64.0.3"),
@ -2162,7 +2164,7 @@ func Test_getFilteredByACLPeers(t *testing.T) {
},
},
want: types.Machines{
{
types.Machine{
ID: 2,
IPAddresses: types.MachineAddresses{netip.MustParseAddr("100.64.0.2")},
User: types.User{Name: "marc"},
@ -2173,21 +2175,21 @@ func Test_getFilteredByACLPeers(t *testing.T) {
name: "host cannot directly talk to destination, but return path is authorized",
args: args{
machines: types.Machines{ // list of all machines in the database
{
types.Machine{
ID: 1,
IPAddresses: types.MachineAddresses{
netip.MustParseAddr("100.64.0.1"),
},
User: types.User{Name: "joe"},
},
{
types.Machine{
ID: 2,
IPAddresses: types.MachineAddresses{
netip.MustParseAddr("100.64.0.2"),
},
User: types.User{Name: "marc"},
},
{
types.Machine{
ID: 3,
IPAddresses: types.MachineAddresses{
netip.MustParseAddr("100.64.0.3"),
@ -2210,7 +2212,7 @@ func Test_getFilteredByACLPeers(t *testing.T) {
},
},
want: types.Machines{
{
types.Machine{
ID: 3,
IPAddresses: types.MachineAddresses{netip.MustParseAddr("100.64.0.3")},
User: types.User{Name: "mickael"},
@ -2221,21 +2223,21 @@ func Test_getFilteredByACLPeers(t *testing.T) {
name: "rules allows all hosts to reach one destination",
args: args{
machines: types.Machines{ // list of all machines in the database
{
types.Machine{
ID: 1,
IPAddresses: types.MachineAddresses{
netip.MustParseAddr("100.64.0.1"),
},
User: types.User{Name: "joe"},
},
{
types.Machine{
ID: 2,
IPAddresses: types.MachineAddresses{
netip.MustParseAddr("100.64.0.2"),
},
User: types.User{Name: "marc"},
},
{
types.Machine{
ID: 3,
IPAddresses: types.MachineAddresses{
netip.MustParseAddr("100.64.0.3"),
@ -2260,7 +2262,7 @@ func Test_getFilteredByACLPeers(t *testing.T) {
},
},
want: types.Machines{
{
types.Machine{
ID: 2,
IPAddresses: types.MachineAddresses{
netip.MustParseAddr("100.64.0.2"),
@ -2273,21 +2275,21 @@ func Test_getFilteredByACLPeers(t *testing.T) {
name: "rules allows all hosts to reach one destination, destination can reach all hosts",
args: args{
machines: types.Machines{ // list of all machines in the database
{
types.Machine{
ID: 1,
IPAddresses: types.MachineAddresses{
netip.MustParseAddr("100.64.0.1"),
},
User: types.User{Name: "joe"},
},
{
types.Machine{
ID: 2,
IPAddresses: types.MachineAddresses{
netip.MustParseAddr("100.64.0.2"),
},
User: types.User{Name: "marc"},
},
{
types.Machine{
ID: 3,
IPAddresses: types.MachineAddresses{
netip.MustParseAddr("100.64.0.3"),
@ -2312,14 +2314,14 @@ func Test_getFilteredByACLPeers(t *testing.T) {
},
},
want: types.Machines{
{
types.Machine{
ID: 1,
IPAddresses: types.MachineAddresses{
netip.MustParseAddr("100.64.0.1"),
},
User: types.User{Name: "joe"},
},
{
types.Machine{
ID: 3,
IPAddresses: types.MachineAddresses{
netip.MustParseAddr("100.64.0.3"),
@ -2332,21 +2334,21 @@ func Test_getFilteredByACLPeers(t *testing.T) {
name: "rule allows all hosts to reach all destinations",
args: args{
machines: types.Machines{ // list of all machines in the database
{
types.Machine{
ID: 1,
IPAddresses: types.MachineAddresses{
netip.MustParseAddr("100.64.0.1"),
},
User: types.User{Name: "joe"},
},
{
types.Machine{
ID: 2,
IPAddresses: types.MachineAddresses{
netip.MustParseAddr("100.64.0.2"),
},
User: types.User{Name: "marc"},
},
{
types.Machine{
ID: 3,
IPAddresses: types.MachineAddresses{
netip.MustParseAddr("100.64.0.3"),
@ -2369,14 +2371,14 @@ func Test_getFilteredByACLPeers(t *testing.T) {
},
},
want: types.Machines{
{
types.Machine{
ID: 1,
IPAddresses: types.MachineAddresses{
netip.MustParseAddr("100.64.0.1"),
},
User: types.User{Name: "joe"},
},
{
types.Machine{
ID: 3,
IPAddresses: types.MachineAddresses{netip.MustParseAddr("100.64.0.3")},
User: types.User{Name: "mickael"},
@ -2387,21 +2389,21 @@ func Test_getFilteredByACLPeers(t *testing.T) {
name: "without rule all communications are forbidden",
args: args{
machines: types.Machines{ // list of all machines in the database
{
types.Machine{
ID: 1,
IPAddresses: types.MachineAddresses{
netip.MustParseAddr("100.64.0.1"),
},
User: types.User{Name: "joe"},
},
{
types.Machine{
ID: 2,
IPAddresses: types.MachineAddresses{
netip.MustParseAddr("100.64.0.2"),
},
User: types.User{Name: "marc"},
},
{
types.Machine{
ID: 3,
IPAddresses: types.MachineAddresses{
netip.MustParseAddr("100.64.0.3"),
@ -2427,7 +2429,7 @@ func Test_getFilteredByACLPeers(t *testing.T) {
name: "issue-699-broken-star",
args: args{
machines: types.Machines{ //
{
types.Machine{
ID: 1,
Hostname: "ts-head-upcrmb",
IPAddresses: types.MachineAddresses{
@ -2436,7 +2438,7 @@ func Test_getFilteredByACLPeers(t *testing.T) {
},
User: types.User{Name: "user1"},
},
{
types.Machine{
ID: 2,
Hostname: "ts-unstable-rlwpvr",
IPAddresses: types.MachineAddresses{
@ -2445,7 +2447,7 @@ func Test_getFilteredByACLPeers(t *testing.T) {
},
User: types.User{Name: "user1"},
},
{
types.Machine{
ID: 3,
Hostname: "ts-head-8w6paa",
IPAddresses: types.MachineAddresses{
@ -2454,7 +2456,7 @@ func Test_getFilteredByACLPeers(t *testing.T) {
},
User: types.User{Name: "user2"},
},
{
types.Machine{
ID: 4,
Hostname: "ts-unstable-lys2ib",
IPAddresses: types.MachineAddresses{
@ -2489,7 +2491,7 @@ func Test_getFilteredByACLPeers(t *testing.T) {
},
},
want: types.Machines{
{
types.Machine{
ID: 1,
Hostname: "ts-head-upcrmb",
IPAddresses: types.MachineAddresses{
@ -2498,7 +2500,7 @@ func Test_getFilteredByACLPeers(t *testing.T) {
},
User: types.User{Name: "user1"},
},
{
types.Machine{
ID: 2,
Hostname: "ts-unstable-rlwpvr",
IPAddresses: types.MachineAddresses{

View file

@ -359,8 +359,6 @@ func (h *Headscale) pollNetMapStream(
return
}
}
logInfo("Finishing map stream session")
}
func closeChanWithLog[C chan []byte | chan struct{} | chan types.StateUpdate](channel C, machine, name string) {