Browse Source

Allow IP address ServerName when "serverName" is not configured

In this case, TLS Client Hello will not have SNI (RFC 6066, Section 3)
RPRX 2 years ago
parent
commit
beb603af06
2 changed files with 4 additions and 4 deletions
  1. 2 2
      transport/internet/reality/reality.go
  2. 2 2
      transport/internet/tls/config.go

+ 2 - 2
transport/internet/reality/reality.go

@@ -107,8 +107,8 @@ func UClient(c net.Conn, config *Config, ctx context.Context, dest net.Destinati
 		InsecureSkipVerify:     true,
 		SessionTicketsDisabled: true,
 	}
-	if utlsConfig.ServerName == "" && dest.Address.Family().IsDomain() {
-		utlsConfig.ServerName = dest.Address.Domain()
+	if utlsConfig.ServerName == "" {
+		utlsConfig.ServerName = dest.Address.String()
 	}
 	uConn.ServerName = utlsConfig.ServerName
 	fingerprint := tls.GetFingerprint(config.Fingerprint)

+ 2 - 2
transport/internet/tls/config.go

@@ -373,8 +373,8 @@ type Option func(*tls.Config)
 // WithDestination sets the server name in TLS config.
 func WithDestination(dest net.Destination) Option {
 	return func(config *tls.Config) {
-		if dest.Address.Family().IsDomain() && config.ServerName == "" {
-			config.ServerName = dest.Address.Domain()
+		if config.ServerName == "" {
+			config.ServerName = dest.Address.String()
 		}
 	}
 }