Changeset 208 for trunk/system


Ignore:
Timestamp:
May 6, 2009, 8:21:23 AM (16 years ago)
Author:
george
Message:
  • Upraveno: Tabulka hosts rozdělena na NetworkDevice, NetworkInterface, NetworkInterfaceType a NetworkLink. Jeden počítač může mít více rozhraní. Nově se již nepočítá pouze s stromovou topologií, ale s celkovou sítí s okruhy. Sloupce Parent byl proto nahrazen tabulkou NetworkLink, ve které jsou uchovány informace o tom, co kam je připojeno. Každé rozhraní má definovaný typ dle NetworkInterfaceType.
  • Upraveno: Tabulka HostType přejmenována na NetworkDeviceType.
  • Smazáno: Původní složka komunikačního programu sunrisechat. Nově nahrazena složkou chat pro podporu IRC.
Location:
trunk/system
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/system/generators/dhcp_routerboard.php

    r197 r208  
    1212  $Commands = array();
    1313  $Commands[] = '/ip dhcp-server lease { remove [find server=dhcp'.$I.']}';
    14   $DbResult2 = $Database->query('SELECT * FROM `hosts` WHERE (`IP` LIKE "192.168.'.$I.'.%") AND (`MAC` != "00:00:00:00:00:00") ORDER BY `IP`');
    15   while($Host = $DbResult2->fetch_assoc())
     14  $DbResult2 = $Database->query('SELECT NetworkInterface.*, NetworkDevice.Name AS DeviceName FROM `NetworkInterface` LEFT JOIN NetworkDevice ON NetworkDevice.Id = NetworkInterface.Device WHERE (`LocalIP` LIKE "192.168.'.$I.'.%") AND (`MAC` != "00:00:00:00:00:00") ORDER BY `LocalIP`');
     15  while($Interface = $DbResult2->fetch_assoc())
    1616  {
    17     $Commands[] = '/ip dhcp-server lease add mac-address='.$Host['MAC'].' address='.$Host['IP'].' server=dhcp'.$I.' comment='.$Host['name'];
     17    $Commands[] = '/ip dhcp-server lease add mac-address='.$Interface['MAC'].' address='.$Interface['LocalIP'].' server=dhcp'.$I.' comment='.$Interface['DeviceName'].'-'.$Interface['Name'];
    1818  }
    1919  $Commands = implode(';', $Commands);
  • trunk/system/generators/nat_routerboard.php

    r197 r208  
    1414  echo($Member['Name'].': ');
    1515  // Hosts
    16   $DbResult2 = $Database->select('hosts', '*', '(external_ip <> "") AND (user='.$Member['Id'].') AND (IP != external_ip) ORDER BY id DESC');
    17   while($Host = $DbResult2->fetch_assoc())
     16  $DbResult2 = $Database->query('SELECT NetworkInterface.*, NetworkDevice.Name AS DeviceName FROM NetworkInterface LEFT JOIN NetworkDevice ON NetworkDevice.Id = NetworkInterface.Device WHERE (NetworkInterface.ExternalIP <> "") AND (NetworkDevice.Member = '.$Member['Id'].') AND (NetworkInterface.LocalIP != NetworkInterface.ExternalIP) ORDER BY id DESC');
     17  while($Interface = $DbResult2->fetch_assoc())
    1818  {
    19     $Host['name'] = RouterOSIdent($Host['name']);
    20     echo($Host['name'].'('.$Host['IP'].'), ');
    21     $Commands[] = ' /ip firewall nat add chain=srcnat src-address='.$Host['IP'].' out-interface='.$InetInterface.' action=src-nat to-addresses='.$Host['external_ip'].' comment="'.$Host['name'].'"';
    22     $Commands[] = ' /ip firewall nat add chain=dstnat dst-address='.$Host['external_ip'].' in-interface='.$InetInterface.' action=dst-nat to-addresses='.$Host['IP'].' comment="'.$Host['name'].'"';
     19    $Name = $Interface['DeviceName'].'-'.$Interface['Name'];
     20    $Name = RouterOSIdent($Name);
     21    echo($Name.'('.$Interface['LocalIP'].'), ');
     22    $Commands[] = ' /ip firewall nat add chain=srcnat src-address='.$Interface['LocalIP'].' out-interface='.$InetInterface.' action=src-nat to-addresses='.$Interface['ExternalIP'].' comment="'.$Name.'"';
     23    $Commands[] = ' /ip firewall nat add chain=dstnat dst-address='.$Interface['ExternalIP'].' in-interface='.$InetInterface.' action=dst-nat to-addresses='.$Interface['LocalIP'].' comment="'.$Name.'"';
    2324  }
    2425
  • trunk/system/generators/netwatch.php

    r197 r208  
    1515    $I = explode('.', $Subnet['AddressRange']);
    1616    $I = $I[2];
    17     $DbResult2 = $Database->query('SELECT * FROM hosts WHERE (IP LIKE "192.168.'.$I.'.%") ORDER BY IP');
    18     while($Host = $DbResult2->fetch_assoc())
     17    $DbResult2 = $Database->query('SELECT NetworkInterface.*, NetworkDevice.Name AS DeviceName FROM NetworkInterface LEFT JOIN NetworkDevice ON NetworkDevice.Id = NetworkInterface.Device WHERE (NetworkInterface.LocalIP LIKE "192.168.'.$I.'.%") ORDER BY NetworkInterface.LocalIP');
     18    while($Interface = $DbResult2->fetch_assoc())
    1919    {
    20       $Commands[] = '/tool netwatch add host='.$Host['IP'].' interval=1m comment='.$Host['name'];
     20      $Commands[] = '/tool netwatch add host='.$Interface['LocalIP'].' interval=1m comment='.$Interface['DeviceName'].'-'.$Interface['Name'];
    2121    }
    2222  }
  • trunk/system/generators/traffic_shaping_routerboard.php

    r204 r208  
    6262$Index = 0;
    6363$DbResult = $Database->query('SELECT Member.*, Subject.Name FROM Member LEFT JOIN Subject ON Subject.Id = Member.Subject');
    64 while($Member = $DbResult->fetch_array())
     64while($Member = $DbResult->fetch_assoc())
    6565{
    6666  $Member['Name'] = RouterOSIdent($Member['Name']);
     
    8888  }
    8989
    90   $DbResult2 = $Database->select('hosts', '*', '(block=0) AND (MAC != "") AND (user='.$Member['Id'].')');
    91   while($Host = $DbResult2->fetch_array())
     90  $DbResult2 = $Database->select('NetworkDevice', '*', 'Member = '.$Member['Id']);
     91  while($Device = $DbResult2->fetch_assoc())
    9292  {
    93     $Host['name'] = RouterOSIdent($Host['name']);
    94     echo($Host['name'].', ');
    95     $IPParts = explode('.', $Host['IP']);
    96     $Subnet = $IPParts[2];
    97     $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 comment="'.$Host['name'].'"';
    98     $Commands[] = ' /queue tree add name='.$Host['name'].'-out limit-at='.$HostSpeedIn.' max-limit='.$UserMaxSpeedIn.' parent='.$Member['Name'].'-out packet-mark='.$PacketMark.' queue=wireless-default';
    99     $PacketMark++;
    100     $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 comment="'.$Host['name'].'"';
    101     $Commands[] = ' /queue tree add name='.$Host['name'].'-in limit-at='.$HostSpeedOut.' max-limit='.$UserMaxSpeedOut.' parent='.$Member['Name'].'-in packet-mark='.$PacketMark.' queue=wireless-default';
    102     $PacketMark++;
     93    $DbResult3 = $Database->select('NetworkInterface', '*', 'Device = '.$Device['Id']);
     94    while($Interface = $DbResult3->fetch_assoc())
     95    {
     96      $Name = $Device['Name'].'-'.$Interface['Name'];
     97      $Name = RouterOSIdent($Name);
     98      echo($Name.', ');
     99      $IPParts = explode('.', $Interface['LocalIP']);
     100      $Subnet = $IPParts[2];
     101      $Commands[] = ' /ip firewall mangle add chain=inet-out-'.$Subnet.' src-address='.$Interface['LocalIP'].' out-interface='.$InetInterface.' action=mark-packet new-packet-mark='.$PacketMark.' passthrough=no comment="'.$Name.'"';
     102      $Commands[] = ' /queue tree add name='.$Name.'-out limit-at='.$HostSpeedIn.' max-limit='.$UserMaxSpeedIn.' parent='.$Member['Name'].'-out packet-mark='.$PacketMark.' queue=wireless-default';
     103      $PacketMark++;
     104      $Commands[] = ' /ip firewall mangle add chain=inet-in-'.$Subnet.' dst-address='.$Interface['LocalIP'].' in-interface='.$InetInterface.' action=mark-packet new-packet-mark='.$PacketMark.' passthrough=no comment="'.$Name.'"';
     105      $Commands[] = ' /queue tree add name='.$Name.'-in limit-at='.$HostSpeedOut.' max-limit='.$UserMaxSpeedOut.' parent='.$Member['Name'].'-in packet-mark='.$PacketMark.' queue=wireless-default';
     106      $PacketMark++;
    103107
    104     // Posílej po menších částech
    105     if($Index > 50)
    106     {
    107       //print_r($Commands);
    108       $Commands = addslashes(implode(';', $Commands));
    109       $Command = '/usr/bin/ssh -l '.$Config['MainRouter']['UserName'].' -i id_dsa '.$Config['MainRouter']['HostName'].' "'.$Commands.'"';
    110       $Output = array();
    111       exec($Command, $Output);
    112       print_r($Output);
    113       $Commands = array();
    114       $Index = 0;
     108      // Posílej po menších částech
     109      if($Index > 50)
     110      {
     111        //print_r($Commands);
     112        $Commands = addslashes(implode(';', $Commands));
     113        $Command = '/usr/bin/ssh -l '.$Config['MainRouter']['UserName'].' -i id_dsa '.$Config['MainRouter']['HostName'].' "'.$Commands.'"';
     114        $Output = array();
     115        exec($Command, $Output);
     116        print_r($Output);
     117        $Commands = array();
     118        $Index = 0;
     119      }
     120      $Index++;
    115121    }
    116     $Index++;
    117122  }
    118123 
  • trunk/system/netwatch_import.php

    r187 r208  
    3333    {
    3434      $Online = 1;
    35       $Values = array('online' => $Online,  'last_online' => 'NOW()');
     35      $Values = array('Online' => $Online,  'LastOnline' => 'NOW()');
    3636    } else
    3737    {
    3838      $Online = 0;
    39       $Values = array('online' => $Online);
     39      $Values = array('Online' => $Online);
    4040    }
    4141
    42     $DbResult = $Database->update('hosts', 'IP="'.$Properties['host'].'"', $Values);
     42    $DbResult = $Database->update('NetworkInterface', 'LocalIP = "'.$Properties['host'].'"', $Values);
    4343    if($Online == 1)
    4444    {
    45       $DbResult = $Database->select('hosts', 'id', 'IP="'.$Properties['host'].'"');
     45      $DbResult = $Database->select('NetworkInterface', 'Id', 'LocalIP = "'.$Properties['host'].'"');
    4646      $DbRow = $DbResult->fetch_array();
    47       $HostId = $DbRow['id'];
     47      $HostId = $DbRow['Id'];
    4848      $DbResult2 = $Database->select('stat_hosts', '*', '(host_id="'.$HostId.'") AND (time = DATE_FORMAT(NOW(), "%Y-%m-%d %H:00:00"))');
    4949      if($DbResult2->num_rows == 0) $Database->query('REPLACE INTO stat_hosts (host_id, time) VALUES ("'.$HostId.'", DATE_FORMAT(NOW(), "%Y-%m-%d %H:00:00"))');         
  • trunk/system/traffic-flow.php

    r161 r208  
    11<?php
    2 include_once('/a/www/centrala/global.php');
     2include_once('../global.php');
    33
    4 $Config['Web']['ShowErrors'] = 1;
     4//$Config['Web']['ShowErrors'] = 1;
    55
    66$Commands = array();
Note: See TracChangeset for help on using the changeset viewer.