tunnel thing
This commit is contained in:
parent
5f4af2f5ee
commit
2fffaee418
7
README
Normal file
7
README
Normal file
|
@ -0,0 +1,7 @@
|
|||
anthony service
|
||||
|
||||
federated server anthony
|
||||
|
||||
federated server alek
|
||||
|
||||
alek: client
|
1
init_query.sh
Normal file
1
init_query.sh
Normal file
|
@ -0,0 +1 @@
|
|||
curl 10.29.55.48:8000/tunnel?petname=Anthony&path=bob
|
25
server.py
25
server.py
|
@ -4,20 +4,33 @@ from urllib import parse
|
|||
from requests import post
|
||||
from inbox import Send, Fetch, inbox
|
||||
|
||||
|
||||
petname_to_pubkey = {}
|
||||
pubkey_to_server = {}
|
||||
|
||||
Q = "blah"
|
||||
|
||||
class HTTPRequestHandler(BaseHTTPRequestHandler):
|
||||
def do_GET(self):
|
||||
'''Fetch the user inbox'''
|
||||
|
||||
user = parse.parse_qs(parse.urlsplit(self.path).query)['user'][0]
|
||||
p = parse.parse_qs(parse.urlsplit(self.path).query)
|
||||
func = parse.urlsplit(self.path).path[1:]
|
||||
|
||||
self.send_response(200)
|
||||
self.send_header('Content-type', 'text/plain')
|
||||
self.end_headers()
|
||||
self.wfile.write(str(Fetch(user)).encode('utf-8'))
|
||||
|
||||
if func == "tunnel":
|
||||
if "pubkey" in p:
|
||||
Q = p["path"]
|
||||
elif "petname" in p:
|
||||
petname = petname_to_pubkey[p["pubkey"]]
|
||||
requests.get("{pubkey_to_server[petname]}/tunnel?pubkey={petname}&path={p['path']}")
|
||||
|
||||
elif func == "getinbox":
|
||||
user = p['user'][0]
|
||||
self.wfile.write(str(Fetch(user)).encode('utf-8'))
|
||||
|
||||
elif func == "queue":
|
||||
self.wfile.write(Q.encode('utf-8'))
|
||||
|
||||
|
||||
def do_POST(self):
|
||||
data = self.rfile.read(int(self.headers['Content-Length']))
|
||||
|
|
1
tunnel_client.py
Normal file
1
tunnel_client.py
Normal file
|
@ -0,0 +1 @@
|
|||
os.system('curl "10.29.55.48:8000/tunnel?dest=anthony"')
|
Loading…
Reference in a new issue