u; download=$user->d; total=$user->transfer_enable; expire=".strtotime($user->expired_at)); } $config = Yaml::parseFile(base_path().$file_path); // 按照核心区分配置 if (str_contains($target, 'clashforwindows') || str_contains($target, 'clashforandroid') || str_contains($target, 'clashx')) { $proxyProfiles = Formatters\Clash::build($servers); } elseif (str_contains($target, 'stash')) { $proxyProfiles = Formatters\Stash::build($servers); } else { $proxyProfiles = Formatters\ClashMeta::build($servers); } $config['proxies'] = array_merge($config['proxies'] ?: [], $proxyProfiles['proxies']); $names = array_column($config['proxies'], 'name'); foreach ($config['proxy-groups'] as $k => $v) { if (! is_array($config['proxy-groups'][$k]['proxies'])) { continue; } $config['proxy-groups'][$k]['proxies'] = array_merge($config['proxy-groups'][$k]['proxies'], $names); } array_unshift($config['rules'], 'DOMAIN,'.$_SERVER['HTTP_HOST'].',DIRECT'); // Set current sub-domain to be direct return str_replace('$app_name', $appName, Yaml::dump($config, 2, 4, Yaml::DUMP_EMPTY_ARRAY_AS_SEQUENCE)); } }