chg: add more logs, add ip selector
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
|
||||
|
||||
2
go.mod
2
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
|
||||
|
||||
4
go.sum
4
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=
|
||||
|
||||
Reference in New Issue
Block a user