Skip to content

Commit

Permalink
允许禁用默认的 urltest 和 selector
Browse files Browse the repository at this point in the history
  • Loading branch information
xmdhs committed Nov 21, 2023
1 parent a5f5fda commit c469dc8
Show file tree
Hide file tree
Showing 10 changed files with 201 additions and 131 deletions.
11 changes: 10 additions & 1 deletion frontend.html
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@
<input type="checkbox" role="switch" v-model="checkbox">
配置文件模板直链
</label>
<label>
<input type="checkbox" role="switch" v-model="disableUrlTest">
禁用默认生成的 urltest 和 selector
</label>
<textarea style="resize: none;height: 25em;" v-model="config" v-show="!checkbox"></textarea>
<input v-model="configurl" v-show="checkbox" />
</details>
Expand Down Expand Up @@ -157,6 +161,7 @@
const inFetch = Vue.ref(false)
const inputRef = Vue.ref(null)
const addTag = Vue.ref(false)
const disableUrlTest = Vue.ref(false)

Vue.watch(saveType, v => {
if (v) {
Expand Down Expand Up @@ -202,6 +207,7 @@
include.value && subUrl.searchParams.set("include", include.value)
exclude.value && subUrl.searchParams.set("exclude", exclude.value)
addTag.value && subUrl.searchParams.set("addTag", "true")
disableUrlTest.value && subUrl.searchParams.set("disableUrlTest", "true")
subUrl.searchParams.set("sub", sub.value)
return subUrl.toString()
}
Expand All @@ -225,6 +231,7 @@
"ConfigUrl": configurl.value,
"UrlTest": customTables.value,
"AddTag": addTag.value,
"DisableUrlTest": disableUrlTest.value
})
})).text()
const subUrl = new URL(new URL(location.href).origin)
Expand Down Expand Up @@ -327,6 +334,7 @@
exclude.value = u.searchParams.get("exclude") || exclude.value
sub.value = u.searchParams.get("sub") || sub.value
addTag.value = u.searchParams.get("addTag") === "true"
disableUrlTest.value = u.searchParams.get("disableUrlTest") === "true"
} catch (error) {
console.log(error)
return
Expand All @@ -353,7 +361,8 @@
addUrlTables,
inFetch,
inputRef,
addTag
addTag,
disableUrlTest
}

},
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ go 1.21
require (
github.com/samber/lo v1.38.1
github.com/tidwall/gjson v1.17.0
github.com/tidwall/sjson v1.2.5
github.com/xmdhs/clash2singbox v0.0.3-0.20231119141103-4a5d4f125895
github.com/xmdhs/clash2singbox v0.0.3-0.20231121051635-553d9dd888b6
go.etcd.io/bbolt v1.3.8
lukechampine.com/blake3 v1.2.1
)

require (
github.com/klauspost/cpuid/v2 v2.2.5 // indirect
github.com/stretchr/testify v1.8.2 // indirect
github.com/tidwall/match v1.1.1 // indirect
github.com/tidwall/pretty v1.2.1 // indirect
golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa // indirect
Expand Down
50 changes: 13 additions & 37 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/klauspost/cpuid/v2 v2.2.5 h1:0E5MSMDEoAulmXNFquVs//DdoomxaoTY1kUhbc/qbZg=
Expand All @@ -6,61 +7,36 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/samber/lo v1.38.1 h1:j2XEAqXKb09Am4ebOg31SpvzUTTs6EN3VfgeLUhPdXM=
github.com/samber/lo v1.38.1/go.mod h1:+m/ZKRl6ClXCE2Lgf3MsQlWfh4bn1bz6CXEOxnEXnEA=
github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
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/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8=
github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
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=
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-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=
github.com/xmdhs/clash2singbox v0.0.0-20230927170528-0f49c5c998fd h1:enHnMUw+ftaaY920lWn5N9I1fqoFCqU0p1C3pOWp5y4=
github.com/xmdhs/clash2singbox v0.0.0-20230927170528-0f49c5c998fd/go.mod h1:B5pbJCwIHhJg6YRPCT04EXw6XXNIIOllMfL3XyJ7ob8=
github.com/xmdhs/clash2singbox v0.0.0-20230928093336-60167b4c3ff6 h1:zZglOS8Msi+UxqfM6umAkl79mays5woeGkXl1AYZq30=
github.com/xmdhs/clash2singbox v0.0.0-20230928093336-60167b4c3ff6/go.mod h1:B5pbJCwIHhJg6YRPCT04EXw6XXNIIOllMfL3XyJ7ob8=
github.com/xmdhs/clash2singbox v0.0.2-0.20231002081500-aed7ac734ca6 h1:5PTDYAXstG6ZSivaq6KLRBuJ4izIwDJtOuvbLuxV8J0=
github.com/xmdhs/clash2singbox v0.0.2-0.20231002081500-aed7ac734ca6/go.mod h1:B5pbJCwIHhJg6YRPCT04EXw6XXNIIOllMfL3XyJ7ob8=
github.com/xmdhs/clash2singbox v0.0.2-0.20231103093306-ac42daec4a48 h1:E4rnwCU0gBD4Cawms8x4m0b5a95BoHJTlCu3CYwD/P8=
github.com/xmdhs/clash2singbox v0.0.2-0.20231103093306-ac42daec4a48/go.mod h1:B5pbJCwIHhJg6YRPCT04EXw6XXNIIOllMfL3XyJ7ob8=
github.com/xmdhs/clash2singbox v0.0.2 h1:/gxaFm8fmv+UcUZzK508Z0yR01wg1LHrrq872Qibk1I=
github.com/xmdhs/clash2singbox v0.0.2/go.mod h1:B5pbJCwIHhJg6YRPCT04EXw6XXNIIOllMfL3XyJ7ob8=
github.com/xmdhs/clash2singbox v0.0.3-0.20231119140104-bdc170160707 h1:aABL1KcLLSVgMARhRId28oH35V6rzhP4CbLQCxZPEOw=
github.com/xmdhs/clash2singbox v0.0.3-0.20231119140104-bdc170160707/go.mod h1:u2kIEBN2r26EGFSdU7mTwCqz4XG2B7Cwq8U1dVn2IXI=
github.com/xmdhs/clash2singbox v0.0.3-0.20231119141103-4a5d4f125895 h1:TQVAJysHSY26pok1/ICn4lupVzAjgHqIVHvE0IVk8T8=
github.com/xmdhs/clash2singbox v0.0.3-0.20231119141103-4a5d4f125895/go.mod h1:u2kIEBN2r26EGFSdU7mTwCqz4XG2B7Cwq8U1dVn2IXI=
go.etcd.io/bbolt v1.3.7 h1:j+zJOnnEjF/kyHlDDgGnVL/AIqIJPq8UoB2GSNfkUfQ=
go.etcd.io/bbolt v1.3.7/go.mod h1:N9Mkw9X8x5fupy0IKsmuqVtoGDyxsaDlbk4Rd05IAQw=
github.com/xmdhs/clash2singbox v0.0.3-0.20231120164206-dd5575b45c7b h1:3Vxc6T2ADqaIjW/P1gC4LtVXEktUhi0VONaaRD19DCw=
github.com/xmdhs/clash2singbox v0.0.3-0.20231120164206-dd5575b45c7b/go.mod h1:u2kIEBN2r26EGFSdU7mTwCqz4XG2B7Cwq8U1dVn2IXI=
github.com/xmdhs/clash2singbox v0.0.3-0.20231121051635-553d9dd888b6 h1:9vNtC0LsvFVrNNqOcXIGJXYK6j49VHy5mLoB4FMhl8E=
github.com/xmdhs/clash2singbox v0.0.3-0.20231121051635-553d9dd888b6/go.mod h1:u2kIEBN2r26EGFSdU7mTwCqz4XG2B7Cwq8U1dVn2IXI=
go.etcd.io/bbolt v1.3.8 h1:xs88BrvEv273UsB79e0hcVrlUWmS0a8upikMFhSyAtA=
go.etcd.io/bbolt v1.3.8/go.mod h1:N9Mkw9X8x5fupy0IKsmuqVtoGDyxsaDlbk4Rd05IAQw=
golang.org/x/exp v0.0.0-20230817173708-d852ddb80c63 h1:m64FZMko/V45gv0bNmrNYoDEq8U5YUhetc9cBWKS1TQ=
golang.org/x/exp v0.0.0-20230817173708-d852ddb80c63/go.mod h1:0v4NqG35kSWCMzLaMeX+IQrlSnVE/bqGSyC2cz/9Le8=
golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa h1:FRnLl4eNAQl8hwxVVC17teOw8kdjVDVAiFMtgUdTSRQ=
golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa/go.mod h1:zk2irFbV9DP96SEBUUAy67IdHUaZuSnrz1n472HUCLE=
golang.org/x/sync v0.3.0 h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E=
golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y=
golang.org/x/sync v0.5.0 h1:60k92dhOjHxJkrqnwsfl8KuaHbn/5dl0lUPUklKo3qE=
golang.org/x/sync v0.5.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM=
golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.14.0 h1:Vz7Qs629MkJkGyHxUlRHizWJRG2j8fbQKjELVSNhy7Q=
golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
lukechampine.com/blake3 v1.2.1 h1:YuqqRuaqsGV71BV/nm9xlI0MKUv4QC54jQnBChWbGnI=
Expand Down
20 changes: 13 additions & 7 deletions handle/handel.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ func Sub(c *http.Client, db db.DB, frontendByte []byte, l *slog.Logger) http.Han
exclude := r.FormValue("exclude")
urltest := r.FormValue("urltest")
addTag := r.FormValue("addTag")
disableUrlTest := r.FormValue("disableUrlTest")
disableUrlTestb := false
addTagb := false

if id == "" && sub == "" {
Expand All @@ -72,6 +74,9 @@ func Sub(c *http.Client, db db.DB, frontendByte []byte, l *slog.Logger) http.Han
if addTag == "true" {
addTagb = true
}
if disableUrlTest == "true" {
disableUrlTestb = true
}

rc := http.NewResponseController(w)
rc.SetWriteDeadline(time.Now().Add(1 * time.Minute))
Expand All @@ -87,13 +92,14 @@ func Sub(c *http.Client, db db.DB, frontendByte []byte, l *slog.Logger) http.Han
}

a := model.ConvertArg{
Sub: sub,
Include: include,
Exclude: exclude,
Config: config,
ConfigUrl: curl,
AddTag: addTagb,
UrlTest: []model.UrlTestArg{},
Sub: sub,
Include: include,
Exclude: exclude,
Config: config,
ConfigUrl: curl,
AddTag: addTagb,
UrlTest: []model.UrlTestArg{},
DisableUrlTest: disableUrlTestb,
}
if urltest != "" {
b, err := zlibDecode(urltest)
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ var configByte []byte
var frontendByte []byte

func main() {
port := ":8080"
port := "127.0.0.1:8080"
if p := os.Getenv("port"); p != "" {
port = p
}
Expand Down
15 changes: 8 additions & 7 deletions model/arg.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package model

type ConvertArg struct {
Sub string
Include string
Exclude string
Config string
ConfigUrl string
AddTag bool
UrlTest []UrlTestArg
Sub string
Include string
Exclude string
Config string
ConfigUrl string
AddTag bool
UrlTest []UrlTestArg
DisableUrlTest bool
}

type UrlTestArg struct {
Expand Down
Loading

0 comments on commit c469dc8

Please sign in to comment.