|
|
|
|
@ -10,6 +10,7 @@ use App\Models\Smartline;
|
|
|
|
|
use App\Utils\ConfRender;
|
|
|
|
|
use App\Utils\Tools;
|
|
|
|
|
use App\Utils\URL;
|
|
|
|
|
use App\Services\Config;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* HomeController
|
|
|
|
|
@ -194,4 +195,274 @@ class LinkController extends BaseController
|
|
|
|
|
);
|
|
|
|
|
return $render->fetch('clash.tpl');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static function getSSPcConf($user)
|
|
|
|
|
{
|
|
|
|
|
$proxy = [];
|
|
|
|
|
$items = URL::getAllItems($user, 0, 1);
|
|
|
|
|
foreach ($items as $item) {
|
|
|
|
|
$proxy_plugin = '';
|
|
|
|
|
$proxy_plugin_opts = '';
|
|
|
|
|
if ($item['obfs'] == 'v2ray' || in_array($item['obfs'], Config::getSupportParam('ss_obfs'))) {
|
|
|
|
|
if ($item['obfs'] == 'v2ray') {
|
|
|
|
|
$proxy_plugin .= 'v2ray';
|
|
|
|
|
} else {
|
|
|
|
|
$proxy_plugin .= 'obfs-local';
|
|
|
|
|
}
|
|
|
|
|
if (strpos($item['obfs'], 'http') !== false) {
|
|
|
|
|
$proxy_plugin_opts .= 'obfs=http';
|
|
|
|
|
} elseif (strpos($item['obfs'], 'tls') !== false) {
|
|
|
|
|
$proxy_plugin_opts .= 'obfs=tls';
|
|
|
|
|
} else {
|
|
|
|
|
$proxy_plugin_opts .= 'v2ray;' . $item['obfs_param'];
|
|
|
|
|
}
|
|
|
|
|
if ($item['obfs_param'] != '' && $item['obfs'] != 'v2ray') {
|
|
|
|
|
$proxy_plugin_opts .= ';obfs-host=' . $item['obfs_param'];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$proxy[] = [
|
|
|
|
|
'remarks' => $item['remark'],
|
|
|
|
|
'server' => $item['address'],
|
|
|
|
|
'server_port' => $item['port'],
|
|
|
|
|
'method' => $item['method'],
|
|
|
|
|
'password' => $item['passwd'],
|
|
|
|
|
'timeout' => 5,
|
|
|
|
|
'plugin' => $proxy_plugin,
|
|
|
|
|
'plugin_opts' => $proxy_plugin_opts
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
$config = [
|
|
|
|
|
'configs' => $proxy,
|
|
|
|
|
'strategy' => null,
|
|
|
|
|
'index' => 0,
|
|
|
|
|
'global' => false,
|
|
|
|
|
'enabled' => true,
|
|
|
|
|
'shareOverLan' => false,
|
|
|
|
|
'isDefault' => false,
|
|
|
|
|
'localPort' => 1080,
|
|
|
|
|
'portableMode' => true,
|
|
|
|
|
'pacUrl' => null,
|
|
|
|
|
'useOnlinePac' => false,
|
|
|
|
|
'secureLocalPac' => true,
|
|
|
|
|
'availabilityStatistics' => false,
|
|
|
|
|
'autoCheckUpdate' => true,
|
|
|
|
|
'checkPreRelease' => false,
|
|
|
|
|
'isVerboseLogging' => false,
|
|
|
|
|
'logViewer' => [
|
|
|
|
|
'topMost' => false,
|
|
|
|
|
'wrapText' => false,
|
|
|
|
|
'toolbarShown' => false,
|
|
|
|
|
'Font' => 'Consolas, 8pt',
|
|
|
|
|
'BackgroundColor' => 'Black',
|
|
|
|
|
'TextColor' => 'White'
|
|
|
|
|
],
|
|
|
|
|
'proxy' => [
|
|
|
|
|
'useProxy' => false,
|
|
|
|
|
'proxyType' => 0,
|
|
|
|
|
'proxyServer' => '',
|
|
|
|
|
'proxyPort' => 0,
|
|
|
|
|
'proxyTimeout' => 3
|
|
|
|
|
],
|
|
|
|
|
'hotkey' => [
|
|
|
|
|
'SwitchSystemProxy' => '',
|
|
|
|
|
'SwitchSystemProxyMode' => '',
|
|
|
|
|
'SwitchAllowLan' => '',
|
|
|
|
|
'ShowLogs' => '',
|
|
|
|
|
'ServerMoveUp' => '',
|
|
|
|
|
'ServerMoveDown' => '',
|
|
|
|
|
'RegHotkeysAtStartup' => false
|
|
|
|
|
]
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
return json_encode($config, JSON_PRETTY_PRINT);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static function getSSRPcConf($user)
|
|
|
|
|
{
|
|
|
|
|
$proxy = [];
|
|
|
|
|
$items = URL::getAllItems($user, 0, 0);
|
|
|
|
|
foreach ($items as $item) {
|
|
|
|
|
$proxy[] = [
|
|
|
|
|
'remarks' => $item['remark'],
|
|
|
|
|
'server' => $item['address'],
|
|
|
|
|
'server_port' => $item['port'],
|
|
|
|
|
'method' => $item['method'],
|
|
|
|
|
'obfs' => $item['obfs'],
|
|
|
|
|
'obfsparam' => $item['obfs_param'],
|
|
|
|
|
'remarks_base64' => base64_encode($item['remark']),
|
|
|
|
|
'password' => $item['passwd'],
|
|
|
|
|
'tcp_over_udp' => false,
|
|
|
|
|
'udp_over_tcp' => false,
|
|
|
|
|
'group' => Config::get('appName'),
|
|
|
|
|
'protocol' => $item['protocol'],
|
|
|
|
|
'protocolparam' => $item['protocol_param'],
|
|
|
|
|
'obfs_udp' => false,
|
|
|
|
|
'enable' => true
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
$config = [
|
|
|
|
|
'configs' => $proxy,
|
|
|
|
|
'index' => 0,
|
|
|
|
|
'random' => true,
|
|
|
|
|
'sysProxyMode' => 1,
|
|
|
|
|
'shareOverLan' => false,
|
|
|
|
|
'localPort' => 1080,
|
|
|
|
|
'localAuthPassword' => Tools::genRandomChar(26),
|
|
|
|
|
'dnsServer' => '',
|
|
|
|
|
'reconnectTimes' => 2,
|
|
|
|
|
'balanceAlgorithm' => 'LowException',
|
|
|
|
|
'randomInGroup' => false,
|
|
|
|
|
'TTL' => 0,
|
|
|
|
|
'connectTimeout' => 5,
|
|
|
|
|
'proxyRuleMode' => 2,
|
|
|
|
|
'proxyEnable' => false,
|
|
|
|
|
'pacDirectGoProxy' => false,
|
|
|
|
|
'proxyType' => 0,
|
|
|
|
|
'proxyHost' => '',
|
|
|
|
|
'proxyPort' => 0,
|
|
|
|
|
'proxyAuthUser' => '',
|
|
|
|
|
'proxyAuthPass' => '',
|
|
|
|
|
'proxyUserAgent' => '',
|
|
|
|
|
'authUser' => '',
|
|
|
|
|
'authPass' => '',
|
|
|
|
|
'autoBan' => false,
|
|
|
|
|
'sameHostForSameTarget' => false,
|
|
|
|
|
'keepVisitTime' => 180,
|
|
|
|
|
'isHideTips' => false,
|
|
|
|
|
'nodeFeedAutoUpdate' => true,
|
|
|
|
|
'serverSubscribes' => [
|
|
|
|
|
[
|
|
|
|
|
'URL' => (Config::get('subUrl') . self::GenerateSSRSubCode($user->id, 0) . '?mu=0'),
|
|
|
|
|
'Group' => Config::get('appName'),
|
|
|
|
|
'LastUpdateTime' => 0
|
|
|
|
|
]
|
|
|
|
|
],
|
|
|
|
|
'token' => [],
|
|
|
|
|
'portMap' => []
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
return json_encode($config, JSON_PRETTY_PRINT);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static function getSSDPcConf($user)
|
|
|
|
|
{
|
|
|
|
|
$id = 1;
|
|
|
|
|
$proxy = [];
|
|
|
|
|
$items = URL::getAllItems($user, 0, 1);
|
|
|
|
|
foreach ($items as $item) {
|
|
|
|
|
$proxy_plugin = '';
|
|
|
|
|
$proxy_plugin_opts = '';
|
|
|
|
|
if ($item['obfs'] == 'v2ray' || in_array($item['obfs'], Config::getSupportParam('ss_obfs'))) {
|
|
|
|
|
if ($item['obfs'] == 'v2ray') {
|
|
|
|
|
$proxy_plugin .= 'v2ray';
|
|
|
|
|
} else {
|
|
|
|
|
$proxy_plugin .= 'simple-obfs';
|
|
|
|
|
}
|
|
|
|
|
if (strpos($item['obfs'], 'http') !== false) {
|
|
|
|
|
$proxy_plugin_opts .= 'obfs=http';
|
|
|
|
|
} elseif (strpos($item['obfs'], 'tls') !== false) {
|
|
|
|
|
$proxy_plugin_opts .= 'obfs=tls';
|
|
|
|
|
} else {
|
|
|
|
|
$proxy_plugin_opts .= 'v2ray;' . $item['obfs_param'];
|
|
|
|
|
}
|
|
|
|
|
if ($item['obfs_param'] != '' && $item['obfs'] != 'v2ray') {
|
|
|
|
|
$proxy_plugin_opts .= ';obfs-host=' . $item['obfs_param'];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$proxy[] = [
|
|
|
|
|
'remarks' => $item['remark'],
|
|
|
|
|
'server' => $item['address'],
|
|
|
|
|
'server_port' => $item['port'],
|
|
|
|
|
'password' => $item['passwd'],
|
|
|
|
|
'method' => $item['method'],
|
|
|
|
|
'plugin' => $proxy_plugin,
|
|
|
|
|
'plugin_opts' => $proxy_plugin_opts,
|
|
|
|
|
'plugin_args' => '',
|
|
|
|
|
'timeout' => 5,
|
|
|
|
|
'id' => $id,
|
|
|
|
|
'ratio' => $item['ratio'],
|
|
|
|
|
'subscription_url' => (Config::get('subUrl') . self::GenerateSSRSubCode($user->id, 0) . '?mu=3')
|
|
|
|
|
];
|
|
|
|
|
$id++;
|
|
|
|
|
}
|
|
|
|
|
$plugin = '';
|
|
|
|
|
$plugin_opts = '';
|
|
|
|
|
if ($user->obfs == 'v2ray' || in_array($user->obfs, Config::getSupportParam('ss_obfs'))) {
|
|
|
|
|
if ($user->obfs == 'v2ray') {
|
|
|
|
|
$plugin .= 'v2ray';
|
|
|
|
|
} else {
|
|
|
|
|
$plugin .= 'simple-obfs';
|
|
|
|
|
}
|
|
|
|
|
if (strpos($user->obfs, 'http') !== false) {
|
|
|
|
|
$plugin_opts .= 'obfs=http';
|
|
|
|
|
} elseif (strpos($user->obfs, 'tls') !== false) {
|
|
|
|
|
$plugin_opts .= 'obfs=tls';
|
|
|
|
|
} else {
|
|
|
|
|
$plugin_opts .= 'v2ray;' . $user->obfs_param;
|
|
|
|
|
}
|
|
|
|
|
if ($user->obfs_param != '' && $user->obfs != 'v2ray') {
|
|
|
|
|
$plugin_opts .= ';obfs-host=' . $user->obfs_param;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$config = [
|
|
|
|
|
'configs' => $proxy,
|
|
|
|
|
'strategy' => null,
|
|
|
|
|
'index' => 0,
|
|
|
|
|
'global' => false,
|
|
|
|
|
'enabled' => true,
|
|
|
|
|
'shareOverLan' => false,
|
|
|
|
|
'isDefault' => false,
|
|
|
|
|
'localPort' => 1080,
|
|
|
|
|
'portableMode' => true,
|
|
|
|
|
'pacUrl' => null,
|
|
|
|
|
'useOnlinePac' => false,
|
|
|
|
|
'secureLocalPac' => true,
|
|
|
|
|
'availabilityStatistics' => false,
|
|
|
|
|
'autoCheckUpdate' => true,
|
|
|
|
|
'checkPreRelease' => false,
|
|
|
|
|
'isVerboseLogging' => false,
|
|
|
|
|
'logViewer' => [
|
|
|
|
|
'topMost' => false,
|
|
|
|
|
'wrapText' => false,
|
|
|
|
|
'toolbarShown' => false,
|
|
|
|
|
'Font' => 'Consolas, 8pt',
|
|
|
|
|
'BackgroundColor' => 'Black',
|
|
|
|
|
'TextColor' => 'White'
|
|
|
|
|
],
|
|
|
|
|
'proxy' => [
|
|
|
|
|
'useProxy' => false,
|
|
|
|
|
'proxyType' => 0,
|
|
|
|
|
'proxyServer' => '',
|
|
|
|
|
'proxyPort' => 0,
|
|
|
|
|
'proxyTimeout' => 3
|
|
|
|
|
],
|
|
|
|
|
'hotkey' => [
|
|
|
|
|
'SwitchSystemProxy' => '',
|
|
|
|
|
'SwitchSystemProxyMode' => '',
|
|
|
|
|
'SwitchAllowLan' => '',
|
|
|
|
|
'ShowLogs' => '',
|
|
|
|
|
'ServerMoveUp' => '',
|
|
|
|
|
'ServerMoveDown' => '',
|
|
|
|
|
'RegHotkeysAtStartup' => false
|
|
|
|
|
],
|
|
|
|
|
'subscriptions' => [
|
|
|
|
|
[
|
|
|
|
|
'airport' => Config::get('appName'),
|
|
|
|
|
'encryption' => $user->method,
|
|
|
|
|
'password' => $user->passwd,
|
|
|
|
|
'port' => $user->port,
|
|
|
|
|
'expiry' => $user->class_expire,
|
|
|
|
|
'traffic_used' => Tools::flowToGB($user->u + $user->d),
|
|
|
|
|
'traffic_total' => Tools::flowToGB($user->transfer_enable),
|
|
|
|
|
'url' => (Config::get('subUrl') . self::GenerateSSRSubCode($user->id, 0) . '?mu=3'),
|
|
|
|
|
'plugin' => $plugin,
|
|
|
|
|
'plugin_options' => $plugin_opts,
|
|
|
|
|
'plugin_arguments' => '',
|
|
|
|
|
'use_proxy' => false
|
|
|
|
|
]
|
|
|
|
|
]
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
return json_encode($config, JSON_PRETTY_PRINT);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|