Classes for finding and managing lists of open proxies.
downloadTorExits
(proxyList, ipaddress, port=443, protocol=None)[source]¶Run a script which downloads a list of Tor exit relays which allow their clients to exit to the given ipaddress and port.
Parameters: |
|
---|---|
Return type: |
|
Returns: | A deferred which will callback with a list, each item in the list is a string containing an IP of a Tor exit relay. |
loadProxiesFromFile
(filename, proxySet=None, removeStale=False)[source]¶Load proxy IP addresses from a list of files.
Parameters: |
|
---|---|
Returns: | A list of all the proxies listed in the **files* (regardless of whether they were added or removed). |
ProxySet
(proxies={})[source]¶Bases: _abcoll.MutableSet
A collections.MutableSet
for storing validated IP addresses.
Initialise a ProxySet
.
Parameters: | proxies (A tuple, list, dict, or set.) – Optionally, initialise with an iterable,
|
---|
_exitTag
= 'exit_relay'¶A tag to apply to IP addresses within this ProxySet
which are known
Tor exit relays.
proxies
¶All proxies in this set, regardless of tags.
exitRelays
¶Get all proxies in this ProxySet
tagged as Tor exit relays.
Return type: | set |
---|---|
Returns: | A set of all known Tor exit relays which are contained
within this ProxySet . |
addProxies
(proxies, tag=None)[source]¶Add proxies to this set.
This calls add()
for each item in the iterable proxies.
Each proxy, if added, will be tagged with a current timestamp.
Parameters: |
|
---|
addExitRelays
(relays)[source]¶Add proxies to this set.
This calls add()
for each item in the iterable proxies.
Each proxy, if added, will be tagged with a current timestamp.
Parameters: |
|
---|
getTag
(ip)[source]¶Get the tag for an ip in this ProxySet
, if available.
Parameters: | ip (basestring or int) – The IP address to obtain the tag for. |
---|---|
Return type: | None or basestring or int |
Returns: | The tag for that ip, iff ip exists in this
ProxySet and it has a tag. |
getAllWithTag
(tag)[source]¶Get all proxies in this ProxySet
with a given tag.
Parameters: | tag (basestring) – A tag to search for. |
---|---|
Return type: | set |
Returns: | A set of all proxies which are contained within this
ProxySet which are also tagged with
tag. |
firstSeen
(ip)[source]¶Get the timestamp when ip was first seen, if available.
Parameters: | ip (basestring or int) – The IP address to obtain a timestamp for. |
---|---|
Return type: | float or None |
Returns: | The timestamp (in seconds since epoch) if available. Otherwise, returns None. |
isExitRelay
(ip)[source]¶Check if ip
is a known Tor exit relay.
Parameters: | ip (basestring or int) – The IP address to check. |
---|---|
Return type: | boolean |
Returns: | True if ip is a known Tor exit relay; False otherwise. |
replaceProxyList
(proxies, tag=None)[source]¶Clear everything and add all proxies
.
Parameters: | proxies (A tuple, list, dict, or set.) – An iterable. For each
|
---|
_assigned
= ('__name__', '__doc__')¶add
(ip, tag=None)[source]¶Add an ip to this set, with an optional tag.
This has no effect if the ip is already present. The ip is
only added if it passes the checks in
isIPAddress()
.
Parameters: |
|
---|---|
Return type: | |
Returns: |
|
copy
()[source]¶Initialise a ProxySet
.
Parameters: | proxies (A tuple, list, dict, or set.) – Optionally, initialise with an iterable,
|
---|
contains
(ip)[source]¶x.__contains__(y) <==> y in x.
Parameters: | ip (basestring or int) – The IP address to check. |
---|---|
Return type: | boolean |
Returns: | True if ip is in this set; False otherwise. |
discard
(ip)[source]¶Entirely remove ip from this set.
Parameters: | ip (basestring or int) – The IP address to remove. |
---|
remove
(other)[source]¶Entirely remove ip from this set.
Parameters: | ip (basestring or int) – The IP address to remove. |
---|
difference
(other)[source]¶Return the difference of two or more sets as a new set.
(i.e. all elements that are in this set but not the others.)
intersection
(other)[source]¶Return the intersection of two or more sets as a new set.
(i.e. elements that are common to all of the sets.)
symmetric_difference
(other)[source]¶Return the symmetric difference of two sets as a new set.
(i.e. all elements that are in exactly one of the sets.)
union
(other)[source]¶Return the union of sets as a new set.
(i.e. all elements that are in either set.)
_abc_cache
= <_weakrefset.WeakSet object>¶_abc_negative_cache
= <_weakrefset.WeakSet object>¶_abc_negative_cache_version
= 25¶_abc_registry
= <_weakrefset.WeakSet object>¶ExitListProtocol
[source]¶Bases: twisted.internet.protocol.ProcessProtocol
A Protocol
for get-exit-list
.
Attr boolean connected: | |
---|---|
True if our transport is connected. |
|
Attr transport: | If twisted.internet.reactor.spawnProcess() is
called with an instance of this class as it’s protocol , then
spawnProcess() will return this
transport . |
Create a protocol for downloading a list of current Tor exit relays.
Variables: |
|
---|---|
Parameters: | script (string) – The full pathname of the script to run. |
connectionMade
()[source]¶Called when a connection is made.
This may be considered the initializer of the protocol, because it is called when the connection is completed. For clients, this is called once the connection to the server has been established; for servers, this is called after an accept() call stops blocking and a socket has been received. If you need to send any greeting or initial message, do it here.