aboutsummaryrefslogtreecommitdiffstats
path: root/fap/httpd
diff options
context:
space:
mode:
Diffstat (limited to 'fap/httpd')
-rwxr-xr-xfap/httpd/# DEPRECATED/server_http.py146
-rwxr-xr-xfap/httpd/# DEPRECATED/terminal.log14
-rwxr-xr-xfap/httpd/README.md26
-rwxr-xr-xfap/httpd/files/.gitignore3
-rw-r--r--fap/httpd/httpd_root/# create_queries - DEPRECATED/create_queries.php55
-rw-r--r--fap/httpd/httpd_root/# create_queries - DEPRECATED/ipcalc_functions.php134
-rw-r--r--fap/httpd/httpd_root/# create_queries - DEPRECATED/patchlist.txt142
-rw-r--r--fap/httpd/httpd_root/# create_queries - DEPRECATED/switches.txt142
-rw-r--r--fap/httpd/httpd_root/.gitignore0
-rwxr-xr-xfap/httpd/httpd_root/.htaccess3
-rwxr-xr-xfap/httpd/httpd_root/ex2200.template288
-rwxr-xr-xfap/httpd/httpd_root/ex2200_secure.template312
-rw-r--r--fap/httpd/httpd_root/pg_connect.php6
-rwxr-xr-xfap/httpd/httpd_root/x.php67
14 files changed, 1338 insertions, 0 deletions
diff --git a/fap/httpd/# DEPRECATED/server_http.py b/fap/httpd/# DEPRECATED/server_http.py
new file mode 100755
index 0000000..a9ae74c
--- /dev/null
+++ b/fap/httpd/# DEPRECATED/server_http.py
@@ -0,0 +1,146 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+
+from http.server import BaseHTTPRequestHandler, HTTPServer
+from string import Template
+import time
+import psycopg2
+import psycopg2.extras
+import sys
+import os
+
+def main():
+ #
+ # Settings
+ #
+ settings = {
+ 'db': {
+ 'user': 'bootstrap',
+ 'password': 'asdf',
+ 'dbname': 'bootstrap',
+ 'host': 'localhost'
+ },
+ 'http': {
+ 'host': '0.0.0.0',
+ 'port': 80
+ }
+ }
+
+ #
+ # Connect to DB
+ #
+ try:
+ connect_params = ("dbname='%s' user='%s' host='%s' password='%s'" % (settings['db']['dbname'], settings['db']['user'], settings['db']['host'], settings['db']['password']))
+ conn = psycopg2.connect(connect_params)
+ cur = conn.cursor(cursor_factory=psycopg2.extras.DictCursor)
+ # cur.execute("""SELECT * from switches""")
+ # rows = cur.fetchall()
+ # print ("\nSwitches in DB during server_http.py startup:")
+ # for row in rows:
+ # print (" --> %s, connected to %s port %s" % (row['hostname'], row['distro_name'], row['distro_phy_port']))
+
+ except (psycopg2.DatabaseError, psycopg2.OperationalError) as e:
+ print ('Error: %s' % e)
+ sys.exit(1)
+
+ except:
+ print(sys.exc_info()[0])
+ sys.exit(1)
+
+ def template_get(model):
+ return open('fap/httpd/' + model + '.template').read()
+
+ def template_parse(template_src, hostname):
+ cur.execute("SELECT * FROM switches WHERE hostname = '%s'" % hostname)
+ if(cur.rowcount == 1):
+ row = cur.fetchall()[0]
+ d={
+ 'hostname': row['hostname'],
+ 'distro_name': row['distro_name'],
+ 'distro_phy_port': row['distro_phy_port'],
+ 'mgmt_addr': row['mgmt_addr'],
+ 'mgmt_cidr': row['mgmt_cidr'],
+ 'mgmt_gw': row['mgmt_gw'],
+ 'mgmt_vlan': row['mgmt_vlan'],
+ 'traffic_vlan': row['traffic_vlan'],
+ 'mgmt_v6_addr': row['mgmt_v6_addr'],
+ 'mgmt_v6_cidr': row['mgmt_v6_cidr'],
+ 'mgmt_v6_gw': row['mgmt_v6_gw']
+ }
+ cur.execute("UPDATE switches SET last_config_fetch = '%s' WHERE hostname = '%s'" % (str(time.time()).split('.')[0], hostname)) # updated DB with last config fetch
+ conn.commit()
+ return Template(template_src).safe_substitute(d)
+ else:
+ return False
+
+ class httpd(BaseHTTPRequestHandler):
+ def do_GET(self):
+ print('[%s] [%s] Incoming HTTP GET URI:%s ' % (self.client_address[0], time.asctime(), self.path))
+
+ # Client asks for the config file
+ if '/tg-edge/' in self.path:
+ hostname = self.path.split('/tg-edge/')[1]
+ if len(hostname) > 0:
+ print('[%s] --> Hostname "%s" accepted, fetching info from DB' % (self.client_address[0], hostname))
+ template_parsed = template_parse(template_get('ex2200'), hostname)
+ if template_parsed:
+ print('[%s] --> Template successfully populated' % self.client_address[0])
+ print('[%s] --> Sending response to client' % self.client_address[0])
+ self.send_response(200)
+ self.send_header("Content-type", "text/plain")
+ self.end_headers()
+ self.wfile.write(bytes(template_parsed, "utf-8"))
+ print('[%s] --> Success - %s bytes sent to client' % (self.client_address[0], len(template_parsed)))
+ else:
+ print('[%s] --> Error - could not find hostname "%s" in DB' % (self.client_address[0], hostname))
+ else:
+ print('[%s] --> Rejected due to missing hostname' % self.client_address[0])
+
+ # Client asks for a file download - most likely a JunOS file
+ elif '/files/' in self.path:
+ # It seems that "http.server" escapes nastiness from the URL - ("/files/../../../root_file" => "/files/root_file")
+ requested_file = self.path.split('/files/')[1]
+ files_dir = 'fap/httpd/files/'
+ print('[%s] --> File request for "%s" in "%s"' % (self.client_address[0], requested_file, files_dir))
+ if os.path.isfile(files_dir + requested_file):
+ print('[%s] --> File found' % self.client_address[0])
+ try:
+ f = open(files_dir + requested_file)
+ self.send_response(200)
+ self.send_header('Content-type', 'application/x-gzip') # correct content type for tar.gz
+ self.end_headers()
+ print('[%s] --> File transfer started' % self.client_address[0])
+ f = open(files_dir + requested_file, 'rb')
+ self.wfile.write(f.read())
+ f.close()
+ print('[%s] --> File transfer completed' % self.client_address[0])
+ return
+ except IOError:
+ self.send_error(404,'File Not Found: %s' % self.path)
+ print('[%s] --> ERROR 404 - File not found' % self.client_address[0])
+ pass
+ except:
+ print('[%s] --> Generic error during file reading' % self.client_address[0])
+ pass
+ else:
+ print('[%s] --> File request rejected due to nonexisting file' % self.client_address[0])
+ else:
+ print('[%s] --> rejected due to bad URI' % self.client_address[0])
+ # silence stderr from BaseHTTPRequestHandler
+ # source: http://stackoverflow.com/questions/3389305/how-to-silent-quiet-httpserver-and-basichttprequesthandlers-stderr-output
+ def log_message(self, format, *args):
+ return
+
+ httpd_instance = HTTPServer((settings['http']['host'], settings['http']['port']), httpd)
+ print("\n[%s] Server Starts - %s:%s" % (time.asctime(), settings['http']['host'], settings['http']['port']))
+
+ try:
+ httpd_instance.serve_forever()
+ except KeyboardInterrupt:
+ pass
+
+ httpd_instance.server_close()
+ print("\n\n[%s] HTTP Server stopped\n" % time.asctime())
+
+if __name__ == "__main__":
+ main()
diff --git a/fap/httpd/# DEPRECATED/terminal.log b/fap/httpd/# DEPRECATED/terminal.log
new file mode 100755
index 0000000..bedb829
--- /dev/null
+++ b/fap/httpd/# DEPRECATED/terminal.log
@@ -0,0 +1,14 @@
+j@lappie:~/git/tgmanage$ sudo python3 fap/httpd/server_http.py
+
+[Thu Feb 19 23:15:45 2015] Server Starts - 0.0.0.0:80
+[10.0.200.101] [Fri Feb 20 00:18:25 2015] Incoming HTTP GET URI://tg-edge/e-00-1
+[10.0.200.101] --> Hostname "e-00-1" accepted, fetching info from DB
+[10.0.200.101] --> Template successfully populated
+[10.0.200.101] --> Sending response to client
+[10.0.200.101] --> Success - 1437 bytes sent to client
+[10.0.200.101] [Fri Feb 20 00:18:26 2015] Incoming HTTP GET URI://files/jinstall-ex-2200-12.3R6.6-domestic-signed.tgz
+[10.0.200.101] --> File request for "jinstall-ex-2200-12.3R6.6-domestic-signed.tgz" in "fap/httpd/files/"
+[10.0.200.101] --> File found
+[10.0.200.101] --> File transfer started
+[10.0.200.101] --> File transfer completed
+
diff --git a/fap/httpd/README.md b/fap/httpd/README.md
new file mode 100755
index 0000000..73c5634
--- /dev/null
+++ b/fap/httpd/README.md
@@ -0,0 +1,26 @@
+# HTTPD
+
+Well, not working out quite as I've hoped (at least for now).
+
+Resorted to Apache2, PHP and Postgres for the HTTP. Apache starts at boot, so no action required to get the stack up and after installation.
+
+```
+j@lappie:~/git/tgmanage$ cat /etc/apache2/sites-enabled/000-default.conf
+<VirtualHost *:80>
+ ServerAdmin webmaster@localhost
+
+ DocumentRoot /home/j/git/tgmanage/fap/httpd/httpd_root/
+
+ <Directory /home/j/git/tgmanage/fap/httpd/httpd_root>
+ Options Indexes FollowSymLinks MultiViews
+ AllowOverride All
+ Order allow,deny
+ allow from all
+ </Directory>
+
+ ErrorLog ${APACHE_LOG_DIR}/error.log
+ LogLevel warn
+
+ CustomLog ${APACHE_LOG_DIR}/access.log combined
+</VirtualHost>
+```
diff --git a/fap/httpd/files/.gitignore b/fap/httpd/files/.gitignore
new file mode 100755
index 0000000..cec9082
--- /dev/null
+++ b/fap/httpd/files/.gitignore
@@ -0,0 +1,3 @@
+*
+
+!.gitignore
diff --git a/fap/httpd/httpd_root/# create_queries - DEPRECATED/create_queries.php b/fap/httpd/httpd_root/# create_queries - DEPRECATED/create_queries.php
new file mode 100644
index 0000000..8d4bf26
--- /dev/null
+++ b/fap/httpd/httpd_root/# create_queries - DEPRECATED/create_queries.php
@@ -0,0 +1,55 @@
+<?php
+ /*
+ Used for generating SQL queries for FAP
+ Jonas Lindstad for TG15
+ GPL V2
+ */
+
+ chdir(__DIR__); # sets the executing directory to be the path of this script - necessary for CLI require() usage
+ header("Content-Type: text/plain");
+
+ require 'ipcalc_functions.php';
+ /*
+ Load data sources
+ */
+ $patchlist = file('patchlist.txt');
+ $switches = file('switches.txt');
+
+ $dataset = array();
+
+ foreach($patchlist as $lines){
+ $pieces = explode(' ', trim($lines));
+ $dataset[$pieces[0]] = array(
+ 'hostname' => $pieces[0],
+ 'distro_name' => 'rs1.' . $pieces[1], # prefix with "rs." so we get "rs1.distro0" syntax
+ 'distro_phy_port' => $pieces[2]
+ );
+ }
+
+ /*
+ Assign to logical and usable names in array
+ */
+ foreach($switches as $lines){
+ $pieces = explode(' ', trim($lines));
+ $dataset[$pieces[0]]['mgmt_v4_addr'] = explode('/', $pieces[3])[0];
+ $dataset[$pieces[0]]['mgmt_v4_cidr'] = explode('/', $pieces[3])[1];
+ $dataset[$pieces[0]]['mgmt_v4_gw'] = net_to_gw($pieces[3]);
+ $dataset[$pieces[0]]['mgmt_v6_addr'] = explode('/', $pieces[4])[0];
+ $dataset[$pieces[0]]['mgmt_v6_cidr'] = explode('/', $pieces[4])[1];
+ $dataset[$pieces[0]]['mgmt_v6_gw'] = net_to_gw($pieces[4]);
+ $dataset[$pieces[0]]['traffic_vlan'] = $pieces[5];
+ $dataset[$pieces[0]]['mgmt_vlan'] = '666';
+ }
+
+ /*
+ Prints the query rows
+ */
+ $sql_query = '';
+ foreach($dataset as $k => $v){
+ $columns = implode(', ', array_keys($v));
+ $values = "'" . implode("', '", array_values($v)) . "'";
+ $sql_query .= 'INSERT INTO switches (' . $columns . ') VALUES (' . $values . ');' . "\n";
+ }
+
+ echo $sql_query;
+?>
diff --git a/fap/httpd/httpd_root/# create_queries - DEPRECATED/ipcalc_functions.php b/fap/httpd/httpd_root/# create_queries - DEPRECATED/ipcalc_functions.php
new file mode 100644
index 0000000..e848ef1
--- /dev/null
+++ b/fap/httpd/httpd_root/# create_queries - DEPRECATED/ipcalc_functions.php
@@ -0,0 +1,134 @@
+<?php
+ /*
+ Mainly copied from djamps's work - https://github.com/djamps/php-ipv6-calculator/blob/master/ipcalc.php
+ Edited by Jonas Lindstad for The Gathering 2015
+ Licensed under GPL
+ */
+
+
+
+ // Convert array of short unsigned integers to binary
+ function _packBytes($array) {
+ foreach ( $array as $byte ) {
+ $chars .= pack('C',$byte);
+ }
+ return $chars;
+ }
+
+
+ // Convert binary to array of short integers
+ function _unpackBytes($string) {
+ return unpack('C*',$string);
+ }
+
+
+ // Add array of short unsigned integers
+ function _addBytes($array1,$array2) {
+ $result = array();
+ $carry = 0;
+ foreach ( array_reverse($array1,true) as $value1 ) {
+ $value2 = array_pop($array2);
+ if ( empty($result) ) { $value2++; }
+ $newValue = $value1 + $value2 + $carry;
+ if ( $newValue > 255 ) {
+ $newValue = $newValue - 256;
+ $carry = 1;
+ } else {
+ $carry = 0;
+ }
+ array_unshift($result,$newValue);
+ }
+ return $result;
+ }
+
+
+ /* Useful Functions */
+ function _cdr2Bin ($cdrin,$len=4){
+ if ( $len > 4 || $cdrin > 32 ) { // Are we ipv6?
+ return str_pad(str_pad("", $cdrin, "1"), 128, "0");
+ } else {
+ return str_pad(str_pad("", $cdrin, "1"), 32, "0");
+ }
+ }
+
+
+ function _bin2Cdr ($binin){
+ return strlen(rtrim($binin,"0"));
+ }
+
+
+ function _cdr2Char ($cdrin,$len=4){
+ $hex = _bin2Hex(_cdr2Bin($cdrin,$len));
+ return _hex2Char($hex);
+ }
+
+
+ function _char2Cdr ($char){
+ $bin = _hex2Bin(_char2Hex($char));
+ return _bin2Cdr($bin);
+ }
+
+
+ function _hex2Char($hex){
+ return pack('H*',$hex);
+ }
+
+
+ function _char2Hex($char){
+ $hex = unpack('H*',$char);
+ return array_pop($hex);
+ }
+
+
+ function _hex2Bin($hex){
+ $bin='';
+ for($i=0;$i<strlen($hex);$i++)
+ $bin.=str_pad(decbin(hexdec($hex{$i})),4,'0',STR_PAD_LEFT);
+ return $bin;
+ }
+
+
+ function _bin2Hex($bin){
+ $hex='';
+ for($i=strlen($bin)-4;$i>=0;$i-=4)
+ $hex.=dechex(bindec(substr($bin,$i,4)));
+ return strrev($hex);
+ }
+
+ /*
+ Converts a v4/v6 subnet to the first usable IP
+ */
+ function net_to_gw($net){
+ $maxSubNets = '2048'; // Stop memory leak from invalid input or large ranges
+ $charHost = inet_pton(strtok($net, '/'));
+ $charMask = _cdr2Char(strtok('/'),strlen($charHost));
+ $charHostMask = substr(_cdr2Char(127),-strlen($charHost));
+ $charNet = $charHost & $charMask; // Supernet network address
+ $charHostMin = $charNet | ~$charHostMask;
+ return inet_ntop($charHostMin);
+ }
+
+
+
+
+
+
+
+
+/*
+
+ $maxSubNets = '2048'; // Stop memory leak from invalid input or large ranges
+ $superNet = '2a02:ed02:180a::13/64';
+ if (ereg('/',$superNet)){ //if cidr type mask
+ $charHost = inet_pton(strtok($superNet, '/'));
+ $charMask = _cdr2Char(strtok('/'),strlen($charHost));
+ }
+
+ $charHostMask = substr(_cdr2Char(127),-strlen($charHost));
+ $charNet = $charHost & $charMask; // Supernet network address
+ $charHostMin = $charNet | ~$charHostMask;
+ echo 'Første brukbare adresse i ' . $superNet . ': ';
+ echo inet_ntop($charHostMin);
+*/
+
+?>
diff --git a/fap/httpd/httpd_root/# create_queries - DEPRECATED/patchlist.txt b/fap/httpd/httpd_root/# create_queries - DEPRECATED/patchlist.txt
new file mode 100644
index 0000000..7454441
--- /dev/null
+++ b/fap/httpd/httpd_root/# create_queries - DEPRECATED/patchlist.txt
@@ -0,0 +1,142 @@
+e1-3 distro0 ge-0/0/0 ge-1/0/0 ge-2/0/0 ge-3/0/0
+e3-3 distro0 ge-0/0/1 ge-1/0/1 ge-2/0/1 ge-3/0/1
+e3-4 distro0 ge-0/0/2 ge-1/0/2 ge-2/0/2 ge-3/0/2
+e5-2 distro1 ge-0/0/0 ge-1/0/0 ge-2/0/0 ge-3/0/0
+e5-3 distro0 ge-0/0/3 ge-1/0/3 ge-2/0/3 ge-3/0/3
+e5-4 distro0 ge-0/0/4 ge-1/0/4 ge-2/0/4 ge-3/0/4
+e7-2 distro1 ge-0/0/1 ge-1/0/1 ge-2/0/1 ge-3/0/1
+e7-3 distro0 ge-0/0/5 ge-1/0/5 ge-2/0/5 ge-3/0/5
+e7-4 distro0 ge-0/0/6 ge-1/0/6 ge-2/0/6 ge-3/0/6
+e9-2 distro1 ge-0/0/2 ge-1/0/2 ge-2/0/2 ge-3/0/2
+e9-3 distro0 ge-0/0/7 ge-1/0/7 ge-2/0/7 ge-3/0/7
+e9-4 distro0 ge-0/0/8 ge-1/0/8 ge-2/0/8 ge-3/0/8
+e11-1 distro1 ge-0/0/3 ge-1/0/3 ge-2/0/3 ge-3/0/3
+e11-2 distro1 ge-0/0/4 ge-1/0/4 ge-2/0/4 ge-3/0/4
+e11-3 distro0 ge-0/0/9 ge-1/0/9 ge-2/0/9 ge-3/0/9
+e11-4 distro0 ge-0/0/10 ge-1/0/10 ge-2/0/10 ge-3/0/10
+e13-1 distro1 ge-0/0/5 ge-1/0/5 ge-2/0/5 ge-3/0/5
+e13-2 distro1 ge-0/0/6 ge-1/0/6 ge-2/0/6 ge-3/0/6
+e13-3 distro0 ge-0/0/11 ge-1/0/11 ge-2/0/11 ge-3/0/11
+e13-4 distro0 ge-0/0/12 ge-1/0/12 ge-2/0/12 ge-3/0/12
+e15-1 distro1 ge-0/0/7 ge-1/0/7 ge-2/0/7 ge-3/0/7
+e15-2 distro1 ge-0/0/8 ge-1/0/8 ge-2/0/8 ge-3/0/8
+e15-3 distro0 ge-0/0/13 ge-1/0/13 ge-2/0/13 ge-3/0/13
+e15-4 distro0 ge-0/0/14 ge-1/0/14 ge-2/0/14 ge-3/0/14
+e17-1 distro1 ge-0/0/9 ge-1/0/9 ge-2/0/9 ge-3/0/9
+e17-2 distro1 ge-0/0/10 ge-1/0/10 ge-2/0/10 ge-3/0/10
+e17-3 distro2 ge-0/0/0 ge-1/0/0 ge-2/0/0 ge-3/0/0
+e17-4 distro2 ge-0/0/1 ge-1/0/1 ge-2/0/1 ge-3/0/1
+e19-1 distro1 ge-0/0/11 ge-1/0/11 ge-2/0/11 ge-3/0/11
+e19-2 distro1 ge-0/0/12 ge-1/0/12 ge-2/0/12 ge-3/0/12
+e19-3 distro2 ge-0/0/2 ge-1/0/2 ge-2/0/2 ge-3/0/2
+e19-4 distro2 ge-0/0/3 ge-1/0/3 ge-2/0/3 ge-3/0/3
+e21-1 distro1 ge-0/0/13 ge-1/0/13 ge-2/0/13 ge-3/0/13
+e21-2 distro1 ge-0/0/14 ge-1/0/14 ge-2/0/14 ge-3/0/14
+e21-3 distro2 ge-0/0/4 ge-1/0/4 ge-2/0/4 ge-3/0/4
+e21-4 distro2 ge-0/0/5 ge-1/0/5 ge-2/0/5 ge-3/0/5
+e23-1 distro1 ge-0/0/15 ge-1/0/15 ge-2/0/15 ge-3/0/15
+e23-2 distro1 ge-0/0/16 ge-1/0/16 ge-2/0/16 ge-3/0/16
+e23-3 distro2 ge-0/0/6 ge-1/0/6 ge-2/0/6 ge-3/0/6
+e23-4 distro2 ge-0/0/7 ge-1/0/7 ge-2/0/7 ge-3/0/7
+e25-1 distro1 ge-0/0/17 ge-1/0/17 ge-2/0/17 ge-3/0/17
+e25-2 distro1 ge-0/0/18 ge-1/0/18 ge-2/0/18 ge-3/0/18
+e25-3 distro2 ge-0/0/8 ge-1/0/8 ge-2/0/8 ge-3/0/8
+e25-4 distro2 ge-0/0/9 ge-1/0/9 ge-2/0/9 ge-3/0/9
+e27-1 distro1 ge-0/0/19 ge-1/0/19 ge-2/0/19 ge-3/0/19
+e27-2 distro1 ge-0/0/20 ge-1/0/20 ge-2/0/20 ge-3/0/20
+e27-3 distro2 ge-0/0/10 ge-1/0/10 ge-2/0/10 ge-3/0/10
+e27-4 distro2 ge-0/0/11 ge-1/0/11 ge-2/0/11 ge-3/0/11
+e27-1 distro1 ge-0/0/21 ge-1/0/21 ge-2/0/21 ge-3/0/21
+e27-2 distro1 ge-0/0/22 ge-1/0/22 ge-2/0/22 ge-3/0/22
+e29-1 distro3 ge-0/0/0 ge-1/0/0 ge-2/0/0 ge-3/0/0
+e29-2 distro3 ge-0/0/1 ge-1/0/1 ge-2/0/1 ge-3/0/1
+e31-1 distro3 ge-0/0/2 ge-1/0/2 ge-2/0/2 ge-3/0/2
+e31-2 distro3 ge-0/0/3 ge-1/0/3 ge-2/0/3 ge-3/0/3
+e33-1 distro3 ge-0/0/4 ge-1/0/4 ge-2/0/4 ge-3/0/4
+e33-2 distro3 ge-0/0/5 ge-1/0/5 ge-2/0/5 ge-3/0/5
+e35-1 distro3 ge-0/0/6 ge-1/0/6 ge-2/0/6 ge-3/0/6
+e35-2 distro3 ge-0/0/7 ge-1/0/7 ge-2/0/7 ge-3/0/7
+e37-1 distro3 ge-0/0/8 ge-1/0/8 ge-2/0/8 ge-3/0/8
+e37-2 distro3 ge-0/0/9 ge-1/0/9 ge-2/0/9 ge-3/0/9
+e39-1 distro3 ge-0/0/10 ge-1/0/10 ge-2/0/10 ge-3/0/10
+e39-2 distro3 ge-0/0/11 ge-1/0/11 ge-2/0/11 ge-3/0/11
+e41-1 distro3 ge-0/0/12 ge-1/0/12 ge-2/0/12 ge-3/0/12
+e41-2 distro3 ge-0/0/13 ge-1/0/13 ge-2/0/13 ge-3/0/13
+e43-1 distro3 ge-0/0/14 ge-1/0/14 ge-2/0/14 ge-3/0/14
+e43-2 distro3 ge-0/0/15 ge-1/0/15 ge-2/0/15 ge-3/0/15
+e45-1 distro4 ge-0/0/0 ge-1/0/0 ge-2/0/0 ge-3/0/0
+e45-2 distro4 ge-0/0/1 ge-1/0/1 ge-2/0/1 ge-3/0/1
+e45-3 distro5 ge-0/0/0 ge-1/0/0 ge-2/0/0 ge-3/0/0
+e45-4 distro5 ge-0/0/1 ge-1/0/1 ge-2/0/1 ge-3/0/1
+e47-1 distro4 ge-0/0/2 ge-1/0/2 ge-2/0/2 ge-3/0/2
+e47-2 distro4 ge-0/0/3 ge-1/0/3 ge-2/0/3 ge-3/0/3
+e47-3 distro5 ge-0/0/2 ge-1/0/2 ge-2/0/2 ge-3/0/2
+e47-4 distro5 ge-0/0/3 ge-1/0/3 ge-2/0/3 ge-3/0/3
+e49-1 distro4 ge-0/0/4 ge-1/0/4 ge-2/0/4 ge-3/0/4
+e49-2 distro4 ge-0/0/5 ge-1/0/5 ge-2/0/5 ge-3/0/5
+e49-3 distro5 ge-0/0/4 ge-1/0/4 ge-2/0/4 ge-3/0/4
+e49-4 distro5 ge-0/0/5 ge-1/0/5 ge-2/0/5 ge-3/0/5
+e51-1 distro4 ge-0/0/6 ge-1/0/6 ge-2/0/6 ge-3/0/6
+e51-2 distro4 ge-0/0/7 ge-1/0/7 ge-2/0/7 ge-3/0/7
+e51-3 distro5 ge-0/0/6 ge-1/0/6 ge-2/0/6 ge-3/0/6
+e51-4 distro5 ge-0/0/7 ge-1/0/7 ge-2/0/7 ge-3/0/7
+e53-1 distro4 ge-0/0/8 ge-1/0/8 ge-2/0/8 ge-3/0/8
+e53-2 distro4 ge-0/0/9 ge-1/0/9 ge-2/0/9 ge-3/0/9
+e53-3 distro5 ge-0/0/8 ge-1/0/8 ge-2/0/8 ge-3/0/8
+e53-4 distro5 ge-0/0/9 ge-1/0/9 ge-2/0/9 ge-3/0/9
+e55-1 distro4 ge-0/0/10 ge-1/0/10 ge-2/0/10 ge-3/0/10
+e55-2 distro4 ge-0/0/11 ge-1/0/11 ge-2/0/11 ge-3/0/11
+e55-3 distro5 ge-0/0/10 ge-1/0/10 ge-2/0/10 ge-3/0/10
+e55-4 distro5 ge-0/0/11 ge-1/0/11 ge-2/0/11 ge-3/0/11
+e57-1 distro4 ge-0/0/12 ge-1/0/12 ge-2/0/12 ge-3/0/12
+e57-2 distro4 ge-0/0/13 ge-1/0/13 ge-2/0/13 ge-3/0/13
+e57-3 distro5 ge-0/0/12 ge-1/0/12 ge-2/0/12 ge-3/0/12
+e57-4 distro5 ge-0/0/13 ge-1/0/13 ge-2/0/13 ge-3/0/13
+e59-1 distro4 ge-0/0/14 ge-1/0/14 ge-2/0/14 ge-3/0/14
+e59-2 distro4 ge-0/0/15 ge-1/0/15 ge-2/0/15 ge-3/0/15
+e59-3 distro5 ge-0/0/14 ge-1/0/14 ge-2/0/14 ge-3/0/14
+e59-4 distro5 ge-0/0/15 ge-1/0/15 ge-2/0/15 ge-3/0/15
+e61-1 distro4 ge-0/0/16 ge-1/0/16 ge-2/0/16 ge-3/0/16
+e61-2 distro4 ge-0/0/17 ge-1/0/17 ge-2/0/17 ge-3/0/17
+e61-3 distro5 ge-0/0/16 ge-1/0/16 ge-2/0/16 ge-3/0/16
+e61-4 distro5 ge-0/0/17 ge-1/0/17 ge-2/0/17 ge-3/0/17
+e63-1 distro7 ge-0/0/0 ge-1/0/0 ge-2/0/0 ge-3/0/0
+e63-2 distro7 ge-0/0/1 ge-1/0/1 ge-2/0/1 ge-3/0/1
+e63-3 distro6 ge-0/0/0 ge-1/0/0 ge-2/0/0 ge-3/0/0
+e63-4 distro6 ge-0/0/1 ge-1/0/1 ge-2/0/1 ge-3/0/1
+e65-1 distro7 ge-0/0/2 ge-1/0/2 ge-2/0/2 ge-3/0/2
+e65-2 distro7 ge-0/0/3 ge-1/0/3 ge-2/0/3 ge-3/0/3
+e65-3 distro6 ge-0/0/2 ge-1/0/2 ge-2/0/2 ge-3/0/2
+e65-4 distro6 ge-0/0/3 ge-1/0/3 ge-2/0/3 ge-3/0/3
+e67-1 distro7 ge-0/0/4 ge-1/0/4 ge-2/0/4 ge-3/0/4
+e67-2 distro7 ge-0/0/5 ge-1/0/5 ge-2/0/5 ge-3/0/5
+e67-3 distro6 ge-0/0/4 ge-1/0/4 ge-2/0/4 ge-3/0/4
+e67-4 distro6 ge-0/0/5 ge-1/0/5 ge-2/0/5 ge-3/0/5
+e69-1 distro7 ge-0/0/6 ge-1/0/6 ge-2/0/6 ge-3/0/6
+e69-2 distro7 ge-0/0/7 ge-1/0/7 ge-2/0/7 ge-3/0/7
+e69-3 distro6 ge-0/0/6 ge-1/0/6 ge-2/0/6 ge-3/0/6
+e69-4 distro6 ge-0/0/7 ge-1/0/7 ge-2/0/7 ge-3/0/7
+e71-1 distro7 ge-0/0/8 ge-1/0/8 ge-2/0/8 ge-3/0/8
+e71-2 distro7 ge-0/0/9 ge-1/0/9 ge-2/0/9 ge-3/0/9
+e71-3 distro6 ge-0/0/8 ge-1/0/8 ge-2/0/8 ge-3/0/8
+e71-4 distro6 ge-0/0/9 ge-1/0/9 ge-2/0/9 ge-3/0/9
+e73-1 distro7 ge-0/0/10 ge-1/0/10 ge-2/0/10 ge-3/0/10
+e73-2 distro7 ge-0/0/11 ge-1/0/11 ge-2/0/11 ge-3/0/11
+e73-3 distro6 ge-0/0/10 ge-1/0/10 ge-2/0/10 ge-3/0/10
+e73-4 distro6 ge-0/0/11 ge-1/0/11 ge-2/0/11 ge-3/0/11
+e75-1 distro7 ge-0/0/12 ge-1/0/12 ge-2/0/12 ge-3/0/12
+e75-2 distro7 ge-0/0/13 ge-1/0/13 ge-2/0/13 ge-3/0/13
+e75-3 distro6 ge-0/0/12 ge-1/0/12 ge-2/0/12 ge-3/0/12
+e75-4 distro6 ge-0/0/13 ge-1/0/13 ge-2/0/13 ge-3/0/13
+e77-1 distro7 ge-0/0/14 ge-1/0/14 ge-2/0/14 ge-3/0/14
+e77-2 distro7 ge-0/0/15 ge-1/0/15 ge-2/0/15 ge-3/0/15
+e77-3 distro6 ge-0/0/14 ge-1/0/14 ge-2/0/14 ge-3/0/14
+e77-4 distro6 ge-0/0/15 ge-1/0/15 ge-2/0/15 ge-3/0/15
+e79-1 distro7 ge-0/0/16 ge-1/0/16 ge-2/0/16 ge-3/0/16
+e79-2 distro7 ge-0/0/17 ge-1/0/17 ge-2/0/17 ge-3/0/17
+e79-3 distro6 ge-0/0/16 ge-1/0/16 ge-2/0/16 ge-3/0/16
+e79-4 distro6 ge-0/0/17 ge-1/0/17 ge-2/0/17 ge-3/0/17
+e81-1 distro7 ge-0/0/18 ge-1/0/18 ge-2/0/18 ge-3/0/18
+e81-2 distro7 ge-0/0/19 ge-1/0/19 ge-2/0/19 ge-3/0/19
+e83-1 distro7 ge-0/0/20 ge-1/0/20 ge-2/0/20 ge-3/0/20
+e83-2 distro7 ge-0/0/21 ge-1/0/21 ge-2/0/21 ge-3/0/21
diff --git a/fap/httpd/httpd_root/# create_queries - DEPRECATED/switches.txt b/fap/httpd/httpd_root/# create_queries - DEPRECATED/switches.txt
new file mode 100644
index 0000000..c9d60d9
--- /dev/null
+++ b/fap/httpd/httpd_root/# create_queries - DEPRECATED/switches.txt
@@ -0,0 +1,142 @@
+e1-3 151.216.129.0/26 2a02:ed02:129a::/64 151.216.180.2/26 2a02:ed02:180a::2/64 1013 distro0
+e3-3 151.216.129.64/26 2a02:ed02:129b::/64 151.216.180.3/26 2a02:ed02:180a::3/64 1033 distro0
+e3-4 151.216.129.128/26 2a02:ed02:129c::/64 151.216.180.4/26 2a02:ed02:180a::4/64 1034 distro0
+e5-2 151.216.129.192/26 2a02:ed02:129d::/64 151.216.180.66/26 2a02:ed02:180b::66/64 1052 distro1
+e5-3 151.216.130.0/26 2a02:ed02:130a::/64 151.216.180.5/26 2a02:ed02:180a::5/64 1053 distro0
+e5-4 151.216.130.64/26 2a02:ed02:130b::/64 151.216.180.6/26 2a02:ed02:180a::6/64 1054 distro0
+e7-2 151.216.130.128/26 2a02:ed02:130c::/64 151.216.180.67/26 2a02:ed02:180b::67/64 1072 distro1
+e7-3 151.216.130.192/26 2a02:ed02:130d::/64 151.216.180.7/26 2a02:ed02:180a::7/64 1073 distro0
+e7-4 151.216.131.0/26 2a02:ed02:131a::/64 151.216.180.8/26 2a02:ed02:180a::8/64 1074 distro0
+e9-2 151.216.131.64/26 2a02:ed02:131b::/64 151.216.180.68/26 2a02:ed02:180b::68/64 1092 distro1
+e9-3 151.216.131.128/26 2a02:ed02:131c::/64 151.216.180.9/26 2a02:ed02:180a::9/64 1093 distro0
+e9-4 151.216.131.192/26 2a02:ed02:131d::/64 151.216.180.10/26 2a02:ed02:180a::10/64 1094 distro0
+e11-1 151.216.132.0/26 2a02:ed02:132a::/64 151.216.180.69/26 2a02:ed02:180b::69/64 1111 distro1
+e11-2 151.216.132.64/26 2a02:ed02:132b::/64 151.216.180.70/26 2a02:ed02:180b::70/64 1112 distro1
+e11-3 151.216.132.128/26 2a02:ed02:132c::/64 151.216.180.11/26 2a02:ed02:180a::11/64 1113 distro0
+e11-4 151.216.132.192/26 2a02:ed02:132d::/64 151.216.180.12/26 2a02:ed02:180a::12/64 1114 distro0
+e13-1 151.216.133.0/26 2a02:ed02:133a::/64 151.216.180.71/26 2a02:ed02:180b::71/64 1131 distro1
+e13-2 151.216.133.64/26 2a02:ed02:133b::/64 151.216.180.72/26 2a02:ed02:180b::72/64 1132 distro1
+e13-3 151.216.133.128/26 2a02:ed02:133c::/64 151.216.180.13/26 2a02:ed02:180a::13/64 1133 distro0
+e13-4 151.216.133.192/26 2a02:ed02:133d::/64 151.216.180.14/26 2a02:ed02:180a::14/64 1134 distro0
+e15-1 151.216.134.0/26 2a02:ed02:134a::/64 151.216.180.73/26 2a02:ed02:180b::73/64 1151 distro1
+e15-2 151.216.134.64/26 2a02:ed02:134b::/64 151.216.180.74/26 2a02:ed02:180b::74/64 1152 distro1
+e15-3 151.216.134.128/26 2a02:ed02:134c::/64 151.216.180.15/26 2a02:ed02:180a::15/64 1153 distro0
+e15-4 151.216.134.192/26 2a02:ed02:134d::/64 151.216.180.16/26 2a02:ed02:180a::16/64 1154 distro0
+e17-1 151.216.135.0/26 2a02:ed02:135a::/64 151.216.180.75/26 2a02:ed02:180b::75/64 1171 distro1
+e17-2 151.216.135.64/26 2a02:ed02:135b::/64 151.216.180.76/26 2a02:ed02:180b::76/64 1172 distro1
+e17-3 151.216.135.128/26 2a02:ed02:135c::/64 151.216.180.130/26 2a02:ed02:180c::130/64 1173 distro2
+e17-4 151.216.135.192/26 2a02:ed02:135d::/64 151.216.180.131/26 2a02:ed02:180c::131/64 1174 distro2
+e19-1 151.216.136.0/26 2a02:ed02:136a::/64 151.216.180.77/26 2a02:ed02:180b::77/64 1191 distro1
+e19-2 151.216.136.64/26 2a02:ed02:136b::/64 151.216.180.78/26 2a02:ed02:180b::78/64 1192 distro1
+e19-3 151.216.136.128/26 2a02:ed02:136c::/64 151.216.180.132/26 2a02:ed02:180c::132/64 1193 distro2
+e19-4 151.216.136.192/26 2a02:ed02:136d::/64 151.216.180.133/26 2a02:ed02:180c::133/64 1194 distro2
+e21-1 151.216.137.0/26 2a02:ed02:137a::/64 151.216.180.79/26 2a02:ed02:180b::79/64 1211 distro1
+e21-2 151.216.137.64/26 2a02:ed02:137b::/64 151.216.180.80/26 2a02:ed02:180b::80/64 1212 distro1
+e21-3 151.216.137.128/26 2a02:ed02:137c::/64 151.216.180.134/26 2a02:ed02:180c::134/64 1213 distro2
+e21-4 151.216.137.192/26 2a02:ed02:137d::/64 151.216.180.135/26 2a02:ed02:180c::135/64 1214 distro2
+e23-1 151.216.138.0/26 2a02:ed02:138a::/64 151.216.180.81/26 2a02:ed02:180b::81/64 1231 distro1
+e23-2 151.216.138.64/26 2a02:ed02:138b::/64 151.216.180.82/26 2a02:ed02:180b::82/64 1232 distro1
+e23-3 151.216.138.128/26 2a02:ed02:138c::/64 151.216.180.136/26 2a02:ed02:180c::136/64 1233 distro2
+e23-4 151.216.138.192/26 2a02:ed02:138d::/64 151.216.180.137/26 2a02:ed02:180c::137/64 1234 distro2
+e25-1 151.216.139.0/26 2a02:ed02:139a::/64 151.216.180.83/26 2a02:ed02:180b::83/64 1251 distro1
+e25-2 151.216.139.64/26 2a02:ed02:139b::/64 151.216.180.84/26 2a02:ed02:180b::84/64 1252 distro1
+e25-3 151.216.139.128/26 2a02:ed02:139c::/64 151.216.180.138/26 2a02:ed02:180c::138/64 1253 distro2
+e25-4 151.216.139.192/26 2a02:ed02:139d::/64 151.216.180.139/26 2a02:ed02:180c::139/64 1254 distro2
+e27-1 151.216.140.0/26 2a02:ed02:140a::/64 151.216.180.85/26 2a02:ed02:180b::85/64 1271 distro1
+e27-2 151.216.140.64/26 2a02:ed02:140b::/64 151.216.180.86/26 2a02:ed02:180b::86/64 1272 distro1
+e27-3 151.216.140.128/26 2a02:ed02:140c::/64 151.216.180.140/26 2a02:ed02:180c::140/64 1273 distro2
+e27-4 151.216.140.192/26 2a02:ed02:140d::/64 151.216.180.141/26 2a02:ed02:180c::141/64 1274 distro2
+e27-1 151.216.141.0/26 2a02:ed02:141a::/64 151.216.180.87/26 2a02:ed02:180b::87/64 1271 distro1
+e27-2 151.216.141.64/26 2a02:ed02:141b::/64 151.216.180.88/26 2a02:ed02:180b::88/64 1272 distro1
+e29-1 151.216.141.128/26 2a02:ed02:141c::/64 151.216.180.194/26 2a02:ed02:180d::194/64 1291 distro3
+e29-2 151.216.141.192/26 2a02:ed02:141d::/64 151.216.180.195/26 2a02:ed02:180d::195/64 1292 distro3
+e31-1 151.216.142.0/26 2a02:ed02:142a::/64 151.216.180.196/26 2a02:ed02:180d::196/64 1311 distro3
+e31-2 151.216.142.64/26 2a02:ed02:142b::/64 151.216.180.197/26 2a02:ed02:180d::197/64 1312 distro3
+e33-1 151.216.142.128/26 2a02:ed02:142c::/64 151.216.180.198/26 2a02:ed02:180d::198/64 1331 distro3
+e33-2 151.216.142.192/26 2a02:ed02:142d::/64 151.216.180.199/26 2a02:ed02:180d::199/64 1332 distro3
+e35-1 151.216.143.0/26 2a02:ed02:143a::/64 151.216.180.200/26 2a02:ed02:180d::200/64 1351 distro3
+e35-2 151.216.143.64/26 2a02:ed02:143b::/64 151.216.180.201/26 2a02:ed02:180d::201/64 1352 distro3
+e37-1 151.216.143.128/26 2a02:ed02:143c::/64 151.216.180.202/26 2a02:ed02:180d::202/64 1371 distro3
+e37-2 151.216.143.192/26 2a02:ed02:143d::/64 151.216.180.203/26 2a02:ed02:180d::203/64 1372 distro3
+e39-1 151.216.144.0/26 2a02:ed02:144a::/64 151.216.180.204/26 2a02:ed02:180d::204/64 1391 distro3
+e39-2 151.216.144.64/26 2a02:ed02:144b::/64 151.216.180.205/26 2a02:ed02:180d::205/64 1392 distro3
+e41-1 151.216.144.128/26 2a02:ed02:144c::/64 151.216.180.206/26 2a02:ed02:180d::206/64 1411 distro3
+e41-2 151.216.144.192/26 2a02:ed02:144d::/64 151.216.180.207/26 2a02:ed02:180d::207/64 1412 distro3
+e43-1 151.216.145.0/26 2a02:ed02:145a::/64 151.216.180.208/26 2a02:ed02:180d::208/64 1431 distro3
+e43-2 151.216.145.64/26 2a02:ed02:145b::/64 151.216.180.209/26 2a02:ed02:180d::209/64 1432 distro3
+e45-1 151.216.145.128/26 2a02:ed02:145c::/64 151.216.181.2/26 2a02:ed02:181a::2/64 1451 distro4
+e45-2 151.216.145.192/26 2a02:ed02:145d::/64 151.216.181.3/26 2a02:ed02:181a::3/64 1452 distro4
+e45-3 151.216.146.0/26 2a02:ed02:146a::/64 151.216.181.66/26 2a02:ed02:181b::66/64 1453 distro5
+e45-4 151.216.146.64/26 2a02:ed02:146b::/64 151.216.181.67/26 2a02:ed02:181b::67/64 1454 distro5
+e47-1 151.216.146.128/26 2a02:ed02:146c::/64 151.216.181.4/26 2a02:ed02:181a::4/64 1471 distro4
+e47-2 151.216.146.192/26 2a02:ed02:146d::/64 151.216.181.5/26 2a02:ed02:181a::5/64 1472 distro4
+e47-3 151.216.147.0/26 2a02:ed02:147a::/64 151.216.181.68/26 2a02:ed02:181b::68/64 1473 distro5
+e47-4 151.216.147.64/26 2a02:ed02:147b::/64 151.216.181.69/26 2a02:ed02:181b::69/64 1474 distro5
+e49-1 151.216.147.128/26 2a02:ed02:147c::/64 151.216.181.6/26 2a02:ed02:181a::6/64 1491 distro4
+e49-2 151.216.147.192/26 2a02:ed02:147d::/64 151.216.181.7/26 2a02:ed02:181a::7/64 1492 distro4
+e49-3 151.216.148.0/26 2a02:ed02:148a::/64 151.216.181.70/26 2a02:ed02:181b::70/64 1493 distro5
+e49-4 151.216.148.64/26 2a02:ed02:148b::/64 151.216.181.71/26 2a02:ed02:181b::71/64 1494 distro5
+e51-1 151.216.148.128/26 2a02:ed02:148c::/64 151.216.181.8/26 2a02:ed02:181a::8/64 1511 distro4
+e51-2 151.216.148.192/26 2a02:ed02:148d::/64 151.216.181.9/26 2a02:ed02:181a::9/64 1512 distro4
+e51-3 151.216.149.0/26 2a02:ed02:149a::/64 151.216.181.72/26 2a02:ed02:181b::72/64 1513 distro5
+e51-4 151.216.149.64/26 2a02:ed02:149b::/64 151.216.181.73/26 2a02:ed02:181b::73/64 1514 distro5
+e53-1 151.216.149.128/26 2a02:ed02:149c::/64 151.216.181.10/26 2a02:ed02:181a::10/64 1531 distro4
+e53-2 151.216.149.192/26 2a02:ed02:149d::/64 151.216.181.11/26 2a02:ed02:181a::11/64 1532 distro4
+e53-3 151.216.150.0/26 2a02:ed02:150a::/64 151.216.181.74/26 2a02:ed02:181b::74/64 1533 distro5
+e53-4 151.216.150.64/26 2a02:ed02:150b::/64 151.216.181.75/26 2a02:ed02:181b::75/64 1534 distro5
+e55-1 151.216.150.128/26 2a02:ed02:150c::/64 151.216.181.12/26 2a02:ed02:181a::12/64 1551 distro4
+e55-2 151.216.150.192/26 2a02:ed02:150d::/64 151.216.181.13/26 2a02:ed02:181a::13/64 1552 distro4
+e55-3 151.216.151.0/26 2a02:ed02:151a::/64 151.216.181.76/26 2a02:ed02:181b::76/64 1553 distro5
+e55-4 151.216.151.64/26 2a02:ed02:151b::/64 151.216.181.77/26 2a02:ed02:181b::77/64 1554 distro5
+e57-1 151.216.151.128/26 2a02:ed02:151c::/64 151.216.181.14/26 2a02:ed02:181a::14/64 1571 distro4
+e57-2 151.216.151.192/26 2a02:ed02:151d::/64 151.216.181.15/26 2a02:ed02:181a::15/64 1572 distro4
+e57-3 151.216.152.0/26 2a02:ed02:152a::/64 151.216.181.78/26 2a02:ed02:181b::78/64 1573 distro5
+e57-4 151.216.152.64/26 2a02:ed02:152b::/64 151.216.181.79/26 2a02:ed02:181b::79/64 1574 distro5
+e59-1 151.216.152.128/26 2a02:ed02:152c::/64 151.216.181.16/26 2a02:ed02:181a::16/64 1591 distro4
+e59-2 151.216.152.192/26 2a02:ed02:152d::/64 151.216.181.17/26 2a02:ed02:181a::17/64 1592 distro4
+e59-3 151.216.153.0/26 2a02:ed02:153a::/64 151.216.181.80/26 2a02:ed02:181b::80/64 1593 distro5
+e59-4 151.216.153.64/26 2a02:ed02:153b::/64 151.216.181.81/26 2a02:ed02:181b::81/64 1594 distro5
+e61-1 151.216.153.128/26 2a02:ed02:153c::/64 151.216.181.18/26 2a02:ed02:181a::18/64 1611 distro4
+e61-2 151.216.153.192/26 2a02:ed02:153d::/64 151.216.181.19/26 2a02:ed02:181a::19/64 1612 distro4
+e61-3 151.216.154.0/26 2a02:ed02:154a::/64 151.216.181.82/26 2a02:ed02:181b::82/64 1613 distro5
+e61-4 151.216.154.64/26 2a02:ed02:154b::/64 151.216.181.83/26 2a02:ed02:181b::83/64 1614 distro5
+e63-1 151.216.154.128/26 2a02:ed02:154c::/64 151.216.181.194/26 2a02:ed02:181d::194/64 1631 distro7
+e63-2 151.216.154.192/26 2a02:ed02:154d::/64 151.216.181.195/26 2a02:ed02:181d::195/64 1632 distro7
+e63-3 151.216.155.0/26 2a02:ed02:155a::/64 151.216.181.130/26 2a02:ed02:181c::130/64 1633 distro6
+e63-4 151.216.155.64/26 2a02:ed02:155b::/64 151.216.181.131/26 2a02:ed02:181c::131/64 1634 distro6
+e65-1 151.216.155.128/26 2a02:ed02:155c::/64 151.216.181.196/26 2a02:ed02:181d::196/64 1651 distro7
+e65-2 151.216.155.192/26 2a02:ed02:155d::/64 151.216.181.197/26 2a02:ed02:181d::197/64 1652 distro7
+e65-3 151.216.156.0/26 2a02:ed02:156a::/64 151.216.181.132/26 2a02:ed02:181c::132/64 1653 distro6
+e65-4 151.216.156.64/26 2a02:ed02:156b::/64 151.216.181.133/26 2a02:ed02:181c::133/64 1654 distro6
+e67-1 151.216.156.128/26 2a02:ed02:156c::/64 151.216.181.198/26 2a02:ed02:181d::198/64 1671 distro7
+e67-2 151.216.156.192/26 2a02:ed02:156d::/64 151.216.181.199/26 2a02:ed02:181d::199/64 1672 distro7
+e67-3 151.216.157.0/26 2a02:ed02:157a::/64 151.216.181.134/26 2a02:ed02:181c::134/64 1673 distro6
+e67-4 151.216.157.64/26 2a02:ed02:157b::/64 151.216.181.135/26 2a02:ed02:181c::135/64 1674 distro6
+e69-1 151.216.157.128/26 2a02:ed02:157c::/64 151.216.181.200/26 2a02:ed02:181d::200/64 1691 distro7
+e69-2 151.216.157.192/26 2a02:ed02:157d::/64 151.216.181.201/26 2a02:ed02:181d::201/64 1692 distro7
+e69-3 151.216.158.0/26 2a02:ed02:158a::/64 151.216.181.136/26 2a02:ed02:181c::136/64 1693 distro6
+e69-4 151.216.158.64/26 2a02:ed02:158b::/64 151.216.181.137/26 2a02:ed02:181c::137/64 1694 distro6
+e71-1 151.216.158.128/26 2a02:ed02:158c::/64 151.216.181.202/26 2a02:ed02:181d::202/64 1711 distro7
+e71-2 151.216.158.192/26 2a02:ed02:158d::/64 151.216.181.203/26 2a02:ed02:181d::203/64 1712 distro7
+e71-3 151.216.159.0/26 2a02:ed02:159a::/64 151.216.181.138/26 2a02:ed02:181c::138/64 1713 distro6
+e71-4 151.216.159.64/26 2a02:ed02:159b::/64 151.216.181.139/26 2a02:ed02:181c::139/64 1714 distro6
+e73-1 151.216.159.128/26 2a02:ed02:159c::/64 151.216.181.204/26 2a02:ed02:181d::204/64 1731 distro7
+e73-2 151.216.159.192/26 2a02:ed02:159d::/64 151.216.181.205/26 2a02:ed02:181d::205/64 1732 distro7
+e73-3 151.216.160.0/26 2a02:ed02:160a::/64 151.216.181.140/26 2a02:ed02:181c::140/64 1733 distro6
+e73-4 151.216.160.64/26 2a02:ed02:160b::/64 151.216.181.141/26 2a02:ed02:181c::141/64 1734 distro6
+e75-1 151.216.160.128/26 2a02:ed02:160c::/64 151.216.181.206/26 2a02:ed02:181d::206/64 1751 distro7
+e75-2 151.216.160.192/26 2a02:ed02:160d::/64 151.216.181.207/26 2a02:ed02:181d::207/64 1752 distro7
+e75-3 151.216.161.0/26 2a02:ed02:161a::/64 151.216.181.142/26 2a02:ed02:181c::142/64 1753 distro6
+e75-4 151.216.161.64/26 2a02:ed02:161b::/64 151.216.181.143/26 2a02:ed02:181c::143/64 1754 distro6
+e77-1 151.216.161.128/26 2a02:ed02:161c::/64 151.216.181.208/26 2a02:ed02:181d::208/64 1771 distro7
+e77-2 151.216.161.192/26 2a02:ed02:161d::/64 151.216.181.209/26 2a02:ed02:181d::209/64 1772 distro7
+e77-3 151.216.162.0/26 2a02:ed02:162a::/64 151.216.181.144/26 2a02:ed02:181c::144/64 1773 distro6
+e77-4 151.216.162.64/26 2a02:ed02:162b::/64 151.216.181.145/26 2a02:ed02:181c::145/64 1774 distro6
+e79-1 151.216.162.128/26 2a02:ed02:162c::/64 151.216.181.210/26 2a02:ed02:181d::210/64 1791 distro7
+e79-2 151.216.162.192/26 2a02:ed02:162d::/64 151.216.181.211/26 2a02:ed02:181d::211/64 1792 distro7
+e79-3 151.216.163.0/26 2a02:ed02:163a::/64 151.216.181.146/26 2a02:ed02:181c::146/64 1793 distro6
+e79-4 151.216.163.64/26 2a02:ed02:163b::/64 151.216.181.147/26 2a02:ed02:181c::147/64 1794 distro6
+e81-1 151.216.163.128/26 2a02:ed02:163c::/64 151.216.181.212/26 2a02:ed02:181d::212/64 1811 distro7
+e81-2 151.216.163.192/26 2a02:ed02:163d::/64 151.216.181.213/26 2a02:ed02:181d::213/64 1812 distro7
+e83-1 151.216.164.0/26 2a02:ed02:164a::/64 151.216.181.214/26 2a02:ed02:181d::214/64 1831 distro7
+e83-2 151.216.164.64/26 2a02:ed02:164b::/64 151.216.181.215/26 2a02:ed02:181d::215/64 1832 distro7
diff --git a/fap/httpd/httpd_root/.gitignore b/fap/httpd/httpd_root/.gitignore
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/fap/httpd/httpd_root/.gitignore
diff --git a/fap/httpd/httpd_root/.htaccess b/fap/httpd/httpd_root/.htaccess
new file mode 100755
index 0000000..17add11
--- /dev/null
+++ b/fap/httpd/httpd_root/.htaccess
@@ -0,0 +1,3 @@
+RewriteEngine on
+RewriteRule ^files/(.+)$ x.php?mode=image&file=$1 [L]
+RewriteRule ^tg-edge/(.+)$ x.php?mode=config&hostname=$1 [L]
diff --git a/fap/httpd/httpd_root/ex2200.template b/fap/httpd/httpd_root/ex2200.template
new file mode 100755
index 0000000..7f3bbaf
--- /dev/null
+++ b/fap/httpd/httpd_root/ex2200.template
@@ -0,0 +1,288 @@
+system {
+ host-name <?php echo $c['hostname']; ?>;
+ auto-snapshot;
+ time-zone Europe/Oslo;
+ authentication-order [ tacplus password ];
+ root-authentication {
+ encrypted-password "<sensored>";
+ }
+ name-server {
+ 2a02:ed02:1ee7::66;
+ 2a02:ed02:1337::2;
+ }
+ login {
+ user technet {
+ uid 2000;
+ class super-user;
+ authentication {
+ encrypted-password "<sensored>";
+ }
+ }
+ }
+ services {
+ ssh {
+ root-login deny;
+ }
+ netconf {
+ ssh;
+ }
+ }
+ syslog {
+ user * {
+ any emergency;
+ }
+ file messages {
+ any notice;
+ authorization info;
+ }
+ file interactive-commands {
+ interactive-commands any;
+ }
+ }
+ ntp {
+ server 2001:700:100:2::6;
+ }
+}
+
+chassis {
+ aggregated-devices {
+ ethernet {
+ device-count 1;
+ }
+ }
+ alarm {
+ management-ethernet {
+ link-down ignore;
+ }
+ }
+}
+
+interfaces {
+ interface-range edge-ports {
+ description "Clients";
+ member-range ge-0/0/0 to ge-0/0/43;
+ unit 0 {
+ family ethernet-switching {
+ port-mode access;
+ vlan {
+ members clients;
+ }
+ }
+ }
+ }
+ interface-range core-ports {
+ description "<?php echo $c['distro_name']; ?> <?php echo $c['distro_phy_port']; ?>";
+ member-range ge-0/0/44 to ge-0/0/47;
+ ether-options {
+ 802.3ad ae0;
+ }
+ }
+ ae0 {
+ description "<?php echo $c['distro_name']; ?> <?php echo $c['distro_phy_port']; ?>";
+ aggregated-ether-options {
+ lacp {
+ active;
+ }
+ }
+ unit 0 {
+ family ethernet-switching {
+ port-mode trunk;
+ vlan {
+ members [clients mgmt];
+ }
+ }
+ }
+ }
+ vlan {
+ unit <?php echo $c['mgmt_vlan']; ?> {
+ description "MGMT L3 interface";
+ family inet {
+ filter {
+ input v4-mgmt;
+ }
+ address <?php echo $c['mgmt_v4_addr'] . '/' . $c['mgmt_v4_cidr']; ?>;
+ }
+ family inet6 {
+ filter {
+ input v6-mgmt;
+ }
+ address <?php echo $c['mgmt_v6_addr'] . '/' . $c['mgmt_v6_cidr']; ?>;
+ }
+ }
+ }
+}
+
+snmp {
+ community <sensored> {
+ client-list-name mgmt;
+ }
+}
+
+policy-options {
+ prefix-list v4-mgmt {
+ /* nLogic jumpstation */
+ <sensored>
+ /* Harald jumpstation */
+ <sensored>
+ /* Tech colo-boks */
+ <sensored>
+ /* NOC clients */
+ 151.216.254.0/24;
+ /* Servers */
+ 185.12.59.0/26;
+ }
+ prefix-list v6-mgmt {
+ /* Harald jumpstation */
+ <sensored>
+ /* nLogic jumpstation */
+ <sensored>
+ /* Tech colo-boks */
+ <sensored>
+ /* NOC clients */
+ 2a02:ed02:254::/64;
+ /* Servers */
+ 2a02:ed02:1337::/64;
+ }
+ prefix-list mgmt {
+ /* nLogic jumpstation */
+ <sensored>
+ /* Harald jumpstation */
+ <sensored>
+ /* Tech colo-boks */
+ <sensored>
+ /* NOC clients */
+ 151.216.254.0/24;
+ /* Servers */
+ 185.12.59.0/26;
+ /* Harald jumpstation */
+ <sensored>
+ /* nLogic jumpstation */
+ <sensored>
+ /* Tech colo-boks */
+ <sensored>
+ /* NOC clients */
+ 2a02:ed02:254::/64;
+ /* Servers */
+ 2a02:ed02:1337::/64;
+ }
+}
+firewall {
+ family inet {
+ filter v4-mgmt {
+ term accept-ssh {
+ from {
+ source-prefix-list {
+ v4-mgmt;
+ }
+ destination-port 22;
+ }
+ then {
+ accept;
+ }
+ }
+ term discard-ssh {
+ from {
+ destination-port 22;
+ }
+ then {
+ discard;
+ }
+ }
+ term accept-all {
+ then {
+ accept;
+ }
+ }
+ }
+ }
+ family inet6 {
+ filter v6-mgmt {
+ term accept-ssh {
+ from {
+ source-prefix-list {
+ v6-mgmt;
+ }
+ destination-port 22;
+ }
+ then {
+ accept;
+ }
+ }
+ term discard-ssh {
+ from {
+ destination-port 22;
+ }
+ then {
+ discard;
+ }
+ }
+ term accept-all {
+ then {
+
+ accept;
+ }
+ }
+ }
+ }
+}
+
+protocols {
+ sflow {
+ sample-rate {
+ ingress 10000;
+ egress 10000;
+ }
+ collector <sensored>;
+ interfaces edge-ports;
+ interfaces core-ports;
+ }
+ igmp-snooping {
+ vlan all {
+ version 3;
+ immediate-leave;
+ }
+ }
+ mld-snooping {
+ vlan all {
+ version 2;
+ immediate-leave;
+ }
+ }
+ rstp {
+ bridge-priority 8k;
+ interface edge-ports {
+ edge;
+ no-root-port;
+ }
+ }
+ lldp {
+ interface ae0.0
+ }
+}
+
+vlans {
+ clients {
+ vlan-id <?php echo $c['traffic_vlan']; ?>;
+ }
+ mgmt {
+ vlan-id <?php echo $c['mgmt_vlan']; ?>;
+ l3-interface vlan.<?php echo $c['mgmt_vlan']; ?>;
+ }
+}
+
+routing-options {
+ rib inet.0 {
+ static {
+ route 0.0.0.0/0 {
+ next-hop <?php echo $c['mgmt_v4_gw']; ?>;
+ }
+ }
+ }
+ rib inet6.0 {
+ static {
+ route ::/0 {
+ next-hop <?php echo $c['mgmt_v6_gw']; ?>;
+ }
+ }
+ }
+}
diff --git a/fap/httpd/httpd_root/ex2200_secure.template b/fap/httpd/httpd_root/ex2200_secure.template
new file mode 100755
index 0000000..de9bd3b
--- /dev/null
+++ b/fap/httpd/httpd_root/ex2200_secure.template
@@ -0,0 +1,312 @@
+system {
+ host-name <?php echo $c['hostname']; ?>;
+ auto-snapshot;
+ time-zone Europe/Oslo;
+ authentication-order [ tacplus password ];
+ root-authentication {
+ encrypted-password "<sensored>";
+ }
+ name-server {
+ 2a02:ed02:1ee7::66;
+ 2a02:ed02:1337::2;
+ }
+ login {
+ user technet {
+ uid 2000;
+ class super-user;
+ authentication {
+ encrypted-password "<sensored>";
+ }
+ }
+ }
+ services {
+ ssh {
+ root-login deny;
+ }
+ netconf {
+ ssh;
+ }
+ }
+ syslog {
+ user * {
+ any emergency;
+ }
+ file messages {
+ any notice;
+ authorization info;
+ }
+ file interactive-commands {
+ interactive-commands any;
+ }
+ }
+ ntp {
+ server 2001:700:100:2::6;
+ }
+}
+
+chassis {
+ aggregated-devices {
+ ethernet {
+ device-count 1;
+ }
+ }
+ alarm {
+ management-ethernet {
+ link-down ignore;
+ }
+ }
+}
+
+interfaces {
+ interface-range edge-ports {
+ description "Clients";
+ member-range ge-0/0/0 to ge-0/0/43;
+ unit 0 {
+ family ethernet-switching {
+ port-mode access;
+ vlan {
+ members clients;
+ }
+ }
+ }
+ }
+ interface-range core-ports {
+ description "<?php echo $c['distro_name']; ?> <?php echo $c['distro_phy_port']; ?>";
+ member-range ge-0/0/44 to ge-0/0/47;
+ ether-options {
+ 802.3ad ae0;
+ }
+ }
+ ae0 {
+ description "<?php echo $c['distro_name']; ?> <?php echo $c['distro_phy_port']; ?>";
+ aggregated-ether-options {
+ lacp {
+ active;
+ }
+ }
+ unit 0 {
+ family ethernet-switching {
+ port-mode trunk;
+ vlan {
+ members [clients mgmt];
+ }
+ }
+ }
+ }
+ vlan {
+ unit <?php echo $c['mgmt_vlan']; ?> {
+ description "MGMT L3 interface";
+ family inet {
+ filter {
+ input v4-mgmt;
+ }
+ address <?php echo $c['mgmt_v4_addr'] . '/' . $c['mgmt_v4_cidr']; ?>;
+ }
+ family inet6 {
+ filter {
+ input v6-mgmt;
+ }
+ address <?php echo $c['mgmt_v6_addr'] . '/' . $c['mgmt_v6_cidr']; ?>;
+ }
+ }
+ }
+}
+
+snmp {
+ community <sensored> {
+ client-list-name mgmt;
+ }
+}
+
+policy-options {
+ prefix-list v4-mgmt {
+ /* nLogic jumpstation */
+ <sensored>
+ /* Harald jumpstation */
+ <sensored>
+ /* Tech colo-boks */
+ <sensored>
+ /* NOC clients */
+ 151.216.254.0/24;
+ /* Servers */
+ 185.12.59.0/26;
+ }
+ prefix-list v6-mgmt {
+ /* Harald jumpstation */
+ <sensored>
+ /* nLogic jumpstation */
+ <sensored>
+ /* Tech colo-boks */
+ <sensored>
+ /* NOC clients */
+ 2a02:ed02:254::/64;
+ /* Servers */
+ 2a02:ed02:1337::/64;
+ }
+ prefix-list mgmt {
+ /* nLogic jumpstation */
+ <sensored>
+ /* Harald jumpstation */
+ <sensored>
+ /* Tech colo-boks */
+ <sensored>
+ /* NOC clients */
+ 151.216.254.0/24;
+ /* Servers */
+ 185.12.59.0/26;
+ /* Harald jumpstation */
+ <sensored>
+ /* nLogic jumpstation */
+ <sensored>
+ /* Tech colo-boks */
+ <sensored>
+ /* NOC clients */
+ 2a02:ed02:254::/64;
+ /* Servers */
+ 2a02:ed02:1337::/64;
+ }
+}
+firewall {
+ family inet {
+ filter v4-mgmt {
+ term accept-ssh {
+ from {
+ source-prefix-list {
+ v4-mgmt;
+ }
+ destination-port 22;
+ }
+ then {
+ accept;
+ }
+ }
+ term discard-ssh {
+ from {
+ destination-port 22;
+ }
+ then {
+ discard;
+ }
+ }
+ term accept-all {
+ then {
+ accept;
+ }
+ }
+ }
+ }
+ family inet6 {
+ filter v6-mgmt {
+ term accept-ssh {
+ from {
+ source-prefix-list {
+ v6-mgmt;
+ }
+ destination-port 22;
+ }
+ then {
+ accept;
+ }
+ }
+ term discard-ssh {
+ from {
+ destination-port 22;
+ }
+ then {
+ discard;
+ }
+ }
+ term accept-all {
+ then {
+
+ accept;
+ }
+ }
+ }
+ }
+}
+
+protocols {
+ sflow {
+ sample-rate {
+ ingress 10000;
+ egress 10000;
+ }
+ collector 91.209.30.12;
+ interfaces edge-ports;
+ interfaces core-ports;
+ }
+ igmp-snooping {
+ vlan all {
+ version 3;
+ immediate-leave;
+ }
+ }
+ mld-snooping {
+ vlan all {
+ version 2;
+ immediate-leave;
+ }
+ }
+ rstp {
+ bridge-priority 8k;
+ interface edge-ports {
+ edge;
+ no-root-port;
+ }
+ }
+ lldp {
+ interface ae0.0
+ }
+}
+ethernet-switching-options {
+ secure-access-port {
+ interface edge-ports {
+ no-dhcp-trusted;
+ }
+ vlan clients {
+ arp-inspection;
+ examine-dhcp;
+ examine-dhcpv6;
+ neighbor-discovery-inspection;
+ ip-source-guard;
+ ipv6-source-guard;
+ dhcp-option82;
+ dhcpv6-option18 {
+ use-option-82;
+ }
+ }
+ ipv6-source-guard-sessions {
+ max-number 128;
+ }
+ }
+ storm-control {
+ interface all;
+ }
+}
+vlans {
+ clients {
+ vlan-id <?php echo $c['traffic_vlan']; ?>;
+ }
+ mgmt {
+ vlan-id <?php echo $c['mgmt_vlan']; ?>;
+ l3-interface vlan.<?php echo $c['mgmt_vlan']; ?>;
+ }
+}
+
+routing-options {
+ rib inet.0 {
+ static {
+ route 0.0.0.0/0 {
+ next-hop <?php echo $c['mgmt_v4_gw']; ?>;
+ }
+ }
+ }
+ rib inet6.0 {
+ static {
+ route ::/0 {
+ next-hop <?php echo $c['mgmt_v6_gw']; ?>;
+ }
+ }
+ }
+}
diff --git a/fap/httpd/httpd_root/pg_connect.php b/fap/httpd/httpd_root/pg_connect.php
new file mode 100644
index 0000000..6808cb0
--- /dev/null
+++ b/fap/httpd/httpd_root/pg_connect.php
@@ -0,0 +1,6 @@
+<?php
+ if(!$dbconn = pg_connect("host=localhost dbname=fap user=fap password=<sensored>")){
+ echo 'Could not connect:' . pg_last_error();
+ exit();
+ }
+?>
diff --git a/fap/httpd/httpd_root/x.php b/fap/httpd/httpd_root/x.php
new file mode 100755
index 0000000..dda20f2
--- /dev/null
+++ b/fap/httpd/httpd_root/x.php
@@ -0,0 +1,67 @@
+<?php
+ if(isset($_GET['mode'])){
+ function log_to_file($text){
+ $out = date('c') . ' - ' . $_SERVER['REMOTE_ADDR'] . ' - ' . $text . "\n";
+ file_put_contents('../../logs/httpd.log', $out, FILE_APPEND);
+ }
+
+ if($_GET['mode'] === 'config'){
+ # LASTE NED CONFIG
+ /*
+ header('Content-Description: File Transfer');
+ header('Content-Type: application/octet-stream');
+ header('Content-Disposition: attachment; filename='.basename($file));
+ header('Content-Length: ' . filesize('../files/' . $_GET['file']));
+ */
+
+ # File containing pg_connect() with DB credentials - excluded for GIT safety
+ require 'pg_connect.php';
+
+
+ $template = 'ex2200.template'; # default template
+
+ $pieces = explode('/', $_GET['hostname']);
+ if(count($pieces) == 2){
+ $_GET['hostname'] = $pieces[0];
+ if($pieces[1] == 'secure'){
+ $template = 'ex2200_secure.template';
+ }
+ }
+
+
+ // Performing SQL query
+ $query = 'SELECT * FROM switches WHERE hostname = \'' . $_GET['hostname'] . '\'';
+ $result = pg_query($query) or die('Query failed: ' . pg_last_error());
+ if(pg_num_rows($result) == 1){
+ $c = pg_fetch_assoc($result);
+ include $template;
+ log_to_file('Served ' . $template . ' to client');
+ }else{
+ log_to_file('Hostname not found in DB');
+ header("HTTP/1.0 404 Not Found");
+ exit();
+ }
+
+ }elseif($_GET['mode'] === 'image'){
+ if(isset($_GET['file']) && is_readable('../files/' . $_GET['file'])){
+ # SEND IMAGE
+ header('Content-Description: File Transfer');
+ header('Content-Type: application/octet-stream');
+ header('Content-Disposition: attachment; filename='.basename($file));
+ header('Content-Length: ' . filesize('../files/' . $_GET['file']));
+
+ $time_start = microtime(true);
+ $bytes = readfile('../files/' . $_GET['file']);
+ $time_end = microtime(true);
+ $time = $time_end - $time_start;
+
+ log_to_file('Transferred "' . $_GET['file'] . '" in ' . round($time, 2) . 'sec (' . round(($bytes/$time)/(1024*128), 2) . 'Mbit/s)');
+ }else{
+ log_to_file('404 - File not found');
+ header("HTTP/1.1 404 Not Found");
+ exit();
+ }
+
+ }
+ }
+?>