mirror of
https://github.com/juanfont/headscale.git
synced 2024-11-29 18:33:05 +00:00
server_url and base_domain: re-word error message, fix a one-off bug and add a test case for the bug.
This commit is contained in:
parent
c4ac626298
commit
e834017314
2 changed files with 8 additions and 4 deletions
|
@ -30,7 +30,7 @@ const (
|
||||||
|
|
||||||
var (
|
var (
|
||||||
errOidcMutuallyExclusive = errors.New("oidc_client_secret and oidc_client_secret_path are mutually exclusive")
|
errOidcMutuallyExclusive = errors.New("oidc_client_secret and oidc_client_secret_path are mutually exclusive")
|
||||||
errServerURLSuffix = errors.New("server_url cannot be a suffix of the base_domain, this will cause the headscale server and embedded DERP to become unreachable from the Tailscale node.")
|
errServerURLSuffix = errors.New("server_url cannot be part of base_domain in a way that could make the DERP and headscale server unreachable.")
|
||||||
)
|
)
|
||||||
|
|
||||||
type IPAllocationStrategy string
|
type IPAllocationStrategy string
|
||||||
|
@ -946,8 +946,8 @@ func isSafeServerURL(serverURL, baseDomain string) error {
|
||||||
|
|
||||||
s := len(serverDomainParts)
|
s := len(serverDomainParts)
|
||||||
b := len(baseDomainParts)
|
b := len(baseDomainParts)
|
||||||
for i := 1; i < len(baseDomainParts)-1; i++ {
|
for i := 0; i < len(baseDomainParts); i++ {
|
||||||
if serverDomainParts[s-i] != baseDomainParts[b-i] {
|
if serverDomainParts[s-i-1] != baseDomainParts[b-i-1] {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -140,7 +140,7 @@ func TestReadConfig(t *testing.T) {
|
||||||
return LoadServerConfig()
|
return LoadServerConfig()
|
||||||
},
|
},
|
||||||
want: nil,
|
want: nil,
|
||||||
wantErr: "server_url cannot be a suffix of the base_domain, this will cause the headscale server and embedded DERP to become unreachable from the Tailscale node.",
|
wantErr: errServerURLSuffix.Error(),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "base-domain-not-in-server-url",
|
name: "base-domain-not-in-server-url",
|
||||||
|
@ -362,6 +362,10 @@ func TestSafeServerURL(t *testing.T) {
|
||||||
serverURL: "https://headscale.com",
|
serverURL: "https://headscale.com",
|
||||||
baseDomain: "clients.subdomain.headscale.com",
|
baseDomain: "clients.subdomain.headscale.com",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
serverURL: "https://headscale.kristoffer.com",
|
||||||
|
baseDomain: "mybase",
|
||||||
|
},
|
||||||
{
|
{
|
||||||
serverURL: "https://server.headscale.com",
|
serverURL: "https://server.headscale.com",
|
||||||
baseDomain: "headscale.com",
|
baseDomain: "headscale.com",
|
||||||
|
|
Loading…
Reference in a new issue