Revision 8dfb0c00
Added by Seth Mos about 13 years ago
usr/local/sbin/prefixes.php | ||
---|---|---|
1 | 1 |
<?php |
2 | 2 |
|
3 | 3 |
$leases_file = "/var/dhcpd/var/db/dhcpd6.leases"; |
4 |
$leasefile = file($leases_file); |
|
4 |
if(!file_exists($leases_file)) { |
|
5 |
exit(1); |
|
6 |
} |
|
5 | 7 |
|
6 |
foreach($leasefile as $line) {
|
|
8 |
foreach(file($leases_file) as $line) {
|
|
7 | 9 |
// echo "$line"; |
8 | 10 |
if(preg_match("/^(ia-[np][ad])[ ]+\"(.*?)\"/i ", $line, $duidmatch)) { |
9 | 11 |
$type = $duidmatch[1]; |
... | ... | |
44 | 46 |
unset($ia_pd); |
45 | 47 |
continue; |
46 | 48 |
} |
47 |
array_shift($leasefile); |
|
48 | 49 |
} |
49 | 50 |
|
50 | 51 |
$routes = array(); |
... | ... | |
52 | 53 |
if($entry['ia-pd'] <> "") { |
53 | 54 |
$routes[$entry['ia-na']] = $entry['ia-pd']; |
54 | 55 |
} |
56 |
array_shift($duid_arr); |
|
55 | 57 |
} |
56 | 58 |
|
57 | 59 |
// echo "add routes\n"; |
... | ... | |
80 | 82 |
// echo "remove routes\n"; |
81 | 83 |
foreach ($expires as $prefix) { |
82 | 84 |
echo "/sbin/route delete -inet6 {$prefix['prefix']}\n"; |
85 |
array_shift($expires); |
|
83 | 86 |
} |
84 | 87 |
|
85 | 88 |
?> |
Also available in: Unified diff
Add a few micro optimizations, bail out when the file does not exist.