Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions app/Protocols/ClashMeta.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ public function handle()
return $group['proxies'];
});
$config['proxy-groups'] = array_values($config['proxy-groups']);
$config = $this->buildRules($config);
$config = $this->buildRules($config,$user);

$yaml = Yaml::dump($config, 2, 4, Yaml::DUMP_EMPTY_ARRAY_AS_SEQUENCE);
$yaml = str_replace('$app_name', admin_setting('app_name', 'XBoard'), $yaml);
Expand All @@ -155,10 +155,11 @@ public function handle()
/**
* Build the rules for Clash.
*/
public function buildRules($config)
public function buildRules($config,$user)
{
// Force the current subscription domain to be a direct rule
$subsDomain = request()->header('Host');
$subsURL = Helper::getSubscribeUrl($user['token']);
$subsDomain = parse_url($subsURL, PHP_URL_HOST);
if ($subsDomain) {
array_unshift($config['rules'], "DOMAIN,{$subsDomain},DIRECT");
}
Expand Down Expand Up @@ -705,4 +706,4 @@ protected static function appendUtls(&$array, $protocol_settings)
}
}
}
}
}