new: configurable warp noise parameters, fix stopping issues

This commit is contained in:
Hiddify
2024-02-13 16:52:58 +01:00
parent a1314d84a9
commit 313b9a9adb
7 changed files with 40 additions and 20 deletions

View File

@@ -182,7 +182,9 @@ func patchWarp(base *option.Outbound) error {
port, _ := warp["port"].(float64)
detour, _ := warp["detour"].(string)
fakePackets, _ := warp["fake_packets"].(string)
warpConfig, err := generateWarp(key, host, uint16(port), fakePackets)
fakePacketsSize, _ := warp["fake_packets_size"].(string)
fakePacketsDelay, _ := warp["fake_packets_delay"].(string)
warpConfig, err := generateWarp(key, host, uint16(port), fakePackets, fakePacketsSize, fakePacketsDelay)
if err != nil {
fmt.Printf("Error generating warp config: %v", err)
return err

View File

@@ -155,7 +155,7 @@ func generateRandomPort() uint16 {
return warpPorts[rand.Intn(len(warpPorts))]
}
func generateWarp(license string, host string, port uint16, fakePackets string) (*T.Outbound, error) {
func generateWarp(license string, host string, port uint16, fakePackets string, fakePacketsSize string, fakePacketsDelay string) (*T.Outbound, error) {
if host == "" || isBlockedDomain(host) {
host = "auto"
}
@@ -163,6 +163,13 @@ func generateWarp(license string, host string, port uint16, fakePackets string)
if host == "auto" && fakePackets == "" {
fakePackets = "8-15"
}
if fakePackets != "" && fakePacketsSize == "" {
fakePacketsSize = "40-100"
}
if fakePackets != "" && fakePacketsDelay == "" {
fakePacketsDelay = "200-500"
}
// warp.UpdatePath("./secondary")
if _, err := os.Stat("./wgcf-identity.json"); err == nil {
os.Remove("./wgcf-identity.json")
@@ -185,6 +192,8 @@ func generateWarp(license string, host string, port uint16, fakePackets string)
singboxConfig, err := wireGuardToSingbox(wgConfig, host, port)
singboxConfig.WireGuardOptions.FakePackets = fakePackets
singboxConfig.WireGuardOptions.FakePacketsSize = fakePacketsSize
singboxConfig.WireGuardOptions.FakePacketsDelay = fakePacketsDelay
singboxJSON, err := json.MarshalIndent(singboxConfig, "", " ")
if err != nil {
fmt.Println("Error marshaling Singbox configuration:", err)