5
0
mirror of https://github.com/cwinfo/yggdrasil-go.git synced 2024-11-24 21:51:35 +00:00

Set SNI by default if the peering URI contains a DNS name

This commit is contained in:
Neil Alexander 2021-07-28 22:23:33 +01:00
parent d8df9755f2
commit f094cf34bf

View File

@ -99,6 +99,13 @@ func (l *links) call(u *url.URL, sintf string) error {
case "tls": case "tls":
tcpOpts.upgrade = l.tcp.tls.forDialer tcpOpts.upgrade = l.tcp.tls.forDialer
tcpOpts.tlsSNI = u.Query().Get("sni") tcpOpts.tlsSNI = u.Query().Get("sni")
if tcpOpts.tlsSNI == "" {
// SNI headers must contain hostnames and not IP addresses, so we must make sure
// that we do not populate the SNI with an IP literal.
if host, _, err := net.SplitHostPort(u.Host); err == nil && net.ParseIP(host) == nil {
tcpOpts.tlsSNI = host
}
}
l.tcp.call(u.Host, tcpOpts, sintf) l.tcp.call(u.Host, tcpOpts, sintf)
default: default:
return errors.New("unknown call scheme: " + u.Scheme) return errors.New("unknown call scheme: " + u.Scheme)