|
@@ -13,7 +13,7 @@ class V4Controller extends Controller
|
|
|
{
|
|
|
public function __construct()
|
|
|
{
|
|
|
- $this->middleware('auth:api')->except('login', 'register', 'shop', 'getConfig','version','buy','ClashConfig','getsysconfig','GetV2rayNode','checkNodeWeihu','UserDis');
|
|
|
+ $this->middleware('auth:api')->except('login', 'register', 'shop', 'getConfig','version','buy','ClashConfig','getsysconfig','GetV2rayNode','checkNodeWeihu','UserDis','NodeWeihu');
|
|
|
auth()->shouldUse('api');
|
|
|
}
|
|
|
|
|
@@ -28,6 +28,44 @@ class V4Controller extends Controller
|
|
|
}
|
|
|
return response()->json(['ret' => 1, 'data' => $userinfo], 200);
|
|
|
}
|
|
|
+ public function NodeWeihu() {
|
|
|
+ $query = Node::with(['onlineLogs', 'dailyDataFlows']);
|
|
|
+ $nodeList = $query->where("country_code","=","us")->get();
|
|
|
+ $nodeOlin = [];
|
|
|
+
|
|
|
+ foreach ($nodeList as $key => $node) {
|
|
|
+ // 在线人数
|
|
|
+ $online_log = $node->onlineLogs()->where('log_time', '>=', strtotime('-5 minutes'))->latest('log_time')->first();
|
|
|
+ $online_users = $online_log->online_user ?? 0;
|
|
|
+ $nodeOlin[$key]["name"] =$node->name;
|
|
|
+ $nodeOlin[$key]["id"] =$node->id;
|
|
|
+ $nodeOlin[$key]["online_user"] = $online_users;
|
|
|
+ }
|
|
|
+
|
|
|
+ // var_dump($nodeOlin); die();
|
|
|
+ $logInfo = [];
|
|
|
+ foreach ($nodeOlin as $key => $vva) {
|
|
|
+ $input = [
|
|
|
+ "status" => $vva["online_user"] > 0 ? 1 : 0
|
|
|
+ ];
|
|
|
+ $post = Node::find($vva["id"]);
|
|
|
+// var_dump($post["name"]);
|
|
|
+// var_dump($post["status"]); die();
|
|
|
+ if($post->update($input)){
|
|
|
+ $logInfo[$key]["id"] = $vva["id"];
|
|
|
+ $logInfo[$key]["name"] =$vva["name"];
|
|
|
+ $logInfo[$key]["status"] = "{$input["status"]}更新成功";
|
|
|
+ }else{
|
|
|
+ $logInfo[$key]["id"] = $vva["id"];
|
|
|
+ $logInfo[$key]["name"] =$vva["name"];
|
|
|
+ $logInfo[$key]["status"] = "{$input["status"]}更新失败";
|
|
|
+ }
|
|
|
+// var_dump($logInfo);
|
|
|
+// die();
|
|
|
+ }
|
|
|
+
|
|
|
+ return response()->json(['ret' => 1, 'data' => $logInfo], 200);
|
|
|
+ }
|
|
|
|
|
|
|
|
|
public function checkNodeWeihu() {
|