622e6ce559dd77133ef3f04e72dbe7d922285034
[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 # $Id$
13 #
14
15 *filter
16 -F BLACKLIST
17
18 <?php
19
20 // Get admin API handle
21 require_once 'plc_api.php';
22 global $adm;
23
24 // Look up the node
25 $interfaces = $adm->GetInterfaces(array('ip' => $_SERVER['REMOTE_ADDR']));
26 if (!empty($interfaces)) {
27   $nodes = $adm->GetNodes(array($interfaces[0]['node_id']));
28   if (!empty($nodes)) {
29     $node = $nodes[0];
30   }
31 }
32
33 if (isset($node)) {
34   // XXX Implement generic "networks" table
35   // $networks = $adm->GetNetworks();
36   $networks = array();
37   foreach ($networks as $network) {
38     if ($network['blacklisted']) {
39       $dest = $network['ip'];
40       if ($network['netmask']) {
41         $dest .= "/" . $network['netmask'];
42       }
43       print "-A BLACKLIST -d $dest -j LOGDROP\n";
44     }
45   }
46 }
47
48 print "\n";
49
50 ?>
51
52 COMMIT