Ignore:
Timestamp:
Dec 6, 2008, 11:33:29 AM (16 years ago)
Author:
george
Message:
  • Opraveno: Nastavení řízení průtoku dat pro routerboard. Chyba převodu diakritiky a optimalizace rozdělením pravidel v sekci mangle do více podskupin podle podsítě a deaktivace passthrough.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • system/generators/traffic_shaping_routerboard.php

    r119 r120  
    3636
    3737// 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';
    4143
    4244// Slow free internet
    4345$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=forward out-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;
    4547$PacketMark++;
    4648$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=forward in-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;
    4850$PacketMark++;
     51
     52// Divide rules by subnet number
     53foreach(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}
    4958
    5059// Process users
     
    5261while($User = $DbResult->fetch_array())
    5362{
    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'].": ");
    5869  $SpeedIn = round($Tarify[$User['inet_tarif_now']]['min_speed'] / $InDivider);
    5970  $SpeedOut = round($Tarify[$User['inet_tarif_now']]['min_speed'] / $OutDivider);
     
    7485  {
    7586    $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';
    7891    $Commands[] = ' /queue tree add name='.$Host['name'].'-out limit-at='.$HostSpeedIn.' max-limit='.$UserMaxSpeedIn.' parent='.$User['fullname'].'-out packet-mark='.$PacketMark;
    7992    $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';
    8194    $Commands[] = ' /queue tree add name='.$Host['name'].'-in limit-at='.$HostSpeedOut.' max-limit='.$UserMaxSpeedOut.' parent='.$User['fullname'].'-in packet-mark='.$PacketMark;
    8295    $PacketMark++;
     
    98111*/
    99112  }
     113  echo("\n");
    100114}
    101115$Commands = implode(';', $Commands);
Note: See TracChangeset for help on using the changeset viewer.