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