From 2ee6c3392bfd4d130d567935c88bca3460b574d0 Mon Sep 17 00:00:00 2001 From: mercury Date: Wed, 26 Nov 2025 00:50:43 +0400 Subject: [PATCH] ability to add IPs and subnets to warplist --- app/bot.php | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/app/bot.php b/app/bot.php index 9c8614e..47601d5 100644 --- a/app/bot.php +++ b/app/bot.php @@ -2924,7 +2924,28 @@ DNS-over-HTTPS with IP: $rules[] = [ "type" => "field", "outboundTag" => "warp", - "domain" => array_keys(array_filter($c['warplist'])), + "domain" => array_keys(array_filter($c['warplist'], function ($v, $k){ + if (!empty($v)) { + if (!preg_match('~^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}(/\d{1,2})?$~', $k)) { + return true; + } + } + return false; + }, ARRAY_FILTER_USE_BOTH)), + ]; + } + if (!empty($c['warplist']) && !empty(array_filter($c['warplist']))) { + $rules[] = [ + "type" => "field", + "outboundTag" => "warp", + "ip" => array_keys(array_filter($c['warplist'], function ($v, $k){ + if (!empty($v)) { + if (preg_match('~^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}(/\d{1,2})?$~', $k)) { + return true; + } + } + return false; + }, ARRAY_FILTER_USE_BOTH)), ]; } $xr['routing']['rules'] = $rules ?: [];