Skip to content

Commit

Permalink
Allow IP address ServerName when "serverName" is not configured
Browse files Browse the repository at this point in the history
In this case, TLS Client Hello will not have SNI (RFC 6066, Section 3)
  • Loading branch information
RPRX authored and yuhan6665 committed Mar 26, 2023
1 parent 141d3f1 commit ff6bad9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions transport/internet/reality/reality.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions transport/internet/tls/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
}
}
Expand Down

0 comments on commit ff6bad9

Please sign in to comment.