Skip to content

Commit

Permalink
V2ray webApi 错误修复
Browse files Browse the repository at this point in the history
  • Loading branch information
ZBrettonYe committed Jul 17, 2020
1 parent 08d739e commit 335a717
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 16 deletions.
1 change: 0 additions & 1 deletion app/Http/Controllers/Api/WebApi/BaseController.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ public function setUserTraffic(Request $request, $id): JsonResponse {
return $this->returnData('上报用户流量日志成功', 'success', 200);
}


// 获取节点的审计规则
public function getNodeRule($id): JsonResponse {
$nodeRule = RuleGroupNode::whereNodeId($id)->first();
Expand Down
28 changes: 16 additions & 12 deletions app/Http/Controllers/Api/WebApi/V2RayController.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function getNodeInfo($id): JsonResponse {
'v2_host' => $node->v2_host,
'v2_path' => $node->v2_path,
'v2_tls' => $node->v2_tls? true : false,
'v2_tls_provider' => Helpers::systemConfig()['v2ray_tls_provider']?: $node->tls_provider,
'v2_tls_provider' => $node->tls_provider?: Helpers::systemConfig()['v2ray_tls_provider'],
]);
}

Expand All @@ -52,24 +52,28 @@ public function getUserList($id): JsonResponse {
$data[] = $new;
}

if($data){
return $this->returnData('获取用户列表成功', 'success', 200, $data, ['updateTime' => time()]);
}

return $this->returnData('获取用户列表失败');
return $this->returnData('获取用户列表成功', 'success', 200, $data, ['updateTime' => time()]);
}

// 上报节点伪装域名证书信息
public function addCertificate(Request $request, $id): JsonResponse {
$key = $request->input('key');
$pem = $request->input('pem');

if($request->has(['key', 'pem'])){
$node = SsNode::find($id);
$obj = new NodeCertificate();
$obj->domain = $node->server;
$obj->key = $request->input('key');
$obj->pem = $request->input('pem');
$obj->save();
$Dv = NodeCertificate::query()->whereDomain($node->v2_host)->first();
if($Dv){
$ret = NodeCertificate::query()->whereId($Dv->id)->update(['key' => $key, 'pem' => $pem]);
}else{
$ret = new NodeCertificate();
$ret->domain = $node->server;
$ret->key = $request->input('key');
$ret->pem = $request->input('pem');
$ret->save();
}

if($obj->id){
if($ret){
return $this->returnData('上报节点伪装域名证书成功', 'success', 200);
}
}
Expand Down
4 changes: 2 additions & 2 deletions app/Http/Middleware/WebApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ public function handle($request, Closure $next) {
$key = $request->header('key');
$time = $request->header('timestamp');

if(isset($key)){// 未提供 key
if(!isset($key)){// 未提供 key
return $this->returnData('Your key is null!');
}

if(isset($id)){// 未提供 node
if(!isset($id)){// 未提供 node
return $this->returnData('Your Node Id is null!');
}

Expand Down
2 changes: 1 addition & 1 deletion resources/views/user/payment.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
</div>
<div class="col-auto ml-auto mr-auto">
@if($payment->qr_code && $payment->url)
<img src="data:image/png;base64, {!! base64_encode(QrCode::format('png')->margin(2)->eyeColor(1, 0, 204, 153, 0, 153, 119)->style('round', 0.9)->size(250)->errorCorrection('H')->merge(url($pay_type_icon), .3, true)->generate($payment->url))!!}" alt="支付二维码">
<img src="data:image/png;base64, {!! base64_encode(QrCode::format('png')->margin(2)->eyeColor(1, 0, 204, 153, 0, 153, 119)->size(250)->errorCorrection('H')->merge(url($pay_type_icon), .3, true)->generate($payment->url))!!}" alt="支付二维码">
@else
<img class="h-250 w-250" src="{{$payment->qr_code}}" alt="支付二维码">
@endif
Expand Down

0 comments on commit 335a717

Please sign in to comment.