diff --git a/config/outbound.go b/config/outbound.go index 2417429..658229d 100644 --- a/config/outbound.go +++ b/config/outbound.go @@ -3,7 +3,9 @@ package config import ( "encoding/json" "fmt" + "math/rand" "net" + "strings" C "github.com/sagernet/sing-box/constant" "github.com/sagernet/sing-box/option" @@ -168,8 +170,11 @@ func patchOutbound(base option.Outbound, configOpt ConfigOptions) (*option.Outbo func patchWarp(base *option.Outbound) error { if base.Type == C.TypeWireGuard { - host := base.WireGuardOptions.Server - if host == "default" || host == "random" || host == "auto" { + splt := strings.Split(base.WireGuardOptions.Server, "*") + host := splt[rand.Intn(len(splt))] + base.WireGuardOptions.Server = host + fmt.Printf("Selected Host is:%s\n", host) + if host == "default" || host == "random" || host == "auto" || isBlockedDomain(host) { base.WireGuardOptions.Server = getRandomIP() } if base.WireGuardOptions.ServerPort == 0 { diff --git a/config/parser.go b/config/parser.go index 0d86449..37d2cdf 100644 --- a/config/parser.go +++ b/config/parser.go @@ -82,7 +82,7 @@ func patchConfig(content []byte, name string) ([]byte, error) { if err != nil { return nil, fmt.Errorf("[SingboxParser] unmarshal error: %w", err) } - b, _ := batch.New(context.Background(), batch.WithConcurrencyNum[*option.Outbound](10)) + b, _ := batch.New(context.Background(), batch.WithConcurrencyNum[*option.Outbound](2)) for _, base := range options.Outbounds { out := base b.Go(base.Tag, func() (*option.Outbound, error) { diff --git a/config/warp.go b/config/warp.go index 6ae5fa1..f5b6016 100644 --- a/config/warp.go +++ b/config/warp.go @@ -102,7 +102,7 @@ func generateWarp(license string, host string, port uint16, fakePackets string, } func generateWarpSingbox(wgConfig warp.WireguardConfig, host string, port uint16, fakePackets string, fakePacketsSize string, fakePacketsDelay string) (*T.Outbound, error) { - if host == "" || isBlockedDomain(host) { + if host == "" { host = "auto" } diff --git a/go.mod b/go.mod index 7b771dc..3e12612 100644 --- a/go.mod +++ b/go.mod @@ -109,4 +109,4 @@ replace github.com/sagernet/sing-box => github.com/hiddify/hiddify-sing-box v1.8 replace github.com/sagernet/wireguard-go => github.com/hiddify/wireguard-go v0.0.0-20240214142457-fadc619f4357 -replace github.com/bepass-org/wireguard-go => github.com/hiddify-com/wireguard-go v0.0.2-alpha.0.20240215114454-3acea56c88fc +replace github.com/bepass-org/wireguard-go => github.com/hiddify-com/wireguard-go v0.0.2-alpha.0.20240220074702-29dc5459810f diff --git a/go.sum b/go.sum index 542cf26..e6c57cc 100644 --- a/go.sum +++ b/go.sum @@ -51,8 +51,8 @@ github.com/google/pprof v0.0.0-20231101202521-4ca4178f5c7a h1:fEBsGL/sjAuJrgah5X github.com/google/pprof v0.0.0-20231101202521-4ca4178f5c7a/go.mod h1:czg5+yv1E0ZGTi6S6vVK1mke0fV+FaUhNGcd6VRS9Ik= github.com/hashicorp/yamux v0.1.1 h1:yrQxtgseBDrq9Y652vSRDvsKCJKOUD+GzTS4Y0Y8pvE= github.com/hashicorp/yamux v0.1.1/go.mod h1:CtWFDAQgb7dxtzFs4tWbplKIe2jSi3+5vKbgIO0SLnQ= -github.com/hiddify-com/wireguard-go v0.0.2-alpha.0.20240215114454-3acea56c88fc h1:7Nbu6wraBxlYZzBCcacGwMP8iv1cxbToFRLDeZgajdo= -github.com/hiddify-com/wireguard-go v0.0.2-alpha.0.20240215114454-3acea56c88fc/go.mod h1:E1qZQpw2IrbRtFpTloTHGfJ2bJc4ZpZRNS497Eq5jCo= +github.com/hiddify-com/wireguard-go v0.0.2-alpha.0.20240220074702-29dc5459810f h1:h9Vsu3eALcx5il3kYVTTZ/la6znEXLrBMJtkRWuUZ+M= +github.com/hiddify-com/wireguard-go v0.0.2-alpha.0.20240220074702-29dc5459810f/go.mod h1:E1qZQpw2IrbRtFpTloTHGfJ2bJc4ZpZRNS497Eq5jCo= github.com/hiddify/hiddify-sing-box v1.8.6-0.20240219213330-bd64e4e35e00 h1:ff/d4hMZTQv0DNAIr6Oiov4juvLjzazvGPvTimNeCpo= github.com/hiddify/hiddify-sing-box v1.8.6-0.20240219213330-bd64e4e35e00/go.mod h1:usnCk4Fbp/3HAJ+b7LnogPP7x4En2Kc4ujNlnDsi1Sc= github.com/hiddify/ray2sing v0.0.0-20240213091709-ba1d827e4f4a h1:ObxmZ8AyhIxtH2Vu+vmDAsxsbsTPGq9pJzcY0V+3BCU=