-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpHOME.py
More file actions
50 lines (43 loc) · 1.76 KB
/
pHOME.py
File metadata and controls
50 lines (43 loc) · 1.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from BaseHTTPServer import HTTPServer
from SimpleHTTPServer import SimpleHTTPRequestHandler
class HTTPHandler (SimpleHTTPRequestHandler):
server_version = "pHOME-for-pNET/HTTP/0.1"
def do_GET(self):
if(self.path[0:4] == "/new" && self.client_address[0:-3]=='10.0.0.'):
self.send_response(200, 'OK')
self.end_headers()
self.wfile.write("0.5")
elif(self.path[0:4] == "/iam"):
self.send_response(200, 'OK')
self.end_headers()
self.wfile.write("saved")
else:
if(self.headers["host"] == "node.pnet"):
self.send_response(200, 'OK')
self.send_header('Content-type', 'text/html')
self.end_headers()
self.wfile.write("<html><head><title>pNET .:HOME:.</title></head><body><h1>pNET</h1><small>The citizen network</small></body></html>")
elif(self.headers["host"][-4] == ".pnet"):
self.send_response(300, 'Multiple Choices')
self.send_header('Content-type', 'text/html')
self.end_headers()
self.wfile.write("<html><head><title>pNET .:DNS RESOLVE:.</title></head><body>")
self.wfile.write("<h1>'" + self.headers["host"] + "'</h1><ul>")
self.wfile.write('<li><a href="B8E8562ED536.mac.pnet">B8E8562ED536.mac.pnet</a> (10.0.38.254) <i>no description</i></li>')
self.wfile.write('<li><a href="BAE856E26B00.mac.pnet">BAE856E26B00.mac.pnet</a> (10.0.15.254) <i>Yolo</i></li>')
self.wfile.write("</ul></body></html>")
else:
self.send_response(200, 'OK')
self.end_headers()
self.wfile.write("parents{'0.1'}\nchilds{'0.3','0.4'}")
try:
httpd = HTTPServer(('', 80), HTTPHandler)
print "[pNET] pHOME : started"
httpd.serve_forever()
except KeyboardInterrupt:
print "[pNET] pHOME : ended by ^C"
except Exception, error:
print "[pNET] pHOME error: " + str(error)
sys.exit()