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 (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"log"
|
"log"
|
||||||
|
"os"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"tailscale.com/tailcfg"
|
"tailscale.com/tailcfg"
|
||||||
@ -34,7 +34,7 @@ type Headscale struct {
|
|||||||
|
|
||||||
// NewHeadscale returns the Headscale app
|
// NewHeadscale returns the Headscale app
|
||||||
func NewHeadscale(cfg Config) (*Headscale, error) {
|
func NewHeadscale(cfg Config) (*Headscale, error) {
|
||||||
content, err := ioutil.ReadFile(cfg.PrivateKeyPath)
|
content, err := os.ReadFile(cfg.PrivateKeyPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,6 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"time"
|
"time"
|
||||||
@ -24,7 +23,7 @@ func (h *Headscale) KeyHandler(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (h *Headscale) RegistrationHandler(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")
|
mKeyStr := c.Param("id")
|
||||||
mKey, err := wgcfg.ParseHexKey(mKeyStr)
|
mKey, err := wgcfg.ParseHexKey(mKeyStr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -104,7 +103,7 @@ func (h *Headscale) RegistrationHandler(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (h *Headscale) PollNetMapHandler(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")
|
mKeyStr := c.Param("id")
|
||||||
mKey, err := wgcfg.ParseHexKey(mKeyStr)
|
mKey, err := wgcfg.ParseHexKey(mKeyStr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -126,6 +125,7 @@ func (h *Headscale) PollNetMapHandler(c *gin.Context) {
|
|||||||
c.String(http.StatusInternalServerError, ":(")
|
c.String(http.StatusInternalServerError, ":(")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
defer db.Close()
|
||||||
var m Machine
|
var m Machine
|
||||||
if db.First(&m, "machine_key = ?", mKey.HexString()).RecordNotFound() {
|
if db.First(&m, "machine_key = ?", mKey.HexString()).RecordNotFound() {
|
||||||
log.Printf("Cannot encode message: %s", err)
|
log.Printf("Cannot encode message: %s", err)
|
||||||
|
Loading…
Reference in New Issue
Block a user