commit 842da03cdd0cbe424d8aca6e753accf55923b4c8
Author: Damian Johnson <atagar(a)torproject.org>
Date: Sat Jul 4 15:24:38 2015 -0700
Add is_user_traffic_allowed() to the Controller
Simple helper method to help users determine if inbound or outbound connections
are possibly directly servicing users, and by extension private.
---
docs/change_log.rst | 1 +
stem/control.py | 46 ++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 47 insertions(+)
diff --git a/docs/change_log.rst b/docs/change_log.rst
index a6529fd..5eade67 100644
--- a/docs/change_log.rst
+++ b/docs/change_log.rst
@@ -47,6 +47,7 @@ The following are only available within Stem's `git repository
* Dramatic, `300x performance improvement <https://github.com/DonnchaC/stem/pull/1>`_ for reading from the control port with python 3
* :func:`~stem.connection.connect` and :func:`~stem.control.Controller.from_port` now connect to both port 9051 (relay's default) and 9151 (Tor Browser's default) (:trac:`16075`)
* Added `support for NETWORK_LIVENESS events <api/response.html#stem.response.events.NetworkLivenessEvent>`_ (:spec:`44aac63`)
+ * Added :func:`~stem.control.Controller.is_user_traffic_allowed` to the :class:`~stem.control.Controller`
* IPv6 addresses could trigger errors in :func:`~stem.control.Controller.get_listeners`, :class:`~stem.response.events.ORConnEvent`, and quite a few other things (:trac:`16174`)
* Don't obscure stacktraces, most notably :class:`~stem.control.Controller` getter methods with default values
diff --git a/stem/control.py b/stem/control.py
index f08a455..d9693cc 100644
--- a/stem/control.py
+++ b/stem/control.py
@@ -81,6 +81,7 @@ If you're fine with allowing your script to raise exceptions then this can be mo
|- get_protocolinfo - information about the controller interface
|- get_user - provides the user tor is running as
|- get_pid - provides the pid of our tor process
+ |- is_user_traffic_allowed - checks if we send or receive direct user traffic
|
|- get_microdescriptor - querying the microdescriptor for a relay
|- get_microdescriptors - provides all currently available microdescriptors
@@ -380,6 +381,11 @@ AccountingStats = collections.namedtuple('AccountingStats', [
'write_limit',
])
+UserTrafficAllowed = collections.namedtuple('UserTrafficAllowed', [
+ 'inbound',
+ 'outbound',
+])
+
CreateHiddenServiceOutput = collections.namedtuple('CreateHiddenServiceOutput', [
'path',
'hostname',
@@ -1494,6 +1500,46 @@ class Controller(BaseController):
else:
raise ValueError("Unable to resolve tor's pid" if self.is_localhost() else "Tor isn't running locally")
+ def is_user_traffic_allowed(self):
+ """
+ Checks if we're likely to service direct user traffic. This essentially
+ boils down to...
+
+ * If we're a bridge or guard relay, inbound connections are possibly from
+ users.
+
+ * If our exit policy allows traffic then output connections are possibly
+ from users.
+
+ Note the word 'likely'. These is a decent guess in practice, but not always
+ correct. For instance, information about which flags we have are only
+ fetched periodically.
+
+ This method is intended to help you avoid eavesdropping on user traffic.
+ Monitoring user connections is not only unethical, but likely a violation
+ of wiretapping laws.
+
+ .. versionadded:: 1.5.0
+
+ :returns: **namedtuple** with an **inbound** and **outbound** boolean
+ attribute to indicate if we're likely to have user traffic there
+ """
+
+ inbound_allowed, outbound_allowed = False, False
+
+ if self.get_conf('BridgeRelay', None) == '1':
+ inbound_allowed = True
+
+ if self.get_conf('ORPort', None):
+ if not inbound_allowed:
+ consensus_entry = self.get_network_status(default = None)
+ inbound_allowed = consensus_entry and 'Guard' in consensus_entry.flags
+
+ exit_policy = self.get_exit_policy(None)
+ outbound_allowed = exit_policy and exit_policy.is_exiting_allowed()
+
+ return UserTrafficAllowed(inbound_allowed, outbound_allowed)
+
@with_default()
def get_microdescriptor(self, relay = None, default = UNDEFINED):
"""
commit 28cbc64f9098cccf1d74d636bce09d714b35f0a3
Author: Damian Johnson <atagar(a)torproject.org>
Date: Sat Jul 4 15:54:32 2015 -0700
Client usage example didn't work with python3
Good point from Priler that our example should use BytesIO rather than
StringIO to work under python3...
https://trac.torproject.org/projects/tor/ticket/16502
---
docs/_static/example/client_usage_using_pycurl.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/docs/_static/example/client_usage_using_pycurl.py b/docs/_static/example/client_usage_using_pycurl.py
index a15db5e..48ebdac 100644
--- a/docs/_static/example/client_usage_using_pycurl.py
+++ b/docs/_static/example/client_usage_using_pycurl.py
@@ -1,5 +1,5 @@
+import io
import pycurl
-import StringIO
import stem.process
@@ -13,7 +13,7 @@ def query(url):
Uses pycurl to fetch a site using the proxy on the SOCKS_PORT.
"""
- output = StringIO.StringIO()
+ output = io.BytesIO()
query = pycurl.Curl()
query.setopt(pycurl.URL, url)
commit e3831e25e23c85893097f493c08eb210bd7e7b69
Author: Translation commit bot <translation(a)torproject.org>
Date: Sat Jul 4 15:45:07 2015 +0000
Update translations for bridgedb_completed
---
da/LC_MESSAGES/bridgedb.po | 33 +++++++++++++++++----------------
1 file changed, 17 insertions(+), 16 deletions(-)
diff --git a/da/LC_MESSAGES/bridgedb.po b/da/LC_MESSAGES/bridgedb.po
index c647db3..eda484e 100644
--- a/da/LC_MESSAGES/bridgedb.po
+++ b/da/LC_MESSAGES/bridgedb.po
@@ -5,16 +5,16 @@
# Translators:
# Christian Villum <villum(a)autofunk.dk>, 2014-2015
# David Nielsen <gnomeuser(a)gmail.com>, 2014
+# Mogelbjerg <jan(a)mogelbjerg.dk>, 2015
# OliverMller <theoliver(a)live.co.uk>, 2011
# Thomas Pryds <thomas(a)pryds.eu>, 2014
# Tore Bjørnson <tore.bjornson(a)gmail.com>, 2013
msgid ""
msgstr ""
"Project-Id-Version: The Tor Project\n"
-"Report-Msgid-Bugs-To: 'https://trac.torproject.org/projects/tor/newticket?component=BridgeDB&keywo…'\n"
-"POT-Creation-Date: 2015-02-03 03:24+0000\n"
-"PO-Revision-Date: 2015-02-23 06:50+0000\n"
-"Last-Translator: Christian Villum <villum(a)autofunk.dk>\n"
+"Report-Msgid-Bugs-To: 'https://trac.torproject.org/projects/tor/newticket?component=BridgeDB&keywo…'POT-Creation-Date: 2015-03-19 22:13+0000\n"
+"PO-Revision-Date: 2015-07-04 15:32+0000\n"
+"Last-Translator: Mogelbjerg <jan(a)mogelbjerg.dk>\n"
"Language-Team: Danish (http://www.transifex.com/projects/p/torproject/language/da/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
@@ -34,7 +34,7 @@ msgstr ""
#. "fteproxy"
#. "Tor"
#. "Tor Browser"
-#: lib/bridgedb/HTTPServer.py:122
+#: lib/bridgedb/HTTPServer.py:107
msgid "Sorry! Something went wrong with your request."
msgstr "Beklager, noget gik galt med din anmodning."
@@ -205,26 +205,27 @@ msgstr "Sådan starter du med at bruge dine broer"
#: lib/bridgedb/strings.py:121
#, python-format
msgid ""
-"To enter bridges into Tor Browser, follow the instructions on the %s Tor\n"
-"Browser download page %s to start Tor Browser."
-msgstr "For at tilføje broer til Tor Browseren, følg instruktionerne på %s Tor\nBrowserens hjemmeside %s for at starte Tor Browser."
+"To enter bridges into Tor Browser, first go to the %s Tor Browser download\n"
+"page %s and then follow the instructions there for downloading and starting\n"
+"Tor Browser."
+msgstr "For at tage broer ind i Tor-browseren, gå da først til %s Tor-bowsers\ndownloadside %s og følg instruktionerne i hvordan Tor-browseren \ndownloades og startes."
#. TRANSLATORS: Please DO NOT translate "Tor".
-#: lib/bridgedb/strings.py:125
+#: lib/bridgedb/strings.py:126
msgid ""
"When the 'Tor Network Settings' dialogue pops up, click 'Configure' and follow\n"
"the wizard until it asks:"
msgstr "Når 'Tor netværksindstillinger' vinduet popper op, klik 'Indstil' og følg guiden til den siger:"
#. TRANSLATORS: Please DO NOT translate "Tor".
-#: lib/bridgedb/strings.py:129
+#: lib/bridgedb/strings.py:130
msgid ""
"Does your Internet Service Provider (ISP) block or otherwise censor connections\n"
"to the Tor network?"
msgstr "Blokerer eller på anden vis censurerer din internetudbyder forbindelser\ntil Tor netværket?"
#. TRANSLATORS: Please DO NOT translate "Tor".
-#: lib/bridgedb/strings.py:133
+#: lib/bridgedb/strings.py:134
msgid ""
"Select 'Yes' and then click 'Next'. To configure your new bridges, copy and\n"
"paste the bridge lines into the text input box. Finally, click 'Connect', and\n"
@@ -232,29 +233,29 @@ msgid ""
"button in the 'Tor Network Settings' wizard for further assistance."
msgstr "Vælg 'Ja' og klik så på 'Næste'. For at konfigurere dine nye broer, kopier og indsæt brolinierne i den næste input boks. Klik til sidst 'Forbind', og så er du klar! Hvis du støder på problemer, så prøv at klikke på 'Hjælp'-knappen i 'Tor Netværksindstillinger'-guiden for at få yderligere hjælp."
-#: lib/bridgedb/strings.py:141
+#: lib/bridgedb/strings.py:142
msgid "Displays this message."
msgstr "Vis denne besked."
#. TRANSLATORS: Please try to make it clear that "vanilla" here refers to the
#. same non-Pluggable Transport bridges described above as being
#. "plain-ol'-vanilla" bridges.
-#: lib/bridgedb/strings.py:145
+#: lib/bridgedb/strings.py:146
msgid "Request vanilla bridges."
msgstr "Anmod almindelige broer."
-#: lib/bridgedb/strings.py:146
+#: lib/bridgedb/strings.py:147
msgid "Request IPv6 bridges."
msgstr "Amod IPv6 broer."
#. TRANSLATORS: Please DO NOT translate the word the word "TYPE".
-#: lib/bridgedb/strings.py:148
+#: lib/bridgedb/strings.py:149
msgid "Request a Pluggable Transport by TYPE."
msgstr "Anmod om Pluggable Transport efter TYPE."
#. TRANSLATORS: Please DO NOT translate "BridgeDB".
#. TRANSLATORS: Please DO NOT translate "GnuPG".
-#: lib/bridgedb/strings.py:151
+#: lib/bridgedb/strings.py:152
msgid "Get a copy of BridgeDB's public GnuPG key."
msgstr "Hent en kopi af BridgeDB's offentlige GnuPG nøgle."
commit 2be063c9681c1aae56be7643ee060acb11696873
Author: Translation commit bot <translation(a)torproject.org>
Date: Sat Jul 4 15:45:03 2015 +0000
Update translations for bridgedb
---
da/LC_MESSAGES/bridgedb.po | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/da/LC_MESSAGES/bridgedb.po b/da/LC_MESSAGES/bridgedb.po
index 26b322e..eda484e 100644
--- a/da/LC_MESSAGES/bridgedb.po
+++ b/da/LC_MESSAGES/bridgedb.po
@@ -5,6 +5,7 @@
# Translators:
# Christian Villum <villum(a)autofunk.dk>, 2014-2015
# David Nielsen <gnomeuser(a)gmail.com>, 2014
+# Mogelbjerg <jan(a)mogelbjerg.dk>, 2015
# OliverMller <theoliver(a)live.co.uk>, 2011
# Thomas Pryds <thomas(a)pryds.eu>, 2014
# Tore Bjørnson <tore.bjornson(a)gmail.com>, 2013
@@ -12,8 +13,8 @@ msgid ""
msgstr ""
"Project-Id-Version: The Tor Project\n"
"Report-Msgid-Bugs-To: 'https://trac.torproject.org/projects/tor/newticket?component=BridgeDB&keywo…'POT-Creation-Date: 2015-03-19 22:13+0000\n"
-"PO-Revision-Date: 2015-04-19 08:23+0000\n"
-"Last-Translator: runasand <runa.sandvik(a)gmail.com>\n"
+"PO-Revision-Date: 2015-07-04 15:32+0000\n"
+"Last-Translator: Mogelbjerg <jan(a)mogelbjerg.dk>\n"
"Language-Team: Danish (http://www.transifex.com/projects/p/torproject/language/da/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
@@ -207,7 +208,7 @@ msgid ""
"To enter bridges into Tor Browser, first go to the %s Tor Browser download\n"
"page %s and then follow the instructions there for downloading and starting\n"
"Tor Browser."
-msgstr ""
+msgstr "For at tage broer ind i Tor-browseren, gå da først til %s Tor-bowsers\ndownloadside %s og følg instruktionerne i hvordan Tor-browseren \ndownloades og startes."
#. TRANSLATORS: Please DO NOT translate "Tor".
#: lib/bridgedb/strings.py:126