mirror of
https://github.com/lkddi/Xboard.git
synced 2026-04-24 03:57:27 +08:00
feat: Singbox、clash订阅增加绕过服务器地址规则
1、优化订阅下发代码 2、singbox、clash、meta订阅下发增加绕过服务器地址规则,防止重复代理
This commit is contained in:
+25
-16
@@ -129,25 +129,34 @@ class Helper
|
||||
}
|
||||
|
||||
/**
|
||||
* 替换字符串中的 [num1-num2] 格式为介于 num1 和 num2 之间的随机数字
|
||||
* 根据规则替换域名中对应的字符串
|
||||
*
|
||||
* @param string $input 用户输入的字符串
|
||||
* @return string 替换后的字符串
|
||||
*/
|
||||
public static function replaceRandomNumber($input) {
|
||||
// 匹配 [1-4999] 格式的正则表达式
|
||||
$pattern = '/\[(\d+)-(\d+)\]/';
|
||||
|
||||
// 使用 preg_replace_callback 替换匹配到的内容
|
||||
$result = preg_replace_callback($pattern, function ($matches) {
|
||||
// 提取最小和最大值
|
||||
$min = intval($matches[1]);
|
||||
$max = intval($matches[2]);
|
||||
// 生成随机数
|
||||
$randomNumber = rand($min, $max);
|
||||
return $randomNumber;
|
||||
}, $input);
|
||||
|
||||
return $result;
|
||||
public static function replaceByPattern($input)
|
||||
{
|
||||
$patterns = [
|
||||
'/\[(\d+)-(\d+)\]/' => function ($matches) {
|
||||
$min = intval($matches[1]);
|
||||
$max = intval($matches[2]);
|
||||
if ($min > $max) {
|
||||
list($min, $max) = [$max, $min];
|
||||
}
|
||||
$randomNumber = rand($min, $max);
|
||||
return $randomNumber;
|
||||
},
|
||||
'/\[uuid\]/' => function () {
|
||||
return self::guid(true);
|
||||
}
|
||||
];
|
||||
foreach ($patterns as $pattern => $callback) {
|
||||
$input = preg_replace_callback($pattern, $callback, $input);
|
||||
}
|
||||
return $input;
|
||||
}
|
||||
|
||||
public static function getIpByDomainName($domain) {
|
||||
return gethostbynamel($domain) ?: [];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user