Radius Rest API

This commit is contained in:
Ibnu Maksum
2024-07-06 22:49:02 +07:00
parent 835276fef5
commit 410eb34d4a
7 changed files with 265 additions and 18 deletions

View File

@ -31,9 +31,23 @@ class MikrotikPppoe
{
$mikrotik = $this->info($plan['routers']);
$client = $this->getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
$this->removePpoeUser($client, $customer['username']);
$this->removePpoeActive($client, $customer['username']);
$this->addPpoeUser($client, $plan, $customer);
//check if customer exists
$printRequest = new RouterOS\Request('/ppp/secret/print');
$printRequest->setQuery(RouterOS\Query::where('name', $customer['username']));
$cid = $client->sendSync($printRequest)->getProperty('.id');
if (empty($cid)) {
//customer not exists, add it
$this->addPpoeUser($client, $plan, $customer);
}else{
$setRequest = new RouterOS\Request('/ppp/secret/set');
$setRequest->setArgument('numbers', $cid);
$setRequest->setArgument('profile', $plan['name_plan']);
$setRequest->setArgument('comment', $customer['fullname'] . ' | ' . $customer['email']);
$setRequest->setArgument('password', $customer['password']);
$client->sendSync($setRequest);
//disconnect then
$this->removePpoeActive($client, $customer['username']);
}
}
function remove_customer($customer, $plan)
@ -212,15 +226,6 @@ class MikrotikPppoe
return $client->sendSync($printRequest)->getProperty('.id');
}
function connect_customer($customer, $ip, $mac_address, $router_name)
{
}
function disconnect_customer($customer, $router_name)
{
}
function info($name)
{
return ORM::for_table('tbl_routers')->where('name', $name)->find_one();