derp/derphttp: strip port numbers from URL hostname

When trying to set up multiple derper instances meshing with each
other, it turned out that while one can specify an alternative
listening port using the -a flag, the TLS hostname gets incorrectly
determined and includes the set alternative listening port as part of
the hostname. Thus, the TLS hostname validation always fails when the
-mesh-with values have ports.

Updates #9949

Signed-off-by: Thomas Kosiewski <thomas.kosiewski@loft.sh>
This commit is contained in:
Thomas Kosiewski 2023-10-24 16:27:29 +02:00 committed by GitHub
parent 514539b611
commit b2ae8fdf80
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 1 deletions

View File

@ -226,7 +226,7 @@ func (c *Client) useHTTPS() bool {
// tlsServerName returns the tls.Config.ServerName value (for the TLS ClientHello).
func (c *Client) tlsServerName(node *tailcfg.DERPNode) string {
if c.url != nil {
return c.url.Host
return c.url.Hostname()
}
return node.HostName
}