コード例 #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
ファイル: _http.py プロジェクト: prototypefund/leap-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)
コード例 #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
ファイル: _http.py プロジェクト: Lucas-Developer/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 = 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
ファイル: gerrit_agent.py プロジェクト: leiferikb/bitpop
  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
ファイル: agent.py プロジェクト: EricSchles/txtorhttpproxy
    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