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


Python socks.ProxyConnectionError方法代码示例

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


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

示例1: SOCKS5_connect_timeout_test

# 需要导入模块: import socks [as 别名]
# 或者: from socks import ProxyConnectionError [as 别名]
def SOCKS5_connect_timeout_test():
    s = socks.socksocket()
    s.settimeout(0.0001)
    s.set_proxy(socks.SOCKS5, "8.8.8.8", 80)
    try:
        s.connect(("ifconfig.me", 80))
    except socks.ProxyConnectionError as e:
        assert str(e.socket_err) == "timed out" 
开发者ID:nil0x42,项目名称:phpsploit,代码行数:10,代码来源:sockstest.py

示例2: _open_socket

# 需要导入模块: import socks [as 别名]
# 或者: from socks import ProxyConnectionError [as 别名]
def _open_socket(addrinfo_list, sockopt, timeout):
    err = None
    for addrinfo in addrinfo_list:
        family, socktype, proto = addrinfo[:3]
        sock = socket.socket(family, socktype, proto)
        sock.settimeout(timeout)
        for opts in DEFAULT_SOCKET_OPTION:
            sock.setsockopt(*opts)
        for opts in sockopt:
            sock.setsockopt(*opts)

        address = addrinfo[4]
        try:
            sock.connect(address)
            err = None
        except ProxyConnectionError as error:
            err = WebSocketProxyException(str(error))
            err.remote_ip = str(address[0])
            continue
        except socket.error as error:
            error.remote_ip = str(address[0])
            try:
                eConnRefused = (errno.ECONNREFUSED, errno.WSAECONNREFUSED)
            except:
                eConnRefused = (errno.ECONNREFUSED, )
            if error.errno in eConnRefused:
                err = error
                continue
            else:
                raise error
        else:
            break
    else:
        raise err

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

示例3: _open_socket

# 需要导入模块: import socks [as 别名]
# 或者: from socks import ProxyConnectionError [as 别名]
def _open_socket(addrinfo_list, sockopt, timeout):
    err = None
    for addrinfo in addrinfo_list:
        family, socktype, proto = addrinfo[:3]
        sock = socket.socket(family, socktype, proto)
        sock.settimeout(timeout)
        for opts in DEFAULT_SOCKET_OPTION:
            sock.setsockopt(*opts)
        for opts in sockopt:
            sock.setsockopt(*opts)

        address = addrinfo[4]
        err = None
        while not err:
            try:
                sock.connect(address)
            except ProxyConnectionError as error:
                err = WebSocketProxyException(str(error))
                err.remote_ip = str(address[0])
                continue
            except socket.error as error:
                error.remote_ip = str(address[0])
                try:
                    eConnRefused = (errno.ECONNREFUSED, errno.WSAECONNREFUSED)
                except:
                    eConnRefused = (errno.ECONNREFUSED, )
                if error.errno == errno.EINTR:
                    continue
                elif error.errno in eConnRefused:
                    err = error
                    continue
                else:
                    raise error
            else:
                break
        else:
            continue
        break
    else:
        if err:
            raise err

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

示例4: fly

# 需要导入模块: import socks [as 别名]
# 或者: from socks import ProxyConnectionError [as 别名]
def fly():
    """
    Main function
    """
    # Initial
    args = parse_arguments()
    try:
        proxy_connect(args)
        init(args)
    # Twitter API connection problem
    except TwitterHTTPError as e:
        printNicely('')
        printNicely(
            magenta('We have connection problem with twitter REST API right now :('))
        detail_twitter_error(e)
        save_history()
        sys.exit()
    # Proxy connection problem
    except (socks.ProxyConnectionError, URLError):
        printNicely(
            magenta('There seems to be a connection problem.'))
        printNicely(
            magenta('You might want to check your proxy settings (host, port and type)!'))
        save_history()
        sys.exit()

    # Spawn stream thread
    target = args.stream.split()[0]
    if target == 'mine':
        spawn_personal_stream(args)
    else:
        try:
            stuff = args.stream.split()[1]
        except:
            stuff = None
        spawn_dict = {
            'public': spawn_public_stream,
            'list': spawn_list_stream,
        }
        spawn_dict.get(target)(args, stuff)

    # Start listen process
    time.sleep(0.5)
    g['reset'] = True
    g['prefix'] = True
    listen() 
开发者ID:orakaro,项目名称:rainbowstream,代码行数:48,代码来源:rainbow.py


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