- Timestamp:
- Apr 6, 2020, 11:17:40 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/NetworkConfigLinux/Generators/TrafficShaping.php
r790 r873 1 1 <?php 2 2 3 if (isset($_SERVER['REMOTE_ADDR'])) die();3 if (isset($_SERVER['REMOTE_ADDR'])) die(); 4 4 5 5 $Enabled = 1; … … 37 37 exec('/sbin/iptables -t mangle -F PREROUTING'); 38 38 exec('/sbin/iptables -t mangle -F POSTROUTING'); 39 if ($Enabled)39 if ($Enabled) 40 40 { 41 41 //exec('/sbin/iptables -t mangle -A FORWARD -j MARK --set-mark 0'); … … 48 48 // In going traffic 49 49 fputs($File, "/sbin/tc qdisc del dev ".$InInterface." root\n"); 50 if ($Enabled)50 if ($Enabled) 51 51 { 52 52 fputs($File, "/sbin/tc qdisc add dev ".$InInterface." root handle 1:0 htb default 2\n"); … … 59 59 // Out going traffic 60 60 fputs($File, "/sbin/tc qdisc del dev ".$OutInterface." root\n"); 61 if ($Enabled)61 if ($Enabled) 62 62 { 63 63 fputs($File, "/sbin/tc qdisc add dev ".$OutInterface." root handle 1:0 htb default 2\n"); … … 69 69 } 70 70 71 if (!$Enabled) die("Traffic shaping disabled\n");72 73 if ($ClassesEnabled)71 if (!$Enabled) die("Traffic shaping disabled\n"); 72 73 if ($ClassesEnabled) 74 74 { 75 75 $ClassId = 3; … … 124 124 125 125 $DbResult = $Database->select('users', '*, CONCAT(second_name, " ", first_name) as fullname', '(inet=1)'); 126 while ($User = $DbResult->fetch_array())126 while ($User = $DbResult->fetch_array()) 127 127 { 128 128 $UserClassId = $ClassId; … … 152 152 153 153 $DbResult2 = $Database->select('hosts','*',"block=0 AND MAC!='' AND user=".$User['id']); 154 while ($Host = $DbResult2->fetch_array())155 //if ($Row['name'] != 'WOW')154 while ($Host = $DbResult2->fetch_array()) 155 //if ($Row['name'] != 'WOW') 156 156 { 157 157 $HostClassId = $ClassId; … … 160 160 fputs($FileClassInfo, '1:'.$HostClassId.' '.$Host['name']."\n"); 161 161 //echo(' Host class id: '.$HostClassId."\n"); 162 //if ($User['inet'] == 1)162 //if ($User['inet'] == 1) 163 163 { 164 164 $Prio = 1; 165 if ($Host['vpn'] == 1)165 if ($Host['vpn'] == 1) 166 166 { 167 if ($Host['external_ip'] != '') $Host['IP'] = $Host['external_ip'];167 if ($Host['external_ip'] != '') $Host['IP'] = $Host['external_ip']; 168 168 else $Host['IP'] = ToVpnIp($Host); 169 169 } 170 170 171 //if ($Host['name'] == 'TERMINAL') $SpeedDivider = 0.5;171 //if ($Host['name'] == 'TERMINAL') $SpeedDivider = 0.5; 172 172 //else 173 173 $SpeedDivider = 1; 174 174 175 if ($Host['name'] == 'centrala')175 if ($Host['name'] == 'centrala') 176 176 { 177 177 $Host['IP'] = $Host['external_ip']; … … 183 183 $TableIn = 'FORWARD'; 184 184 } 185 //if ($Row['name'] == 'TERMINAL2') $Prio = 0;186 // if ($Row['name'] = 'TERMINAL2') $Prio = 0;187 if ($Host['name'] == 'voip-hajda') $Protocol = ' -p tcp';185 //if ($Row['name'] == 'TERMINAL2') $Prio = 0; 186 // if ($Row['name'] = 'TERMINAL2') $Prio = 0; 187 if ($Host['name'] == 'voip-hajda') $Protocol = ' -p tcp'; 188 188 else $Protocol = ''; 189 // if ($Host['name'] == 'KARLOS') $UserMaxSpeedIn = 128000;189 // if ($Host['name'] == 'KARLOS') $UserMaxSpeedIn = 128000; 190 190 /* 191 if ($Host['name'] == 'GAME')191 if ($Host['name'] == 'GAME') 192 192 { 193 193 exec('/sbin/iptables -t mangle -F game-server'); … … 195 195 $TableIn = 'game-server'; 196 196 }*/ 197 //if ($Host['name'] == 'TBC') continue;197 //if ($Host['name'] == 'TBC') continue; 198 198 199 199 // In going traffic … … 213 213 } 214 214 // Free inet 215 if ($Tarify[$User['inet_tarif_now']]['group_id'] == 3)215 if ($Tarify[$User['inet_tarif_now']]['group_id'] == 3) 216 216 { 217 217 //exec('/sbin/iptables -t mangle -A '.$TableIn.' -i eth1 -d '.$Host['IP'].$Protocol." -j MARK --set-mark ".$FreeInetClass); … … 220 220 // VoIP devices 221 221 /* 222 if (($Host['name'] == 'HAJDA-VOIP') || ($Host['name'] == 'NAVRATIL-VOIP'))222 if (($Host['name'] == 'HAJDA-VOIP') || ($Host['name'] == 'NAVRATIL-VOIP')) 223 223 { 224 224 exec('/sbin/iptables -t mangle -A '.$TableIn." -i eth1 -d ".$Host['IP']." -p udp -j MARK --set-mark ".$VoipClassId); 225 225 exec('/sbin/iptables -t mangle -A '.$TableOut." -o eth1 -s ".$Host['IP']." -p udp -j MARK --set-mark ".$VoipClassId); 226 226 } else 227 if ($Host['name'] == 'GAME')227 if ($Host['name'] == 'GAME') 228 228 { 229 229 exec('/sbin/iptables -t mangle -A FORWARD -o eth1 -s '.$Host['IP']." -j game-server");
Note:
See TracChangeset
for help on using the changeset viewer.