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)
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):

View File

@ -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": {},