d2b893c3e27f3b73465d85e2f0356adf316a003f
[nodeconfig.git] / PlanetLabConf / proxies.php
1 #
2 # /etc/planetlab/proxies
3 #
4 # post: service vnet restart
5 #
6 # Proxy (a.k.a. network telescope a.k.a. honeypot) interface configuration
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 <?php
16 // Get admin API handle
17 require_once 'plc_api.php';
18 global $adm;
19
20 // Look up the node
21 $interfaces = $adm->GetInterfaces(array('ip' => $_SERVER['REMOTE_ADDR']));
22 if (!empty($interfaces)) {
23   $nodes = $adm->GetNodes(array($interfaces[0]['node_id']));
24   if (!empty($nodes)) {
25     $node = $nodes[0];
26   }
27 }
28
29 if (!isset($node)) {
30   exit();
31 }
32
33 $interfaces = $adm->GetInterfaces($node['interface_ids']);
34
35 foreach ($interfaces as $interface) {
36   // XXX PL2896: need interfaces.device
37   switch ($interface['method']) {
38   case 'tap':
39     $dev = "tap0";
40     $types['taps'][$dev][0] = $interface['ip'] . "/" . $interface['gateway'];
41     break;
42   case 'proxy':
43     $dev = "proxy0";
44     $types['proxies'][$dev][] = $interface['ip'];
45     break;
46   }
47 }
48
49 // taps="tap0 tap1 ..."
50 // tap0="1.2.3.4/5.6.7.8"
51 // tap1="9.10.11.12/13.14.15.16"
52 // ...
53 // proxies="proxy0 proxy1 ..."
54 // proxy0="1.2.3.4 5.6.7.8 ..."
55 // proxy1="9.10.11.12 13.14.15.16 ..."
56 // ...
57 if (isset($types)) {
58   foreach ($types as $type => $devs) {
59     print("$type=\"" . implode(" ", array_keys($devs)) . "\"\n");
60     foreach ($devs as $dev => $ips) {
61       print("$dev=\"" . implode(" ", $ips) . "\"\n");
62     }
63   }
64 }
65
66 ?>