mirror of
https://github.com/v2board/v2board.git
synced 2025-01-10 16:19:10 +08:00
update: clash regex
This commit is contained in:
parent
2b698b63e0
commit
90f9c181a0
@ -55,17 +55,18 @@ class Clash
|
|||||||
$isFilter = false;
|
$isFilter = false;
|
||||||
foreach ($config['proxy-groups'][$k]['proxies'] as $src) {
|
foreach ($config['proxy-groups'][$k]['proxies'] as $src) {
|
||||||
foreach ($proxies as $dst) {
|
foreach ($proxies as $dst) {
|
||||||
if ($this->isMatch($src, $dst)) {
|
if (!$this->isRegex($src)) continue;
|
||||||
$isFilter = true;
|
$isFilter = true;
|
||||||
$config['proxy-groups'][$k]['proxies'] = array_diff($config['proxy-groups'][$k]['proxies'], [$src]);
|
$config['proxy-groups'][$k]['proxies'] = array_values(array_diff($config['proxy-groups'][$k]['proxies'], [$src]));
|
||||||
|
if ($this->isMatch($src, $dst)) {
|
||||||
array_push($config['proxy-groups'][$k]['proxies'], $dst);
|
array_push($config['proxy-groups'][$k]['proxies'], $dst);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if ($isFilter) continue;
|
||||||
}
|
}
|
||||||
if (!$isFilter) {
|
if ($isFilter) continue;
|
||||||
$config['proxy-groups'][$k]['proxies'] = array_merge($config['proxy-groups'][$k]['proxies'], $proxies);
|
$config['proxy-groups'][$k]['proxies'] = array_merge($config['proxy-groups'][$k]['proxies'], $proxies);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
// Force the current subscription domain to be a direct rule
|
// Force the current subscription domain to be a direct rule
|
||||||
$subsDomain = $_SERVER['SERVER_NAME'];
|
$subsDomain = $_SERVER['SERVER_NAME'];
|
||||||
$subsDomainRule = "DOMAIN,{$subsDomain},DIRECT";
|
$subsDomainRule = "DOMAIN,{$subsDomain},DIRECT";
|
||||||
@ -155,10 +156,11 @@ class Clash
|
|||||||
|
|
||||||
private function isMatch($exp, $str)
|
private function isMatch($exp, $str)
|
||||||
{
|
{
|
||||||
try {
|
return @preg_match($exp, $str);
|
||||||
return preg_match($exp, $str);
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function isRegex($exp)
|
||||||
|
{
|
||||||
|
return @preg_match($exp, null) !== false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
2
resources/rules/.gitignore
vendored
2
resources/rules/.gitignore
vendored
@ -1 +1 @@
|
|||||||
custom.clash.yaml
|
custom.*
|
||||||
|
Loading…
Reference in New Issue
Block a user