Skip to content

Commit

Permalink
new: add custom url test and dns
Browse files Browse the repository at this point in the history
  • Loading branch information
x committed Dec 29, 2024
1 parent 55a70ff commit a22b99a
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 15 deletions.
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,10 @@ require (

replace github.com/sagernet/sing-box => github.com/hiddify/hiddify-sing-box v1.8.9-0.20241229165737-711ea7a9f7b2

replace github.com/xtls/xray-core => github.com/hiddify/xray-core v0.0.0-20241219203851-cd7ad9af63bd
replace github.com/xtls/xray-core => github.com/hiddify/xray-core v0.0.0-20241229214239-f398d912c726

replace github.com/sagernet/wireguard-go => github.com/hiddify/wireguard-go v0.0.0-20240727191222-383c1da14ff1

replace github.com/bepass-org/warp-plus => github.com/hiddify/warp-plus v0.0.0-20240717223357-4f3122e0d11d

replace github.com/hiddify/ray2sing => github.com/hiddify/ray2sing v0.0.0-20241219213739-113036bccaba
replace github.com/hiddify/ray2sing => github.com/hiddify/ray2sing v0.0.0-20241229214451-3fc92fa15e53
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -243,14 +243,14 @@ github.com/hectane/go-acl v0.0.0-20230122075934-ca0b05cb1adb h1:PGufWXXDq9yaev6x
github.com/hectane/go-acl v0.0.0-20230122075934-ca0b05cb1adb/go.mod h1:QiyDdbZLaJ/mZP4Zwc9g2QsfaEA4o7XvvgZegSci5/E=
github.com/hiddify/hiddify-sing-box v1.8.9-0.20241229165737-711ea7a9f7b2 h1:ofbqvCRR39WDY/5Q+Hpr04ZP+YUqAwzchlkkLOs59V8=
github.com/hiddify/hiddify-sing-box v1.8.9-0.20241229165737-711ea7a9f7b2/go.mod h1:u16dzx+T4FD39c223mKWT0H0mcHhVRpQaBlN34dPXMk=
github.com/hiddify/ray2sing v0.0.0-20241219213739-113036bccaba h1:q28rvz9DROJ6P07DlLbSx6cxR00lVp2GYuSCn3WDrpU=
github.com/hiddify/ray2sing v0.0.0-20241219213739-113036bccaba/go.mod h1:soYE48y/Q2HtgRFpcX6LcekVyigy7IELYw4fmIGwLSA=
github.com/hiddify/ray2sing v0.0.0-20241229214451-3fc92fa15e53 h1:zarihBuE+gyDGr07eaDBugJ1ZbiUkH0fad88Pg5AzMQ=
github.com/hiddify/ray2sing v0.0.0-20241229214451-3fc92fa15e53/go.mod h1:S23JGf2Oj7a3sfg42ycDTLIqaPLmymEnMPnV4szxCvU=
github.com/hiddify/warp-plus v0.0.0-20240717223357-4f3122e0d11d h1:vRGKh9ou+/vQGfVYa8MczhbIVjHxlP52OWwrDWO77RA=
github.com/hiddify/warp-plus v0.0.0-20240717223357-4f3122e0d11d/go.mod h1:uSRUbr1CcvFrEV69FTvuJFwpzEmwO8N4knb6+Zq3Ys4=
github.com/hiddify/wireguard-go v0.0.0-20240727191222-383c1da14ff1 h1:xdbHlZtzs+jijAxy85qal835GglwmjohA/srHT8gm9s=
github.com/hiddify/wireguard-go v0.0.0-20240727191222-383c1da14ff1/go.mod h1:K4J7/npM+VAMUeUmTa2JaA02JmyheP0GpRBOUvn3ecc=
github.com/hiddify/xray-core v0.0.0-20241219203851-cd7ad9af63bd h1:YSbH/Rm6SEdhmSfGVnrTuHJ3+wWokxD19PxTUeFt2mk=
github.com/hiddify/xray-core v0.0.0-20241219203851-cd7ad9af63bd/go.mod h1:CgrkWZfvA/aGJkyL4OOxlvnStf5wRHMvm8nDCUWcd08=
github.com/hiddify/xray-core v0.0.0-20241229214239-f398d912c726 h1:Pbs5hPlunfy2Uoi0shB9rd5uykgT5XUcPw6mFx9LMgM=
github.com/hiddify/xray-core v0.0.0-20241229214239-f398d912c726/go.mod h1:CgrkWZfvA/aGJkyL4OOxlvnStf5wRHMvm8nDCUWcd08=
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
github.com/hudl/fargo v1.3.0/go.mod h1:y3CKSmjA+wD2gak7sUSXTAoopbhU08POFhmITJgmKTg=
github.com/imkira/go-observer/v2 v2.0.0-20230629064422-8e0b61f11f1b h1:1+115FqGoS8p6Iry9AYmrcWDvSveH0F7P2nX1LU00qg=
Expand Down
27 changes: 19 additions & 8 deletions v2/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ const (
DNSFakeTag = "dns-fake"
DNSTricksDirectTag = "dns-trick-direct"

OutboundDirectTag = "direct"
OutboundBypassTag = "bypass"
OutboundBlockTag = "block"
OutboundDirectTag = "direct §hide§"
OutboundBypassTag = "bypass §hide§"
OutboundBlockTag = "block §hide§"
OutboundSelectTag = "select"
OutboundURLTestTag = "auto"
OutboundDNSTag = "dns-out"
OutboundDirectFragmentTag = "direct-fragment"
OutboundDNSTag = "dns-out §hide§"
OutboundDirectFragmentTag = "direct-fragment §hide§"

InboundTUNTag = "tun-in"
InboundMixedTag = "mixed-in"
Expand Down Expand Up @@ -141,7 +141,7 @@ func setOutbounds(options *option.Options, input *option.Options, opt *HiddifyOp
out = *outbound

switch out.Type {
case C.TypeDirect, C.TypeBlock, C.TypeDNS:
case C.TypeBlock, C.TypeDNS:
continue
case C.TypeSelector, C.TypeURLTest:
continue
Expand All @@ -159,14 +159,17 @@ func setOutbounds(options *option.Options, input *option.Options, opt *HiddifyOp

}
}

testurls := []string{"http://captive.apple.com/generate_204", "https://cp.cloudflare.com", "https://google.com/generate_204"}
if isBlockedConnectionTestUrl(opt.ConnectionTestUrl) {
testurls = []string{}
}
urlTest := option.Outbound{
Type: C.TypeURLTest,
Tag: OutboundURLTestTag,
URLTestOptions: option.URLTestOutboundOptions{
Outbounds: tags,
URL: opt.ConnectionTestUrl,
URLs: []string{"http://captive.apple.com/generate_204", "https://cp.cloudflare.com", "https://google.com/generate_204"},
URLs: testurls,
Interval: option.Duration(opt.URLTestInterval.Duration()),
// IdleTimeout: option.Duration(opt.URLTestIdleTimeout.Duration()),
Tolerance: 1,
Expand Down Expand Up @@ -232,6 +235,14 @@ func setOutbounds(options *option.Options, input *option.Options, opt *HiddifyOp
return nil
}

func isBlockedConnectionTestUrl(d string) bool {
u, err := url.Parse(d)
if err != nil {
return false
}
return isBlockedDomain(u.Host)
}

func setClashAPI(options *option.Options, opt *HiddifyOptions) {
if opt.EnableClashApi {
if opt.ClashApiSecret == "" {
Expand Down
2 changes: 1 addition & 1 deletion v2/extension/server/run_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func StartTestExtensionServer() {
Secret: "",
Debug: false,
Mode: hcore.SetupMode_OLD,
})
}, nil)
StartExtensionServer()
}

Expand Down

0 comments on commit a22b99a

Please sign in to comment.