mirror of
https://github.com/XTLS/Xray-core.git
synced 2025-08-22 17:46:48 +08:00
TLS ECH client: Use chrome-fingerprint and add padding; Add "h2c" and echSockopt
; Fix some issues (#4949)
Completes https://github.com/XTLS/Xray-core/pull/3813
This commit is contained in:
@@ -8,6 +8,7 @@ import (
|
||||
"crypto/tls"
|
||||
"crypto/x509"
|
||||
"encoding/base64"
|
||||
"github.com/xtls/xray-core/features/dns"
|
||||
"os"
|
||||
"slices"
|
||||
"strings"
|
||||
@@ -275,6 +276,9 @@ func getNewGetCertificateFunc(certs []*tls.Certificate, rejectUnknownSNI bool) f
|
||||
}
|
||||
|
||||
func (c *Config) parseServerName() string {
|
||||
if IsFromMitm(c.ServerName) {
|
||||
return ""
|
||||
}
|
||||
return c.ServerName
|
||||
}
|
||||
|
||||
@@ -447,7 +451,11 @@ func (c *Config) GetTLSConfig(opts ...Option) *tls.Config {
|
||||
if len(c.EchConfigList) > 0 || len(c.EchServerKeys) > 0 {
|
||||
err := ApplyECH(c, config)
|
||||
if err != nil {
|
||||
errors.LogError(context.Background(), err)
|
||||
if c.EchForceQuery || errors.Cause(err) != dns.ErrEmptyResponse {
|
||||
errors.LogError(context.Background(), err)
|
||||
} else {
|
||||
errors.LogInfo(context.Background(), err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -469,6 +477,12 @@ func WithDestination(dest net.Destination) Option {
|
||||
}
|
||||
}
|
||||
|
||||
func WithOverrideName(serverName string) Option {
|
||||
return func(config *tls.Config) {
|
||||
config.ServerName = serverName
|
||||
}
|
||||
}
|
||||
|
||||
// WithNextProto sets the ALPN values in TLS config.
|
||||
func WithNextProto(protocol ...string) Option {
|
||||
return func(config *tls.Config) {
|
||||
@@ -509,3 +523,7 @@ func ParseCurveName(curveNames []string) []tls.CurveID {
|
||||
}
|
||||
return curveIDs
|
||||
}
|
||||
|
||||
func IsFromMitm(str string) bool {
|
||||
return strings.ToLower(str) == "frommitm"
|
||||
}
|
||||
|
Reference in New Issue
Block a user