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"
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user