示例#1
0
文件: _http.py 项目: DarkDare/soledad
 def __init__(self, uuid, token, cert_file):
     self._uuid = uuid
     self._token = None
     self._creds = None
     self.set_token(token)
     # pin this agent with the platform TLS certificate
     factory = get_compatible_ssl_context_factory(cert_file)
     Agent.__init__(self, reactor, contextFactory=factory)
示例#2
0
文件: _http.py 项目: leapcode/soledad
 def __init__(self, uuid, token, cert_file, throttling=False):
     self._uuid = uuid
     self._token = None
     self._creds = None
     self.set_token(token)
     factory = getPolicyForHTTPS(cert_file)
     pool = self._get_pool()
     _Agent.__init__(self, reactor, contextFactory=factory, pool=pool)
示例#3
0
 def __init__(self, uuid, token, cert_file, throttling=False):
     self._uuid = uuid
     self._token = None
     self._creds = None
     self.set_token(token)
     factory = getPolicyForHTTPS(cert_file)
     pool = self._get_pool()
     _Agent.__init__(self, reactor, contextFactory=factory, pool=pool)
示例#4
0
    def __init__(self,
                 reactor,
                 contextFactory=WebClientContextFactory(),
                 connectTimeout=None,
                 bindAddress=None):
        Agent.__init__(self, reactor, contextFactory)

        self._connectTimeout = connectTimeout
        self._bindAddress = bindAddress
示例#5
0
    def __init__(self,
                 reactor,
                 connectTimeout=None,
                 bindAddress=None,
                 pool=None,
                 torSocksHostname=None,
                 torSocksPort=None,
                 isolationMode=None):
        """
        Create a L{TorAgent}.

        @param reactor: A provider of
            L{twisted.internet.interfaces.IReactorTCP}
            to place outgoing connections.
        @type reactor: L{twisted.internet.interfaces.IReactorTCP}.

        @param connectTimeout: The amount of time that this L{Agent} will wait
            for the peer to accept a connection.
        @type connectTimeout: L{float}

        @param bindAddress: The local address for client sockets to bind to.
        @type bindAddress: L{bytes}

        @param pool: An L{HTTPConnectionPool} instance, or C{None}, in which
            case a non-persistent L{HTTPConnectionPool} instance will be
            created.
        @type pool: L{HTTPConnectionPool}

        @param torSocksHostname: A C{str} giving the tor SOCKS hostname
            that this TorAgent will use for outbound Tor connections.

        @param torSocksPort: An C{int} giving the SOCKS port number that will be used
            for outbound Tor connections.

        @param isolationMode: A Tor circuit isolation mode:
        - monoCircuit means always let tor process decide which circuit to use
        - circuitPerAgent means always use one tor circuit per agent instance
        """
        Agent.__init__(self,
                       reactor,
                       connectTimeout=None,
                       bindAddress=None,
                       pool=None)

        self._connectTimeout = connectTimeout
        self._bindAddress = bindAddress

        self.torSocksHostname = torSocksHostname
        self.torSocksPort = torSocksPort

        if isolationMode in self.isolationModes:
            self.isolationMode = isolationMode
            if isolationMode == 'circuitPerAgent':
                self.username, self.password = self._genRandomUserPass()
        else:
            raise TorAgentCircuitIsolationModeNotSupported(
                "Unsupported mode: %r" % (isolationMode, ))
示例#6
0
 def __init__(self, uuid, token, cert_file):
     self._uuid = uuid
     self._token = None
     self._creds = None
     self.set_token(token)
     # pin this agent with the platform TLS certificate
     factory = getPolicyForHTTPS(cert_file)
     persistent = os.environ.get('SOLEDAD_HTTP_PERSIST', None)
     pool = HTTPConnectionPool(reactor, persistent=bool(persistent))
     Agent.__init__(self, reactor, contextFactory=factory, pool=pool)
示例#7
0
    def __init__(self, gerrit_host, *args, **kwargs):
        url_parts = urlparse.urlparse(gerrit_host)
        if url_parts.scheme:
            self.gerrit_protocol = url_parts.scheme
        self.gerrit_host = url_parts.netloc

        auth_entry = NETRC.authenticators(self.gerrit_host.partition(':')[0])
        if auth_entry:
            self.auth_token = 'Basic %s' % (base64.b64encode(
                '%s:%s' % (auth_entry[0], auth_entry[2])))
        else:
            self.auth_token = None
        Agent.__init__(self, reactor, *args, **kwargs)
示例#8
0
  def __init__(self, gerrit_host, *args, **kwargs):
    url_parts = urlparse.urlparse(gerrit_host)
    if url_parts.scheme:
      self.gerrit_protocol = url_parts.scheme
    self.gerrit_host = url_parts.netloc

    auth_entry = NETRC.authenticators(self.gerrit_host.partition(':')[0])
    if auth_entry:
      self.auth_token = 'Basic %s' % (
          base64.b64encode('%s:%s' % (auth_entry[0], auth_entry[2])))
    else:
      self.auth_token = None
    Agent.__init__(self, reactor, *args, **kwargs)
示例#9
0
    def __init__(self, reactor,
                 connectTimeout=None, bindAddress=None,
                 pool=None, torSocksHostname=None, torSocksPort=None, isolationMode=None):
        """
        Create a L{TorAgent}.

        @param reactor: A provider of
            L{twisted.internet.interfaces.IReactorTCP}
            to place outgoing connections.
        @type reactor: L{twisted.internet.interfaces.IReactorTCP}.

        @param connectTimeout: The amount of time that this L{Agent} will wait
            for the peer to accept a connection.
        @type connectTimeout: L{float}

        @param bindAddress: The local address for client sockets to bind to.
        @type bindAddress: L{bytes}

        @param pool: An L{HTTPConnectionPool} instance, or C{None}, in which
            case a non-persistent L{HTTPConnectionPool} instance will be
            created.
        @type pool: L{HTTPConnectionPool}

        @param torSocksHostname: A C{str} giving the tor SOCKS hostname
            that this TorAgent will use for outbound Tor connections.

        @param torSocksPort: An C{int} giving the SOCKS port number that will be used
            for outbound Tor connections.

        @param isolationMode: A Tor circuit isolation mode:
        - monoCircuit means always let tor process decide which circuit to use
        - circuitPerAgent means always use one tor circuit per agent instance
        """
        Agent.__init__(self, reactor,connectTimeout=None, bindAddress=None, pool=None)

        self._connectTimeout = connectTimeout
        self._bindAddress = bindAddress

        self.torSocksHostname = torSocksHostname
        self.torSocksPort = torSocksPort

        if isolationMode in self.isolationModes:
            self.isolationMode = isolationMode
            if isolationMode == 'circuitPerAgent':
                self.username, self.password = self._genRandomUserPass()
        else:
            raise TorAgentCircuitIsolationModeNotSupported("Unsupported mode: %r" % (isolationMode,))
示例#10
0
	def __init__(self, *args, **kwargs):
		Agent.__init__(self, *args, **kwargs)
示例#11
0
文件: utils.py 项目: calston/tensor
 def __init__(self, reactor, path, **kwargs):
     self.path = path
     Agent.__init__(self, reactor, **kwargs)
示例#12
0
   def __init__(self, reactor, contextFactory = WebClientContextFactory(),
                connectTimeout = None, bindAddress = None):
      Agent.__init__(self, reactor, contextFactory)

      self._connectTimeout = connectTimeout
      self._bindAddress = bindAddress
示例#13
0
 def __init__(self, reactor, path, **kwargs):
     self.path = path
     Agent.__init__(self, reactor, **kwargs)
示例#14
0
文件: utils.py 项目: geostarling/duct
 def __init__(self, react, path, **kwargs):
     Agent.__init__(self, react, **kwargs)
     self.path = path