mirror of
https://github.com/cedar2025/Xboard.git
synced 2025-03-14 08:48:13 -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->serverService = $serverService;
|
||||||
$this->nodeId = $request->input('node_id');
|
$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);
|
$this->nodeInfo = $this->serverService->getServer($this->nodeId, $this->nodeType);
|
||||||
if(!$this->nodeInfo) {
|
if(!$this->nodeInfo) {
|
||||||
Log::channel("daily")->info("$this->nodeId $this->nodeType $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)
|
public function handle(Request $request, Closure $next)
|
||||||
{
|
{
|
||||||
|
// alias
|
||||||
|
$aliasTypes = [
|
||||||
|
'v2ray' => 'vmess',
|
||||||
|
'hysteria2' => 'hysteria'
|
||||||
|
];
|
||||||
$request->validate([
|
$request->validate([
|
||||||
'token' => ['required','string',function ($attribute, $value, $fail) {
|
'token' => ['required','string',function ($attribute, $value, $fail) {
|
||||||
if ($value != admin_setting('server_token')) {
|
if ($value != admin_setting('server_token')) {
|
||||||
$fail("The $attribute is error.");
|
$fail("The $attribute is error.");
|
||||||
}
|
}
|
||||||
}],
|
}],
|
||||||
|
'node_id' => 'required',
|
||||||
'node_type' => [
|
'node_type' => [
|
||||||
'nullable',
|
'nullable',
|
||||||
'string',
|
'string',
|
||||||
'regex:/^(?i)(hysteria|vless|trojan|vmess|v2ray|tuic|shadowsocks|shadowsocks-plugin)$/',
|
'regex:/^(?i)(hysteria|hysteria2|vless|trojan|vmess|v2ray|tuic|shadowsocks|shadowsocks-plugin)$/',
|
||||||
function ($attribute, $value, $fail) {
|
function ($attribute, $value, $fail)use($aliasTypes) {
|
||||||
// 将值转换为小写
|
// 将值转换为小写
|
||||||
request()->merge([$attribute => strtolower($value)]);
|
request()->merge([$attribute => strtolower($value)]);
|
||||||
|
// 类别别名
|
||||||
|
if (in_array($value, array_keys($aliasTypes))){
|
||||||
|
request()->merge([$attribute => $aliasTypes[$value]]);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
],
|
]
|
||||||
'node_id' => 'required'
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return $next($request);
|
return $next($request);
|
||||||
|
Loading…
Reference in New Issue
Block a user