Browse Source

next

master
gsd 4 weeks ago
parent
commit
ad56780fea
  1. 18
      server.py

18
server.py

@ -22,16 +22,16 @@ class Collector:
if not request.headers.get("Secret", ""): if not request.headers.get("Secret", ""):
print("secret empty") print("secret empty")
return Response(status_code=400) return Response(status_code=400)
if not request.headers.get("Host", ""): if not request.headers.get("Host", "") and not request.headers.get("Host-replace", ""):
print("host empty") print("host empty")
return Response(status_code=400) return Response(status_code=400)
if not request.headers.get("Secret", "") in self.secrets: if not request.headers.get("Secret", "") in self.secrets:
return Response(status_code=400) return Response(status_code=400)
if not request.headers.get("Host", "").split(":")[0] in self.hosts: host = request.headers.get("Host-replace", "") or request.headers.get("Host", "")
print(request.headers.get("Host", "")) host = host.split(":")[0]
print(request.headers) if not host in self.hosts:
return Response(status_code=400) return Response(status_code=400)
return None return None
@ -51,8 +51,11 @@ class Collector:
if response: if response:
return response return response
if request.headers.get("Host", "").split(":")[0] in self.store and self.store[request.headers.get("Host", "").split(":")[0]]['data']: host = request.headers.get("Host-replace", "") or request.headers.get("Host", "")
return Response(content=self.store[request.headers.get("Host", "").split(":")[0]]['data'], status_code=200) host = host.split(":")[0]
if host in self.store and self.store[host]['data']:
return Response(content=self.store[host]['data'], status_code=200)
else: else:
return Response(status_code=404) return Response(status_code=404)
@ -62,7 +65,8 @@ class Collector:
if response: if response:
return response return response
host = request.headers.get("Host", "").split(":")[0] host = request.headers.get("Host-replace", "") or request.headers.get("Host", "")
host = host.split(":")[0]
self.store[host] = { self.store[host] = {
"data":await request.body(), "data":await request.body(),

Loading…
Cancel
Save