mirror of
				https://github.com/v2board/v2board.git
				synced 2025-10-31 17:31:49 +08:00 
			
		
		
		
	update: add random port
This commit is contained in:
		| @@ -8,6 +8,7 @@ use App\Models\User; | ||||
| use App\Models\ServerV2ray; | ||||
| use App\Models\ServerTrojan; | ||||
| use App\Utils\CacheKey; | ||||
| use App\Utils\Helper; | ||||
| use Illuminate\Support\Facades\Cache; | ||||
|  | ||||
| class ServerService | ||||
| @@ -34,6 +35,9 @@ class ServerService | ||||
|                 } | ||||
|                 array_push($servers, $v2ray[$i]->toArray()); | ||||
|             } | ||||
|             if (strpos($v2ray[$i]['port'], '-') !== false) { | ||||
|                 $v2ray[$i]['port'] = Helper::randomPort($v2ray[$i]['port']); | ||||
|             } | ||||
|         } | ||||
|  | ||||
|  | ||||
| @@ -59,6 +63,9 @@ class ServerService | ||||
|                 } | ||||
|                 array_push($servers, $trojan[$i]->toArray()); | ||||
|             } | ||||
|             if (strpos($trojan[$i]['port'], '-') !== false) { | ||||
|                 $trojan[$i]['port'] = Helper::randomPort($trojan[$i]['port']); | ||||
|             } | ||||
|         } | ||||
|         return $servers; | ||||
|     } | ||||
| @@ -82,7 +89,9 @@ class ServerService | ||||
|                 } | ||||
|                 array_push($servers, $shadowsocks[$i]->toArray()); | ||||
|             } | ||||
|  | ||||
|             if (strpos($shadowsocks[$i]['port'], '-') !== false) { | ||||
|                 $shadowsocks[$i]['port'] = Helper::randomPort($shadowsocks[$i]['port']); | ||||
|             } | ||||
|         } | ||||
|         return $servers; | ||||
|     } | ||||
|   | ||||
| @@ -112,4 +112,9 @@ class Helper | ||||
|         } | ||||
|         return $subscribeUrl; | ||||
|     } | ||||
|  | ||||
|     public static function randomPort($range) { | ||||
|         $portRange = explode('-', $range); | ||||
|         return rand($portRange[0], $portRange[1]); | ||||
|     } | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user