mirror of
https://github.com/juanfont/headscale.git
synced 2024-12-26 22:25:52 -05:00
fix: remove db twice
* fix: remove db twice. * better for new error, use errors.New. * Error strings should not be capitalized or end with punctuation. https://github.com/golang/go/wiki/CodeReviewComments#error-strings
This commit is contained in:
parent
d30b682a6e
commit
07a9f95aeb
5
cli.go
5
cli.go
@ -2,6 +2,7 @@ package headscale
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
@ -86,7 +87,7 @@ func (h *Headscale) EnableNodeRoute(namespace string, nodeName string, routeStr
|
|||||||
log.Printf("Cannot open DB: %s", err)
|
log.Printf("Cannot open DB: %s", err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
defer db.Close()
|
|
||||||
routes, _ := json.Marshal([]string{routeStr}) // TODO: only one for the time being, so overwriting the rest
|
routes, _ := json.Marshal([]string{routeStr}) // TODO: only one for the time being, so overwriting the rest
|
||||||
m.EnabledRoutes = postgres.Jsonb{RawMessage: json.RawMessage(routes)}
|
m.EnabledRoutes = postgres.Jsonb{RawMessage: json.RawMessage(routes)}
|
||||||
db.Save(&m)
|
db.Save(&m)
|
||||||
@ -104,8 +105,8 @@ func (h *Headscale) EnableNodeRoute(namespace string, nodeName string, routeStr
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return fmt.Errorf("Could not find routable range")
|
|
||||||
|
|
||||||
|
return errors.New("could not find routable range")
|
||||||
}
|
}
|
||||||
|
|
||||||
func eqCIDRs(a, b []netaddr.IPPrefix) bool {
|
func eqCIDRs(a, b []netaddr.IPPrefix) bool {
|
||||||
|
Loading…
Reference in New Issue
Block a user