mirror of
https://github.com/juanfont/headscale.git
synced 2024-12-25 01:07:52 +00:00
fix(machines): use ListAllMachines function
added a simple filter to remove the current node
This commit is contained in:
parent
960412a335
commit
9c6ce02554
10
machine.go
10
machine.go
@ -154,10 +154,9 @@ func (h *Headscale) getFilteredByACLPeers(machine *Machine) (Machines, error) {
|
|||||||
Str("machine", machine.Name).
|
Str("machine", machine.Name).
|
||||||
Msg("Finding peers filtered by ACLs")
|
Msg("Finding peers filtered by ACLs")
|
||||||
|
|
||||||
machines := Machines{}
|
machines, err := h.ListAllMachines()
|
||||||
if err := h.db.Preload("Namespace").Where("machine_key <> ? AND registered",
|
if err != nil {
|
||||||
machine.MachineKey).Find(&machines).Error; err != nil {
|
log.Error().Err(err).Msg("Error retrieving list of machines")
|
||||||
log.Error().Err(err).Msg("Error accessing db")
|
|
||||||
return Machines{}, err
|
return Machines{}, err
|
||||||
}
|
}
|
||||||
peers := make(map[uint64]Machine)
|
peers := make(map[uint64]Machine)
|
||||||
@ -180,6 +179,9 @@ func (h *Headscale) getFilteredByACLPeers(machine *Machine) (Machines, error) {
|
|||||||
// how to talk to node A and then add the peering resource.
|
// how to talk to node A and then add the peering resource.
|
||||||
|
|
||||||
for _, peer := range machines {
|
for _, peer := range machines {
|
||||||
|
if peer.ID == machine.ID {
|
||||||
|
continue
|
||||||
|
}
|
||||||
for _, rule := range h.aclRules {
|
for _, rule := range h.aclRules {
|
||||||
var dst []string
|
var dst []string
|
||||||
for _, d := range rule.DstPorts {
|
for _, d := range rule.DstPorts {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user