mirror of
				https://github.com/v2board/v2board.git
				synced 2025-10-31 09:21:46 +08:00 
			
		
		
		
	update: sort leave alert
This commit is contained in:
		
							
								
								
									
										65
									
								
								app/Console/Commands/CheckServer.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										65
									
								
								app/Console/Commands/CheckServer.php
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,65 @@ | |||||||
|  | <?php | ||||||
|  |  | ||||||
|  | namespace App\Console\Commands; | ||||||
|  |  | ||||||
|  | use App\Services\ServerService; | ||||||
|  | use App\Services\TelegramService; | ||||||
|  | use App\Utils\CacheKey; | ||||||
|  | use Illuminate\Console\Command; | ||||||
|  | use Illuminate\Support\Facades\Cache; | ||||||
|  |  | ||||||
|  | class CheckServer extends Command | ||||||
|  | { | ||||||
|  |     /** | ||||||
|  |      * The name and signature of the console command. | ||||||
|  |      * | ||||||
|  |      * @var string | ||||||
|  |      */ | ||||||
|  |     protected $signature = 'check:server'; | ||||||
|  |  | ||||||
|  |     /** | ||||||
|  |      * The console command description. | ||||||
|  |      * | ||||||
|  |      * @var string | ||||||
|  |      */ | ||||||
|  |     protected $description = '节点检查任务'; | ||||||
|  |  | ||||||
|  |     /** | ||||||
|  |      * Create a new command instance. | ||||||
|  |      * | ||||||
|  |      * @return void | ||||||
|  |      */ | ||||||
|  |     public function __construct() | ||||||
|  |     { | ||||||
|  |         parent::__construct(); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     /** | ||||||
|  |      * Execute the console command. | ||||||
|  |      * | ||||||
|  |      * @return mixed | ||||||
|  |      */ | ||||||
|  |     public function handle() | ||||||
|  |     { | ||||||
|  |         $this->checkOffline(); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     private function checkOffline() | ||||||
|  |     { | ||||||
|  |         $serverService = new ServerService(); | ||||||
|  |         $servers = $serverService->getAllServers(); | ||||||
|  |         foreach ($servers as $server) { | ||||||
|  |             if ($server['parent_id']) continue; | ||||||
|  |             if ($server['last_check_at'] && (time() - $server['last_check_at']) > 1800) { | ||||||
|  |                 $telegramService = new TelegramService(); | ||||||
|  |                 $message = sprintf( | ||||||
|  |                     "节点掉线通知\r\n----\r\n节点名称:%s\r\n节点地址:%s\r\n", | ||||||
|  |                     $server['name'], | ||||||
|  |                     $server['host'] | ||||||
|  |                 ); | ||||||
|  |                 $telegramService->sendMessageWithAdmin($message); | ||||||
|  |                 Cache::forget(CacheKey::get(sprintf("SERVER_%s_LAST_CHECK_AT", strtoupper($server['type'])), $server->id)); | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | } | ||||||
| @@ -15,16 +15,8 @@ class ManageController extends Controller | |||||||
|     public function getNodes(Request $request) |     public function getNodes(Request $request) | ||||||
|     { |     { | ||||||
|         $serverService = new ServerService(); |         $serverService = new ServerService(); | ||||||
|         $servers = array_merge( |  | ||||||
|             $serverService->getShadowsocksServers(), |  | ||||||
|             $serverService->getV2rayServers(), |  | ||||||
|             $serverService->getTrojanServers() |  | ||||||
|         ); |  | ||||||
|         $serverService->mergeData($servers); |  | ||||||
|         $tmp = array_column($servers, 'sort'); |  | ||||||
|         array_multisort($tmp, SORT_ASC, $servers); |  | ||||||
|         return response([ |         return response([ | ||||||
|             'data' => $servers |             'data' => $serverService->getAllServers() | ||||||
|         ]); |         ]); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -358,4 +358,17 @@ class ServerService | |||||||
|             } |             } | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     public function getAllServers() | ||||||
|  |     { | ||||||
|  |         $servers = array_merge( | ||||||
|  |             $this->getShadowsocksServers(), | ||||||
|  |             $this->getV2rayServers(), | ||||||
|  |             $this->getTrojanServers() | ||||||
|  |         ); | ||||||
|  |         $this->mergeData($servers); | ||||||
|  |         $tmp = array_column($servers, 'sort'); | ||||||
|  |         array_multisort($tmp, SORT_ASC, $servers); | ||||||
|  |         return $servers; | ||||||
|  |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -236,5 +236,5 @@ return [ | |||||||
|     | The only modification by laravel config |     | The only modification by laravel config | ||||||
|     | |     | | ||||||
|     */ |     */ | ||||||
|     'version' => '1.5.2.1622635807521' |     'version' => '1.5.2.1623150408913' | ||||||
| ]; | ]; | ||||||
|   | |||||||
							
								
								
									
										2
									
								
								public/assets/admin/umi.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								public/assets/admin/umi.js
									
									
									
									
										vendored
									
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
		Reference in New Issue
	
	Block a user