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