mirror of
https://github.com/juanfont/headscale.git
synced 2024-11-29 18:33:05 +00:00
Address a bunch of golint warnings.
This commit is contained in:
parent
d30b682a6e
commit
f7b6c68d22
7 changed files with 13 additions and 3 deletions
2
api.go
2
api.go
|
@ -104,7 +104,7 @@ func (h *Headscale) RegistrationHandler(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
log.Println("Hey! Not registered. Not asking for key rotation. Send a passive-agressive authurl to register")
|
||||
log.Println("Hey! Not registered. Not asking for key rotation. Send a passive-aggressive authurl to register")
|
||||
resp.AuthURL = fmt.Sprintf("%s/register?key=%s",
|
||||
h.cfg.ServerURL, mKey.HexString())
|
||||
respBody, err := encode(resp, &mKey, h.privateKey)
|
||||
|
|
2
app.go
2
app.go
|
@ -114,10 +114,10 @@ func (h *Headscale) Serve() error {
|
|||
go func() {
|
||||
log.Fatal(http.ListenAndServe(":http", m.HTTPHandler(http.HandlerFunc(h.redirect))))
|
||||
}()
|
||||
err = s.ListenAndServeTLS("", "")
|
||||
} else {
|
||||
return errors.New("Unknown value for TLSLetsEncryptChallengeType")
|
||||
}
|
||||
err = s.ListenAndServeTLS("", "")
|
||||
} else if h.cfg.TLSCertPath == "" {
|
||||
if !strings.HasPrefix(h.cfg.ServerURL, "http://") {
|
||||
fmt.Println("WARNING: listening without TLS but ServerURL does not start with http://")
|
||||
|
|
4
cli.go
4
cli.go
|
@ -51,6 +51,8 @@ func (h *Headscale) RegisterMachine(key string, namespace string) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// ListNodeRoutes prints the subnet routes advertised by a node (identified by
|
||||
// namespace and node name)
|
||||
func (h *Headscale) ListNodeRoutes(namespace string, nodeName string) error {
|
||||
m, err := h.GetMachine(namespace, nodeName)
|
||||
if err != nil {
|
||||
|
@ -65,6 +67,8 @@ func (h *Headscale) ListNodeRoutes(namespace string, nodeName string) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// EnableNodeRoute enables a subnet route advertised by a node (identified by
|
||||
// namespace and node name)
|
||||
func (h *Headscale) EnableNodeRoute(namespace string, nodeName string, routeStr string) error {
|
||||
m, err := h.GetMachine(namespace, nodeName)
|
||||
if err != nil {
|
||||
|
|
2
db.go
2
db.go
|
@ -4,7 +4,7 @@ import (
|
|||
"errors"
|
||||
|
||||
"github.com/jinzhu/gorm"
|
||||
_ "github.com/jinzhu/gorm/dialects/postgres"
|
||||
_ "github.com/jinzhu/gorm/dialects/postgres" // sql driver
|
||||
)
|
||||
|
||||
const dbVersion = "1"
|
||||
|
|
|
@ -176,6 +176,7 @@ func (h *Headscale) getPeers(m Machine) (*[]*tailcfg.Node, error) {
|
|||
return &peers, nil
|
||||
}
|
||||
|
||||
// GetMachine finds a Machine by name and namespace and returns the Machine struct
|
||||
func (h *Headscale) GetMachine(namespace string, name string) (*Machine, error) {
|
||||
machines, err := h.ListMachinesInNamespace(namespace)
|
||||
if err != nil {
|
||||
|
@ -190,6 +191,7 @@ func (h *Headscale) GetMachine(namespace string, name string) (*Machine, error)
|
|||
return nil, fmt.Errorf("not found")
|
||||
}
|
||||
|
||||
// GetHostInfo returns a Hostinfo struct for the machine
|
||||
func (m *Machine) GetHostInfo() (*tailcfg.Hostinfo, error) {
|
||||
hostinfo := tailcfg.Hostinfo{}
|
||||
if len(m.HostInfo.RawMessage) != 0 {
|
||||
|
|
|
@ -91,6 +91,7 @@ func (h *Headscale) ListMachinesInNamespace(name string) (*[]Machine, error) {
|
|||
return &machines, nil
|
||||
}
|
||||
|
||||
// SetMachineNamespace assigns a Machine to a namespace
|
||||
func (h *Headscale) SetMachineNamespace(m *Machine, namespaceName string) error {
|
||||
n, err := h.GetNamespace(namespaceName)
|
||||
if err != nil {
|
||||
|
|
|
@ -7,6 +7,7 @@ import (
|
|||
"time"
|
||||
)
|
||||
|
||||
// PreAuthKey describes a pre-authorization key usable in a particular namespace
|
||||
type PreAuthKey struct {
|
||||
ID uint64 `gorm:"primary_key"`
|
||||
Key string
|
||||
|
@ -18,6 +19,7 @@ type PreAuthKey struct {
|
|||
Expiration *time.Time
|
||||
}
|
||||
|
||||
// CreatePreAuthKey creates a new PreAuthKey in a namespace, and returns it
|
||||
func (h *Headscale) CreatePreAuthKey(namespaceName string, reusable bool, expiration *time.Time) (*PreAuthKey, error) {
|
||||
n, err := h.GetNamespace(namespaceName)
|
||||
if err != nil {
|
||||
|
@ -49,6 +51,7 @@ func (h *Headscale) CreatePreAuthKey(namespaceName string, reusable bool, expira
|
|||
return &k, nil
|
||||
}
|
||||
|
||||
// GetPreAuthKeys returns the list of PreAuthKeys for a namespace
|
||||
func (h *Headscale) GetPreAuthKeys(namespaceName string) (*[]PreAuthKey, error) {
|
||||
n, err := h.GetNamespace(namespaceName)
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in a new issue