Skip to content

Commit

Permalink
use headscale server url as domain instead of base_domain
Browse files Browse the repository at this point in the history
Fixes juanfont#2336

Signed-off-by: Kristoffer Dalby <[email protected]>
  • Loading branch information
kradalby committed Jan 10, 2025
1 parent ede4f97 commit e57b1a1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
5 changes: 2 additions & 3 deletions hscontrol/mapper/mapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,7 @@ func generateUserProfiles(

var profiles []tailcfg.UserProfile
for _, user := range userMap {
profiles = append(profiles,
user.TailscaleUserProfile())
profiles = append(profiles, user.TailscaleUserProfile())
}

return profiles
Expand Down Expand Up @@ -455,7 +454,7 @@ func (m *Mapper) baseWithConfigMapResponse(

resp.DERPMap = m.derpMap

resp.Domain = m.cfg.BaseDomain
resp.Domain = m.cfg.Domain()

// Do not instruct clients to collect services we do not
// support or do anything with them
Expand Down
11 changes: 11 additions & 0 deletions hscontrol/types/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,17 @@ func validatePKCEMethod(method string) error {
return nil
}

// Domain returns the hostname/domain part of the ServerURL.
// If the ServerURL is not a valid URL, it returns the BaseDomain.
func (c *Config) Domain() string {
u, err := url.Parse(c.ServerURL)
if err != nil {
return c.BaseDomain
}

return u.Hostname()
}

// LoadConfig prepares and loads the Headscale configuration into Viper.
// This means it sets the default values, reads the configuration file and
// environment variables, and handles deprecated configuration options.
Expand Down

0 comments on commit e57b1a1

Please sign in to comment.