mirror of
https://github.com/juanfont/headscale.git
synced 2025-08-15 09:07:46 +00:00
Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
5748744134 | ||
![]() |
31556e1ac0 | ||
![]() |
0159649d0a | ||
![]() |
cf9d920e4a | ||
![]() |
7d46dfe012 | ||
![]() |
eabb1ce881 |
2
.github/workflows/release.yml
vendored
2
.github/workflows/release.yml
vendored
@@ -7,7 +7,7 @@ on:
|
||||
|
||||
jobs:
|
||||
goreleaser:
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: ubuntu-18.04 # due to CGO we need to user an older version
|
||||
steps:
|
||||
-
|
||||
name: Checkout
|
||||
|
@@ -62,8 +62,7 @@ archives:
|
||||
- linux-armhf
|
||||
- linux-amd64
|
||||
name_template: "{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}"
|
||||
format: zip
|
||||
# wrap_in_directory: true
|
||||
format: binary
|
||||
|
||||
checksum:
|
||||
name_template: 'checksums.txt'
|
||||
|
17
api.go
17
api.go
@@ -46,7 +46,7 @@ func (h *Headscale) RegisterWebAPI(c *gin.Context) {
|
||||
|
||||
<p>
|
||||
<code>
|
||||
<b>headscale -n NAMESPACE node register %s</b>
|
||||
<b>headscale -n NAMESPACE nodes register %s</b>
|
||||
</code>
|
||||
</p>
|
||||
|
||||
@@ -76,7 +76,7 @@ func (h *Headscale) RegistrationHandler(c *gin.Context) {
|
||||
}
|
||||
|
||||
var m Machine
|
||||
if result := h.db.First(&m, "machine_key = ?", mKey.HexString()); errors.Is(result.Error, gorm.ErrRecordNotFound) {
|
||||
if result := h.db.Preload("Namespace").First(&m, "machine_key = ?", mKey.HexString()); errors.Is(result.Error, gorm.ErrRecordNotFound) {
|
||||
log.Println("New Machine!")
|
||||
m = Machine{
|
||||
Expiry: &req.Expiry,
|
||||
@@ -200,7 +200,7 @@ func (h *Headscale) PollNetMapHandler(c *gin.Context) {
|
||||
}
|
||||
|
||||
var m Machine
|
||||
if result := h.db.First(&m, "machine_key = ?", mKey.HexString()); errors.Is(result.Error, gorm.ErrRecordNotFound) {
|
||||
if result := h.db.Preload("Namespace").First(&m, "machine_key = ?", mKey.HexString()); errors.Is(result.Error, gorm.ErrRecordNotFound) {
|
||||
log.Printf("Ignoring request, cannot find machine with key %s", mKey.HexString())
|
||||
c.String(http.StatusUnauthorized, "")
|
||||
return
|
||||
@@ -357,16 +357,23 @@ func (h *Headscale) getMapResponse(mKey wgkey.Key, req tailcfg.MapRequest, m Mac
|
||||
log.Printf("Cannot fetch peers: %s", err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
profile := tailcfg.UserProfile{
|
||||
ID: tailcfg.UserID(m.NamespaceID),
|
||||
LoginName: m.Namespace.Name,
|
||||
DisplayName: m.Namespace.Name,
|
||||
}
|
||||
|
||||
resp := tailcfg.MapResponse{
|
||||
KeepAlive: false,
|
||||
Node: node,
|
||||
Peers: *peers,
|
||||
DNS: []netaddr.IP{},
|
||||
SearchPaths: []string{},
|
||||
Domain: "foobar@example.com",
|
||||
Domain: "headscale.net",
|
||||
PacketFilter: *h.aclRules,
|
||||
DERPMap: h.cfg.DerpMap,
|
||||
UserProfiles: []tailcfg.UserProfile{},
|
||||
UserProfiles: []tailcfg.UserProfile{profile},
|
||||
}
|
||||
|
||||
var respBody []byte
|
||||
|
4
app.go
4
app.go
@@ -78,7 +78,7 @@ func NewHeadscale(cfg Config) (*Headscale, error) {
|
||||
case "sqlite3":
|
||||
dbString = cfg.DBpath
|
||||
default:
|
||||
return nil, errors.New("Unsupported DB")
|
||||
return nil, errors.New("unsupported DB")
|
||||
}
|
||||
|
||||
h := Headscale{
|
||||
@@ -175,7 +175,7 @@ func (h *Headscale) Serve() error {
|
||||
}()
|
||||
err = s.ListenAndServeTLS("", "")
|
||||
} else {
|
||||
return errors.New("Unknown value for TLSLetsEncryptChallengeType")
|
||||
return errors.New("unknown value for TLSLetsEncryptChallengeType")
|
||||
}
|
||||
} else if h.cfg.TLSCertPath == "" {
|
||||
if !strings.HasPrefix(h.cfg.ServerURL, "http://") {
|
||||
|
@@ -121,9 +121,12 @@ func getHeadscaleApp() (*headscale.Headscale, error) {
|
||||
}
|
||||
|
||||
// We are doing this here, as in the future could be cool to have it also hot-reload
|
||||
err = h.LoadACLPolicy(absPath(viper.GetString("acl_policy_path")))
|
||||
if err != nil {
|
||||
log.Printf("Could not load the ACL policy: %s", err)
|
||||
|
||||
if viper.GetString("acl_policy_path") != "" {
|
||||
err = h.LoadACLPolicy(absPath(viper.GetString("acl_policy_path")))
|
||||
if err != nil {
|
||||
log.Printf("Could not load the ACL policy: %s", err)
|
||||
}
|
||||
}
|
||||
|
||||
return h, nil
|
||||
|
@@ -154,7 +154,6 @@ func (m Machine) toNode() (*tailcfg.Node, error) {
|
||||
}
|
||||
|
||||
func (h *Headscale) getPeers(m Machine) (*[]*tailcfg.Node, error) {
|
||||
|
||||
machines := []Machine{}
|
||||
if err := h.db.Where("namespace_id = ? AND machine_key <> ? AND registered",
|
||||
m.NamespaceID, m.MachineKey).Find(&machines).Error; err != nil {
|
||||
|
@@ -106,10 +106,10 @@ func (h *Headscale) SetMachineNamespace(m *Machine, namespaceName string) error
|
||||
func (n *Namespace) toUser() *tailcfg.User {
|
||||
u := tailcfg.User{
|
||||
ID: tailcfg.UserID(n.ID),
|
||||
LoginName: "",
|
||||
LoginName: n.Name,
|
||||
DisplayName: n.Name,
|
||||
ProfilePicURL: "",
|
||||
Domain: "",
|
||||
Domain: "headscale.net",
|
||||
Logins: []tailcfg.LoginID{},
|
||||
Created: time.Time{},
|
||||
}
|
||||
|
Reference in New Issue
Block a user