Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions cmd/tunnel/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
12 changes: 8 additions & 4 deletions cmd/tunnel/tunnel.go
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down