mirror of
https://github.com/cedar2025/Xboard.git
synced 2025-03-13 00:08:14 -04:00
feat: 兼容V2bx 的Hysteria2
This commit is contained in:
parent
b489f8f6f1
commit
e0eac8f703
@ -22,7 +22,7 @@ class UniProxyController extends Controller
|
||||
{
|
||||
$this->serverService = $serverService;
|
||||
$this->nodeId = $request->input('node_id');
|
||||
$this->nodeType = $request->input('node_type') === 'v2ray' ? 'vmess' : $request->input('node_type');
|
||||
$this->nodeType = $request->input('node_type');
|
||||
$this->nodeInfo = $this->serverService->getServer($this->nodeId, $this->nodeType);
|
||||
if(!$this->nodeInfo) {
|
||||
Log::channel("daily")->info("$this->nodeId $this->nodeType $this->nodeInfo");
|
||||
|
@ -16,22 +16,31 @@ class Server
|
||||
*/
|
||||
public function handle(Request $request, Closure $next)
|
||||
{
|
||||
// alias
|
||||
$aliasTypes = [
|
||||
'v2ray' => 'vmess',
|
||||
'hysteria2' => 'hysteria'
|
||||
];
|
||||
$request->validate([
|
||||
'token' => ['required','string',function ($attribute, $value, $fail) {
|
||||
if ($value != admin_setting('server_token')) {
|
||||
$fail("The $attribute is error.");
|
||||
}
|
||||
}],
|
||||
'node_id' => 'required',
|
||||
'node_type' => [
|
||||
'nullable',
|
||||
'string',
|
||||
'regex:/^(?i)(hysteria|vless|trojan|vmess|v2ray|tuic|shadowsocks|shadowsocks-plugin)$/',
|
||||
function ($attribute, $value, $fail) {
|
||||
'regex:/^(?i)(hysteria|hysteria2|vless|trojan|vmess|v2ray|tuic|shadowsocks|shadowsocks-plugin)$/',
|
||||
function ($attribute, $value, $fail)use($aliasTypes) {
|
||||
// 将值转换为小写
|
||||
request()->merge([$attribute => strtolower($value)]);
|
||||
// 类别别名
|
||||
if (in_array($value, array_keys($aliasTypes))){
|
||||
request()->merge([$attribute => $aliasTypes[$value]]);
|
||||
}
|
||||
},
|
||||
],
|
||||
'node_id' => 'required'
|
||||
]
|
||||
]);
|
||||
|
||||
return $next($request);
|
||||
|
Loading…
Reference in New Issue
Block a user