diff --git a/cmd/cmd_warp.go b/cmd/cmd_warp.go index f2d20381..e7437b70 100644 --- a/cmd/cmd_warp.go +++ b/cmd/cmd_warp.go @@ -147,10 +147,9 @@ func parsePeerConfig(peerConfig *PeerConfig, line string) { } func generateWarp() *T.Outbound { license := "" - endpoint := "engage.cloudflareclient.com:2408" if !warp.CheckProfileExists(license) { - warp.LoadOrCreateIdentity(license, endpoint) + warp.LoadOrCreateIdentity(license) } wgConfig, err := readWireGuardConfig("wgcf-profile.ini") diff --git a/config/outbound.go b/config/outbound.go index 528def8c..f23258f2 100644 --- a/config/outbound.go +++ b/config/outbound.go @@ -148,7 +148,7 @@ func patchWarp(base *option.Outbound) error { host, _ := warp["host"].(string) port, _ := warp["port"].(float64) fakePackets, _ := warp["fake_packets"].(string) - warpConfig, err := generateWarp(key, host, uint16(port)) + warpConfig, err := generateWarp(key, host, uint16(port), fakePackets) if err != nil { fmt.Printf("Error generating warp config: %v", err) return err @@ -156,7 +156,6 @@ func patchWarp(base *option.Outbound) error { base.Type = C.TypeWireGuard base.WireGuardOptions = warpConfig.WireGuardOptions - base.WireGuardOptions.FakePackets = fakePackets } diff --git a/config/warp.go b/config/warp.go index 9f7f6f4b..80e57133 100644 --- a/config/warp.go +++ b/config/warp.go @@ -146,7 +146,7 @@ func getRandomIP() string { ip, err := warp.RandomIPFromRange(randomRange) if err == nil { - ip.String() + return ip.String() } return "engage.cloudflareclient.com" } @@ -155,10 +155,13 @@ func generateRandomPort() uint16 { return warpPorts[rand.Intn(len(warpPorts))] } -func generateWarp(license string, host string, port uint16) (*T.Outbound, error) { +func generateWarp(license string, host string, port uint16, fakePackets string) (*T.Outbound, error) { if host == "" { host = "auto" } + if host == "auto" && fakePackets == "" { + fakePackets = "5-10" + } if host == "default" || host == "random" || host == "auto" { host = getRandomIP() } @@ -181,9 +184,8 @@ func generateWarp(license string, host string, port uint16) (*T.Outbound, error) } // fmt.Printf("%v", wgConfig) singboxConfig, err := wireGuardToSingbox(wgConfig, host, port) - if host == "auto" && singboxConfig.WireGuardOptions.FakePackets == "" { - singboxConfig.WireGuardOptions.FakePackets = "5-10" - } + + singboxConfig.WireGuardOptions.FakePackets = fakePackets singboxJSON, err := json.MarshalIndent(singboxConfig, "", " ") if err != nil { fmt.Println("Error marshaling Singbox configuration:", err) diff --git a/go.mod b/go.mod index ec1867c4..2fa4a1d1 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/hiddify/libcore go 1.21.5 require ( - github.com/hiddify/ray2sing v0.0.0-20240126122154-854054f22383 + github.com/hiddify/ray2sing v0.0.0-20240126124612-8e00e77ec754 github.com/sagernet/gomobile v0.1.1 github.com/sagernet/sing v0.3.0 github.com/sagernet/sing-box v1.8.2 diff --git a/go.sum b/go.sum index 49f5dcec..61b8b5ca 100644 --- a/go.sum +++ b/go.sum @@ -51,8 +51,8 @@ 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/hiddify-sing-box v1.7.9-0.20240125210314-493067cd2d66 h1:1soOFv4mdCq9OiRN4eo4B0ylDY1EeSnl0M7szOTYNz4= github.com/hiddify/hiddify-sing-box v1.7.9-0.20240125210314-493067cd2d66/go.mod h1:DnlHl/vlinL9Mn95+qJ3RzgE3E/9pWlAvTsauo7F5HM= -github.com/hiddify/ray2sing v0.0.0-20240126122154-854054f22383 h1:yFWzs/DLEXpcdXaVFFEQBHz2Q6XQ+j/IqXC/Qzm7dGw= -github.com/hiddify/ray2sing v0.0.0-20240126122154-854054f22383/go.mod h1:zYKnf7EoPqrk7JOMO9BApTXxfH0sva8AKfoFywN7uuA= +github.com/hiddify/ray2sing v0.0.0-20240126124612-8e00e77ec754 h1:OS1xPGAR34zQ2btXGa2ZVpI0nXQnkB6meI1hXkQvgJM= +github.com/hiddify/ray2sing v0.0.0-20240126124612-8e00e77ec754/go.mod h1:zYKnf7EoPqrk7JOMO9BApTXxfH0sva8AKfoFywN7uuA= github.com/hiddify/wireguard-go v0.0.0-20240125143346-481d18d77fe1 h1:neOb+wzHbWLNZ2sHFEV4+GTuqORO7/MndQLFW8FjUY8= github.com/hiddify/wireguard-go v0.0.0-20240125143346-481d18d77fe1/go.mod h1:K4J7/npM+VAMUeUmTa2JaA02JmyheP0GpRBOUvn3ecc= github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=