mirror of
https://github.com/v2board/v2board.git
synced 2025-07-04 19:13:21 +08:00
Insert Matched Proxies While Preserving Array Order
The matched proxies are now inserted in place of the search parameters, while maintaining the original order of the entire array. This ensures that the structure of the proxy list remains consistent and predictable.
This commit is contained in:
24
app/Http/Controllers/Client/Protocols/Clash.php
Normal file → Executable file
24
app/Http/Controllers/Client/Protocols/Clash.php
Normal file → Executable file
@ -62,20 +62,22 @@ class Clash
|
||||
$config['proxies'] = array_merge($config['proxies'] ? $config['proxies'] : [], $proxy);
|
||||
foreach ($config['proxy-groups'] as $k => $v) {
|
||||
if (!is_array($config['proxy-groups'][$k]['proxies'])) $config['proxy-groups'][$k]['proxies'] = [];
|
||||
$isFilter = false;
|
||||
foreach ($config['proxy-groups'][$k]['proxies'] as $src) {
|
||||
foreach ($proxies as $dst) {
|
||||
if (!$this->isRegex($src)) continue;
|
||||
$isFilter = true;
|
||||
$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);
|
||||
$updatedProxies = [];
|
||||
foreach ($config['proxy-groups'][$k]['proxies'] as $index => $src) {
|
||||
if ($this->isRegex($src)) {
|
||||
foreach ($proxies as $dst) {
|
||||
if ($this->isMatch($src, $dst)) {
|
||||
$updatedProxies[] = $dst;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$updatedProxies[] = $src;
|
||||
}
|
||||
if ($isFilter) continue;
|
||||
}
|
||||
if ($isFilter) continue;
|
||||
$config['proxy-groups'][$k]['proxies'] = array_merge($config['proxy-groups'][$k]['proxies'], $proxies);
|
||||
if (empty($updatedProxies) && !empty($config['proxy-groups'][$k]['proxies'])) {
|
||||
$updatedProxies = array_merge($updatedProxies, $proxies);
|
||||
}
|
||||
$config['proxy-groups'][$k]['proxies'] = $updatedProxies;
|
||||
}
|
||||
|
||||
$config['proxy-groups'] = array_filter($config['proxy-groups'], function($group) {
|
||||
|
Reference in New Issue
Block a user