当前位置: 首页>>代码示例>>Python>>正文


Python socks.HTTP属性代码示例

本文整理汇总了Python中socks.HTTP属性的典型用法代码示例。如果您正苦于以下问题:Python socks.HTTP属性的具体用法?Python socks.HTTP怎么用?Python socks.HTTP使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在socks的用法示例。


在下文中一共展示了socks.HTTP属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: update_config

# 需要导入模块: import socks [as 别名]
# 或者: from socks import HTTP [as 别名]
def update_config(self):
        if int(self.config.PROXY_ENABLE):

            if self.config.PROXY_TYPE == "HTTP":
                proxy_type = socks.HTTP
            elif self.config.PROXY_TYPE == "SOCKS4":
                proxy_type = socks.SOCKS4
            elif self.config.PROXY_TYPE == "SOCKS5":
                proxy_type = socks.SOCKS5
            else:
                self.logger.error("proxy type %s unknown, disable proxy", self.config.PROXY_TYPE)
                raise Exception()

            socks.set_default_proxy(proxy_type, self.config.PROXY_HOST, self.config.PROXY_PORT,
                                    self.config.PROXY_USER,
                                    self.config.PROXY_PASSWD) 
开发者ID:miketwes,项目名称:XX-Net-mini,代码行数:18,代码来源:connect_creator.py

示例2: _tunnel

# 需要导入模块: import socks [as 别名]
# 或者: from socks import HTTP [as 别名]
def _tunnel(sock, host, port, auth):
    debug("Connecting proxy...")
    connect_header = "CONNECT %s:%d HTTP/1.0\r\n" % (host, port)
    # TODO: support digest auth.
    if auth and auth[0]:
        auth_str = auth[0]
        if auth[1]:
            auth_str += ":" + auth[1]
        encoded_str = base64encode(auth_str.encode()).strip().decode()
        connect_header += "Proxy-Authorization: Basic %s\r\n" % encoded_str
    connect_header += "\r\n"
    dump("request header", connect_header)

    send(sock, connect_header)

    try:
        status, resp_headers, status_message = read_headers(sock)
    except Exception as e:
        raise WebSocketProxyException(str(e))

    if status != 200:
        raise WebSocketProxyException(
            "failed CONNECT via proxy status: %r" % status)

    return sock 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:27,代码来源:_http.py

示例3: test_proxy_options

# 需要导入模块: import socks [as 别名]
# 或者: from socks import HTTP [as 别名]
def test_proxy_options(
        self,
        option_test_required_patching,
        client_create_method,
        create_method_args,
        mock_mqtt_pipeline_init,
        mock_http_pipeline_init,
    ):
        proxy_options = ProxyOptions(proxy_type=socks.HTTP, proxy_addr="127.0.0.1", proxy_port=8888)
        client_create_method(*create_method_args, proxy_options=proxy_options)

        # Get configuration object, and ensure it was used for both protocol pipelines
        assert mock_mqtt_pipeline_init.call_count == 1
        config = mock_mqtt_pipeline_init.call_args[0][0]
        assert isinstance(config, IoTHubPipelineConfig)
        assert config == mock_http_pipeline_init.call_args[0][0]

        assert config.proxy_options is proxy_options 
开发者ID:Azure,项目名称:azure-iot-sdk-python,代码行数:20,代码来源:shared_client_tests.py

示例4: proxy_connect

# 需要导入模块: import socks [as 别名]
# 或者: from socks import HTTP [as 别名]
def proxy_connect(args):
    """
    Connect to specified proxy
    """
    if args.proxy_host:
        # Setup proxy by monkeypatching the standard lib
        if args.proxy_type.lower() == "socks5" or not args.proxy_type:
            socks.set_default_proxy(
                socks.SOCKS5, args.proxy_host,
                int(args.proxy_port))
        elif args.proxy_type.lower() == "http":
            socks.set_default_proxy(
                socks.HTTP, args.proxy_host,
                int(args.proxy_port))
        elif args.proxy_type.lower() == "socks4":
            socks.set_default_proxy(
                socks.SOCKS4, args.proxy_host,
                int(args.proxy_port))
        else:
            printNicely(
                magenta('Sorry, wrong proxy type specified! Aborting...'))
            sys.exit()
        socket.socket = socks.socksocket 
开发者ID:orakaro,项目名称:rainbowstream,代码行数:25,代码来源:rainbow.py

示例5: _tunnel

# 需要导入模块: import socks [as 别名]
# 或者: from socks import HTTP [as 别名]
def _tunnel(sock, host, port, auth):
    debug("Connecting proxy...")
    connect_header = "CONNECT %s:%d HTTP/1.0\r\n" % (host, port)
    # TODO: support digest auth.
    if auth and auth[0]:
        auth_str = auth[0]
        if auth[1]:
            auth_str += ":" + auth[1]
        encoded_str = base64encode(auth_str.encode()).strip().decode().replace('\n', '')
        connect_header += "Proxy-Authorization: Basic %s\r\n" % encoded_str
    connect_header += "\r\n"
    dump("request header", connect_header)

    send(sock, connect_header)

    try:
        status, resp_headers, status_message = read_headers(sock)
    except Exception as e:
        raise WebSocketProxyException(str(e))

    if status != 200:
        raise WebSocketProxyException(
            "failed CONNECT via proxy status: %r" % status)

    return sock 
开发者ID:Tautulli,项目名称:Tautulli,代码行数:27,代码来源:_http.py

示例6: load_proxy_config

# 需要导入模块: import socks [as 别名]
# 或者: from socks import HTTP [as 别名]
def load_proxy_config():
    global default_socket
    if g.config.PROXY_ENABLE:

        if g.config.PROXY_TYPE == "HTTP":
            proxy_type = socks.HTTP
        elif g.config.PROXY_TYPE == "SOCKS4":
            proxy_type = socks.SOCKS4
        elif g.config.PROXY_TYPE == "SOCKS5":
            proxy_type = socks.SOCKS5
        else:
            xlog.error("proxy type %s unknown, disable proxy", g.config.PROXY_TYPE)
            raise Exception()

        socks.set_default_proxy(proxy_type, g.config.PROXY_HOST, g.config.PROXY_PORT,
                                g.config.PROXY_USER, g.config.PROXY_PASSWD) 
开发者ID:miketwes,项目名称:XX-Net-mini,代码行数:18,代码来源:connect_manager.py

示例7: raw_HTTP_request

# 需要导入模块: import socks [as 别名]
# 或者: from socks import HTTP [as 别名]
def raw_HTTP_request():
    req = "GET /ip HTTP/1.1\r\n"
    req += "Host: ifconfig.me\r\n"
    req += "User-Agent: Mozilla\r\n"
    req += "Accept: text/html\r\n"
    req += "\r\n"
    return req.encode() 
开发者ID:nil0x42,项目名称:phpsploit,代码行数:9,代码来源:sockstest.py

示例8: socket_HTTP_test

# 需要导入模块: import socks [as 别名]
# 或者: from socks import HTTP [as 别名]
def socket_HTTP_test():
    s = socks.socksocket()
    s.set_proxy(socks.HTTP, "127.0.0.1", 8081)
    s.connect(("ifconfig.me", 80))
    s.sendall(raw_HTTP_request())
    status = s.recv(2048).splitlines()[0]
    assert status.startswith(b"HTTP/1.1 200") 
开发者ID:nil0x42,项目名称:phpsploit,代码行数:9,代码来源:sockstest.py

示例9: socket_SOCKS4_test

# 需要导入模块: import socks [as 别名]
# 或者: from socks import HTTP [as 别名]
def socket_SOCKS4_test():
    s = socks.socksocket()
    s.set_proxy(socks.SOCKS4, "127.0.0.1", 1080)
    s.connect(("ifconfig.me", 80))
    s.sendall(raw_HTTP_request())
    status = s.recv(2048).splitlines()[0]
    assert status.startswith(b"HTTP/1.1 200") 
开发者ID:nil0x42,项目名称:phpsploit,代码行数:9,代码来源:sockstest.py

示例10: socket_SOCKS5_test

# 需要导入模块: import socks [as 别名]
# 或者: from socks import HTTP [as 别名]
def socket_SOCKS5_test():
    s = socks.socksocket()
    s.set_proxy(socks.SOCKS5, "127.0.0.1", 1081)
    s.connect(("ifconfig.me", 80))
    s.sendall(raw_HTTP_request())
    status = s.recv(2048).splitlines()[0]
    assert status.startswith(b"HTTP/1.1 200") 
开发者ID:nil0x42,项目名称:phpsploit,代码行数:9,代码来源:sockstest.py

示例11: socket_SOCKS5_auth_test

# 需要导入模块: import socks [as 别名]
# 或者: from socks import HTTP [as 别名]
def socket_SOCKS5_auth_test():
    # TODO: add support for this test. Will need a better SOCKS5 server.
    s = socks.socksocket()
    s.set_proxy(socks.SOCKS5, "127.0.0.1", 1081, username="a", password="b")
    s.connect(("ifconfig.me", 80))
    s.sendall(raw_HTTP_request())
    status = s.recv(2048).splitlines()[0]
    assert status.startswith(b"HTTP/1.1 200") 
开发者ID:nil0x42,项目名称:phpsploit,代码行数:10,代码来源:sockstest.py

示例12: socket_SOCKS4_IP_test

# 需要导入模块: import socks [as 别名]
# 或者: from socks import HTTP [as 别名]
def socket_SOCKS4_IP_test():
    s = socks.socksocket()
    s.set_proxy(socks.SOCKS4, "127.0.0.1", 1080)
    s.connect(("133.242.129.236", 80))
    s.sendall(raw_HTTP_request())
    status = s.recv(2048).splitlines()[0]
    assert status.startswith(b"HTTP/1.1 200") 
开发者ID:nil0x42,项目名称:phpsploit,代码行数:9,代码来源:sockstest.py

示例13: socket_SOCKS5_IP_test

# 需要导入模块: import socks [as 别名]
# 或者: from socks import HTTP [as 别名]
def socket_SOCKS5_IP_test():
    s = socks.socksocket()
    s.set_proxy(socks.SOCKS5, "127.0.0.1", 1081)
    s.connect(("133.242.129.236", 80))
    s.sendall(raw_HTTP_request())
    status = s.recv(2048).splitlines()[0]
    assert status.startswith(b"HTTP/1.1 200") 
开发者ID:nil0x42,项目名称:phpsploit,代码行数:9,代码来源:sockstest.py

示例14: urllib2_HTTP_test

# 需要导入模块: import socks [as 别名]
# 或者: from socks import HTTP [as 别名]
def urllib2_HTTP_test():
    socks.set_default_proxy(socks.HTTP, "127.0.0.1", 8081)
    socks.wrap_module(urllib2)
    status = urllib2.urlopen("http://ifconfig.me/ip").getcode()
    assert status == 200 
开发者ID:nil0x42,项目名称:phpsploit,代码行数:7,代码来源:sockstest.py

示例15: urllib2_handler_HTTP_test

# 需要导入模块: import socks [as 别名]
# 或者: from socks import HTTP [as 别名]
def urllib2_handler_HTTP_test():
    opener = urllib2.build_opener(sockshandler.SocksiPyHandler(socks.HTTP, "127.0.0.1", 8081))
    status = opener.open("http://ifconfig.me/ip").getcode()
    assert status == 200 
开发者ID:nil0x42,项目名称:phpsploit,代码行数:6,代码来源:sockstest.py


注:本文中的socks.HTTP属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。