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);
|
Cache::put(CacheKey::get('SERVER_V2RAY_ONLINE_USER', $server->id), count($data), 3600);
|
||||||
$serverService = new ServerService();
|
$serverService = new ServerService();
|
||||||
$userService = new UserService();
|
$userService = new UserService();
|
||||||
|
DB::beginTransaction();
|
||||||
|
try {
|
||||||
foreach ($data as $item) {
|
foreach ($data as $item) {
|
||||||
$u = $item['u'] * $server->rate;
|
$u = $item['u'] * $server->rate;
|
||||||
$d = $item['d'] * $server->rate;
|
$d = $item['d'] * $server->rate;
|
||||||
if (!$userService->trafficFetch($u, $d, $item['user_id'])) {
|
if (!$userService->trafficFetch($u, $d, $item['user_id'])) {
|
||||||
return response([
|
continue;
|
||||||
'ret' => 0,
|
|
||||||
'msg' => 'user fetch fail'
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$serverService->log(
|
$serverService->log(
|
||||||
@ -96,6 +95,14 @@ class DeepbworkController extends Controller
|
|||||||
'vmess'
|
'vmess'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
DB::rollBack();
|
||||||
|
return response([
|
||||||
|
'ret' => 0,
|
||||||
|
'msg' => 'user fetch fail'
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
DB::commit();
|
||||||
|
|
||||||
return response([
|
return response([
|
||||||
'ret' => 1,
|
'ret' => 1,
|
||||||
|
@ -73,15 +73,12 @@ class ShadowsocksTidalabController extends Controller
|
|||||||
$serverService = new ServerService();
|
$serverService = new ServerService();
|
||||||
$userService = new UserService();
|
$userService = new UserService();
|
||||||
DB::beginTransaction();
|
DB::beginTransaction();
|
||||||
|
try {
|
||||||
foreach ($data as $item) {
|
foreach ($data as $item) {
|
||||||
$u = $item['u'] * $server->rate;
|
$u = $item['u'] * $server->rate;
|
||||||
$d = $item['d'] * $server->rate;
|
$d = $item['d'] * $server->rate;
|
||||||
if (!$userService->trafficFetch((float)$u, (float)$d, (int)$item['user_id'])) {
|
if (!$userService->trafficFetch((float)$u, (float)$d, (int)$item['user_id'])) {
|
||||||
DB::rollBack();
|
continue;
|
||||||
return response([
|
|
||||||
'ret' => 0,
|
|
||||||
'msg' => 'user fetch fail'
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$serverService->log(
|
$serverService->log(
|
||||||
@ -93,6 +90,13 @@ class ShadowsocksTidalabController extends Controller
|
|||||||
'shadowsocks'
|
'shadowsocks'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
DB::rollBack();
|
||||||
|
return response([
|
||||||
|
'ret' => 0,
|
||||||
|
'msg' => 'user fetch fail'
|
||||||
|
]);
|
||||||
|
}
|
||||||
DB::commit();
|
DB::commit();
|
||||||
|
|
||||||
return response([
|
return response([
|
||||||
@ -100,22 +104,4 @@ class ShadowsocksTidalabController extends Controller
|
|||||||
'msg' => 'ok'
|
'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();
|
$serverService = new ServerService();
|
||||||
$userService = new UserService();
|
$userService = new UserService();
|
||||||
DB::beginTransaction();
|
DB::beginTransaction();
|
||||||
|
try {
|
||||||
foreach ($data as $item) {
|
foreach ($data as $item) {
|
||||||
$u = $item['u'] * $server->rate;
|
$u = $item['u'] * $server->rate;
|
||||||
$d = $item['d'] * $server->rate;
|
$d = $item['d'] * $server->rate;
|
||||||
if (!$userService->trafficFetch($u, $d, $item['user_id'])) {
|
if (!$userService->trafficFetch($u, $d, $item['user_id'])) {
|
||||||
DB::rollBack();
|
continue;
|
||||||
return response([
|
|
||||||
'ret' => 0,
|
|
||||||
'msg' => 'user fetch fail'
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$serverService->log(
|
$serverService->log(
|
||||||
@ -95,6 +92,13 @@ class TrojanTidalabController extends Controller
|
|||||||
'trojan'
|
'trojan'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
DB::rollBack();
|
||||||
|
return response([
|
||||||
|
'ret' => 0,
|
||||||
|
'msg' => 'user fetch fail'
|
||||||
|
]);
|
||||||
|
}
|
||||||
DB::commit();
|
DB::commit();
|
||||||
|
|
||||||
return response([
|
return response([
|
||||||
|
Loading…
Reference in New Issue
Block a user