This commit is contained in:
Ameir Abdeldayem 2024-06-10 13:15:50 -04:00 committed by GitHub
commit 1b19b98a31
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 15 additions and 10 deletions

View file

@ -42,12 +42,13 @@ type Tunnel struct {
// ClientConfig is a tunnel client configuration.
type ClientConfig struct {
ServerAddr string `yaml:"server_addr"`
TLSCrt string `yaml:"tls_crt"`
TLSKey string `yaml:"tls_key"`
RootCA string `yaml:"root_ca"`
Backoff BackoffConfig `yaml:"backoff"`
Tunnels map[string]*Tunnel `yaml:"tunnels"`
ServerAddr string `yaml:"server_addr"`
ServerHostname string `yaml:"server_hostname"`
TLSCrt string `yaml:"tls_crt"`
TLSKey string `yaml:"tls_key"`
RootCA string `yaml:"root_ca"`
Backoff BackoffConfig `yaml:"backoff"`
Tunnels map[string]*Tunnel `yaml:"tunnels"`
}
func loadClientConfigFromFile(file string) (*ClientConfig, error) {

View file

@ -130,11 +130,15 @@ func tlsConfig(config *ClientConfig) (*tls.Config, error) {
}
}
host, _, err := net.SplitHostPort(config.ServerAddr)
if err != nil {
return nil, err
var host string
if config.ServerHostname != "" {
host = config.ServerHostname
} else {
host, _, err = net.SplitHostPort(config.ServerAddr)
if err != nil {
return nil, err
}
}
return &tls.Config{
ServerName: host,
Certificates: []tls.Certificate{cert},