示例#1
0
文件: server.py 项目: blanu/pyptlib
def reportEnd():
    """
        This method should be called after all transports have been launched.
        It generates output to Tor informing that all transports have been launched.
    """

    config = ServerConfig()
    config.writeMethodEnd()
示例#2
0
文件: server.py 项目: blanu/pyptlib
def reportFailure(name, message):
    """
        This method should be called to report when a transport has failed to launch.
        It generates output to Tor informing that the transport failed to launch and cannot be used.
        After all transports have been launched, the server should call reportEnd().
    """

    config = ServerConfig()
    config.writeMethodError(name, message)
示例#3
0
文件: server.py 项目: blanu/pyptlib
def reportSuccess(name, address, options):
    """
        This method should be called to report when a transport has been successfully launched.
        It generates output to Tor informing that the transport launched successfully and can be used.
        After all transports have been launched, the server should call reportEnd().
    """

    config = ServerConfig()
    config.writeMethod(name, address, options)
示例#4
0
文件: server.py 项目: blanu/pyptlib
def init(transports):
    """
        Initialize the pluggable transport by parsing the environment variables and generating output to report any errors.
        The given transports are checked against the transports enabled by Tor and a list of matching transports is returned.
        The server should then launch all of the transports in the list and report on the success or failure of those launches.
    """

    supportedTransportVersion = '1'

    try:
        config = ServerConfig()
    except EnvException:
        return []

    if config.checkManagedTransportVersion(supportedTransportVersion):
        config.writeVersion(supportedTransportVersion)
    else:
        config.writeVersionError()
        return []

    matchedTransports = []
    for transport in transports:
        if config.checkTransportEnabled(transport):
            matchedTransports.append(transport)

    return matchedTransports