- Add LDCNetworks API
This commit is contained in:
parent
8d80e6c674
commit
7a4de8716b
2 changed files with 31 additions and 0 deletions
30
app/Http/Controllers/API/LDCNetworksController.php
Normal file
30
app/Http/Controllers/API/LDCNetworksController.php
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\API;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\LDCNetworks;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class LDCNetworksController extends Controller
|
||||
{
|
||||
public function index(Request $request) {
|
||||
$token = $request->token;
|
||||
|
||||
if ($token !== 'CE8S52Qq7stf5k8frF4T')
|
||||
return response('Unauthorized', 401);
|
||||
|
||||
$ips = [];
|
||||
|
||||
$networks = LDCNetworks::all();
|
||||
foreach ($networks as $network) {
|
||||
$infos = explode('.', $network->first_ip);
|
||||
$min = $infos[3];
|
||||
$max = explode('.', $network->last_ip)[3];
|
||||
for ($i = $min; $i <= $max; $i++) {
|
||||
$ips[] = "$infos[0].$infos[1].$infos[2].$i";
|
||||
}
|
||||
}
|
||||
return response($ips);
|
||||
}
|
||||
}
|
||||
|
|
@ -18,3 +18,4 @@ Route::middleware('auth:api')->get('/user', function (Request $request) {
|
|||
});
|
||||
|
||||
Route::post('/status-checker', 'API\StatusCheckerController@index');
|
||||
Route::get('/ldc-networks', 'API\LDCNetworksController@index');
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue