Changeset 698
- Timestamp:
- Sep 28, 2014, 10:41:47 PM (10 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Common/Global.php
r682 r698 18 18 include_once(dirname(__FILE__).'/Setup/Setup.php'); 19 19 include_once(dirname(__FILE__).'/PrefixMultiplier.php'); 20 include_once(dirname(__FILE__).'/NetworkAddress.php'); 20 21 include_once(dirname(__FILE__).'/VCL/General.php'); 21 22 include_once(dirname(__FILE__).'/VCL/Database.php'); -
trunk/Common/NetworkAddress.php
r695 r698 5 5 var $Address; 6 6 var $Prefix; 7 7 8 8 function __construct() 9 9 { … … 11 11 $this->Prefix = 0; 12 12 } 13 13 14 14 function GetNetMask() 15 15 { … … 21 21 return(implode('.', array(($this->Address >> 24) & 255, ($this->Address >> 16) & 255, ($this->Address >> 8) & 255, ($this->Address & 255)))); 22 22 } 23 23 24 24 function AddressFromString($Value) 25 25 { … … 27 27 $this->Address = ($Parts[0] << 24) | ($Parts[1] << 16) | ($Parts[2] << 8) | $Parts[3]; 28 28 } 29 29 30 30 function GetRange() 31 31 { … … 37 37 $To->Address = $From->Address + $HostMask; 38 38 $To->Prefix = 32; 39 return(array('From' => $From, 'To' => $To)); 39 return(array('From' => $From, 'To' => $To)); 40 40 } 41 41 … … 49 49 50 50 function Contain($Address) 51 { 51 { 52 52 $UpperNetmask = $this->GetNetMask(); 53 53 if(($this->Prefix < $Address->Prefix) and (($Address->Address & $UpperNetmask) == ($this->Address & $UpperNetmask))) $Result = true; … … 62 62 var $Address; 63 63 var $Prefix; 64 64 65 65 function __construct() 66 66 { … … 68 68 $this->Prefix = 0; 69 69 } 70 70 71 71 function AddressToString() 72 72 { 73 73 return(inet_ntop($this->Address)); 74 74 } 75 75 76 76 function AddressFromString($Value) 77 77 { 78 78 $this->Address = inet_pton($Value); 79 79 } 80 80 81 function GetOctets() 82 { 83 $Result = array(); 84 $Data = array_reverse(unpack('C*', $this->Address)); 85 foreach($Data as $Item) 86 { 87 88 $Result[] = dechex($Item & 15); 89 $Result[] = dechex(($Item >> 4) & 15); 90 } 91 return($Result); 92 } 93 81 94 } -
trunk/Modules/NetworkConfigLinux/Generators/DNS.php
r695 r698 17 17 $MinimumTime = 10800; 18 18 $TTL = 86400; 19 $BaseDir = '/home/chronos/Projekty/centrala/trunk/var/named'; 19 $BaseDir = '/var/named'; 20 //$BaseDir = '/home/chronos/Projekty/centrala/trunk/var/named'; 20 21 if(!file_exists($BaseDir)) die('Base directory "'.$BaseDir.'" not exists.'); 21 22 $MailServer = 'centrala'; … … 68 69 $Output .= strtolower($Host['Name'])."\tIN\tAAAA\t".$Host['IPv6']."\n"; 69 70 } 70 71 71 72 // Alias list 72 73 foreach($DNS['Alias'] as $Alias) … … 112 113 } 113 114 114 /* 115 // Generate reverse DNS IPv6 records 115 // Generate reverse DNS IPv6 records 116 116 foreach($DNS['IPv6Network'] as $Network) 117 117 { 118 $Parts = explode('.', $Network); 118 $Parts = explode('/', $Network); 119 $NetworkAddress = $Parts[0]; 120 $Prefix = $Parts[1]; 119 121 $Output = // '$ORIGIN '.$Parts[2].'.'.$Parts[1].'.'.$Parts[0].'.in-addr.arpa'."\n". 120 122 '$TTL '.$DNS['TTL']."\n". … … 134 136 foreach($DNS['Host'] as $Host) 135 137 if(array_key_exists('IPv6', $Host) and ($Host['IPv6'] != '')) 136 if(substr($Host['IPv6'], 0, strlen($Network)) == $Network)137 138 { 138 $Remaining = substr($Host['IPv6'], strlen($Network)); 139 $Remaining = explode(':', $Remaining); 140 foreach($Remaining) 141 $Remaining = array_reverse($Remaining); 142 139 $Addr = new NetworkAddressIPv6(); 140 $Addr->AddressFromString($Host['IPv6']); 141 $Octets = $Addr->GetOctets(); 142 $Octets = array_slice($Octets, 0, (128 - $Prefix) / 4); 143 $Octets = array_reverse($Octets); 144 $Octets = implode('.', $Octets); 145 143 146 $Host['Name'] = strtolower($Host['Name']); 144 $Output .= implode(':', $Remaining)."\tIN\tPTR\t".$Host['Name'].".".$DNS['Domain'].".\n";147 $Output .= $Octets."\tIN\tPTR\t".$Host['Name'].".".$DNS['Domain'].".\n"; 145 148 } 146 $Reverse = implode(':', array_reverse(explode(':', $Network))); 147 $File = fopen($DNS['BaseDir'].$Reverse.'.ipv6.arpa.zone', 'w+'); 149 150 $NetAddr = new NetworkAddressIPv6(); 151 $NetAddr->AddressFromString($NetworkAddress); 152 $Octets = array_reverse($NetAddr->GetOctets()); 153 $Octets = array_reverse(array_slice($Octets, 0, $Prefix / 4)); 154 $FileName = implode('.', $Octets).'.ipv6.arpa.zone'; 155 $File = fopen($DNS['BaseDir'].$FileName, 'w+'); 148 156 fputs($File, $Output); 149 //echo($Output);150 157 fclose($File); 151 158 } 152 */153 159 } 154 160 … … 169 175 'Host' => array(), 170 176 'Alias' => array(), 171 'Network' => array('10.145.64', '10.145.65', '10.145.66', '10.145.67', '10.145.68', 172 173 'IPv6Network' => array('2 001:470:9ab9:1'),177 'Network' => array('10.145.64', '10.145.65', '10.145.66', '10.145.67', '10.145.68', 178 '10.145.69', '10.145.70', '10.145.71', '77.92.221', '172.16.0', '172.16.1'), 179 'IPv6Network' => array('2a00:e580:244::/48'), 174 180 ); 175 181 … … 232 238 'Alias' => array(), 233 239 'Network' => array('81.2.194', '193.86.238', '212.111.4', '77.92.221'), 234 'IPv6Network' => array('2 001:470:9ab9:1'),240 'IPv6Network' => array('2a00:e580:244::/48'), 235 241 ); 236 242 … … 271 277 'Host' => array(), 272 278 'Alias' => array(), 273 'Network' => array('10.145.64', '10.145.65', '10.145.66', '10.145.67', 279 'Network' => array('10.145.64', '10.145.65', '10.145.66', '10.145.67', 274 280 '10.145.68', '10.145.69', '10.145.70', '10.145.71'), 275 281 'IPv6Network' => array(), … … 311 317 'Host' => array(), 312 318 'Alias' => array(), 313 'Network' => array('10.145.64', '10.145.65', '10.145.66', '10.145.67', 319 'Network' => array('10.145.64', '10.145.65', '10.145.66', '10.145.67', 314 320 '10.145.68', '10.145.69', '10.145.70', '10.145.71'), 315 321 'IPv6Network' => array(),
Note:
See TracChangeset
for help on using the changeset viewer.