summaryrefslogtreecommitdiffstats
path: root/etc
diff options
context:
space:
mode:
authorScott Ullrich <sullrich@pfsense.org>2011-03-23 19:14:28 -0400
committerScott Ullrich <sullrich@pfsense.org>2011-03-23 19:14:28 -0400
commitd322e3b37fea3f53117ebdaeb9737f0000d46c82 (patch)
tree40f27519f1f98298a3f47075b7f3975caab227f6 /etc
parentd421e31930e8fc036b70eb0af4fc08872147fb75 (diff)
downloadpfsense-d322e3b37fea3f53117ebdaeb9737f0000d46c82.zip
pfsense-d322e3b37fea3f53117ebdaeb9737f0000d46c82.tar.gz
Fix voucher disconnect sync issue
Diffstat (limited to 'etc')
-rw-r--r--etc/inc/captiveportal.inc11
-rw-r--r--etc/inc/voucher.inc48
2 files changed, 59 insertions, 0 deletions
diff --git a/etc/inc/captiveportal.inc b/etc/inc/captiveportal.inc
index ef59446..f8c0ccd 100644
--- a/etc/inc/captiveportal.inc
+++ b/etc/inc/captiveportal.inc
@@ -881,6 +881,17 @@ function captiveportal_disconnect($dbent, $radiusservers,$term_cause = 1,$stop_t
/* Release the ruleno so it can be reallocated to new clients. */
captiveportal_free_ipfw_ruleno($dbent[1]);
+
+ // XMLRPC Call over to the master Voucher node
+ $a_voucher = &$config['voucher'];
+ if(!empty($a_voucher['vouchersyncdbip'])) {
+ $syncip = $a_voucher['vouchersyncdbip'];
+ $syncport = $a_voucher['vouchersyncport'];
+ $syncpass = $a_voucher['vouchersyncpass'];
+ $vouchersyncusername = $a_voucher['vouchersyncusername'];
+ $remote_status = xmlrpc_sync_voucher_disconnect($dben, $syncip, $syncport, $syncpass, $vouchersyncusername, $term_cause, $stop_time);
+ }
+
}
/* remove a single client by sessionid */
diff --git a/etc/inc/voucher.inc b/etc/inc/voucher.inc
index 3b34e93..f4b5e1b 100644
--- a/etc/inc/voucher.inc
+++ b/etc/inc/voucher.inc
@@ -37,6 +37,54 @@
if(!function_exists('captiveportal_syslog'))
require_once("captiveportal.inc");
+function xmlrpc_sync_voucher_disconnect($dbent, $syncip, $port, $password, $username, $term_cause = "1", $stop_time = null) {
+ global $g, $config;
+ require_once("xmlrpc.inc");
+ if($port == "443")
+ $url = "https://{$syncip}:{$port}";
+ else
+ $url = "http://{$syncip}:{$port}";
+
+ /* Construct code that is run on remote machine */
+ $method = 'pfsense.exec_php';
+ $execcmd = <<<EOF
+ require_once('/etc/inc/captiveportal.inc');
+ require_once('/etc/inc/voucher.inc');
+ \$radiusservers = captiveportal_get_radius_servers();
+ captiveportal_disconnect(\$dbent, \$radiusservers, \$term_cause, \$stop_time);
+
+EOF;
+
+ /* assemble xmlrpc payload */
+ $params = array(
+ XML_RPC_encode($password),
+ XML_RPC_encode($execcmd)
+ );
+
+ log_error("Captive Portal Voucher XMLRPC sync data {$url}:{$port}.");
+ $msg = new XML_RPC_Message($method, $params);
+ $cli = new XML_RPC_Client('/xmlrpc.php', $url, $port);
+ $cli->setCredentials($username, $password);
+ $resp = $cli->send($msg, "250");
+ if(!is_object($resp)) {
+ $error = "A communications error occurred while attempting CaptivePortalVoucherSync XMLRPC sync with {$url}:{$port} (pfsense.exec_php).";
+ log_error($error);
+ file_notice("CaptivePortalVoucherSync", $error, "Communications error occurred", "");
+ return false;
+ } elseif($resp->faultCode()) {
+ $error = "An error code was received while attempting CaptivePortalVoucherSync XMLRPC sync with {$url}:{$port} - Code " . $resp->faultCode() . ": " . $resp->faultString();
+ log_error($error);
+ file_notice("CaptivePortalVoucherSync", $error, "Error code received", "");
+ return false;
+ } else {
+ log_error("CaptivePortalVoucherSync XMLRPC reload data success with {$url}:{$port} (pfsense.exec_php).");
+ }
+
+ $toreturn = XML_RPC_Decode($resp->value());
+
+ return $toreturn;
+}
+
function xmlrpc_sync_used_voucher($voucher_received, $syncip, $port, $password, $username) {
global $g, $config;
require_once("xmlrpc.inc");
OpenPOWER on IntegriCloud