mirror of
https://github.com/nitezs/sub2clash.git
synced 2024-12-23 13:44:42 -05:00
fix: hy2 解析缺少 name 字段
This commit is contained in:
parent
faaf5c366a
commit
aa9e102a81
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,7 +1,6 @@
|
||||
.idea
|
||||
dist
|
||||
subs
|
||||
test
|
||||
logs
|
||||
sub2clash.db
|
||||
.env
|
||||
|
@ -38,6 +38,8 @@ func ParseHysteria2(proxy string) (model.Proxy, error) {
|
||||
if strings.Contains(proxy, "#") {
|
||||
splitResult := strings.Split(proxy, "#")
|
||||
name, _ = url.QueryUnescape(splitResult[len(splitResult)-1])
|
||||
} else {
|
||||
name = strings.Join(serverAndPort, ":")
|
||||
}
|
||||
// 返回结果
|
||||
result := model.Proxy{
|
||||
|
22
test/parser_test.go
Normal file
22
test/parser_test.go
Normal file
@ -0,0 +1,22 @@
|
||||
package test
|
||||
|
||||
import (
|
||||
"sub2clash/parser"
|
||||
"testing"
|
||||
|
||||
"gopkg.in/yaml.v3"
|
||||
)
|
||||
|
||||
func TestHy2Parser(t *testing.T) {
|
||||
res, err := parser.ParseHysteria2("hysteria2://letmein@example.com/?insecure=1&obfs=salamander&obfs-password=gawrgura&pinSHA256=deadbeef&sni=real.example.com")
|
||||
if err != nil {
|
||||
t.Log(err.Error())
|
||||
t.Fail()
|
||||
}
|
||||
bytes, err := yaml.Marshal(res)
|
||||
if err != nil {
|
||||
t.Log(err.Error())
|
||||
t.Fail()
|
||||
}
|
||||
t.Log(string(bytes))
|
||||
}
|
Loading…
Reference in New Issue
Block a user