diff --git a/.gitignore b/.gitignore index 9c505bf..00b5f63 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,5 @@ logs data .env .vscode/settings.json -test \ No newline at end of file +test +*test.go \ No newline at end of file diff --git a/api/static/index.js b/api/static/index.js index 35bc1f1..575e48e 100644 --- a/api/static/index.js +++ b/api/static/index.js @@ -179,6 +179,10 @@ async function parseInputURL() { let hash = url.pathname.substring(url.pathname.lastIndexOf("/s/") + 3); let q = new URLSearchParams(); let password = url.searchParams.get("password"); + if (password === null) { + alert("仅可解析加密短链"); + return; + } q.append("hash", hash); q.append("password", password); try { diff --git a/parser/hysteria2.go b/parser/hysteria2.go index 2eb07ae..33a7d9e 100644 --- a/parser/hysteria2.go +++ b/parser/hysteria2.go @@ -72,6 +72,14 @@ func ParseHysteria2(proxy string) (model.Proxy, error) { enableTLS := pinSHA256 != "" insecureBool := insecure == "1" + if remarks == "" { + remarksIndex := strings.LastIndex(proxy, "#") + if remarksIndex != -1 { + remarks = proxy[remarksIndex:] + remarks, _ = url.QueryUnescape(remarks) + } + } + result := model.Proxy{ Type: "hysteria2", Name: remarks,