File tree Expand file tree Collapse file tree 2 files changed +13
-9
lines changed Expand file tree Collapse file tree 2 files changed +13
-9
lines changed Original file line number Diff line number Diff line change 1
1
package outbound
2
2
3
3
import (
4
+ "context"
4
5
"encoding/base64"
5
6
"fmt"
6
7
7
8
"github.com/metacubex/mihomo/component/ech"
9
+ "github.com/metacubex/mihomo/component/resolver"
8
10
)
9
11
10
12
type ECHOptions struct {
@@ -22,7 +24,13 @@ func (o ECHOptions) Parse() (*ech.Config, error) {
22
24
if err != nil {
23
25
return nil , fmt .Errorf ("base64 decode ech config string failed: %v" , err )
24
26
}
25
- echConfig .EncryptedClientHelloConfigList = list
27
+ echConfig .GetEncryptedClientHelloConfigList = func (ctx context.Context , serverName string ) ([]byte , error ) {
28
+ return list , nil
29
+ }
30
+ } else {
31
+ echConfig .GetEncryptedClientHelloConfigList = func (ctx context.Context , serverName string ) ([]byte , error ) {
32
+ return resolver .ResolveECHWithResolver (ctx , serverName , resolver .ProxyServerHostResolver )
33
+ }
26
34
}
27
35
return echConfig , nil
28
36
}
Original file line number Diff line number Diff line change @@ -4,24 +4,20 @@ import (
4
4
"context"
5
5
"fmt"
6
6
7
- "github.com/metacubex/mihomo/component/resolver"
8
7
tlsC "github.com/metacubex/mihomo/component/tls"
9
8
)
10
9
11
10
type Config struct {
12
- EncryptedClientHelloConfigList []byte
11
+ GetEncryptedClientHelloConfigList func ( ctx context. Context , serverName string ) ( []byte , error )
13
12
}
14
13
15
14
func (cfg * Config ) ClientHandle (ctx context.Context , tlsConfig * tlsC.Config ) (err error ) {
16
15
if cfg == nil {
17
16
return nil
18
17
}
19
- echConfigList := cfg .EncryptedClientHelloConfigList
20
- if len (echConfigList ) == 0 {
21
- echConfigList , err = resolver .ResolveECH (ctx , tlsConfig .ServerName )
22
- if err != nil {
23
- return fmt .Errorf ("resolve ECH config error: %w" , err )
24
- }
18
+ echConfigList , err := cfg .GetEncryptedClientHelloConfigList (ctx , tlsConfig .ServerName )
19
+ if err != nil {
20
+ return fmt .Errorf ("resolve ECH config error: %w" , err )
25
21
}
26
22
27
23
tlsConfig .EncryptedClientHelloConfigList = echConfigList
You can’t perform that action at this time.
0 commit comments