bridgedb.distribute

Classes for creating bridge distribution systems.

Inheritance diagram of Distributor

interface IDistribute[source]

Extends: bridgedb.interfaces.IName

An interface specification for a system which distributes bridges.

_bridgesPerResponseMin

The minimum number of bridges to distribute (if possible), per client request.

_bridgesPerResponseMax

The maximum number of bridges to distribute (if possible), per client request.

_hashringLevelMin

The bare minimum number of bridges which should be in a hashring. If there less bridges than this, then the implementer of IDistribute should only distribute _bridgesPerResponseMin number of bridges, per client request.

_hashringLevelMax

The number of bridges which should be in a hashring for the implementer of IDistribute to distribute _bridgesPerResponseMax number of bridges, per client request.

hashring

An implementer of bridgedb.hashring.IHashring which stores the entirety of bridges allocated to this Distributor by the BridgeDB. This Distributor is only capable of distributing these bridges to its clients, and these bridges are only distributable by this Distributor.

key

A master key which is used to HMAC bridge and client data into this Distributor’s hashring and its subhashrings.

__str__()

Get a string representation of this Distributor’s name.

bridgesPerResponse(hashring)

Get the current number of bridges to return in a response.

getBridges(bridgeRequest)

Get bridges based on a client’s bridgeRequest.

class Distributor(key=None)[source]

Bases: bridgedb.interfaces.Named

A Distributor distributes bridges to clients.

Inherit from me to create a new type of Distributor.

Create a new bridge Distributor.

Parameters:key – A master key for this Distributor. This is used to HMAC bridge and client data in order to arrange them into hashring structures.
_bridgesPerResponseMin = 1
_bridgesPerResponseMax = 3
_hashringLevelMin = 20
_hashringLevelMax = 100
hashring

Get this Distributor’s main hashring, which holds all bridges allocated to this Distributor.

Return type:Hashring.
Returns:An implementer of :interface:`~bridgedb.hashring.IHashring`.
name

Get the name of this Distributor.

Return type:str
Returns:A string which identifies this Distributor.
bridgesPerResponse(hashring=None)[source]

Get the current number of bridge to distribute in response to a client’s request for bridges.

getBridges(bridgeRequest)[source]

Get some bridges in response to a client’s bridgeRequest.

Parameters:bridgeRequest (BridgeRequestBase) – A client’s request for bridges, including some information on the client making the request, whether they asked for IPv4 or IPv6 bridges, which type of PluggableTransport they wanted, etc.