mirror of
https://github.com/lkddi/Xboard.git
synced 2026-04-24 20:17:32 +08:00
refactor: move subscribe templates to dedicated database table
This commit is contained in:
@@ -27,9 +27,7 @@ class Clash extends AbstractProtocol
|
||||
$appName = admin_setting('app_name', 'XBoard');
|
||||
|
||||
// 优先从数据库配置中获取模板
|
||||
$template = admin_setting('subscribe_template_clash', File::exists(base_path(self::CUSTOM_TEMPLATE_FILE))
|
||||
? File::get(base_path(self::CUSTOM_TEMPLATE_FILE))
|
||||
: File::get(base_path(self::DEFAULT_TEMPLATE_FILE)));
|
||||
$template = subscribe_template('clash');
|
||||
|
||||
$config = Yaml::parse($template);
|
||||
$proxy = [];
|
||||
|
||||
@@ -65,13 +65,7 @@ class ClashMeta extends AbstractProtocol
|
||||
$user = $this->user;
|
||||
$appName = admin_setting('app_name', 'XBoard');
|
||||
|
||||
$template = admin_setting('subscribe_template_clashmeta', File::exists(base_path(self::CUSTOM_TEMPLATE_FILE))
|
||||
? File::get(base_path(self::CUSTOM_TEMPLATE_FILE))
|
||||
: (
|
||||
File::exists(base_path(self::CUSTOM_CLASH_TEMPLATE_FILE))
|
||||
? File::get(base_path(self::CUSTOM_CLASH_TEMPLATE_FILE))
|
||||
: File::get(base_path(self::DEFAULT_TEMPLATE_FILE))
|
||||
));
|
||||
$template = subscribe_template('clashmeta');
|
||||
|
||||
$config = Yaml::parse($template);
|
||||
$proxy = [];
|
||||
|
||||
@@ -83,9 +83,7 @@ class SingBox extends AbstractProtocol
|
||||
|
||||
protected function loadConfig()
|
||||
{
|
||||
$jsonData = admin_setting('subscribe_template_singbox', File::exists(base_path(self::CUSTOM_TEMPLATE_FILE))
|
||||
? File::get(base_path(self::CUSTOM_TEMPLATE_FILE))
|
||||
: File::get(base_path(self::DEFAULT_TEMPLATE_FILE)));
|
||||
$jsonData = subscribe_template('singbox');
|
||||
|
||||
return is_array($jsonData) ? $jsonData : json_decode($jsonData, true);
|
||||
}
|
||||
|
||||
@@ -18,14 +18,14 @@ class Stash extends AbstractProtocol
|
||||
Server::TYPE_HYSTERIA,
|
||||
Server::TYPE_TROJAN,
|
||||
Server::TYPE_TUIC,
|
||||
// Server::TYPE_ANYTLS,
|
||||
Server::TYPE_ANYTLS,
|
||||
Server::TYPE_SOCKS,
|
||||
Server::TYPE_HTTP,
|
||||
];
|
||||
protected $protocolRequirements = [
|
||||
'stash' => [
|
||||
'anytls' => [
|
||||
'base_version' => '9.9.9'
|
||||
'base_version' => '3.3.0' // AnyTLS 协议在3.3.0版本中添加
|
||||
],
|
||||
'vless' => [
|
||||
'protocol_settings.tls' => [
|
||||
@@ -79,13 +79,7 @@ class Stash extends AbstractProtocol
|
||||
$user = $this->user;
|
||||
$appName = admin_setting('app_name', 'XBoard');
|
||||
|
||||
$template = admin_setting('subscribe_template_stash', File::exists(base_path(self::CUSTOM_TEMPLATE_FILE))
|
||||
? File::get(base_path(self::CUSTOM_TEMPLATE_FILE))
|
||||
: (
|
||||
File::exists(base_path(self::CUSTOM_CLASH_TEMPLATE_FILE))
|
||||
? File::get(base_path(self::CUSTOM_CLASH_TEMPLATE_FILE))
|
||||
: File::get(base_path(self::DEFAULT_TEMPLATE_FILE))
|
||||
));
|
||||
$template = subscribe_template('stash');
|
||||
|
||||
$config = Yaml::parse($template);
|
||||
$proxy = [];
|
||||
|
||||
@@ -58,9 +58,7 @@ class Surfboard extends AbstractProtocol
|
||||
}
|
||||
}
|
||||
|
||||
$config = admin_setting('subscribe_template_surfboard', File::exists(base_path(self::CUSTOM_TEMPLATE_FILE))
|
||||
? File::get(base_path(self::CUSTOM_TEMPLATE_FILE))
|
||||
: File::get(base_path(self::DEFAULT_TEMPLATE_FILE)));
|
||||
$config = subscribe_template('surfboard');
|
||||
// Subscription link
|
||||
$subsURL = Helper::getSubscribeUrl($user['token']);
|
||||
$subsDomain = request()->header('Host');
|
||||
|
||||
@@ -78,9 +78,7 @@ class Surge extends AbstractProtocol
|
||||
}
|
||||
|
||||
|
||||
$config = admin_setting('subscribe_template_surge', File::exists(base_path(self::CUSTOM_TEMPLATE_FILE))
|
||||
? File::get(base_path(self::CUSTOM_TEMPLATE_FILE))
|
||||
: File::get(base_path(self::DEFAULT_TEMPLATE_FILE)));
|
||||
$config = subscribe_template('surge');
|
||||
|
||||
// Subscription link
|
||||
$subsDomain = request()->header('Host');
|
||||
|
||||
Reference in New Issue
Block a user