remove legacy layer, just assume 4.3 and GetInterfaces
[nodeconfig.git] / PlanetLabConf / blacklist.php
1 #
2 # /etc/planetlab/blacklist
3 #
4 # post: iptables-restore --noflush < /etc/planetlab/blacklist
5 #
6 # PlanetLab per-node outbound blacklist
7
8 # Aaron Klingaman <alk@cs.princeton.edu>
9 # Mark Huang <mlhuang@cs.princeton.edu>
10 # Copyright (C) 2004 The Trustees of Princeton University
11 #
12
13 *filter
14 -F BLACKLIST
15
16 <?php
17
18 // Get admin API handle
19 require_once 'plc_api.php';
20 global $adm;
21
22 $interfaces = $adm->GetInterfaces(array('ip' => $_SERVER['REMOTE_ADDR']));
23 if (!empty($interfaces)) {
24   $nodes = $adm->GetNodes(array($interfaces[0]['node_id']));
25   if (!empty($nodes)) {
26     $node = $nodes[0];
27   }
28 }
29
30 if (isset($node)) {
31   // XXX Implement generic "networks" table
32   // $networks = $adm->GetNetworks();
33   $networks = array();
34   foreach ($networks as $network) {
35     if ($network['blacklisted']) {
36       $dest = $network['ip'];
37       if ($network['netmask']) {
38         $dest .= "/" . $network['netmask'];
39       }
40       print "-A BLACKLIST -d $dest -j LOGDROP\n";
41     }
42   }
43 }
44
45 print "\n";
46
47 ?>
48
49 COMMIT