Python socks 模块,PROXY_TYPE_HTTP 实例源码

我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用socks.PROXY_TYPE_HTTP

项目:httplib2    作者:httplib2    | 项目源码 | 文件源码
def __init__(self, proxy_type, proxy_host, proxy_port, proxy_rdns=True, proxy_user=None, proxy_pass=None, proxy_headers=None):
      """
        Args:
          proxy_type: The type of proxy server.  This must be set to one of
          socks.PROXY_TYPE_XXX constants.  For example:

            p = ProxyInfo(proxy_type=socks.PROXY_TYPE_HTTP,
              proxy_host='localhost', proxy_port=8000)

          proxy_host: The hostname or IP address of the proxy server.

          proxy_port: The port that the proxy server is running on.

          proxy_rdns: If True (default), DNS queries will not be performed
          locally, and instead, handed to the proxy to resolve.  This is useful
          if the network does not allow resolution of non-local names.  In
          httplib2 0.9 and earlier, this defaulted to False.

          proxy_user: The username used to authenticate with the proxy server.

          proxy_pass: The password used to authenticate with the proxy server.

          proxy_headers: Additional or modified headers for the proxy connect request.
      """
      self.proxy_type, self.proxy_host, self.proxy_port, self.proxy_rdns, self.proxy_user, self.proxy_pass, self.proxy_headers = proxy_type, proxy_host, proxy_port, proxy_rdns, proxy_user, proxy_pass, proxy_headers
项目:Fetch    作者:bourdakos1    | 项目源码 | 文件源码
def __init__(self, proxy_type, proxy_host, proxy_port, proxy_rdns=True, proxy_user=None, proxy_pass=None):
      """
        Args:
          proxy_type: The type of proxy server.  This must be set to one of
          socks.PROXY_TYPE_XXX constants.  For example:

            p = ProxyInfo(proxy_type=socks.PROXY_TYPE_HTTP,
              proxy_host='localhost', proxy_port=8000)

          proxy_host: The hostname or IP address of the proxy server.

          proxy_port: The port that the proxy server is running on.

          proxy_rdns: If True (default), DNS queries will not be performed
          locally, and instead, handed to the proxy to resolve.  This is useful
          if the network does not allow resolution of non-local names.  In
          httplib2 0.9 and earlier, this defaulted to False.

          proxy_user: The username used to authenticate with the proxy server.

          proxy_pass: The password used to authenticate with the proxy server.
      """
      self.proxy_type, self.proxy_host, self.proxy_port, self.proxy_rdns, self.proxy_user, self.proxy_pass = proxy_type, proxy_host, proxy_port, proxy_rdns, proxy_user, proxy_pass
项目:weevely3-stealth    作者:edibledinos    | 项目源码 | 文件源码
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
项目:catchup4kodi    作者:catchup4kodi    | 项目源码 | 文件源码
def get_proxy():
    proxy_server = None
    proxy_type_id = 0
    proxy_port = 8080
    proxy_user = None
    proxy_pass = None
    try:
        proxy_server = __settings__.getSetting('proxy_server')
        proxy_type_id = __settings__.getSetting('proxy_type')
        proxy_port = int(__settings__.getSetting('proxy_port'))
        proxy_user = __settings__.getSetting('proxy_user')
        proxy_pass = __settings__.getSetting('proxy_pass')

    except:
        pass

    if   proxy_type_id == '0': proxy_type = socks.PROXY_TYPE_HTTP_NO_TUNNEL
    elif proxy_type_id == '1': proxy_type = socks.PROXY_TYPE_HTTP
    elif proxy_type_id == '2': proxy_type = socks.PROXY_TYPE_SOCKS4
    elif proxy_type_id == '3': proxy_type = socks.PROXY_TYPE_SOCKS5

    proxy_dns = True

    return (proxy_type, proxy_server, proxy_port, proxy_dns, proxy_user, proxy_pass)
项目:zabbix-youtrack-action    作者:devopshq    | 项目源码 | 文件源码
def __init__(self, proxy_type, proxy_host, proxy_port, proxy_rdns=True, proxy_user=None, proxy_pass=None):
      """
        Args:
          proxy_type: The type of proxy server.  This must be set to one of
          socks.PROXY_TYPE_XXX constants.  For example:

            p = ProxyInfo(proxy_type=socks.PROXY_TYPE_HTTP,
              proxy_host='localhost', proxy_port=8000)

          proxy_host: The hostname or IP address of the proxy server.

          proxy_port: The port that the proxy server is running on.

          proxy_rdns: If True (default), DNS queries will not be performed
          locally, and instead, handed to the proxy to resolve.  This is useful
          if the network does not allow resolution of non-local names.  In
          httplib2 0.9 and earlier, this defaulted to False.

          proxy_user: The username used to authenticate with the proxy server.

          proxy_pass: The password used to authenticate with the proxy server.
      """
      self.proxy_type, self.proxy_host, self.proxy_port, self.proxy_rdns, self.proxy_user, self.proxy_pass = proxy_type, proxy_host, proxy_port, proxy_rdns, proxy_user, proxy_pass
项目:TumblrVideos    作者:moedje    | 项目源码 | 文件源码
def __init__(self, consumer_key, consumer_secret="", oauth_token="", oauth_secret="", host="https://api.tumblr.com",
                 proxy_url=None):
        self.host = host
        self.consumer = oauth.Consumer(key=consumer_key, secret=consumer_secret)
        self.token = oauth.Token(key=oauth_token, secret=oauth_secret)
        self.proxy_url = proxy_url
        if proxy_url:
            print("Generating Proxy From proxy_url")
            self.proxy_info = httplib2.proxy_info_from_url("https://" + proxy_url, 'http')
            self.proxy_info.proxy_rdns = True
            # uri = urlparse(proxy_url)
            # self.proxy_info = ProxyInfo(socks.PROXY_TYPE_HTTP,uri.hostname,uri.port,proxy_rdns=True)
        else:
            print("Generating proxy from ENV")
            proxy_url = os.environ.get('HTTPS_PROXY', None)
            if proxy_url:
                uri = urlparse(proxy_url)
                self.proxy_info = ProxyInfo(socks.PROXY_TYPE_HTTP, uri.hostname, uri.port, proxy_rdns=True)
            else:
                self.proxy_info = None
项目:oscars2016    作者:0x0ece    | 项目源码 | 文件源码
def __init__(self, proxy_type, proxy_host, proxy_port,
                 proxy_rdns=True, proxy_user=None, proxy_pass=None):
        """
        Args:
          proxy_type: The type of proxy server.  This must be set to one of
          socks.PROXY_TYPE_XXX constants.  For example:

            p = ProxyInfo(proxy_type=socks.PROXY_TYPE_HTTP,
              proxy_host='localhost', proxy_port=8000)

          proxy_host: The hostname or IP address of the proxy server.

          proxy_port: The port that the proxy server is running on.

          proxy_rdns: If True (default), DNS queries will not be performed
          locally, and instead, handed to the proxy to resolve.  This is useful
          if the network does not allow resolution of non-local names.  In
          httplib2 0.9 and earlier, this defaulted to False.

          proxy_user: The username used to authenticate with the proxy server.

          proxy_pass: The password used to authenticate with the proxy server.
        """
        self.proxy_type = proxy_type
        self.proxy_host = proxy_host
        self.proxy_port = proxy_port
        self.proxy_rdns = proxy_rdns
        self.proxy_user = proxy_user
        self.proxy_pass = proxy_pass
项目:oscars2016    作者:0x0ece    | 项目源码 | 文件源码
def proxy_info_from_url(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 ProxyInfo(
        proxy_type = proxy_type,
        proxy_host = host,
        proxy_port = port,
        proxy_user = username or None,
        proxy_pass = password or None,
    )
项目:sndlatr    作者:Schibum    | 项目源码 | 文件源码
def __init__(self, proxy_type, proxy_host, proxy_port,
                 proxy_rdns=None, proxy_user=None, proxy_pass=None):
        """The parameter proxy_type must be set to one of socks.PROXY_TYPE_XXX
        constants. For example:

        p = ProxyInfo(proxy_type=socks.PROXY_TYPE_HTTP,
            proxy_host='localhost', proxy_port=8000)
        """
        self.proxy_type = proxy_type
        self.proxy_host = proxy_host
        self.proxy_port = proxy_port
        self.proxy_rdns = proxy_rdns
        self.proxy_user = proxy_user
        self.proxy_pass = proxy_pass
项目:sndlatr    作者:Schibum    | 项目源码 | 文件源码
def proxy_info_from_url(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 ProxyInfo(
        proxy_type = proxy_type,
        proxy_host = host,
        proxy_port = port,
        proxy_user = username or None,
        proxy_pass = password or None,
    )
项目:GAMADV-XTD    作者:taers232c    | 项目源码 | 文件源码
def __init__(self, proxy_type, proxy_host, proxy_port,
                 proxy_rdns=True, proxy_user=None, proxy_pass=None, proxy_headers=None):
        """
        Args:
          proxy_type: The type of proxy server.  This must be set to one of
          socks.PROXY_TYPE_XXX constants.  For example:

            p = ProxyInfo(proxy_type=socks.PROXY_TYPE_HTTP,
              proxy_host='localhost', proxy_port=8000)

          proxy_host: The hostname or IP address of the proxy server.

          proxy_port: The port that the proxy server is running on.

          proxy_rdns: If True (default), DNS queries will not be performed
          locally, and instead, handed to the proxy to resolve.  This is useful
          if the network does not allow resolution of non-local names.  In
          httplib2 0.9 and earlier, this defaulted to False.

          proxy_user: The username used to authenticate with the proxy server.

          proxy_pass: The password used to authenticate with the proxy server.

          proxy_headers: Additional or modified headers for the proxy connect request.
        """
        self.proxy_type = proxy_type
        self.proxy_host = proxy_host
        self.proxy_port = proxy_port
        self.proxy_rdns = proxy_rdns
        self.proxy_user = proxy_user
        self.proxy_pass = proxy_pass
        self.proxy_headers = proxy_headers
项目:GAMADV-XTD    作者:taers232c    | 项目源码 | 文件源码
def proxy_info_from_url(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 ProxyInfo(
        proxy_type = proxy_type,
        proxy_host = host,
        proxy_port = port,
        proxy_user = username or None,
        proxy_pass = password or None,
        proxy_headers = None,
    )
项目:httplib2    作者:httplib2    | 项目源码 | 文件源码
def __init__(self, proxy_type, proxy_host, proxy_port,
                 proxy_rdns=True, proxy_user=None, proxy_pass=None, proxy_headers=None):
        """
        Args:
          proxy_type: The type of proxy server.  This must be set to one of
          socks.PROXY_TYPE_XXX constants.  For example:

            p = ProxyInfo(proxy_type=socks.PROXY_TYPE_HTTP,
              proxy_host='localhost', proxy_port=8000)

          proxy_host: The hostname or IP address of the proxy server.

          proxy_port: The port that the proxy server is running on.

          proxy_rdns: If True (default), DNS queries will not be performed
          locally, and instead, handed to the proxy to resolve.  This is useful
          if the network does not allow resolution of non-local names.  In
          httplib2 0.9 and earlier, this defaulted to False.

          proxy_user: The username used to authenticate with the proxy server.

          proxy_pass: The password used to authenticate with the proxy server.

          proxy_headers: Additional or modified headers for the proxy connect request.
        """
        self.proxy_type = proxy_type
        self.proxy_host = proxy_host
        self.proxy_port = proxy_port
        self.proxy_rdns = proxy_rdns
        self.proxy_user = proxy_user
        self.proxy_pass = proxy_pass
        self.proxy_headers = proxy_headers
项目:httplib2    作者:httplib2    | 项目源码 | 文件源码
def proxy_info_from_url(url, method='http'):
    """
    Construct a ProxyInfo from a URL (such as http_proxy env var)
    """
    url = urllib.parse.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 ProxyInfo(
        proxy_type = proxy_type,
        proxy_host = host,
        proxy_port = port,
        proxy_user = username or None,
        proxy_pass = password or None,
        proxy_headers = None,
    )
项目:Texty    作者:sarthfrey    | 项目源码 | 文件源码
def __init__(self, proxy_type, proxy_host, proxy_port,
                 proxy_rdns=True, proxy_user=None, proxy_pass=None):
        """
        Args:
          proxy_type: The type of proxy server.  This must be set to one of
          socks.PROXY_TYPE_XXX constants.  For example:

            p = ProxyInfo(proxy_type=socks.PROXY_TYPE_HTTP,
              proxy_host='localhost', proxy_port=8000)

          proxy_host: The hostname or IP address of the proxy server.

          proxy_port: The port that the proxy server is running on.

          proxy_rdns: If True (default), DNS queries will not be performed
          locally, and instead, handed to the proxy to resolve.  This is useful
          if the network does not allow resolution of non-local names.  In
          httplib2 0.9 and earlier, this defaulted to False.

          proxy_user: The username used to authenticate with the proxy server.

          proxy_pass: The password used to authenticate with the proxy server.
        """
        self.proxy_type = proxy_type
        self.proxy_host = proxy_host
        self.proxy_port = proxy_port
        self.proxy_rdns = proxy_rdns
        self.proxy_user = proxy_user
        self.proxy_pass = proxy_pass
项目:Texty    作者:sarthfrey    | 项目源码 | 文件源码
def proxy_info_from_url(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 ProxyInfo(
        proxy_type = proxy_type,
        proxy_host = host,
        proxy_port = port,
        proxy_user = username or None,
        proxy_pass = password or None,
    )
项目:office-interoperability-tools    作者:milossramek    | 项目源码 | 文件源码
def __init__(self, proxy_type, proxy_host, proxy_port,
        proxy_rdns=None, proxy_user=None, proxy_pass=None):
        """The parameter proxy_type must be set to one of socks.PROXY_TYPE_XXX
        constants. For example:

        p = ProxyInfo(proxy_type=socks.PROXY_TYPE_HTTP,
            proxy_host='localhost', proxy_port=8000)
        """
        self.proxy_type = proxy_type
        self.proxy_host = proxy_host
        self.proxy_port = proxy_port
        self.proxy_rdns = proxy_rdns
        self.proxy_user = proxy_user
        self.proxy_pass = proxy_pass
项目:office-interoperability-tools    作者:milossramek    | 项目源码 | 文件源码
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,
        )
项目:touch-pay-client    作者:HackPucBemobi    | 项目源码 | 文件源码
def __init__(self, timeout, proxy=None, cacert=None, sessions=False):
#            httplib2.debuglevel=4 
            kwargs = {}
            if proxy:
                import socks
                kwargs['proxy_info'] = httplib2.ProxyInfo(proxy_type=socks.PROXY_TYPE_HTTP, **proxy)
                log.info("using proxy %s" % proxy)

            # set optional parameters according to supported httplib2 version
            if httplib2.__version__ >= '0.3.0':
                kwargs['timeout'] = timeout
            if httplib2.__version__ >= '0.7.0':
                kwargs['disable_ssl_certificate_validation'] = cacert is None
                kwargs['ca_certs'] = cacert
            httplib2.Http.__init__(self, **kwargs)
项目:Taigabot    作者:FrozenPigs    | 项目源码 | 文件源码
def __init__(self, proxy_type, proxy_host, proxy_port,
        proxy_rdns=None, proxy_user=None, proxy_pass=None):
        """The parameter proxy_type must be set to one of socks.PROXY_TYPE_XXX
        constants. For example:

        p = ProxyInfo(proxy_type=socks.PROXY_TYPE_HTTP,
            proxy_host='localhost', proxy_port=8000)
        """
        self.proxy_type = proxy_type
        self.proxy_host = proxy_host
        self.proxy_port = proxy_port
        self.proxy_rdns = proxy_rdns
        self.proxy_user = proxy_user
        self.proxy_pass = proxy_pass
项目:Taigabot    作者:FrozenPigs    | 项目源码 | 文件源码
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,
        )
项目:Intranet-Penetration    作者:yuxiaokui    | 项目源码 | 文件源码
def __init__(self, proxy_type, proxy_host, proxy_port,
        proxy_rdns=True, proxy_user=None, proxy_pass=None):
        """The parameter proxy_type must be set to one of socks.PROXY_TYPE_XXX
        constants. For example:

        p = ProxyInfo(proxy_type=socks.PROXY_TYPE_HTTP,
            proxy_host='localhost', proxy_port=8000)
        """
        self.proxy_type = proxy_type
        self.proxy_host = proxy_host
        self.proxy_port = proxy_port
        self.proxy_rdns = proxy_rdns
        self.proxy_user = proxy_user
        self.proxy_pass = proxy_pass
项目: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,
        )
项目:Fetch    作者:bourdakos1    | 项目源码 | 文件源码
def proxy_info_from_url(url, method='http'):
    """
    Construct a ProxyInfo from a URL (such as http_proxy env var)
    """
    url = urllib.parse.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 ProxyInfo(
        proxy_type = proxy_type,
        proxy_host = host,
        proxy_port = port,
        proxy_user = username or None,
        proxy_pass = password or None,
    )
项目:MKFQ    作者:maojingios    | 项目源码 | 文件源码
def __init__(self, proxy_type, proxy_host, proxy_port,
        proxy_rdns=True, proxy_user=None, proxy_pass=None):
        """The parameter proxy_type must be set to one of socks.PROXY_TYPE_XXX
        constants. For example:

        p = ProxyInfo(proxy_type=socks.PROXY_TYPE_HTTP,
            proxy_host='localhost', proxy_port=8000)
        """
        self.proxy_type = proxy_type
        self.proxy_host = proxy_host
        self.proxy_port = proxy_port
        self.proxy_rdns = proxy_rdns
        self.proxy_user = proxy_user
        self.proxy_pass = proxy_pass
项目:MKFQ    作者:maojingios    | 项目源码 | 文件源码
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,
        )
项目:edx-video-pipeline    作者:edx    | 项目源码 | 文件源码
def __init__(self, proxy_type, proxy_host, proxy_port, proxy_rdns=None, proxy_user=None, proxy_pass=None):
      """The parameter proxy_type must be set to one of socks.PROXY_TYPE_XXX
      constants. For example:

p = ProxyInfo(proxy_type=socks.PROXY_TYPE_HTTP, proxy_host='localhost', proxy_port=8000)
      """
      self.proxy_type, self.proxy_host, self.proxy_port, self.proxy_rdns, self.proxy_user, self.proxy_pass = proxy_type, proxy_host, proxy_port, proxy_rdns, proxy_user, proxy_pass
项目:true_review_web2py    作者:lucadealfaro    | 项目源码 | 文件源码
def __init__(self, timeout, proxy=None, cacert=None, sessions=False):
            ##httplib2.debuglevel=4
            kwargs = {}
            if proxy:
                import socks
                kwargs['proxy_info'] = httplib2.ProxyInfo(proxy_type=socks.PROXY_TYPE_HTTP, **proxy)
                log.info("using proxy %s" % proxy)

            # set optional parameters according supported httplib2 version
            if httplib2.__version__ >= '0.3.0':
                kwargs['timeout'] = timeout
            if httplib2.__version__ >= '0.7.0':
                kwargs['disable_ssl_certificate_validation'] = cacert is None
                kwargs['ca_certs'] = cacert
            httplib2.Http.__init__(self, **kwargs)
项目:spc    作者:whbrewer    | 项目源码 | 文件源码
def __init__(self, timeout, proxy=None, cacert=None, sessions=False):
            ##httplib2.debuglevel=4
            kwargs = {}
            if proxy:
                import socks
                kwargs['proxy_info'] = httplib2.ProxyInfo(proxy_type=socks.PROXY_TYPE_HTTP, **proxy)
                log.info("using proxy %s" % proxy)

            # set optional parameters according supported httplib2 version
            if httplib2.__version__ >= '0.3.0':
                kwargs['timeout'] = timeout
            if httplib2.__version__ >= '0.7.0':
                kwargs['disable_ssl_certificate_validation'] = cacert is None
                kwargs['ca_certs'] = cacert
            httplib2.Http.__init__(self, **kwargs)
项目:catchup4kodi    作者:catchup4kodi    | 项目源码 | 文件源码
def __init__(self, proxy_type, proxy_host, proxy_port, proxy_rdns=None, proxy_user=None, proxy_pass=None):
      """The parameter proxy_type must be set to one of socks.PROXY_TYPE_XXX
      constants. For example:

p = ProxyInfo(proxy_type=socks.PROXY_TYPE_HTTP, proxy_host='localhost', proxy_port=8000)
      """
      self.proxy_type, self.proxy_host, self.proxy_port, self.proxy_rdns, self.proxy_user, self.proxy_pass = proxy_type, proxy_host, proxy_port, proxy_rdns, proxy_user, proxy_pass
项目:wiobot    作者:idreamsi    | 项目源码 | 文件源码
def __init__(self, proxy_type, proxy_host, proxy_port,
                 proxy_rdns=True, proxy_user=None, proxy_pass=None):
        """
        Args:
          proxy_type: The type of proxy server.  This must be set to one of
          socks.PROXY_TYPE_XXX constants.  For example:

            p = ProxyInfo(proxy_type=socks.PROXY_TYPE_HTTP,
              proxy_host='localhost', proxy_port=8000)

          proxy_host: The hostname or IP address of the proxy server.

          proxy_port: The port that the proxy server is running on.

          proxy_rdns: If True (default), DNS queries will not be performed
          locally, and instead, handed to the proxy to resolve.  This is useful
          if the network does not allow resolution of non-local names.  In
          httplib2 0.9 and earlier, this defaulted to False.

          proxy_user: The username used to authenticate with the proxy server.

          proxy_pass: The password used to authenticate with the proxy server.
        """
        self.proxy_type = proxy_type
        self.proxy_host = proxy_host
        self.proxy_port = proxy_port
        self.proxy_rdns = proxy_rdns
        self.proxy_user = proxy_user
        self.proxy_pass = proxy_pass
项目:wiobot    作者:idreamsi    | 项目源码 | 文件源码
def proxy_info_from_url(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 ProxyInfo(
        proxy_type = proxy_type,
        proxy_host = host,
        proxy_port = port,
        proxy_user = username or None,
        proxy_pass = password or None,
    )
项目:REMAP    作者:REMAPApp    | 项目源码 | 文件源码
def __init__(self, proxy_type, proxy_host, proxy_port,
                 proxy_rdns=True, proxy_user=None, proxy_pass=None):
        """
        Args:
          proxy_type: The type of proxy server.  This must be set to one of
          socks.PROXY_TYPE_XXX constants.  For example:

            p = ProxyInfo(proxy_type=socks.PROXY_TYPE_HTTP,
              proxy_host='localhost', proxy_port=8000)

          proxy_host: The hostname or IP address of the proxy server.

          proxy_port: The port that the proxy server is running on.

          proxy_rdns: If True (default), DNS queries will not be performed
          locally, and instead, handed to the proxy to resolve.  This is useful
          if the network does not allow resolution of non-local names.  In
          httplib2 0.9 and earlier, this defaulted to False.

          proxy_user: The username used to authenticate with the proxy server.

          proxy_pass: The password used to authenticate with the proxy server.
        """
        self.proxy_type = proxy_type
        self.proxy_host = proxy_host
        self.proxy_port = proxy_port
        self.proxy_rdns = proxy_rdns
        self.proxy_user = proxy_user
        self.proxy_pass = proxy_pass
项目:REMAP    作者:REMAPApp    | 项目源码 | 文件源码
def proxy_info_from_url(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 ProxyInfo(
        proxy_type = proxy_type,
        proxy_host = host,
        proxy_port = port,
        proxy_user = username or None,
        proxy_pass = password or None,
    )
项目:Problematica-public    作者:TechMaz    | 项目源码 | 文件源码
def __init__(self, timeout, proxy=None, cacert=None, sessions=False):
            ##httplib2.debuglevel=4
            kwargs = {}
            if proxy:
                import socks
                kwargs['proxy_info'] = httplib2.ProxyInfo(proxy_type=socks.PROXY_TYPE_HTTP, **proxy)
                log.info("using proxy %s" % proxy)

            # set optional parameters according supported httplib2 version
            if httplib2.__version__ >= '0.3.0':
                kwargs['timeout'] = timeout
            if httplib2.__version__ >= '0.7.0':
                kwargs['disable_ssl_certificate_validation'] = cacert is None
                kwargs['ca_certs'] = cacert
            httplib2.Http.__init__(self, **kwargs)
项目:python-group-proj    作者:Sharcee    | 项目源码 | 文件源码
def __init__(self, proxy_type, proxy_host, proxy_port,
                 proxy_rdns=True, proxy_user=None, proxy_pass=None, proxy_headers=None):
        """
        Args:
          proxy_type: The type of proxy server.  This must be set to one of
          socks.PROXY_TYPE_XXX constants.  For example:

            p = ProxyInfo(proxy_type=socks.PROXY_TYPE_HTTP,
              proxy_host='localhost', proxy_port=8000)

          proxy_host: The hostname or IP address of the proxy server.

          proxy_port: The port that the proxy server is running on.

          proxy_rdns: If True (default), DNS queries will not be performed
          locally, and instead, handed to the proxy to resolve.  This is useful
          if the network does not allow resolution of non-local names.  In
          httplib2 0.9 and earlier, this defaulted to False.

          proxy_user: The username used to authenticate with the proxy server.

          proxy_pass: The password used to authenticate with the proxy server.

          proxy_headers: Additional or modified headers for the proxy connect request.
        """
        self.proxy_type = proxy_type
        self.proxy_host = proxy_host
        self.proxy_port = proxy_port
        self.proxy_rdns = proxy_rdns
        self.proxy_user = proxy_user
        self.proxy_pass = proxy_pass
        self.proxy_headers = proxy_headers
项目:python-group-proj    作者:Sharcee    | 项目源码 | 文件源码
def proxy_info_from_url(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 ProxyInfo(
        proxy_type = proxy_type,
        proxy_host = host,
        proxy_port = port,
        proxy_user = username or None,
        proxy_pass = password or None,
        proxy_headers = None,
    )
项目:district_profile    作者:jkeltner    | 项目源码 | 文件源码
def __init__(self, proxy_type, proxy_host, proxy_port,
                 proxy_rdns=True, proxy_user=None, proxy_pass=None):
        """
        Args:
          proxy_type: The type of proxy server.  This must be set to one of
          socks.PROXY_TYPE_XXX constants.  For example:

            p = ProxyInfo(proxy_type=socks.PROXY_TYPE_HTTP,
              proxy_host='localhost', proxy_port=8000)

          proxy_host: The hostname or IP address of the proxy server.

          proxy_port: The port that the proxy server is running on.

          proxy_rdns: If True (default), DNS queries will not be performed
          locally, and instead, handed to the proxy to resolve.  This is useful
          if the network does not allow resolution of non-local names.  In
          httplib2 0.9 and earlier, this defaulted to False.

          proxy_user: The username used to authenticate with the proxy server.

          proxy_pass: The password used to authenticate with the proxy server.
        """
        self.proxy_type = proxy_type
        self.proxy_host = proxy_host
        self.proxy_port = proxy_port
        self.proxy_rdns = proxy_rdns
        self.proxy_user = proxy_user
        self.proxy_pass = proxy_pass
项目:district_profile    作者:jkeltner    | 项目源码 | 文件源码
def proxy_info_from_url(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 ProxyInfo(
        proxy_type = proxy_type,
        proxy_host = host,
        proxy_port = port,
        proxy_user = username or None,
        proxy_pass = password or None,
    )
项目:ecodash    作者:Servir-Mekong    | 项目源码 | 文件源码
def __init__(self, proxy_type, proxy_host, proxy_port,
                 proxy_rdns=True, proxy_user=None, proxy_pass=None):
        """
        Args:
          proxy_type: The type of proxy server.  This must be set to one of
          socks.PROXY_TYPE_XXX constants.  For example:

            p = ProxyInfo(proxy_type=socks.PROXY_TYPE_HTTP,
              proxy_host='localhost', proxy_port=8000)

          proxy_host: The hostname or IP address of the proxy server.

          proxy_port: The port that the proxy server is running on.

          proxy_rdns: If True (default), DNS queries will not be performed
          locally, and instead, handed to the proxy to resolve.  This is useful
          if the network does not allow resolution of non-local names.  In
          httplib2 0.9 and earlier, this defaulted to False.

          proxy_user: The username used to authenticate with the proxy server.

          proxy_pass: The password used to authenticate with the proxy server.
        """
        self.proxy_type = proxy_type
        self.proxy_host = proxy_host
        self.proxy_port = proxy_port
        self.proxy_rdns = proxy_rdns
        self.proxy_user = proxy_user
        self.proxy_pass = proxy_pass
项目:ecodash    作者:Servir-Mekong    | 项目源码 | 文件源码
def proxy_info_from_url(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 ProxyInfo(
        proxy_type = proxy_type,
        proxy_host = host,
        proxy_port = port,
        proxy_user = username or None,
        proxy_pass = password or None,
    )
项目:zabbix-youtrack-action    作者:devopshq    | 项目源码 | 文件源码
def proxy_info_from_url(url, method='http'):
    """
    Construct a ProxyInfo from a URL (such as http_proxy env var)
    """
    url = urllib.parse.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 ProxyInfo(
        proxy_type = proxy_type,
        proxy_host = host,
        proxy_port = port,
        proxy_user = username or None,
        proxy_pass = password or None,
    )
项目:Callandtext    作者:iaora    | 项目源码 | 文件源码
def __init__(self, proxy_type, proxy_host, proxy_port,
                 proxy_rdns=True, proxy_user=None, proxy_pass=None):
        """
        Args:
          proxy_type: The type of proxy server.  This must be set to one of
          socks.PROXY_TYPE_XXX constants.  For example:

            p = ProxyInfo(proxy_type=socks.PROXY_TYPE_HTTP,
              proxy_host='localhost', proxy_port=8000)

          proxy_host: The hostname or IP address of the proxy server.

          proxy_port: The port that the proxy server is running on.

          proxy_rdns: If True (default), DNS queries will not be performed
          locally, and instead, handed to the proxy to resolve.  This is useful
          if the network does not allow resolution of non-local names.  In
          httplib2 0.9 and earlier, this defaulted to False.

          proxy_user: The username used to authenticate with the proxy server.

          proxy_pass: The password used to authenticate with the proxy server.
        """
        self.proxy_type = proxy_type
        self.proxy_host = proxy_host
        self.proxy_port = proxy_port
        self.proxy_rdns = proxy_rdns
        self.proxy_user = proxy_user
        self.proxy_pass = proxy_pass
项目:Callandtext    作者:iaora    | 项目源码 | 文件源码
def proxy_info_from_url(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 ProxyInfo(
        proxy_type = proxy_type,
        proxy_host = host,
        proxy_port = port,
        proxy_user = username or None,
        proxy_pass = password or None,
    )
项目:splunk_ta_ps4_f1_2016    作者:jonathanvarley    | 项目源码 | 文件源码
def __init__(self, proxy_type, proxy_host, proxy_port,
                 proxy_rdns=True, proxy_user=None, proxy_pass=None):
        """
        Args:
          proxy_type: The type of proxy server.  This must be set to one of
          socks.PROXY_TYPE_XXX constants.  For example:

            p = ProxyInfo(proxy_type=socks.PROXY_TYPE_HTTP,
              proxy_host='localhost', proxy_port=8000)

          proxy_host: The hostname or IP address of the proxy server.

          proxy_port: The port that the proxy server is running on.

          proxy_rdns: If True (default), DNS queries will not be performed
          locally, and instead, handed to the proxy to resolve.  This is useful
          if the network does not allow resolution of non-local names.  In
          httplib2 0.9 and earlier, this defaulted to False.

          proxy_user: The username used to authenticate with the proxy server.

          proxy_pass: The password used to authenticate with the proxy server.
        """
        self.proxy_type = proxy_type
        self.proxy_host = proxy_host
        self.proxy_port = proxy_port
        self.proxy_rdns = proxy_rdns
        self.proxy_user = proxy_user
        self.proxy_pass = proxy_pass
项目:splunk_ta_ps4_f1_2016    作者:jonathanvarley    | 项目源码 | 文件源码
def proxy_info_from_url(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 ProxyInfo(
        proxy_type = proxy_type,
        proxy_host = host,
        proxy_port = port,
        proxy_user = username or None,
        proxy_pass = password or None,
    )
项目:amazon-alexa-twilio-customer-service    作者:ameerbadri    | 项目源码 | 文件源码
def __init__(self, proxy_type, proxy_host, proxy_port,
                 proxy_rdns=True, proxy_user=None, proxy_pass=None):
        """
        Args:
          proxy_type: The type of proxy server.  This must be set to one of
          socks.PROXY_TYPE_XXX constants.  For example:

            p = ProxyInfo(proxy_type=socks.PROXY_TYPE_HTTP,
              proxy_host='localhost', proxy_port=8000)

          proxy_host: The hostname or IP address of the proxy server.

          proxy_port: The port that the proxy server is running on.

          proxy_rdns: If True (default), DNS queries will not be performed
          locally, and instead, handed to the proxy to resolve.  This is useful
          if the network does not allow resolution of non-local names.  In
          httplib2 0.9 and earlier, this defaulted to False.

          proxy_user: The username used to authenticate with the proxy server.

          proxy_pass: The password used to authenticate with the proxy server.
        """
        self.proxy_type = proxy_type
        self.proxy_host = proxy_host
        self.proxy_port = proxy_port
        self.proxy_rdns = proxy_rdns
        self.proxy_user = proxy_user
        self.proxy_pass = proxy_pass
项目:amazon-alexa-twilio-customer-service    作者:ameerbadri    | 项目源码 | 文件源码
def proxy_info_from_url(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 ProxyInfo(
        proxy_type = proxy_type,
        proxy_host = host,
        proxy_port = port,
        proxy_user = username or None,
        proxy_pass = password or None,
    )
项目:OneClickDTU    作者:satwikkansal    | 项目源码 | 文件源码
def __init__(self, proxy_type, proxy_host, proxy_port,
                 proxy_rdns=True, proxy_user=None, proxy_pass=None):
        """
        Args:
          proxy_type: The type of proxy server.  This must be set to one of
          socks.PROXY_TYPE_XXX constants.  For example:

            p = ProxyInfo(proxy_type=socks.PROXY_TYPE_HTTP,
              proxy_host='localhost', proxy_port=8000)

          proxy_host: The hostname or IP address of the proxy server.

          proxy_port: The port that the proxy server is running on.

          proxy_rdns: If True (default), DNS queries will not be performed
          locally, and instead, handed to the proxy to resolve.  This is useful
          if the network does not allow resolution of non-local names.  In
          httplib2 0.9 and earlier, this defaulted to False.

          proxy_user: The username used to authenticate with the proxy server.

          proxy_pass: The password used to authenticate with the proxy server.
        """
        self.proxy_type = proxy_type
        self.proxy_host = proxy_host
        self.proxy_port = proxy_port
        self.proxy_rdns = proxy_rdns
        self.proxy_user = proxy_user
        self.proxy_pass = proxy_pass
项目:OneClickDTU    作者:satwikkansal    | 项目源码 | 文件源码
def proxy_info_from_url(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 ProxyInfo(
        proxy_type = proxy_type,
        proxy_host = host,
        proxy_port = port,
        proxy_user = username or None,
        proxy_pass = password or None,
    )