Exemple #1
0
class ManagedServer:

    def __init__(self):
        self.handler = ProxyHandler(*getORPort())

        self.supportedTransports = {
            'dummy': DummyServer,
            'rot13': Rot13Server,
            'dust': DustServer,
            'obfs3': Obfs3Server,
            }

        matchedTransports = init(self.supportedTransports)
        for transport in matchedTransports:
            try:
                self.launchServer(transport, 1051)
                reportSuccess(transport, ('127.0.0.1', 1051), None)
            except TransportLaunchException:
                reportFailure(transport, 'Failed to launch')
        reportEnd()

        eventloop.run()

    def launchServer(self, name, port):
        if not name in self.supportedTransports:
            raise TransportLaunchException('Tried to launch unsupported transport %s'
                     % name)

        serverClass = self.supportedTransports[name]
        self.handler.setTransport(serverClass)
        add_service(Service(self.handler.handle, port=port))
Exemple #2
0
    def __init__(self):
        self.handler = ProxyHandler(*getORPort())

        self.supportedTransports = {
            'dummy': DummyServer,
            'rot13': Rot13Server,
            'dust': DustServer,
            'obfs3': Obfs3Server,
            }

        matchedTransports = init(self.supportedTransports)
        for transport in matchedTransports:
            try:
                self.launchServer(transport, 1051)
                reportSuccess(transport, ('127.0.0.1', 1051), None)
            except TransportLaunchException:
                reportFailure(transport, 'Failed to launch')
        reportEnd()

        eventloop.run()