mirror of
https://github.com/v2board/v2board.git
synced 2024-11-10 17:49:11 +08:00
update: traffic submit
This commit is contained in:
parent
675353bbe1
commit
7042dce0a1
@ -77,14 +77,13 @@ class DeepbworkController extends Controller
|
||||
Cache::put(CacheKey::get('SERVER_V2RAY_ONLINE_USER', $server->id), count($data), 3600);
|
||||
$serverService = new ServerService();
|
||||
$userService = new UserService();
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
foreach ($data as $item) {
|
||||
$u = $item['u'] * $server->rate;
|
||||
$d = $item['d'] * $server->rate;
|
||||
if (!$userService->trafficFetch($u, $d, $item['user_id'])) {
|
||||
return response([
|
||||
'ret' => 0,
|
||||
'msg' => 'user fetch fail'
|
||||
]);
|
||||
continue;
|
||||
}
|
||||
|
||||
$serverService->log(
|
||||
@ -96,6 +95,14 @@ class DeepbworkController extends Controller
|
||||
'vmess'
|
||||
);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
DB::rollBack();
|
||||
return response([
|
||||
'ret' => 0,
|
||||
'msg' => 'user fetch fail'
|
||||
]);
|
||||
}
|
||||
DB::commit();
|
||||
|
||||
return response([
|
||||
'ret' => 1,
|
||||
|
@ -73,15 +73,12 @@ class ShadowsocksTidalabController extends Controller
|
||||
$serverService = new ServerService();
|
||||
$userService = new UserService();
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
foreach ($data as $item) {
|
||||
$u = $item['u'] * $server->rate;
|
||||
$d = $item['d'] * $server->rate;
|
||||
if (!$userService->trafficFetch((float)$u, (float)$d, (int)$item['user_id'])) {
|
||||
DB::rollBack();
|
||||
return response([
|
||||
'ret' => 0,
|
||||
'msg' => 'user fetch fail'
|
||||
]);
|
||||
continue;
|
||||
}
|
||||
|
||||
$serverService->log(
|
||||
@ -93,6 +90,13 @@ class ShadowsocksTidalabController extends Controller
|
||||
'shadowsocks'
|
||||
);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
DB::rollBack();
|
||||
return response([
|
||||
'ret' => 0,
|
||||
'msg' => 'user fetch fail'
|
||||
]);
|
||||
}
|
||||
DB::commit();
|
||||
|
||||
return response([
|
||||
@ -100,22 +104,4 @@ class ShadowsocksTidalabController extends Controller
|
||||
'msg' => 'ok'
|
||||
]);
|
||||
}
|
||||
|
||||
// 后端获取配置
|
||||
public function config(Request $request)
|
||||
{
|
||||
$nodeId = $request->input('node_id');
|
||||
$localPort = $request->input('local_port');
|
||||
if (empty($nodeId) || empty($localPort)) {
|
||||
abort(500, '参数错误');
|
||||
}
|
||||
$serverService = new ServerService();
|
||||
try {
|
||||
$json = $serverService->getTrojanConfig($nodeId, $localPort);
|
||||
} catch (\Exception $e) {
|
||||
abort(500, $e->getMessage());
|
||||
}
|
||||
|
||||
die(json_encode($json, JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
}
|
||||
|
@ -75,15 +75,12 @@ class TrojanTidalabController extends Controller
|
||||
$serverService = new ServerService();
|
||||
$userService = new UserService();
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
foreach ($data as $item) {
|
||||
$u = $item['u'] * $server->rate;
|
||||
$d = $item['d'] * $server->rate;
|
||||
if (!$userService->trafficFetch($u, $d, $item['user_id'])) {
|
||||
DB::rollBack();
|
||||
return response([
|
||||
'ret' => 0,
|
||||
'msg' => 'user fetch fail'
|
||||
]);
|
||||
continue;
|
||||
}
|
||||
|
||||
$serverService->log(
|
||||
@ -95,6 +92,13 @@ class TrojanTidalabController extends Controller
|
||||
'trojan'
|
||||
);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
DB::rollBack();
|
||||
return response([
|
||||
'ret' => 0,
|
||||
'msg' => 'user fetch fail'
|
||||
]);
|
||||
}
|
||||
DB::commit();
|
||||
|
||||
return response([
|
||||
|
Loading…
Reference in New Issue
Block a user