From: jdegraeve Date: Fri, 31 Mar 2006 09:02:21 +0000 (+0000) Subject: Activate the radius accounting code to allow more then 1 radius server for accounting... X-Git-Url: https://git.gsnw.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bfc4bc92d5fe7d5a955f0298ed4f2d09a1713c7b;p=m0n0chwall.git Activate the radius accounting code to allow more then 1 radius server for accounting (same behaviour as authentication) git-svn-id: https://svn.m0n0.ch/wall/trunk@120 e36fee2c-cc09-0410-a7cc-ebac5c6737de --- diff --git a/captiveportal/index.php b/captiveportal/index.php index 100d332..b493cba 100755 --- a/captiveportal/index.php +++ b/captiveportal/index.php @@ -281,9 +281,7 @@ function portal_allow($clientip,$clientmac,$clientuser,$password = null, $attrib $cpdb[$i][4], // username $cpdb[$i][5], // sessionid $cpdb[$i][0], // start time - $radiusservers[0]['ipaddr'], - $radiusservers[0]['acctport'], - $radiusservers[0]['key'], + $radiusservers, $cpdb[$i][2], // clientip $cpdb[$i][3], // clientmac 13); // Port Preempted @@ -406,9 +404,7 @@ function disconnect_client($sessionid, $logoutReason = "LOGOUT", $term_cause = 1 $cpdb[$i][4], // username $cpdb[$i][5], // sessionid $cpdb[$i][0], // start time - $radiusservers[0]['ipaddr'], - $radiusservers[0]['acctport'], - $radiusservers[0]['key'], + $radiusservers, $cpdb[$i][2], // clientip $cpdb[$i][3], // clientmac $term_cause); diff --git a/captiveportal/radius_accounting.inc b/captiveportal/radius_accounting.inc index 9f9064d..ad2d0aa 100644 --- a/captiveportal/radius_accounting.inc +++ b/captiveportal/radius_accounting.inc @@ -43,7 +43,7 @@ RADIUS ACCOUNTING START ----------------------- */ -function RADIUS_ACCOUNTING_START($ruleno,$username,$sessionid,$radiusip,$radiusport,$radiuskey,$clientip,$clientmac) { +function RADIUS_ACCOUNTING_START($ruleno,$username,$sessionid,$radiusservers,$clientip,$clientmac) { global $config; @@ -67,6 +67,14 @@ function RADIUS_ACCOUNTING_START($ruleno,$username,$sessionid,$radiusip,$radiusp // Create our instance $racct = new Auth_RADIUS_Acct_Start; + // Initialise our server + foreach ($radiusservers as $radsrv) { + + // Add a new server to our instance + $racct->addServer($radsrv['ipaddr'], $radsrv['port'], $radsrv['key']); + + } + /* Different Authentication options * * Its possible todo other authentication methods but still do radius accounting @@ -80,7 +88,6 @@ function RADIUS_ACCOUNTING_START($ruleno,$username,$sessionid,$radiusip,$radiusp // Construct data package $racct->username = $username; - $racct->addServer($radiusip, $radiusport, $radiuskey); if (PEAR::isError($racct->start())) { $retvalue['acct_val'] = 1; @@ -91,14 +98,6 @@ function RADIUS_ACCOUNTING_START($ruleno,$username,$sessionid,$radiusip,$radiusp $racct->close(); return $retvalue; - /* Old code: - * $status = $racct->start(); - * if(PEAR::isError($status)) { - * if ($debug) - * printf("Radius start: %s
\n", $status->getMessage()); - * exit; - * } - */ } /* @@ -149,7 +148,7 @@ RADIUS ACCOUNTING STOP/UPDATE ----------------------------- */ -function RADIUS_ACCOUNTING_STOP($ruleno,$username,$sessionid,$start_time,$radiusip,$radiusport,$radiuskey,$clientip,$clientmac, $term_cause = 1, $interimupdate=false,$stop_time = null) { +function RADIUS_ACCOUNTING_STOP($ruleno,$username,$sessionid,$start_time,$radiusservers,$clientip,$clientmac, $term_cause = 1, $interimupdate=false,$stop_time = null) { global $config; @@ -183,26 +182,19 @@ function RADIUS_ACCOUNTING_STOP($ruleno,$username,$sessionid,$start_time,$radius else $racct = new Auth_RADIUS_Acct_Stop; - /* - * Currently disabled - Add support for more then one radiusserver. - At most 10 servers may be specified. - When multiple servers are given, they are tried in round-robin fashion until a valid response is received - + // Initialise our server foreach ($radiusservers as $radsrv) { // Add a new server to our instance $racct->addServer($radsrv['ipaddr'], $radsrv['port'], $radsrv['key']); } - */ // See RADIUS_ACCOUNTING_START for info $racct->authentic = RADIUS_AUTH_RADIUS; // Construct data package $racct->username = $username; - $racct->addServer($radiusip, $radiusport, $radiuskey); // Set session_time $racct->session_time = $session_time; diff --git a/phpconf/inc/captiveportal.inc b/phpconf/inc/captiveportal.inc index 824948d..a2f8f45 100644 --- a/phpconf/inc/captiveportal.inc +++ b/phpconf/inc/captiveportal.inc @@ -451,9 +451,7 @@ function captiveportal_prune_old() { $cpdb[$i][4], // username $cpdb[$i][5], // sessionid $cpdb[$i][0], // start time - $radiusservers[0]['ipaddr'], - $radiusservers[0]['acctport'], - $radiusservers[0]['key'], + $radiusservers, $cpdb[$i][2], // clientip $cpdb[$i][3], // clientmac 10); // NAS Request @@ -461,9 +459,7 @@ function captiveportal_prune_old() { RADIUS_ACCOUNTING_START($cpdb[$i][1], // ruleno $cpdb[$i][4], // username $cpdb[$i][5], // sessionid - $radiusservers[0]['ipaddr'], - $radiusservers[0]['acctport'], - $radiusservers[0]['key'], + $radiusservers, $cpdb[$i][2], // clientip $cpdb[$i][3]); // clientmac } else if ($config['captiveportal']['reauthenticateacct'] == "interimupdate") { @@ -471,9 +467,7 @@ function captiveportal_prune_old() { $cpdb[$i][4], // username $cpdb[$i][5], // sessionid $cpdb[$i][0], // start time - $radiusservers[0]['ipaddr'], - $radiusservers[0]['acctport'], - $radiusservers[0]['key'], + $radiusservers, $cpdb[$i][2], // clientip $cpdb[$i][3], // clientmac 10, // NAS Request @@ -516,9 +510,7 @@ function captiveportal_disconnect($dbent, $radiusservers,$term_cause = 1,$stop_t $dbent[4], // username $dbent[5], // sessionid $dbent[0], // start time - $radiusservers[0]['ipaddr'], - $radiusservers[0]['acctport'], - $radiusservers[0]['key'], + $radiusservers, $dbent[2], // clientip $dbent[3], // clientmac $term_cause, // Acct-Terminate-Cause @@ -582,9 +574,7 @@ function captiveportal_radius_stop_all() { $cpdb[$i][4], // username $cpdb[$i][5], // sessionid $cpdb[$i][0], // start time - $radiusservers[0]['ipaddr'], - $radiusservers[0]['acctport'], - $radiusservers[0]['key'], + $radiusservers, $cpdb[$i][2], // clientip $cpdb[$i][3], // clientmac 7); // Admin Reboot @@ -807,9 +797,7 @@ function radius($username,$password,$clientip,$clientmac,$type) { $auth_list['acct_val'] = RADIUS_ACCOUNTING_START($ruleno, $username, $sessionid, - $radiusservers[0]['ipaddr'], - $radiusservers[0]['acctport'], - $radiusservers[0]['key'], + $radiusservers, $clientip, $clientmac); if ($auth_list['acct_val'] == 1) diff --git a/webgui/services_captiveportal.php b/webgui/services_captiveportal.php index 99200e8..c675212 100755 --- a/webgui/services_captiveportal.php +++ b/webgui/services_captiveportal.php @@ -409,7 +409,7 @@ to access after they've authenticated.   > send RADIUS accounting packets
- If this is enabled, RADIUS accounting packets will be sent to the primary RADIUS server. + If this is enabled, RADIUS accounting packets will be sent to the RADIUS server(s). Accounting port