Fix Radius limiting speed

This commit is contained in:
Ibnu Maksum 2024-07-03 09:27:30 +07:00
parent 7f757e07c8
commit 1704fe563d
No known key found for this signature in database
GPG Key ID: 7FC82848810579E5

View File

@ -8,7 +8,8 @@
* better create new plugin * better create new plugin
**/ **/
class Radius { class Radius
{
function add_customer($customer, $plan) function add_customer($customer, $plan)
{ {
@ -51,11 +52,16 @@ class Radius {
$ratos = $rates[0] . '/' . $rates[1]; $ratos = $rates[0] . '/' . $rates[1];
} }
$this->upsertPackage($plan['id'], 'Ascend-Data-Rate', $rates[1], ':='); $this->upsertPackage($plan['id'], 'Ascend-Data-Rate', $this->stringToInteger($rates[1]), ':=');
$this->upsertPackage($plan['id'], 'Ascend-Xmit-Rate', $rates[0], ':='); $this->upsertPackage($plan['id'], 'Ascend-Xmit-Rate', $this->stringToInteger($rates[1]), ':=');
$this->upsertPackage($plan['id'], 'Mikrotik-Rate-Limit', $ratos, ':='); $this->upsertPackage($plan['id'], 'Mikrotik-Rate-Limit', $ratos, ':=');
} }
function stringToInteger($str)
{
return str_replace('G', '000000000', str_replace('M', '000000', str_replace('K', '000', $str)));
}
function update_plan($old_name, $plan) function update_plan($old_name, $plan)
{ {
$this->add_plan($plan); $this->add_plan($plan);
@ -160,8 +166,8 @@ class Radius {
$ratos = $rates[0] . '/' . $rates[1]; $ratos = $rates[0] . '/' . $rates[1];
} }
$this->upsertPackage($plan_id, 'Ascend-Data-Rate', $rates[1], ':='); $this->upsertPackage($plan_id, 'Ascend-Data-Rate', $this->stringToInteger($rates[1]), ':=');
$this->upsertPackage($plan_id, 'Ascend-Xmit-Rate', $rates[0], ':='); $this->upsertPackage($plan_id, 'Ascend-Xmit-Rate', $this->stringToInteger($rates[0]), ':=');
$this->upsertPackage($plan_id, 'Mikrotik-Rate-Limit', $ratos, ':='); $this->upsertPackage($plan_id, 'Mikrotik-Rate-Limit', $ratos, ':=');
// if ($pool != null) { // if ($pool != null) {
// $this->upsertPackage($plan_id, 'Framed-Pool', $pool, ':='); // $this->upsertPackage($plan_id, 'Framed-Pool', $pool, ':=');
@ -394,6 +400,4 @@ class Radius {
} }
return $result; return $result;
} }
} }