Changeset 120 for system/generators/traffic_shaping_routerboard.php
- Timestamp:
- Dec 6, 2008, 11:33:29 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
system/generators/traffic_shaping_routerboard.php
r119 r120 36 36 37 37 // Root of tree and main limit 38 $PacketMark = 0; 39 $Commands[] = ' /queue tree add name=main-out limit-at='.$TotalMaxSpeedIn.' max-limit='.$TotalMaxSpeedIn.' parent=global-out'; 40 $Commands[] = ' /queue tree add name=main-in limit-at='.$TotalMaxSpeedOut.' max-limit='.$TotalMaxSpeedOut.' parent=global-out'; 38 $PacketMark = 1; 39 $Commands[] = ' /queue tree add name=main-out limit-at='.$UsersMaxSpeedIn.' max-limit='.$UsersMaxSpeedIn.' parent=global-out'; 40 $Commands[] = ' /ip firewall mangle add chain=forward out-interface='.$InetInterface.' action=jump jump-target=inet-out'; 41 $Commands[] = ' /queue tree add name=main-in limit-at='.$UsersMaxSpeedOut.' max-limit='.$UsersMaxSpeedOut.' parent=global-out'; 42 $Commands[] = ' /ip firewall mangle add chain=forward in-interface='.$InetInterface.' action=jump jump-target=inet-in'; 41 43 42 44 // Slow free internet 43 45 $Commands[] = ' /queue tree add name=free-out limit-at='.$FreeInetSpeed.' max-limit='.$FreeInetSpeed.' parent=main-out packet-mark='.$PacketMark; 44 $Commands[] = ' /ip firewall mangle add chain= forwardout-interface='.$InetInterface.' action=mark-packet new-packet-mark='.$PacketMark;46 $Commands[] = ' /ip firewall mangle add chain=inet-out out-interface='.$InetInterface.' action=mark-packet new-packet-mark='.$PacketMark; 45 47 $PacketMark++; 46 48 $Commands[] = ' /queue tree add name=free-in limit-at='.$FreeInetSpeed.' max-limit='.$FreeInetSpeed.' parent=main-in packet-mark='.$PacketMark; 47 $Commands[] = ' /ip firewall mangle add chain= forwardin-interface='.$InetInterface.' action=mark-packet new-packet-mark='.$PacketMark;49 $Commands[] = ' /ip firewall mangle add chain=inet-in in-interface='.$InetInterface.' action=mark-packet new-packet-mark='.$PacketMark; 48 50 $PacketMark++; 51 52 // Divide rules by subnet number 53 foreach(array(0, 1, 2, 3, 4, 5, 7) as $Subnet) 54 { 55 $Commands[] = ' /ip firewall mangle add chain=inet-out src-address=192.168.'.$Subnet.'.0/24 out-interface='.$InetInterface.' action=jump jump-target=inet-out-'.$Subnet; 56 $Commands[] = ' /ip firewall mangle add chain=inet-in dst-address=192.168.'.$Subnet.'.0/24 in-interface='.$InetInterface.' action=jump jump-target=inet-in-'.$Subnet; 57 } 49 58 50 59 // Process users … … 52 61 while($User = $DbResult->fetch_array()) 53 62 { 54 echo('Uživatel '.$User['fullname']."\n"); 55 $User['fullname'] = strtolower(strtr($User['fullname'], array('č' => 'c', 'š' => 's', 'ě' => 'e', 'ř' => 'r', 'ž' => 'z', 'ý' => 'y', 'á' => 'a', 'í' => 'i', 'é' => 'e', 'ů' => 'u', 'ú' => 'u', 'ď' => 'd', 'ť' => 't', 'ň' => 'n'))); 56 57 echo('Uživatel '.$User['fullname']."\n"); 63 $User['fullname'] = strtr(strtolower($User['fullname']), array( 64 'č' => 'c', 'š' => 's', 'ě' => 'e', 'ř' => 'r', 'ž' => 'z', 'ý' => 'y', 'á' => 'a', 'í' => 'i', 'é' => 'e', 'ů' => 'u', 'ú' => 'u', 'ď' => 'd', 'ť' => 't', 'ň' => 'n', 'ó' => 'o', 65 'Č' => 'c', 'Š' => 's', 'Ě' => 'e', 'Ř' => 'r', 'Ž' => 'z', 'Ý' => 'y', 'Á' => 'a', 'Í' => 'i', 'É' => 'e', 'Ů' => 'u', 'Ú' => 'u', 'Ď' => 'd', 'Ť' => 't', 'Ň' => 'n', 'Ó' => 'o', 66 )); 67 68 echo('Uživatel '.$User['fullname'].": "); 58 69 $SpeedIn = round($Tarify[$User['inet_tarif_now']]['min_speed'] / $InDivider); 59 70 $SpeedOut = round($Tarify[$User['inet_tarif_now']]['min_speed'] / $OutDivider); … … 74 85 { 75 86 $Host['name'] = strtolower($Host['name']); 76 echo('Počítač '.$Host['name']."\n"); 77 $Commands[] = ' /ip firewall mangle add chain=forward src-address='.$Host['IP'].' out-interface='.$InetInterface.' action=mark-packet new-packet-mark='.$PacketMark; 87 echo($Host['name'].', '); 88 $IPParts = explode('.', $Host['IP']); 89 $Subnet = $IPParts[2]; 90 $Commands[] = ' /ip firewall mangle add chain=inet-out-'.$Subnet.' src-address='.$Host['IP'].' out-interface='.$InetInterface.' action=mark-packet new-packet-mark='.$PacketMark.' passthrough=no'; 78 91 $Commands[] = ' /queue tree add name='.$Host['name'].'-out limit-at='.$HostSpeedIn.' max-limit='.$UserMaxSpeedIn.' parent='.$User['fullname'].'-out packet-mark='.$PacketMark; 79 92 $PacketMark++; 80 $Commands[] = ' /ip firewall mangle add chain= forward dst-address='.$Host['IP'].' in-interface='.$InetInterface.' action=mark-packet new-packet-mark='.$PacketMark;93 $Commands[] = ' /ip firewall mangle add chain=inet-in-'.$Subnet.' dst-address='.$Host['IP'].' in-interface='.$InetInterface.' action=mark-packet new-packet-mark='.$PacketMark.' passthrough=no'; 81 94 $Commands[] = ' /queue tree add name='.$Host['name'].'-in limit-at='.$HostSpeedOut.' max-limit='.$UserMaxSpeedOut.' parent='.$User['fullname'].'-in packet-mark='.$PacketMark; 82 95 $PacketMark++; … … 98 111 */ 99 112 } 113 echo("\n"); 100 114 } 101 115 $Commands = implode(';', $Commands);
Note:
See TracChangeset
for help on using the changeset viewer.