mirror of
https://github.com/juanfont/headscale.git
synced 2024-12-02 14:35:25 +00:00
fix: add error checking in acl and poll
If aclPolicy is not defined, in updateAclPolicy, return an error.
This commit is contained in:
parent
211fe4034a
commit
50af44bc2f
4
acls.go
4
acls.go
@ -86,6 +86,10 @@ func (h *Headscale) UpdateACLRules() error {
|
|||||||
func (h *Headscale) generateACLRules() ([]tailcfg.FilterRule, error) {
|
func (h *Headscale) generateACLRules() ([]tailcfg.FilterRule, error) {
|
||||||
rules := []tailcfg.FilterRule{}
|
rules := []tailcfg.FilterRule{}
|
||||||
|
|
||||||
|
if h.aclPolicy == nil {
|
||||||
|
return nil, errEmptyPolicy
|
||||||
|
}
|
||||||
|
|
||||||
machines, err := h.ListAllMachines()
|
machines, err := h.ListAllMachines()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
3
poll.go
3
poll.go
@ -95,6 +95,7 @@ func (h *Headscale) PollNetMapHandler(ctx *gin.Context) {
|
|||||||
now := time.Now().UTC()
|
now := time.Now().UTC()
|
||||||
|
|
||||||
// update ACLRules with peer informations (to update server tags if necessary)
|
// update ACLRules with peer informations (to update server tags if necessary)
|
||||||
|
if h.aclPolicy != nil {
|
||||||
err = h.UpdateACLRules()
|
err = h.UpdateACLRules()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error().
|
log.Error().
|
||||||
@ -103,7 +104,7 @@ func (h *Headscale) PollNetMapHandler(ctx *gin.Context) {
|
|||||||
Str("machine", machine.Name).
|
Str("machine", machine.Name).
|
||||||
Err(err)
|
Err(err)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// From Tailscale client:
|
// From Tailscale client:
|
||||||
//
|
//
|
||||||
// ReadOnly is whether the client just wants to fetch the MapResponse,
|
// ReadOnly is whether the client just wants to fetch the MapResponse,
|
||||||
|
Loading…
Reference in New Issue
Block a user