refactor: refactor subscription delivery logic, change payment return_url to origin_url concatenation

- Unify protocol filter configuration to client.type.field (dot-path, three-segment) format, support strict whitelist mode
- Refactor AbstractProtocol and all protocol classes for more flexible and maintainable subscription delivery
- Change payment callback logic: use origin_url concatenation instead of return_url for more accurate redirects
This commit is contained in:
xboard
2025-07-18 15:42:58 +08:00
parent e2d7b6a5e0
commit 508caebdcd
14 changed files with 334 additions and 183 deletions

View File

@@ -5,6 +5,7 @@ namespace App\Protocols;
use App\Utils\Helper;
use Illuminate\Support\Facades\File;
use App\Support\AbstractProtocol;
use App\Models\Server;
class Surge extends AbstractProtocol
{
@@ -12,14 +13,14 @@ class Surge extends AbstractProtocol
const CUSTOM_TEMPLATE_FILE = 'resources/rules/custom.surge.conf';
const DEFAULT_TEMPLATE_FILE = 'resources/rules/default.surge.conf';
public $allowedProtocols = [
Server::TYPE_SHADOWSOCKS,
Server::TYPE_VMESS,
Server::TYPE_TROJAN,
Server::TYPE_HYSTERIA,
];
protected $protocolRequirements = [
'surge' => [
'hysteria' => [
'protocol_settings.version' => [
'2' => '2398'
],
],
],
'surge.hysteria.protocol_settings.version' => [2 => '2398'],
];
public function handle()
@@ -34,7 +35,7 @@ class Surge extends AbstractProtocol
foreach ($servers as $item) {
if (
$item['type'] === 'shadowsocks'
$item['type'] === Server::TYPE_SHADOWSOCKS
&& in_array(data_get($item, 'protocol_settings.cipher'), [
'aes-128-gcm',
'aes-192-gcm',
@@ -45,15 +46,15 @@ class Surge extends AbstractProtocol
$proxies .= self::buildShadowsocks($item['password'], $item);
$proxyGroup .= $item['name'] . ', ';
}
if ($item['type'] === 'vmess') {
if ($item['type'] === Server::TYPE_VMESS) {
$proxies .= self::buildVmess($item['password'], $item);
$proxyGroup .= $item['name'] . ', ';
}
if ($item['type'] === 'trojan') {
if ($item['type'] === Server::TYPE_TROJAN) {
$proxies .= self::buildTrojan($item['password'], $item);
$proxyGroup .= $item['name'] . ', ';
}
if ($item['type'] === 'hysteria') {
if ($item['type'] === Server::TYPE_HYSTERIA) {
$proxies .= self::buildHysteria($item['password'], $item);
$proxyGroup .= $item['name'] . ', ';
}