__init__.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:Intranet-Penetration 作者: yuxiaokui 项目源码 文件源码
def from_url(cls, url, method='http'):
        """
        Construct a ProxyInfo from a URL (such as http_proxy env var)
        """
        url = urlparse.urlparse(url)
        username = None
        password = None
        port = None
        if '@' in url[1]:
          ident, host_port = url[1].split('@', 1)
          if ':' in ident:
            username, password = ident.split(':', 1)
          else:
            password = ident
        else:
          host_port = url[1]
        if ':' in host_port:
          host, port = host_port.split(':', 1)
        else:
          host = host_port

        if port:
            port = int(port)
        else:
            port = dict(https=443, http=80)[method]

        proxy_type = 3 # socks.PROXY_TYPE_HTTP
        return cls(
            proxy_type = proxy_type,
            proxy_host = host,
            proxy_port = port,
            proxy_user = username or None,
            proxy_pass = password or None,
        )
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号