コード例 #1
0
ファイル: tylisten.py プロジェクト: zhaozw/hall37
def listenHttp(httpoprt):
    factory = HTTPFactory()
    def _dummy(*args, **argd):
        pass 
    factory.log = _dummy
    factory.protocol = TyHttpChannel
    reactor.listenTCP(httpoprt, factory)
コード例 #2
0
ファイル: main.py プロジェクト: gil/pac4cli
def start_server(port, reactor):
    factory = HTTPFactory()
    factory.protocol = proxy.Proxy
    factory.protocol.requestFactory = WPADProxyRequest

    yield reactor.listenTCP(port, factory, interface="127.0.0.1")
    
    servicemanager.notify_ready();
コード例 #3
0
def start_server(port, reactor):
    factory = HTTPFactory()
    factory.protocol = proxy.Proxy
    factory.protocol.requestFactory = WPADProxyRequest

    yield reactor.listenTCP(port, factory, interface="127.0.0.1")

    systemd.daemon.notify(systemd.daemon.Notification.READY)
コード例 #4
0
ファイル: tylisten.py プロジェクト: zhaozw/hall37
def listenHttp(httpoprt):
    factory = HTTPFactory()

    def _dummy(*args, **argd):
        pass

    factory.log = _dummy
    factory.protocol = TyHttpChannel
    reactor.listenTCP(httpoprt, factory)
コード例 #5
0
ファイル: main.py プロジェクト: projectarkc/arkc-server
def start_proxy(port):
    """Start the internal HTTP proxy server.

    The proxy, which runs locally, serves as a middleware,
    i.e. the client handler forwards clients' requests to the proxy,
    and the proxy is reponsible for communicating with the target server.

    It is suggested that an external HTTP proxy is specified
    in place of the internal one,
    for performance and stability considerations.
    See command line arguments for detailed information.
    """
    factory = HTTPFactory()
    factory.protocol = ConnectProxy
    reactor.listenTCP(port, factory, interface="127.0.0.1")
コード例 #6
0
ファイル: main.py プロジェクト: projectarkc/arkc-server
def start_proxy(port):
    """Start the internal HTTP proxy server.

    The proxy, which runs locally, serves as a middleware,
    i.e. the client handler forwards clients' requests to the proxy,
    and the proxy is reponsible for communicating with the target server.

    It is suggested that an external HTTP proxy is specified
    in place of the internal one,
    for performance and stability considerations.
    See command line arguments for detailed information.
    """
    factory = HTTPFactory()
    factory.protocol = ConnectProxy
    reactor.listenTCP(port, factory, interface="127.0.0.1")
コード例 #7
0
def start_server(interface, port, reactor):
    factory = HTTPFactory()
    factory.protocol = proxy.Proxy
    factory.protocol.requestFactory = WPADProxyRequest

    interface_ips = resolve(interface)
    print(interface_ips)
    for interface_ip in interface_ips:
        logger.info("Binding to interface: '%s'" % interface_ip)
        try:
            yield reactor.listenTCP(port, factory, interface=interface_ip)
        except OSError as e:
            # Most likely the most famous reason we will see this log for,
            # is that we are trying to bind to an IPv6 interface on a
            # system that has the IPv6 stack disabled.
            logger.error("Failed to bind to interface '%s'" % interface_ip)
            continue

    servicemanager.notify_ready()
コード例 #8
0
ファイル: http_proxy.py プロジェクト: uees/networktunnel
    def clientConnectionFailed(self, connector, reason):
        self.request.fail("Gateway Error", str(reason))


if __name__ == '__main__':
    _log.startLogging(sys.stdout)

    ap = argparse.ArgumentParser()
    ap.add_argument('port', default=8090, nargs='?', type=int)
    ap.add_argument('--ssl-cert', type=str)
    ap.add_argument('--ssl-key', type=str)
    ns = ap.parse_args()

    factory = HTTPFactory()
    factory.protocol = ConnectProxy

    if ns.ssl_key and not ns.ssl_cert:
        log.info("--ssl-key must be used with --ssl-cert")
        sys.exit(1)
    if ns.ssl_cert:
        with open(ns.ssl_cert, 'rb') as fp:
            ssl_cert = fp.read()
        if ns.ssl_key:
            from OpenSSL import crypto
            with open(ns.ssl_key, 'rb') as fp:
                ssl_key = fp.read()
            certificate = ssl.PrivateCertificate.load(
                ssl_cert, ssl.KeyPair.load(ssl_key, crypto.FILETYPE_PEM),
                crypto.FILETYPE_PEM)
        else:
コード例 #9
0
ファイル: http.py プロジェクト: xeddmc/i2p-tools
def Proxy(createEndpoint, **kwargs):
    factory = HTTPFactory()
    factory.protocol = _Proxy
    factory.protocol.createEndpoint = createEndpoint
    return factory
コード例 #10
0
All requests will be rewritten to https.""")
    parser.add_argument('-c',
                        '--cert',
                        dest="cert",
                        type=str,
                        required=True,
                        help="The certificate to use in pem format.")
    parser.add_argument('-k',
                        '--key',
                        dest="key",
                        type=str,
                        required=True,
                        help="The private key to use in pem format.")
    parser.add_argument(
        '-p',
        '--port',
        dest='port',
        type=int,
        default=8080,
        help="The port the HTTP proxy listens on (default: 8080).")
    args = parser.parse_args()

    CERTFILE = args.cert
    KEYFILE = args.key

    httpFactory = HTTPFactory()
    httpFactory.protocol = HTTPSClientCertProxyChannel
    reactor.listenTCP(args.port, httpFactory)
    print "now starting..."
    reactor.run()
コード例 #11
0
ファイル: http.py プロジェクト: majestrate/i2p-tools
def Proxy(createEndpoint, **kwargs):
    factory = HTTPFactory()
    factory.protocol = _Proxy
    factory.protocol.createEndpoint = createEndpoint
    return factory
コード例 #12
0
class HTTPSClientCertProxyChannel(HTTPChannel):

    requestFactory = ClientCertRequest


if __name__ == "__main__":

    import argparse

    parser = argparse.ArgumentParser(description="""HTTP proxy that uses a given client certificate to authenticate all proxied
requests with the server.
Notice, that all requests have to be http, even if the target is https.
All requests will be rewritten to https.""")
    parser.add_argument('-c', '--cert', dest="cert", type=str, required=True,
                        help="The certificate to use in pem format.")
    parser.add_argument('-k', '--key', dest="key", type=str, required=True,
                        help="The private key to use in pem format.")
    parser.add_argument('-p', '--port', dest='port', type=int, default=8080,
                        help="The port the HTTP proxy listens on (default: 8080).")
    args = parser.parse_args()

    CERTFILE = args.cert
    KEYFILE = args.key

    httpFactory = HTTPFactory()
    httpFactory.protocol = HTTPSClientCertProxyChannel
    reactor.listenTCP(args.port, httpFactory)
    print "now starting..."
    reactor.run()