From 1a8b29aad3547949d74494ba4a12fb2e39613363 Mon Sep 17 00:00:00 2001 From: Surbiks Date: Sun, 8 Feb 2026 09:19:10 +0330 Subject: [PATCH] use no kernel tun for conflict errors --- web/service/outbound.go | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/web/service/outbound.go b/web/service/outbound.go index 7b86debd..7267e61c 100644 --- a/web/service/outbound.go +++ b/web/service/outbound.go @@ -238,8 +238,24 @@ func (s *OutboundService) createTestConfig(outboundTag string, allOutbounds []in Settings: json_util.RawMessage(`{"auth":"noauth","udp":true}`), } - // Outbounds: copy all as-is, no tag or structure changes - outboundsJSON, _ := json.Marshal(allOutbounds) + // Outbounds: copy all, but set noKernelTun=true for WireGuard outbounds + processedOutbounds := make([]interface{}, len(allOutbounds)) + for i, ob := range allOutbounds { + outbound := ob.(map[string]interface{}) + if protocol, ok := outbound["protocol"].(string); ok && protocol == "wireguard" { + // Set noKernelTun to true for WireGuard outbounds + if settings, ok := outbound["settings"].(map[string]interface{}); ok { + settings["noKernelTun"] = true + } else { + // Create settings if it doesn't exist + outbound["settings"] = map[string]interface{}{ + "noKernelTun": true, + } + } + } + processedOutbounds[i] = outbound + } + outboundsJSON, _ := json.Marshal(processedOutbounds) // Create routing rule to route all traffic through test outbound routingRules := []map[string]interface{}{