0
mirror of https://github.com/XTLS/Xray-core.git synced 2025-05-12 05:01:24 +03:00

Update utls and little change

This commit is contained in:
风扇滑翔翼 2025-05-10 09:21:36 +00:00 committed by GitHub
parent 43d890bce2
commit 38ce793b7c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 16 additions and 15 deletions

View File

@ -27,14 +27,8 @@ func ApplyECH(c *Config, config *tls.Config) error {
// for client
if len(c.EchConfigList) != 0 {
// direct base64 config
if strings.HasPrefix(c.EchConfigList, "base64") {
Base64ECHConfigList := c.EchConfigList[len("base64://"):]
ECHConfigList, err := goech.ECHConfigListFromBase64(Base64ECHConfigList)
if err != nil {
return errors.New("Failed to unmarshal ECHConfigList: ", err)
}
ECHConfig, _ = ECHConfigList.MarshalBinary()
} else { // query config from dns
if strings.Contains(c.EchConfigList, "://") {
// query config from dns
parts := strings.Split(c.EchConfigList, "+")
if len(parts) == 2 {
// parse ECH DNS server in format of "example.com+https://1.1.1.1/dns-query"
@ -53,6 +47,12 @@ func ApplyECH(c *Config, config *tls.Config) error {
if err != nil {
return err
}
} else {
ECHConfigList, err := goech.ECHConfigListFromBase64(c.EchConfigList)
if err != nil {
return errors.New("Failed to unmarshal ECHConfigList: ", err)
}
ECHConfig, _ = ECHConfigList.MarshalBinary()
}
config.EncryptedClientHelloConfigList = ECHConfig

View File

@ -128,12 +128,13 @@ func UClient(c net.Conn, config *tls.Config, fingerprint *utls.ClientHelloID) ne
func copyConfig(c *tls.Config) *utls.Config {
return &utls.Config{
Rand: c.Rand,
RootCAs: c.RootCAs,
ServerName: c.ServerName,
InsecureSkipVerify: c.InsecureSkipVerify,
VerifyPeerCertificate: c.VerifyPeerCertificate,
KeyLogWriter: c.KeyLogWriter,
Rand: c.Rand,
RootCAs: c.RootCAs,
ServerName: c.ServerName,
InsecureSkipVerify: c.InsecureSkipVerify,
VerifyPeerCertificate: c.VerifyPeerCertificate,
KeyLogWriter: c.KeyLogWriter,
EncryptedClientHelloConfigList: c.EncryptedClientHelloConfigList,
}
}
@ -179,7 +180,7 @@ func GetFingerprint(name string) (fingerprint *utls.ClientHelloID) {
var PresetFingerprints = map[string]*utls.ClientHelloID{
// Recommended preset options in GUI clients
"chrome": &utls.HelloChrome_120,
"chrome": &utls.HelloChrome_131,
"firefox": &utls.HelloFirefox_Auto,
"safari": &utls.HelloSafari_Auto,
"ios": &utls.HelloIOS_Auto,