diff --git a/frontend.html b/frontend.html index f2f45ad..c0cb168 100644 --- a/frontend.html +++ b/frontend.html @@ -36,79 +36,90 @@ href="https://sing-box.sagernet.org/installation/clients/sfa/">SFA,ios 版本的未测试。

在此页面粘贴由本工具生成的订阅链接(仅参数保存在链接内可用),可解析到下面的选项中

- - +
+ + +
+
- 配置文件模板 - - - -
-
- 自定义 urltest / selector -
- - + 更多设置 +
+
+ 配置文件模板 - - - -
- - - - - - - - - - - - - - - - - - - - -
tagtoleranceincludeexcludetype
{{ v.tag }}{{ v.tolerance }}{{ v.include }}{{ v.exclude }}{{ v.type }} - -
+ + +
+
+ 自定义 urltest / selector +
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + +
tagtoleranceincludeexcludetype
{{ v.tag }}{{ v.tolerance }}{{ v.include }}{{ v.exclude }}{{ v.type }} + +
+
- + @@ -131,6 +142,7 @@ const customTables = Vue.ref([]); const inFetch = Vue.ref(false) const inputRef = Vue.ref(null) + const addTag = Vue.ref(false) Vue.watch(saveType, v => { if (v) { @@ -175,6 +187,7 @@ configurl.value && subUrl.searchParams.set("configurl", configurl.value) include.value && subUrl.searchParams.set("include", include.value) exclude.value && subUrl.searchParams.set("exclude", exclude.value) + addTag.value && subUrl.searchParams.set("addTag", "true") subUrl.searchParams.set("sub", sub.value) return subUrl.toString() } @@ -197,6 +210,7 @@ "Config": c, "ConfigUrl": configurl.value, "UrlTest": customTables.value, + "AddTag": addTag.value, }) })).text() const subUrl = new URL(new URL(location.href).origin) @@ -298,7 +312,7 @@ include.value = u.searchParams.get("include") || include.value exclude.value = u.searchParams.get("exclude") || exclude.value sub.value = u.searchParams.get("sub") || sub.value - + addTag.value = u.searchParams.get("addTag") === "true" } catch (error) { console.log(error) return @@ -324,7 +338,8 @@ customTables, addUrlTables, inFetch, - inputRef + inputRef, + addTag } }, diff --git a/go.mod b/go.mod index 872dc8d..8ce416a 100644 --- a/go.mod +++ b/go.mod @@ -2,13 +2,11 @@ module github.com/xmdhs/clash2sfa go 1.21 -toolchain go1.21.0 - require ( github.com/samber/lo v1.38.1 - github.com/tidwall/gjson v1.16.0 + github.com/tidwall/gjson v1.17.0 github.com/tidwall/sjson v1.2.5 - github.com/xmdhs/clash2singbox v0.0.0-20230906141725-5eb3ac39d572 + github.com/xmdhs/clash2singbox v0.0.0-20230923074746-2ac2b5c4eda1 go.etcd.io/bbolt v1.3.7 lukechampine.com/blake3 v1.2.1 ) diff --git a/go.sum b/go.sum index 36fbe87..10cd6b2 100644 --- a/go.sum +++ b/go.sum @@ -11,6 +11,8 @@ github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o github.com/tidwall/gjson v1.14.2/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= github.com/tidwall/gjson v1.16.0 h1:SyXa+dsSPpUlcwEDuKuEBJEz5vzTvOea+9rjyYodQFg= github.com/tidwall/gjson v1.16.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= +github.com/tidwall/gjson v1.17.0 h1:/Jocvlh98kcTfpN2+JzGQWQcqrPQwDrVEMApx/M5ZwM= +github.com/tidwall/gjson v1.17.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA= github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM= github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= @@ -18,12 +20,14 @@ github.com/tidwall/pretty v1.2.1 h1:qjsOFOWWQl+N3RsoF5/ssm1pHmJJwhjlSbZ51I6wMl4= github.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= github.com/tidwall/sjson v1.2.5 h1:kLy8mja+1c9jlljvWTlSazM7cKDRfJuR/bOJhcY5NcY= github.com/tidwall/sjson v1.2.5/go.mod h1:Fvgq9kS/6ociJEDnK0Fk1cpYF4FIW6ZF7LAe+6jwd28= -github.com/xmdhs/clash2singbox v0.0.0-20230901181217-b2d94de8a5f3 h1:gQqCj8c+rfDzv3veF2lpxYGE3cv3xvhngdR8NBkArEg= -github.com/xmdhs/clash2singbox v0.0.0-20230901181217-b2d94de8a5f3/go.mod h1:LaCPpH9WkYgPzWSd8RIUHC5Mp0LYCV7LDmCx66VM1tE= -github.com/xmdhs/clash2singbox v0.0.0-20230906134934-d5af231d8b31 h1:18Z1g1FCkii18ciYPYbZ8dHjF1ks/uFovENHTL7XzYQ= -github.com/xmdhs/clash2singbox v0.0.0-20230906134934-d5af231d8b31/go.mod h1:LaCPpH9WkYgPzWSd8RIUHC5Mp0LYCV7LDmCx66VM1tE= github.com/xmdhs/clash2singbox v0.0.0-20230906141725-5eb3ac39d572 h1:YYGsvVa6m0fJVC0TX8sZSyv4vHuonUbEmscrQV0HzcM= github.com/xmdhs/clash2singbox v0.0.0-20230906141725-5eb3ac39d572/go.mod h1:LaCPpH9WkYgPzWSd8RIUHC5Mp0LYCV7LDmCx66VM1tE= +github.com/xmdhs/clash2singbox v0.0.0-20230923072355-f598ffe75395 h1:TwjDa2fyGgnwW+oPH7+EKdciT4fAMzab+NBuXtMzvPY= +github.com/xmdhs/clash2singbox v0.0.0-20230923072355-f598ffe75395/go.mod h1:s8ADgXev99az3CUg5BfuCx5pyvyUqUlqNfnlIEcMHP4= +github.com/xmdhs/clash2singbox v0.0.0-20230923074208-d4342b538b81 h1:fFVHq9cL7cfuOtfM9+VAh6XjC9vQrQH1Jf1BGxiaPrI= +github.com/xmdhs/clash2singbox v0.0.0-20230923074208-d4342b538b81/go.mod h1:s8ADgXev99az3CUg5BfuCx5pyvyUqUlqNfnlIEcMHP4= +github.com/xmdhs/clash2singbox v0.0.0-20230923074746-2ac2b5c4eda1 h1:hIUgda22rPxvWSWbDStKH1ZGb7ja9z8htkLf3cvmgMI= +github.com/xmdhs/clash2singbox v0.0.0-20230923074746-2ac2b5c4eda1/go.mod h1:s8ADgXev99az3CUg5BfuCx5pyvyUqUlqNfnlIEcMHP4= go.etcd.io/bbolt v1.3.7 h1:j+zJOnnEjF/kyHlDDgGnVL/AIqIJPq8UoB2GSNfkUfQ= go.etcd.io/bbolt v1.3.7/go.mod h1:N9Mkw9X8x5fupy0IKsmuqVtoGDyxsaDlbk4Rd05IAQw= golang.org/x/exp v0.0.0-20230817173708-d852ddb80c63 h1:m64FZMko/V45gv0bNmrNYoDEq8U5YUhetc9cBWKS1TQ= diff --git a/handle/handel.go b/handle/handel.go index 6c3f93d..9281603 100644 --- a/handle/handel.go +++ b/handle/handel.go @@ -61,12 +61,17 @@ func Sub(c *http.Client, db db.DB, frontendByte []byte, l *slog.Logger) http.Han include := r.FormValue("include") exclude := r.FormValue("exclude") urltest := r.FormValue("urltest") + addTag := r.FormValue("addTag") + addTagb := false if id == "" && sub == "" { l.DebugContext(ctx, "id 不得为空") http.Error(w, "id 不得为空", 400) return } + if addTag == "true" { + addTagb = true + } rc := http.NewResponseController(w) rc.SetWriteDeadline(time.Now().Add(1 * time.Minute)) @@ -87,6 +92,8 @@ func Sub(c *http.Client, db db.DB, frontendByte []byte, l *slog.Logger) http.Han Exclude: exclude, Config: config, ConfigUrl: curl, + AddTag: addTagb, + UrlTest: []model.UrlTestArg{}, } if urltest != "" { b, err := zlibDecode(urltest) diff --git a/model/arg.go b/model/arg.go index 6d98f4f..60fab8b 100644 --- a/model/arg.go +++ b/model/arg.go @@ -6,6 +6,7 @@ type ConvertArg struct { Exclude string Config string ConfigUrl string + AddTag bool UrlTest []UrlTestArg } diff --git a/service/arg.go b/service/arg.go index a52bc94..2bfe3cb 100644 --- a/service/arg.go +++ b/service/arg.go @@ -59,7 +59,7 @@ func MakeConfig(cxt context.Context, c *http.Client, frontendByte []byte, l *slo } arg.Config = string(b) } - b, err := convert2sing(cxt, c, arg.Config, arg.Sub, arg.Include, arg.Exclude, l) + b, err := convert2sing(cxt, c, arg.Config, arg.Sub, arg.Include, arg.Exclude, arg.AddTag, l) if err != nil { return nil, fmt.Errorf("MakeConfig: %w", err) } diff --git a/service/convert.go b/service/convert.go index acbec9e..7208055 100644 --- a/service/convert.go +++ b/service/convert.go @@ -13,8 +13,8 @@ import ( "github.com/xmdhs/clash2singbox/httputils" ) -func convert2sing(cxt context.Context, client *http.Client, config, sub string, include, exclude string, l *slog.Logger) ([]byte, error) { - c, err := httputils.GetClash(cxt, client, sub) +func convert2sing(cxt context.Context, client *http.Client, config, sub string, include, exclude string, addTag bool, l *slog.Logger) ([]byte, error) { + c, err := httputils.GetClash(cxt, client, sub, addTag) if err != nil { return nil, fmt.Errorf("convert2sing: %w", err) }