mirror of
https://gitclone.com/github.com/MetaCubeX/Clash.Meta
synced 2025-05-25 19:38:07 +08:00
chore: proxy's ech should fetch from proxy-nameserver
This commit is contained in:
parent
5a21bf3642
commit
b1d12a15db
@ -1,10 +1,12 @@
|
||||
package outbound
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/base64"
|
||||
"fmt"
|
||||
|
||||
"github.com/metacubex/mihomo/component/ech"
|
||||
"github.com/metacubex/mihomo/component/resolver"
|
||||
)
|
||||
|
||||
type ECHOptions struct {
|
||||
@ -22,7 +24,13 @@ func (o ECHOptions) Parse() (*ech.Config, error) {
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("base64 decode ech config string failed: %v", err)
|
||||
}
|
||||
echConfig.EncryptedClientHelloConfigList = list
|
||||
echConfig.GetEncryptedClientHelloConfigList = func(ctx context.Context, serverName string) ([]byte, error) {
|
||||
return list, nil
|
||||
}
|
||||
} else {
|
||||
echConfig.GetEncryptedClientHelloConfigList = func(ctx context.Context, serverName string) ([]byte, error) {
|
||||
return resolver.ResolveECHWithResolver(ctx, serverName, resolver.ProxyServerHostResolver)
|
||||
}
|
||||
}
|
||||
return echConfig, nil
|
||||
}
|
||||
|
@ -4,24 +4,20 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/metacubex/mihomo/component/resolver"
|
||||
tlsC "github.com/metacubex/mihomo/component/tls"
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
EncryptedClientHelloConfigList []byte
|
||||
GetEncryptedClientHelloConfigList func(ctx context.Context, serverName string) ([]byte, error)
|
||||
}
|
||||
|
||||
func (cfg *Config) ClientHandle(ctx context.Context, tlsConfig *tlsC.Config) (err error) {
|
||||
if cfg == nil {
|
||||
return nil
|
||||
}
|
||||
echConfigList := cfg.EncryptedClientHelloConfigList
|
||||
if len(echConfigList) == 0 {
|
||||
echConfigList, err = resolver.ResolveECH(ctx, tlsConfig.ServerName)
|
||||
if err != nil {
|
||||
return fmt.Errorf("resolve ECH config error: %w", err)
|
||||
}
|
||||
echConfigList, err := cfg.GetEncryptedClientHelloConfigList(ctx, tlsConfig.ServerName)
|
||||
if err != nil {
|
||||
return fmt.Errorf("resolve ECH config error: %w", err)
|
||||
}
|
||||
|
||||
tlsConfig.EncryptedClientHelloConfigList = echConfigList
|
||||
|
Loading…
Reference in New Issue
Block a user