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:
xboard
2025-05-22 17:58:22 +08:00
parent 2580475f78
commit fc5a957ddd
35 changed files with 1586 additions and 640 deletions
+38 -22
View File
@@ -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);