From 305b6bc81017b208476caa68c9adde83c48bd1ff Mon Sep 17 00:00:00 2001 From: Nachtfalke Date: Tue, 17 Jan 2012 22:18:29 +0100 Subject: Update config/freeradius2/freeradius.inc --- config/freeradius2/freeradius.inc | 160 ++++++++++++++++++++++++++++++++++---- 1 file changed, 146 insertions(+), 14 deletions(-) diff --git a/config/freeradius2/freeradius.inc b/config/freeradius2/freeradius.inc index bc89178a..f3a28e54 100644 --- a/config/freeradius2/freeradius.inc +++ b/config/freeradius2/freeradius.inc @@ -390,7 +390,7 @@ if (is_array($arrusers) && !empty($arrusers)) { // Variables for users file defined parameters $varusersusername = $users['varusersusername']; $varuserspassword = $users['varuserspassword']; - $varuserssimultaneousconnect = ($users['varuserssimultaneousconnect']?$users['varuserssimultaneousconnect']:'1'); + $varuserssimultaneousconnect = ($users['varuserssimultaneousconnect']?$users['varuserssimultaneousconnect']:''); $varusersframedipaddress = $users['varusersframedipaddress']; $varusersframedipnetmask = $users['varusersframedipnetmask']; $varusersframedroute = $users['varusersframedroute']; @@ -404,6 +404,8 @@ if (is_array($arrusers) && !empty($arrusers)) { $varuserspointoftimebytesinput = $users['varuserspointoftimebytesinput']; $varusersamountofbytesoutput = ($users['varusersamountofbytesoutput']?$users['varusersamountofbytesoutput']:''); $varuserspointoftimebytesoutput = $users['varuserspointoftimebytesoutput']; + $varusersmaxbandwidthup = ($users['varusersmaxbandwidthup']?$users['varusersmaxbandwidthup']:''); + $varusersmaxbandwidthdown = ($users['varusersmaxbandwidthdown']?$users['varusersmaxbandwidthdown']:''); // Clear variables for next user foreach additional options TOP $varuserstopadditionaloptions = ''; @@ -491,6 +493,14 @@ if (is_array($arrusers) && !empty($arrusers)) { if ($varusersreplyitem != '') { $varusersreplyitem .=","; } $varusersreplyitem .= "\n\tTunnel-Type = VLAN,\n\tTunnel-Medium-Type = IEEE-802,\n\tTunnel-Private-Group-ID = " . '"' . $varusersvlanid . '"'; } + if ($varusersmaxbandwidthup != '') { + if ($varusersreplyitem != '') { $varusersreplyitem .=","; } + $varusersreplyitem .= "\n\tWISPr-Bandwidth-Max-Up := $varusersmaxbandwidthup"; + } + if ($varusersmaxbandwidthdown != '') { + if ($varusersreplyitem != '') { $varusersreplyitem .=","; } + $varusersreplyitem .= "\n\tWISPr-Bandwidth-Max-Down := $varusersmaxbandwidthdown"; + } if ($varusersadditionaloptionsreplyitems != '') { if ($varusersreplyitem != '') { $varusersreplyitem .=","; } $varusersreplyitem .= "\n\t$varusersadditionaloptionsreplyitems"; @@ -523,18 +533,140 @@ function freeradius_authorizedmacs_resync() { global $config; $conf = ''; - $arrmacs = $config['installedpackages']['freeradiusauthorizedmacs']['config']; if (is_array($arrmacs) && !empty($arrmacs)) { foreach ($arrmacs as $macs) { - // Variables for macs file defined parameters - $varmacaddress = $macs['varmacaddress']; - $varmacaddress = "$varmacaddress" . "\n"; + // Variables for authorized_macs file defined parameters + $varmacsaddress = $macs['varmacsaddress']; + // We don't need a password but we need this field to make syntac correct for CHECK-ITEMS + $varmacspassword = $macs['varmacsaddress']; + + $varmacssimultaneousconnect = ($macs['varmacssimultaneousconnect']?$macs['varmacssimultaneousconnect']:''); + $varmacsframedipaddress = $macs['varmacsframedipaddress']; + $varmacsframedipnetmask = $macs['varmacsframedipnetmask']; + $varmacsframedroute = $macs['varmacsframedroute']; + $varmacsexpiration = $macs['varmacsexpiration']; + $varmacssessiontimeout = $macs['varmacssessiontimeout']; + $varmacslogintime = $macs['varmacslogintime']; + $varmacsvlanid = $macs['varmacsvlanid']; + $varmacsamountoftime = ($macs['varmacsamountoftime']?$macs['varmacsamountoftime']:''); + $varmacspointoftime = $macs['varmacspointoftime']; + $varmacsamountofbytesinput = ($macs['varmacsamountofbytesinput']?$macs['varmacsamountofbytesinput']:''); + $varmacspointoftimebytesinput = $macs['varmacspointoftimebytesinput']; + $varmacsamountofbytesoutput = ($macs['varmacsamountofbytesoutput']?$macs['varmacsamountofbytesoutput']:''); + $varmacspointoftimebytesoutput = $macs['varmacspointoftimebytesoutput']; + $varmacsmaxbandwidthup = ($macs['varmacsmaxbandwidthup']?$macs['varmacsmaxbandwidthup']:''); + $varmacsmaxbandwidthdown = ($macs['varmacsmaxbandwidthdown']?$macs['varmacsmaxbandwidthdown']:''); + + // Clear variables for next mac foreach additional options TOP + $varmacstopadditionaloptions = ''; + $varmacsadditionaloptionstop = ''; + + if(!empty($macs['varmacstopadditionaloptions'])) { + $varmacstopadditionaloptions = explode("|", ($macs['varmacstopadditionaloptions'])); + foreach ($varmacstopadditionaloptions as $toptmp) { + $varmacsadditionaloptionstop .= $toptmp . "\n"; + } + } + + // Clear variables for next mac foreach additional options: CHECK-ITEMS + $varmacscheckitemsadditionaloptions = ''; + $varmacsadditionaloptionscheckitems = ''; + + if(!empty($macs['varmacscheckitemsadditionaloptions'])) { + $varmacscheckitemsadditionaloptions = explode("|", ($macs['varmacscheckitemsadditionaloptions'])); + $varmacsadditionaloptionscheckitems .= ''; + foreach ($varmacscheckitemsadditionaloptions as $checkitemtmp) { + $varmacsadditionaloptionscheckitems .= $checkitemtmp; + } + } + + // Clear variables for next mac foreach additional options: REPLY-ITEMS + $varmacsreplyitemsadditionaloptions = ''; + $varmacsadditionaloptionsreplyitems = ''; + + if(!empty($macs['varmacsreplyitemsadditionaloptions'])) { + $varmacsreplyitemsadditionaloptions = explode("|", ($macs['varmacsreplyitemsadditionaloptions'])); + $varmacsadditionaloptionsreplyitems .= ''; + foreach ($varmacsreplyitemsadditionaloptions as $replyitemtmp) { + $varmacsadditionaloptionsreplyitems .= $replyitemtmp . "\n\t"; + } + } + + // Empty variable + $varmacscheckitem = ''; + $varmacsreplyitem = ''; + + // Add the mac attributes to each mac address. + $varmacscheckitem = "$varmacsaddress" . " Cleartext-Password := " . '"' . $varmacspassword .'"'; + + // Add additional CHECK-ITEMS here. Different formatting in "authorized_macs" file needed. + if ($varmacssimultaneousconnect != '') { + $varmacscheckitem .= ", Simultaneous-Use := " . '"' . $varmacssimultaneousconnect . '"'; + } + if ($varmacsexpiration != '') { + $varmacscheckitem .= ", Expiration := " . '"' . $varmacsexpiration . '"'; + } + if ($varmacslogintime != '') { + $varmacscheckitem .= ", Login-Time := " . '"' . $varmacslogintime . '"'; + } + if ($varmacsamountoftime != '') { + $varmacscheckitem .= ", Max-" . "$varmacspointoftime" . "-Session := " . "$varmacsamountoftime"; + } + if ($varmacsamountofbytesinput != '') { + $varmacscheckitem .= ", Max-" . "$varmacspointoftimebytesinput" . "-Input := " . "$varmacsamountofbytesinput"; + } + if ($varmacsamountofbytesoutput != '') { + $varmacscheckitem .= ", Max-" . "$varmacspointoftimebytesoutput" . "-Output := " . "$varmacsamountofbytesoutput"; + } + if ($varmacsadditionaloptionscheckitems != '') { + $varmacscheckitem .= ", $varmacsadditionaloptionscheckitems"; + } + + // Add additional REPLY-ITEMS here. Different formatting in "authorized_macs" file needed. + if ($varmacsframedipaddress != '') { + if ($varmacsreplyitem != '') { $varmacsreplyitem .=","; } + $varmacsreplyitem .= "\n\tFramed-IP-Address = $varmacsframedipaddress"; + } + if ($varmacsframedipnetmask != '') { + if ($varmacsreplyitem != '') { $varmacsreplyitem .=","; } + $varmacsreplyitem .= "\n\tFramed-IP-Netmask = $varmacsframedipnetmask"; + } + if ($varmacsframedroute != '') { + if ($varmacsreplyitem != '') { $varmacsreplyitem .=","; } + $varmacsreplyitem .= "\n\tFramed-Route = " . '"' . $varmacsframedroute . '"'; + } + if ($varmacssessiontimeout != '') { + if ($varmacsreplyitem != '') { $varmacsreplyitem .=","; } + $varmacsreplyitem .= "\n\tSession-Timeout := $varmacssessiontimeout"; + } + if ($varmacsvlanid != '') { + if ($varmacsreplyitem != '') { $varmacsreplyitem .=","; } + $varmacsreplyitem .= "\n\tTunnel-Type = VLAN,\n\tTunnel-Medium-Type = IEEE-802,\n\tTunnel-Private-Group-ID = " . '"' . $varmacsvlanid . '"'; + } + if ($varmacsmaxbandwidthup != '') { + if ($varmacsreplyitem != '') { $varmacsreplyitem .=","; } + $varmacsreplyitem .= "\n\tWISPr-Bandwidth-Max-Up := $varmacsmaxbandwidthup"; + } + if ($varmacsmaxbandwidthdown != '') { + if ($varmacsreplyitem != '') { $varmacsreplyitem .=","; } + $varmacsreplyitem .= "\n\tWISPr-Bandwidth-Max-Down := $varmacsmaxbandwidthdown"; + } + if ($varmacsadditionaloptionsreplyitems != '') { + if ($varmacsreplyitem != '') { $varmacsreplyitem .=","; } + $varmacsreplyitem .= "\n\t$varmacsadditionaloptionsreplyitems"; + } + + // Cosmetic fix - This is just to make a blank new line after each macs entry + $varmacsreplyitem .= "\n\n"; + $conf .= <<