From beb603af06137df357550fc99b89b2c88f698271 Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Sun, 26 Mar 2023 10:57:20 +0000 Subject: [PATCH] Allow IP address ServerName when "serverName" is not configured In this case, TLS Client Hello will not have SNI (RFC 6066, Section 3) --- transport/internet/reality/reality.go | 4 ++-- transport/internet/tls/config.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/transport/internet/reality/reality.go b/transport/internet/reality/reality.go index a0a66afa..90580056 100644 --- a/transport/internet/reality/reality.go +++ b/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) diff --git a/transport/internet/tls/config.go b/transport/internet/tls/config.go index 9c1f8eee..2e2b784a 100644 --- a/transport/internet/tls/config.go +++ b/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() } } }