Skip to content

Commit e4a3dcc

Browse files
authored
use headscale server url as domain instead of base_domain (#2338)
1 parent caad5c6 commit e4a3dcc

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

hscontrol/mapper/mapper.go

+2-3
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,7 @@ func generateUserProfiles(
105105

106106
var profiles []tailcfg.UserProfile
107107
for _, user := range userMap {
108-
profiles = append(profiles,
109-
user.TailscaleUserProfile())
108+
profiles = append(profiles, user.TailscaleUserProfile())
110109
}
111110

112111
return profiles
@@ -455,7 +454,7 @@ func (m *Mapper) baseWithConfigMapResponse(
455454

456455
resp.DERPMap = m.derpMap
457456

458-
resp.Domain = m.cfg.BaseDomain
457+
resp.Domain = m.cfg.Domain()
459458

460459
// Do not instruct clients to collect services we do not
461460
// support or do anything with them

hscontrol/types/config.go

+11
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,17 @@ func validatePKCEMethod(method string) error {
242242
return nil
243243
}
244244

245+
// Domain returns the hostname/domain part of the ServerURL.
246+
// If the ServerURL is not a valid URL, it returns the BaseDomain.
247+
func (c *Config) Domain() string {
248+
u, err := url.Parse(c.ServerURL)
249+
if err != nil {
250+
return c.BaseDomain
251+
}
252+
253+
return u.Hostname()
254+
}
255+
245256
// LoadConfig prepares and loads the Headscale configuration into Viper.
246257
// This means it sets the default values, reads the configuration file and
247258
// environment variables, and handles deprecated configuration options.

0 commit comments

Comments
 (0)