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


Python socks.PROXY_TYPE_SOCKS4属性代码示例

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


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

示例1: _get_proxy

# 需要导入模块: import socks [as 别名]
# 或者: from socks import PROXY_TYPE_SOCKS4 [as 别名]
def _get_proxy(self):

        url_dissected = url_dissector.findall(
            self.session['proxy']
        )

        if url_dissected and len(url_dissected[0]) == 3:
            protocol, host, port = url_dissected[0]
            if protocol == 'socks5':
                return (socks.PROXY_TYPE_SOCKS5, host, int(port))
            if protocol == 'socks4':
                return (socks.PROXY_TYPE_SOCKS4, host, int(port))
            if protocol.startswith('http'):
                return (socks.PROXY_TYPE_HTTP, host, int(port))

        return None, None, None 
开发者ID:epinna,项目名称:weevely3,代码行数:18,代码来源:channel.py

示例2: __init__

# 需要导入模块: import socks [as 别名]
# 或者: from socks import PROXY_TYPE_SOCKS4 [as 别名]
def __init__(self, proxy_url, username=None, password=None,
                 num_pools=10, headers=None, **connection_pool_kw):
        parsed = parse_url(proxy_url)

        if parsed.scheme == 'socks5':
            socks_version = socks.PROXY_TYPE_SOCKS5
            rdns = False
        elif parsed.scheme == 'socks5h':
            socks_version = socks.PROXY_TYPE_SOCKS5
            rdns = True
        elif parsed.scheme == 'socks4':
            socks_version = socks.PROXY_TYPE_SOCKS4
            rdns = False
        elif parsed.scheme == 'socks4a':
            socks_version = socks.PROXY_TYPE_SOCKS4
            rdns = True
        else:
            raise ValueError(
                "Unable to determine SOCKS version from %s" % proxy_url
            )

        self.proxy_url = proxy_url

        socks_options = {
            'socks_version': socks_version,
            'proxy_host': parsed.host,
            'proxy_port': parsed.port,
            'username': username,
            'password': password,
            'rdns': rdns
        }
        connection_pool_kw['_socks_options'] = socks_options

        super(SOCKSProxyManager, self).__init__(
            num_pools, headers, **connection_pool_kw
        )

        self.pool_classes_by_scheme = SOCKSProxyManager.pool_classes_by_scheme 
开发者ID:getavalon,项目名称:core,代码行数:40,代码来源:socks.py

示例3: __init__

# 需要导入模块: import socks [as 别名]
# 或者: from socks import PROXY_TYPE_SOCKS4 [as 别名]
def __init__(self, proxy_url, username=None, password=None,
                 num_pools=10, headers=None, **connection_pool_kw):
        parsed = parse_url(proxy_url)

        if parsed.scheme == 'socks5':
            socks_version = socks.PROXY_TYPE_SOCKS5
        elif parsed.scheme == 'socks4':
            socks_version = socks.PROXY_TYPE_SOCKS4
        else:
            raise ValueError(
                "Unable to determine SOCKS version from %s" % proxy_url
            )

        self.proxy_url = proxy_url

        socks_options = {
            'socks_version': socks_version,
            'proxy_host': parsed.host,
            'proxy_port': parsed.port,
            'username': username,
            'password': password,
        }
        connection_pool_kw['_socks_options'] = socks_options

        super(SOCKSProxyManager, self).__init__(
            num_pools, headers, **connection_pool_kw
        )

        self.pool_classes_by_scheme = SOCKSProxyManager.pool_classes_by_scheme 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:31,代码来源:socks.py

示例4: __init__

# 需要导入模块: import socks [as 别名]
# 或者: from socks import PROXY_TYPE_SOCKS4 [as 别名]
def __init__(self, _=None):
        """Build self._urllib_opener"""

        proxy = super().__str__()

        if proxy == "None":
            self._urllib_opener = build_opener()
            return

        components = list(re.match(self._match_regexp, proxy).groups())
        self.scheme, self.host, self.port = components
        self.components = components

        if self.scheme == "socks4":
            socks4_handler = SocksiPyHandler(socks.PROXY_TYPE_SOCKS4,
                                             self.host,
                                             int(self.port))
            self._urllib_opener = build_opener(socks4_handler)
        elif self.scheme == "socks5":
            socks5_handler = SocksiPyHandler(socks.PROXY_TYPE_SOCKS5,
                                             self.host,
                                             int(self.port))
            self._urllib_opener = build_opener(socks5_handler)
        else:
            proxy_handler = ProxyHandler({'http': proxy, 'https': proxy})
            self._urllib_opener = build_opener(proxy_handler) 
开发者ID:nil0x42,项目名称:phpsploit,代码行数:28,代码来源:Proxy.py

示例5: ensure_connected

# 需要导入模块: import socks [as 别名]
# 或者: from socks import PROXY_TYPE_SOCKS4 [as 别名]
def ensure_connected(self, connection, proto, host):
		if connection != None and connection.sock != None:
			return connection, False

		if proto == 'https': connector = httplib.HTTPSConnection
		else: connector = httplib.HTTPConnection

		if not self.options.proxy:
			return connector(host, strict=True), True

		host, port = host.split(':')

		proxy_proto, user, pwd, proxy_host = self.options.proxy[:4]
		proxy_port = 9050
		proxy_host = proxy_host.split(':')
		if len(proxy_host) > 1:
			proxy_port = int(proxy_host[1]); proxy_host = proxy_host[0]

		connection = connector(host, strict=True)
		connection.sock = socks.socksocket()

		proxy_type = socks.PROXY_TYPE_SOCKS5
		if proxy_proto == 'http':
			proxy_type = socks.PROXY_TYPE_HTTP
		elif proxy_proto == 'socks4':
			proxy_type = socks.PROXY_TYPE_SOCKS4

		connection.sock.setproxy(proxy_type, proxy_host, proxy_port, True, user, pwd)
		try:
			connection.sock.connect((host, int(port)))
		except socks.Socks5AuthError:
			say_exception('Proxy error:')
			self.stop()
		return connection, True 
开发者ID:theRealTacoTime,项目名称:poclbm,代码行数:36,代码来源:GetworkSource.py


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