mirror of
https://github.com/juanfont/headscale.git
synced 2024-12-20 19:09:07 +01:00
parent
acb645aa9d
commit
272eee79fd
@ -137,6 +137,7 @@ func (h *Headscale) PollNetMapHandler(c *gin.Context) {
|
|||||||
hostinfo, _ := json.Marshal(req.Hostinfo)
|
hostinfo, _ := json.Marshal(req.Hostinfo)
|
||||||
m.Endpoints = postgres.Jsonb{RawMessage: json.RawMessage(endpoints)}
|
m.Endpoints = postgres.Jsonb{RawMessage: json.RawMessage(endpoints)}
|
||||||
m.HostInfo = postgres.Jsonb{RawMessage: json.RawMessage(hostinfo)}
|
m.HostInfo = postgres.Jsonb{RawMessage: json.RawMessage(hostinfo)}
|
||||||
|
m.DiscoKey = wgcfg.Key(req.DiscoKey).HexString()
|
||||||
now := time.Now().UTC()
|
now := time.Now().UTC()
|
||||||
m.LastSeen = &now
|
m.LastSeen = &now
|
||||||
db.Save(&m)
|
db.Save(&m)
|
||||||
@ -254,8 +255,7 @@ func (h *Headscale) getMapKeepAliveResponse(mKey wgcfg.Key, req tailcfg.MapReque
|
|||||||
return &data, nil
|
return &data, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// RegisterWebAPI attaches the machine to a user or team.
|
// RegisterWebAPI shows a simple message in the browser to point to the CLI
|
||||||
// Currently this is a rather temp implementation, as it just registers it.
|
|
||||||
func (h *Headscale) RegisterWebAPI(c *gin.Context) {
|
func (h *Headscale) RegisterWebAPI(c *gin.Context) {
|
||||||
mKeyStr := c.Query("key")
|
mKeyStr := c.Query("key")
|
||||||
if mKeyStr == "" {
|
if mKeyStr == "" {
|
||||||
|
@ -16,6 +16,7 @@ type Machine struct {
|
|||||||
ID uint64 `gorm:"primary_key"`
|
ID uint64 `gorm:"primary_key"`
|
||||||
MachineKey string `gorm:"type:varchar(64);unique_index"`
|
MachineKey string `gorm:"type:varchar(64);unique_index"`
|
||||||
NodeKey string
|
NodeKey string
|
||||||
|
DiscoKey string
|
||||||
IPAddress string
|
IPAddress string
|
||||||
|
|
||||||
Registered bool // temp
|
Registered bool // temp
|
||||||
@ -44,6 +45,10 @@ func (m Machine) toNode() (*tailcfg.Node, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
dKey, err := wgcfg.ParseHexKey(m.DiscoKey)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
addrs := []netaddr.IPPrefix{}
|
addrs := []netaddr.IPPrefix{}
|
||||||
allowedIPs := []netaddr.IPPrefix{}
|
allowedIPs := []netaddr.IPPrefix{}
|
||||||
|
|
||||||
@ -81,6 +86,7 @@ func (m Machine) toNode() (*tailcfg.Node, error) {
|
|||||||
Key: tailcfg.NodeKey(nKey),
|
Key: tailcfg.NodeKey(nKey),
|
||||||
KeyExpiry: *m.Expiry,
|
KeyExpiry: *m.Expiry,
|
||||||
Machine: tailcfg.MachineKey(mKey),
|
Machine: tailcfg.MachineKey(mKey),
|
||||||
|
DiscoKey: tailcfg.DiscoKey(dKey),
|
||||||
Addresses: addrs,
|
Addresses: addrs,
|
||||||
AllowedIPs: allowedIPs,
|
AllowedIPs: allowedIPs,
|
||||||
Endpoints: endpoints,
|
Endpoints: endpoints,
|
||||||
|
Loading…
Reference in New Issue
Block a user