mirror of
https://github.com/juanfont/headscale.git
synced 2024-11-27 12:05:26 +00:00
Fixes here and there
This commit is contained in:
parent
1b7d99d483
commit
563f3c4017
4
app.go
4
app.go
@ -2,8 +2,8 @@ package headscale
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"tailscale.com/tailcfg"
|
||||
@ -34,7 +34,7 @@ type Headscale struct {
|
||||
|
||||
// NewHeadscale returns the Headscale app
|
||||
func NewHeadscale(cfg Config) (*Headscale, error) {
|
||||
content, err := ioutil.ReadFile(cfg.PrivateKeyPath)
|
||||
content, err := os.ReadFile(cfg.PrivateKeyPath)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -5,7 +5,6 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"net/http"
|
||||
"time"
|
||||
@ -24,7 +23,7 @@ func (h *Headscale) KeyHandler(c *gin.Context) {
|
||||
}
|
||||
|
||||
func (h *Headscale) RegistrationHandler(c *gin.Context) {
|
||||
body, _ := ioutil.ReadAll(c.Request.Body)
|
||||
body, _ := io.ReadAll(c.Request.Body)
|
||||
mKeyStr := c.Param("id")
|
||||
mKey, err := wgcfg.ParseHexKey(mKeyStr)
|
||||
if err != nil {
|
||||
@ -104,7 +103,7 @@ func (h *Headscale) RegistrationHandler(c *gin.Context) {
|
||||
}
|
||||
|
||||
func (h *Headscale) PollNetMapHandler(c *gin.Context) {
|
||||
body, _ := ioutil.ReadAll(c.Request.Body)
|
||||
body, _ := io.ReadAll(c.Request.Body)
|
||||
mKeyStr := c.Param("id")
|
||||
mKey, err := wgcfg.ParseHexKey(mKeyStr)
|
||||
if err != nil {
|
||||
@ -126,6 +125,7 @@ func (h *Headscale) PollNetMapHandler(c *gin.Context) {
|
||||
c.String(http.StatusInternalServerError, ":(")
|
||||
return
|
||||
}
|
||||
defer db.Close()
|
||||
var m Machine
|
||||
if db.First(&m, "machine_key = ?", mKey.HexString()).RecordNotFound() {
|
||||
log.Printf("Cannot encode message: %s", err)
|
||||
|
Loading…
Reference in New Issue
Block a user