mirror of
https://github.com/lkddi/Xboard.git
synced 2026-04-24 03:57:27 +08:00
feat: add AnyTLS support and improve system functionality
- Add AnyTLS protocol support - Add system logs viewing in admin panel - Refactor client subscription delivery code - Refactor hook mechanism - Add plugin support for Shadowsocks protocol - Add CSV export option for batch user creation - Fix mobile admin login page width display issue
This commit is contained in:
+38
-22
@@ -2,24 +2,21 @@
|
||||
|
||||
namespace App\Protocols;
|
||||
|
||||
use App\Contracts\ProtocolInterface;
|
||||
use App\Support\AbstractProtocol;
|
||||
|
||||
class Loon implements ProtocolInterface
|
||||
class Loon extends AbstractProtocol
|
||||
{
|
||||
public $flags = ['loon'];
|
||||
private $servers;
|
||||
private $user;
|
||||
|
||||
public function __construct($user, $servers)
|
||||
{
|
||||
$this->user = $user;
|
||||
$this->servers = $servers;
|
||||
}
|
||||
|
||||
public function getFlags(): array
|
||||
{
|
||||
return $this->flags;
|
||||
}
|
||||
protected $protocolRequirements = [
|
||||
'loon' => [
|
||||
'hysteria' => [
|
||||
'protocol_settings.version' => [
|
||||
'2' => '637'
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
public function handle()
|
||||
{
|
||||
@@ -51,10 +48,8 @@ class Loon implements ProtocolInterface
|
||||
|
||||
public static function buildShadowsocks($password, $server)
|
||||
{
|
||||
$cipher = data_get($server['protocol_settings'], 'cipher');
|
||||
$obfs = data_get($server['protocol_settings'], 'obfs');
|
||||
$obfs_host = data_get($server['protocol_settings'], 'obfs_settings.host');
|
||||
$obfs_uri = data_get($server['protocol_settings'], 'obfs_settings.path', '/');
|
||||
$protocol_settings = $server['protocol_settings'];
|
||||
$cipher = data_get($protocol_settings, 'cipher');
|
||||
|
||||
$config = [
|
||||
"{$server['name']}=Shadowsocks",
|
||||
@@ -66,10 +61,31 @@ class Loon implements ProtocolInterface
|
||||
'udp=true'
|
||||
];
|
||||
|
||||
if ($obfs && $obfs_host) {
|
||||
$config[] = "obfs-name={$obfs}";
|
||||
$config[] = "obfs-host={$obfs_host}";
|
||||
$config[] = "obfs-uri={$obfs_uri}";
|
||||
if (data_get($protocol_settings, 'plugin') && data_get($protocol_settings, 'plugin_opts')) {
|
||||
$plugin = data_get($protocol_settings, 'plugin');
|
||||
$pluginOpts = data_get($protocol_settings, 'plugin_opts', '');
|
||||
// 解析插件选项
|
||||
$parsedOpts = collect(explode(';', $pluginOpts))
|
||||
->filter()
|
||||
->mapWithKeys(function ($pair) {
|
||||
if (!str_contains($pair, '=')) {
|
||||
return [];
|
||||
}
|
||||
[$key, $value] = explode('=', $pair, 2);
|
||||
return [trim($key) => trim($value)];
|
||||
})
|
||||
->all();
|
||||
switch ($plugin) {
|
||||
case 'obfs':
|
||||
$config[] = "obfs-name={$parsedOpts['obfs']}";
|
||||
if (isset($parsedOpts['obfs-host'])) {
|
||||
$config[] = "obfs-host={$parsedOpts['obfs-host']}";
|
||||
}
|
||||
if (isset($parsedOpts['path'])) {
|
||||
$config[] = "obfs-uri={$parsedOpts['path']}";
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$config = array_filter($config);
|
||||
|
||||
Reference in New Issue
Block a user