mirror of https://github.com/n1nj4sec/pupy.git
Simplify if
This commit is contained in:
parent
2b79c18dbf
commit
7fdfb0ce92
|
@ -17,6 +17,7 @@ class Circuit(object):
|
|||
self.upstream=stream.upstream
|
||||
self.stream=stream
|
||||
self.transport=transport
|
||||
|
||||
def close(self):
|
||||
self.transport.on_close()
|
||||
self.stream.close()
|
||||
|
@ -33,7 +34,13 @@ class BasePupyTransport(object):
|
|||
self.downstream=stream.downstream
|
||||
self.upstream=stream.upstream
|
||||
self.stream=stream
|
||||
self.circuit=Circuit(self.stream, self, downstream=self.downstream, upstream=self.upstream)
|
||||
|
||||
self.circuit = Circuit(
|
||||
self.stream,
|
||||
self,
|
||||
downstream=self.downstream,
|
||||
upstream=self.upstream)
|
||||
|
||||
self.cookie=None
|
||||
self.closed=False
|
||||
|
||||
|
@ -174,22 +181,25 @@ class TransportWrapper(BasePupyTransport):
|
|||
super(TransportWrapper, self).close()
|
||||
|
||||
def downstream_recv(self, data, idx=0):
|
||||
if not len(data):
|
||||
return
|
||||
|
||||
if idx > len(self.chain) - 1:
|
||||
if len(data):
|
||||
data.write_to(self.upstream)
|
||||
else:
|
||||
if len(data):
|
||||
try:
|
||||
self.chain[idx].downstream_recv(data)
|
||||
except ReleaseChainedTransport:
|
||||
self.chain = self.chain[:idx] + self.chain[idx+1:]
|
||||
del self.chain[idx]
|
||||
self._setup_callbacks()
|
||||
|
||||
def upstream_recv(self, data, idx=None):
|
||||
if not len(data):
|
||||
return
|
||||
|
||||
if idx is None:
|
||||
idx = len(self.chain) - 1
|
||||
|
||||
if len(data):
|
||||
if idx < 0:
|
||||
data.write_to(self.downstream)
|
||||
else:
|
||||
|
|
Loading…
Reference in New Issue