mirror of
https://gitclone.com/github.com/MetaCubeX/Clash.Meta
synced 2025-05-23 18:38:09 +08:00
29 lines
633 B
Go
29 lines
633 B
Go
package outbound
|
|
|
|
import (
|
|
"encoding/base64"
|
|
"fmt"
|
|
|
|
"github.com/metacubex/mihomo/component/ech"
|
|
)
|
|
|
|
type ECHOptions struct {
|
|
Enable bool `proxy:"enable,omitempty" obfs:"enable,omitempty"`
|
|
Config string `proxy:"config,omitempty" obfs:"config,omitempty"`
|
|
}
|
|
|
|
func (o ECHOptions) Parse() (*ech.Config, error) {
|
|
if !o.Enable {
|
|
return nil, nil
|
|
}
|
|
echConfig := &ech.Config{}
|
|
if o.Config != "" {
|
|
list, err := base64.StdEncoding.DecodeString(o.Config)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("base64 decode ech config string failed: %v", err)
|
|
}
|
|
echConfig.EncryptedClientHelloConfigList = list
|
|
}
|
|
return echConfig, nil
|
|
}
|