mirror of
https://github.com/IdalecioSch/WGDashboard-WHMCS.git
synced 2026-07-28 00:30:07 -03:00
misfig suspend/unsuspend
This commit is contained in:
@@ -360,8 +360,10 @@ function wgdashboard_TerminateAccount($params)
|
|||||||
if(!isset($publicKey)) throw new Exception('Failed to terminate peer because it doesn\'t exist.');
|
if(!isset($publicKey)) throw new Exception('Failed to terminate peer because it doesn\'t exist.');
|
||||||
|
|
||||||
$configName = $params['configoptions']['Config Name'] ?? $params['configoption2'] ?? 'wg0';
|
$configName = $params['configoptions']['Config Name'] ?? $params['configoption2'] ?? 'wg0';
|
||||||
$publicKeyEncoded = urlencode($publicKey);
|
|
||||||
$deleteResult = wgdashboard_API($params, 'deletePeers/' . urlencode($configName) . '?id=' . $publicKeyEncoded, [], 'DELETE');
|
$deleteResult = wgdashboard_API($params, 'deletePeers/' . urlencode($configName), [
|
||||||
|
'peers' => [$publicKey]
|
||||||
|
], 'POST');
|
||||||
|
|
||||||
if($deleteResult['status_code'] !== 200) throw new Exception('Failed to delete the peer, received error code: ' . $deleteResult['status_code'] . '. Enable module debug log for more info.');
|
if($deleteResult['status_code'] !== 200) throw new Exception('Failed to delete the peer, received error code: ' . $deleteResult['status_code'] . '. Enable module debug log for more info.');
|
||||||
|
|
||||||
@@ -379,8 +381,10 @@ function wgdashboard_SuspendAccount($params)
|
|||||||
if(!isset($publicKey)) throw new Exception('Failed to suspend peer because it doesn\'t exist.');
|
if(!isset($publicKey)) throw new Exception('Failed to suspend peer because it doesn\'t exist.');
|
||||||
|
|
||||||
$configName = $params['configoptions']['Config Name'] ?? $params['configoption2'] ?? 'wg0';
|
$configName = $params['configoptions']['Config Name'] ?? $params['configoption2'] ?? 'wg0';
|
||||||
$publicKeyEncoded = urlencode($publicKey);
|
|
||||||
$suspendResult = wgdashboard_API($params, 'restrictPeers/' . urlencode($configName) . '?id=' . $publicKeyEncoded, [], 'POST');
|
$suspendResult = wgdashboard_API($params, 'restrictPeers/' . urlencode($configName), [
|
||||||
|
'peers' => [$publicKey]
|
||||||
|
], 'POST');
|
||||||
|
|
||||||
if($suspendResult['status_code'] !== 200) throw new Exception('Failed to suspend the peer, received error code: ' . $suspendResult['status_code'] . '. Enable module debug log for more info.');
|
if($suspendResult['status_code'] !== 200) throw new Exception('Failed to suspend the peer, received error code: ' . $suspendResult['status_code'] . '. Enable module debug log for more info.');
|
||||||
} catch(Exception $err) {
|
} catch(Exception $err) {
|
||||||
@@ -397,8 +401,10 @@ function wgdashboard_UnsuspendAccount($params)
|
|||||||
if(!isset($publicKey)) throw new Exception('Failed to unsuspend peer because it doesn\'t exist.');
|
if(!isset($publicKey)) throw new Exception('Failed to unsuspend peer because it doesn\'t exist.');
|
||||||
|
|
||||||
$configName = $params['configoptions']['Config Name'] ?? $params['configoption2'] ?? 'wg0';
|
$configName = $params['configoptions']['Config Name'] ?? $params['configoption2'] ?? 'wg0';
|
||||||
$publicKeyEncoded = urlencode($publicKey);
|
|
||||||
$unsuspendResult = wgdashboard_API($params, 'allowAccessPeers/' . urlencode($configName) . '?id=' . $publicKeyEncoded, [], 'POST');
|
$unsuspendResult = wgdashboard_API($params, 'allowAccessPeers/' . urlencode($configName), [
|
||||||
|
'peers' => [$publicKey]
|
||||||
|
], 'POST');
|
||||||
|
|
||||||
if($unsuspendResult['status_code'] !== 200) throw new Exception('Failed to unsuspend the peer, received error code: ' . $unsuspendResult['status_code'] . '. Enable module debug log for more info.');
|
if($unsuspendResult['status_code'] !== 200) throw new Exception('Failed to unsuspend the peer, received error code: ' . $unsuspendResult['status_code'] . '. Enable module debug log for more info.');
|
||||||
} catch(Exception $err) {
|
} catch(Exception $err) {
|
||||||
@@ -421,7 +427,7 @@ function wgdashboard_ChangePackage($params)
|
|||||||
'allowed_ip' => $allowedIps,
|
'allowed_ip' => $allowedIps,
|
||||||
];
|
];
|
||||||
|
|
||||||
$updateResult = wgdashboard_API($params, 'updatePeer/' . urlencode($configName) . '/' . urlencode($peerId), $updateData, 'POST');
|
$updateResult = wgdashboard_API($params, 'updatePeerSettings/' . urlencode($configName) . '/' . urlencode($peerId), $updateData, 'POST');
|
||||||
|
|
||||||
if($updateResult['status_code'] !== 200) throw new Exception('Failed to update the peer, received error code: ' . $updateResult['status_code'] . '. Enable module debug log for more info.');
|
if($updateResult['status_code'] !== 200) throw new Exception('Failed to update the peer, received error code: ' . $updateResult['status_code'] . '. Enable module debug log for more info.');
|
||||||
} catch(Exception $err) {
|
} catch(Exception $err) {
|
||||||
|
|||||||
Reference in New Issue
Block a user