34 lines
942 B
PHP
34 lines
942 B
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use APP\Component\Config\IConfig;
|
|
use App\Jobs\Updater\IUpdater;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Http\Response;
|
|
|
|
class DynDnsController extends Controller
|
|
{
|
|
public function update(Request $request) {
|
|
$this->validate($request, [
|
|
'hostname' => 'required',
|
|
'myip' => 'required|ipv4',
|
|
'password' => 'required|',
|
|
'username' => 'required|'
|
|
]);
|
|
|
|
$config = app(IConfig::class);
|
|
$updater = app(IUpdater::class);
|
|
|
|
$userValide = $config->validateUser($request->input("username"), $request->input("password"), $request->input("hostname"));
|
|
|
|
if(!$userValide) {
|
|
return new Response("Invalide Data", 400);
|
|
}
|
|
|
|
$updater->config($request->input("hostname"), $request->input("myip"));
|
|
$this->dispatch($updater);
|
|
|
|
return new Response("Update started", 201);
|
|
}
|
|
}
|