mirror of
https://github.com/juanfont/headscale.git
synced 2024-11-26 08:53:05 +00:00
refactor: introduce func ContainsNodeKey
This commit is contained in:
parent
b6adc84dc6
commit
b3beb73f3f
2 changed files with 11 additions and 12 deletions
|
@ -99,18 +99,7 @@ func (h *Headscale) VerifyHandler(
|
|||
http.Error(writer, "Internal error", http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
for _, node := range nodes {
|
||||
log.Debug().Str("node", node.NodeKey.String()).Msg("Node")
|
||||
}
|
||||
|
||||
allow := false
|
||||
// Check if the node is in the list of nodes
|
||||
for _, node := range nodes {
|
||||
if node.NodeKey == derpAdmitClientRequest.NodePublic {
|
||||
allow = true
|
||||
break
|
||||
}
|
||||
}
|
||||
allow := nodes.ContainsNodeKey(derpAdmitClientRequest.NodePublic)
|
||||
|
||||
resp := tailcfg.DERPAdmitClientResponse{
|
||||
Allow: allow,
|
||||
|
|
|
@ -223,6 +223,16 @@ func (nodes Nodes) FilterByIP(ip netip.Addr) Nodes {
|
|||
return found
|
||||
}
|
||||
|
||||
func (nodes Nodes) ContainsNodeKey(nodeKey key.NodePublic) bool {
|
||||
for _, node := range nodes {
|
||||
if node.NodeKey == nodeKey {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func (node *Node) Proto() *v1.Node {
|
||||
nodeProto := &v1.Node{
|
||||
Id: uint64(node.ID),
|
||||
|
|
Loading…
Reference in a new issue