mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2026-03-04 04:47:30 +00:00
chore: add echparser package for parse ECHConfigList and ECHConfig
This commit is contained in:
30
component/ech/key_test.go
Normal file
30
component/ech/key_test.go
Normal file
@@ -0,0 +1,30 @@
|
||||
package ech
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"testing"
|
||||
|
||||
"github.com/metacubex/mihomo/component/ech/echparser"
|
||||
)
|
||||
|
||||
func TestGenECHConfig(t *testing.T) {
|
||||
domain := "www.example.com"
|
||||
configBase64, _, err := GenECHConfig(domain)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
echConfigList, err := base64.StdEncoding.DecodeString(configBase64)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
echConfigs, err := echparser.ParseECHConfigList(echConfigList)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
if len(echConfigs) == 0 {
|
||||
t.Error("no ech config")
|
||||
}
|
||||
if publicName := string(echConfigs[0].PublicName); publicName != domain {
|
||||
t.Error("ech config domain error, expect ", domain, " got", publicName)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user