mirror of
				https://github.com/v2board/v2board.git
				synced 2025-10-31 09:21:46 +08:00 
			
		
		
		
	format
This commit is contained in:
		| @@ -14,8 +14,10 @@ use Cache; | ||||
| class DeepbworkController extends Controller | ||||
| { | ||||
|     CONST SERVER_CONFIG = '{"api":{"services":["HandlerService","StatsService"],"tag":"api"},"stats":{},"inbound":{"port":443,"protocol":"vmess","settings":{"clients":[]},"streamSettings":{"network":"tcp"},"tag":"proxy"},"inboundDetour":[{"listen":"0.0.0.0","port":23333,"protocol":"dokodemo-door","settings":{"address":"0.0.0.0"},"tag":"api"}],"log":{"loglevel":"debug","access":"access.log","error":"error.log"},"outbound":{"protocol":"freedom","settings":{}},"routing":{"settings":{"rules":[{"inboundTag":["api"],"outboundTag":"api","type":"field"}]},"strategy":"rules"},"policy":{"levels":{"0":{"handshake":4,"connIdle":300,"uplinkOnly":5,"downlinkOnly":30,"statsUserUplink":true,"statsUserDownlink":true}}}}'; | ||||
|  | ||||
|     // 后端获取用户 | ||||
|     public function user (Request $request) { | ||||
|     public function user(Request $request) | ||||
|     { | ||||
|         $nodeId = $request->input('node_id'); | ||||
|         $server = Server::find($nodeId); | ||||
|         if (!$server) { | ||||
| @@ -56,26 +58,27 @@ class DeepbworkController extends Controller | ||||
|     } | ||||
|  | ||||
|     // 后端提交数据 | ||||
|     public function submit (Request $request) { | ||||
| 		Log::info('serverSubmitData:' . $request->input('node_id') . ':' . file_get_contents('php://input')); | ||||
|     public function submit(Request $request) | ||||
|     { | ||||
|         Log::info('serverSubmitData:' . $request->input('node_id') . ':' . file_get_contents('php://input')); | ||||
|         $server = Server::find($request->input('node_id')); | ||||
|         if (!$server) { | ||||
|         	return response([ | ||||
|         		'ret' => 1, | ||||
|         		'msg' => 'ok' | ||||
|         	]); | ||||
|             return response([ | ||||
|                 'ret' => 1, | ||||
|                 'msg' => 'ok' | ||||
|             ]); | ||||
|         } | ||||
|         $data = file_get_contents('php://input'); | ||||
|         $data = json_decode($data, true); | ||||
|         foreach ($data as $item) { | ||||
|         	$u = $item['u'] * $server->rate; | ||||
| 			$d = $item['d'] * $server->rate; | ||||
| 			$user = User::find($item['user_id']); | ||||
| 			$user->t = time(); | ||||
| 			$user->u = $user->u + $u; | ||||
| 			$user->d = $user->d + $d; | ||||
|             $u = $item['u'] * $server->rate; | ||||
|             $d = $item['d'] * $server->rate; | ||||
|             $user = User::find($item['user_id']); | ||||
|             $user->t = time(); | ||||
|             $user->u = $user->u + $u; | ||||
|             $user->d = $user->d + $d; | ||||
|             $user->save(); | ||||
|              | ||||
|  | ||||
|             $serverLog = new ServerLog(); | ||||
|             $serverLog->user_id = $item['user_id']; | ||||
|             $serverLog->server_id = $request->input('node_id'); | ||||
| @@ -84,15 +87,16 @@ class DeepbworkController extends Controller | ||||
|             $serverLog->rate = $server->rate; | ||||
|             $serverLog->save(); | ||||
|         } | ||||
|          | ||||
|     	return response([ | ||||
|     		'ret' => 1, | ||||
|     		'msg' => 'ok' | ||||
|     	]); | ||||
|  | ||||
|         return response([ | ||||
|             'ret' => 1, | ||||
|             'msg' => 'ok' | ||||
|         ]); | ||||
|     } | ||||
|  | ||||
|     // 后端获取配置 | ||||
|     public function config (Request $request) { | ||||
|     public function config(Request $request) | ||||
|     { | ||||
|         $nodeId = $request->input('node_id'); | ||||
|         $localPort = $request->input('local_port'); | ||||
|         if (empty($nodeId) || empty($localPort)) { | ||||
| @@ -108,26 +112,32 @@ class DeepbworkController extends Controller | ||||
|         $json->inbound->streamSettings->network = $server->network; | ||||
|         if ($server->settings) { | ||||
|             switch ($server->network) { | ||||
|                 case 'tcp': $json->inbound->streamSettings->tcpSettings = json_decode($server->settings); | ||||
|                 case 'tcp': | ||||
|                     $json->inbound->streamSettings->tcpSettings = json_decode($server->settings); | ||||
|                     break; | ||||
|                 case 'kcp': $json->inbound->streamSettings->kcpSettings = json_decode($server->settings); | ||||
|                 case 'kcp': | ||||
|                     $json->inbound->streamSettings->kcpSettings = json_decode($server->settings); | ||||
|                     break; | ||||
|                 case 'ws': $json->inbound->streamSettings->wsSettings = json_decode($server->settings); | ||||
|                 case 'ws': | ||||
|                     $json->inbound->streamSettings->wsSettings = json_decode($server->settings); | ||||
|                     break; | ||||
|                 case 'http': $json->inbound->streamSettings->httpSettings = json_decode($server->settings); | ||||
|                 case 'http': | ||||
|                     $json->inbound->streamSettings->httpSettings = json_decode($server->settings); | ||||
|                     break; | ||||
|                 case 'domainsocket': $json->inbound->streamSettings->dsSettings = json_decode($server->settings); | ||||
|                 case 'domainsocket': | ||||
|                     $json->inbound->streamSettings->dsSettings = json_decode($server->settings); | ||||
|                     break; | ||||
|                 case 'quic': $json->inbound->streamSettings->quicSettings = json_decode($server->settings); | ||||
|                 case 'quic': | ||||
|                     $json->inbound->streamSettings->quicSettings = json_decode($server->settings); | ||||
|                     break; | ||||
|             } | ||||
|         } | ||||
|         if ((int)$server->tls) { | ||||
|             $json->inbound->streamSettings->security = "tls"; | ||||
|             $tls = (object) array("certificateFile" => "/home/v2ray.crt", "keyFile" => "/home/v2ray.key"); | ||||
|             $tls = (object)array("certificateFile" => "/home/v2ray.crt", "keyFile" => "/home/v2ray.key"); | ||||
|             $json->inbound->streamSettings->tlsSettings->certificates[0] = $tls; | ||||
|         } | ||||
|          | ||||
|  | ||||
|         die(json_encode($json, JSON_UNESCAPED_UNICODE)); | ||||
|     } | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user