Add ech_config options

This commit is contained in:
Safa Safari 2023-05-06 22:47:13 +03:30
parent e02317a348
commit 314edaa170
4 changed files with 11 additions and 5 deletions

View File

@ -14,7 +14,7 @@ import (
cftls "github.com/sagernet/cloudflare-tls"
"github.com/sagernet/sing-box/adapter"
"github.com/sagernet/sing-box/option"
"github.com/sagernet/sing-dns"
dns "github.com/sagernet/sing-dns"
E "github.com/sagernet/sing/common/exceptions"
mDNS "github.com/miekg/dns"
@ -179,13 +179,16 @@ func NewECHClient(router adapter.Router, serverAddress string, options option.Ou
}
tlsConfig.ClientECHConfigs = clientConfig
} else {
tlsConfig.GetClientECHConfigs = fetchECHClientConfig(router)
tlsConfig.GetClientECHConfigs = fetchECHClientConfig(router, options.ECH.EchDomain)
}
return &ECHClientConfig{&tlsConfig}, nil
}
func fetchECHClientConfig(router adapter.Router) func(ctx context.Context, serverName string) ([]cftls.ECHConfig, error) {
func fetchECHClientConfig(router adapter.Router, EchDomain string) func(ctx context.Context, serverName string) ([]cftls.ECHConfig, error) {
return func(ctx context.Context, serverName string) ([]cftls.ECHConfig, error) {
if EchDomain != "" {
serverName = EchDomain
}
message := &mDNS.Msg{
MsgHdr: mDNS.MsgHdr{
RecursionDesired: true,

View File

@ -62,7 +62,8 @@
"enabled": false,
"pq_signature_schemes_enabled": false,
"dynamic_record_sizing_disabled": false,
"config": ""
"config": "",
"ech_domain": ""
},
"utls": {
"enabled": false,

View File

@ -62,7 +62,8 @@
"enabled": false,
"pq_signature_schemes_enabled": false,
"dynamic_record_sizing_disabled": false,
"config": ""
"config": "",
"ech_domain": ""
},
"utls": {
"enabled": false,

View File

@ -50,6 +50,7 @@ type OutboundECHOptions struct {
PQSignatureSchemesEnabled bool `json:"pq_signature_schemes_enabled,omitempty"`
DynamicRecordSizingDisabled bool `json:"dynamic_record_sizing_disabled,omitempty"`
Config string `json:"config,omitempty"`
EchDomain string `json:"ech_domain,omitempty"`
}
type OutboundUTLSOptions struct {