Пример #1
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()
Пример #2
0
#!/usr/bin/python
# -*- coding: utf-8 -*-

""" This is an example server which shows how to call the pyptlib.easy high-level API. """

from pyptlib.easy.server import init, reportSuccess, reportFailure, reportEnd


class TransportLaunchException(Exception):

    pass


def launchServer(self, name, port):
    if name != "dummy":
        raise TransportLaunchException("Tried to launch unsupported transport %s" % name)


if __name__ == "__main__":
    supportedTransports = ["dummy", "rot13"]

    matchedTransports = init(supportedTransports)
    for transport in matchedTransports:
        try:
            launchServer(transport, 8182)
            reportSuccess(transport, ("127.0.0.1", 8182), None)
        except TransportLaunchException:
            reportFailure(transport, "Failed to launch")
    reportEnd()