[tor-commits] [community/master] the systemd bypass advice applies only if setcap

2020-11-18 Thread phw
commit 935df8b1f5754870c720d6ac8b1e1ab3fce55e97
Author: Roger Dingledine 
Date:   Sun Sep 6 23:50:16 2020 -0400

the systemd bypass advice applies only if setcap

In its current location, the paragraph implies that you need
to turn off NoNewPrivileges in order to run obfsproxy on any port,
and I think you only need to run it if you're using a low port.
---
 .../relay-operations/technical-setup/bridge/debian-ubuntu/contents.lr | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git 
a/content/relay-operations/technical-setup/bridge/debian-ubuntu/contents.lr 
b/content/relay-operations/technical-setup/bridge/debian-ubuntu/contents.lr
index 2633204..c820d2c 100644
--- a/content/relay-operations/technical-setup/bridge/debian-ubuntu/contents.lr
+++ b/content/relay-operations/technical-setup/bridge/debian-ubuntu/contents.lr
@@ -55,12 +55,12 @@ Don't forget to change the `ORPort`, 
`ServerTransportListenAddr`, `ContactInfo`,
 
   `sudo setcap cap_net_bind_service=+ep /usr/bin/obfs4proxy`
 
+  To work around systemd hardening, you will also need to set 
`NoNewPrivileges=no` in `/lib/systemd/system/tor@default.service` and 
`/lib/systemd/system/tor@.service` and then run `systemctl daemon-reload`. For 
more details, see [ticket 
18356](https://gitlab.torproject.org/tpo/core/tor/-/issues/18356).
+
 * Note that both Tor's OR port and its obfs4 port must be reachable.
   If your bridge is behind a firewall or NAT, make sure to open both ports.
   You can use [our reachability test](https://bridges.torproject.org/scan/) to 
see if your obfs4 port is reachable from the Internet.
 
-You will also need to set `NoNewPrivileges=no` in 
`/lib/systemd/system/tor@default.service` and 
`/lib/systemd/system/tor@.service` and then run `systemctl daemon-reload`. (see 
[bug #18356](https://trac.torproject.org/projects/tor/ticket/18356))
-
 ### 4. Restart tor
 
 `systemctl restart tor`

___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [bridgedb/develop] Merge branch 'master' into 'develop'

2020-07-15 Thread phw
commit 8e7c77a6c1455793e2a127a4214d739b313f88e6
Merge: bd8b379 886f396
Author: Philipp Winter 
Date:   Wed Jul 15 21:35:47 2020 +

Merge branch 'master' into 'develop'

Update bridgedb-metrics spec to align with version 2 of the metrics format 
and...

See merge request tpo/anti-censorship/bridgedb!9

 doc/bridgedb-metrics-spec.txt | 16 
 1 file changed, 12 insertions(+), 4 deletions(-)

___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [bridgedb/develop] Align bridgedb-metrics spec with latest format.

2020-07-15 Thread phw
commit 886f3969154fdf17d50637aee751276bae34483c
Author: hanneloresx 
Date:   Sun Jul 12 21:54:33 2020 -0400

Align bridgedb-metrics spec with latest format.

Update bridgedb-metrics spec to align with version 2 of the metrics
format and provide more information on internal metrics.
---
 doc/bridgedb-metrics-spec.txt | 16 
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/doc/bridgedb-metrics-spec.txt b/doc/bridgedb-metrics-spec.txt
index aac838a..9a51926 100644
--- a/doc/bridgedb-metrics-spec.txt
+++ b/doc/bridgedb-metrics-spec.txt
@@ -25,10 +25,10 @@ file is formatted as follows:
 
   VERSION determines the version of the metrics format.  As the
   format changes over time, we will increment VERSION.  The latest
-  version is 1 -- the first iteration of the metrics format.
+  version is 2 -- the second iteration of the metrics format.
 
   Example:
-bridgedb-metrics-version 1
+bridgedb-metrics-version 2
 
   "bridgedb-metric-count" METRIC_KEY COUNT NL
   [Any number.]
@@ -75,11 +75,16 @@ file is formatted as follows:
 
   Strings in between quotes (e.g., "handouts") are literals and show up in
   the hierarchy as is.  Upper-case strings (e.g., TRANSPORT) are
-  placeholders, which are explained below.
+  placeholders, which are explained below.  The internal.handouts 
+  metrics provide statistics on how often a given bridge was handed out 
+  during the measurement interval. Bridges that were not handed out will 
+  not be part of these metrics.
 
   TRANSPORT refers to a pluggable transport protocol.  This includes
   "obfs2", "obfs3", "obfs4", "scramblesuit", and "fte".  These
-  pluggable transports will change in the future.
+  pluggable transports will change in the future.  This field also 
includes 
+  "unallocated" when reporting internal metrics to report on bridges left 
+  unallocated as configured.
 
   CC refers to a two-letter country code of the user's IP address.  We use
   two reserved country codes, "??" and "zz".  "??" denotes that we couldn't
@@ -91,6 +96,9 @@ file is formatted as follows:
 
   The field RESERVED is reserved for an anomaly score.  It is currently set
   to "none" and should be ignored by implementations.
+  
+  SUBRING refers to a subring of a hashring that bridges are arranged into 
+  during distribution.
 
   COUNT is the approximate number of user requests for the given
   METRIC_KEY.  We round up the number of requests to the next



___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [bridgedb/develop] Only process text/plain part of emails.

2020-07-13 Thread phw
commit 61e63879157343571f89ec02e0e21dd19e270e64
Author: Philipp Winter 
Date:   Mon Jun 1 15:12:34 2020 -0700

Only process text/plain part of emails.

When our autoresponder receives a multipart email from a user, it may
get confused by the parts that are not text/plain.  Instead of bending
over backwards to parse all sorts email encodings, this patch discard
the parts of a multipart email that aren't text/plain.

This fixes tpo/anti-censorship/bridgedb#33835.
---
 CHANGELOG |  4 +++
 bridgedb/distributors/email/server.py | 18 +-
 bridgedb/test/test_email_server.py| 63 +++
 3 files changed, 84 insertions(+), 1 deletion(-)

diff --git a/CHANGELOG b/CHANGELOG
index 860cbda..ad20b91 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,7 @@
+* FIXES 
https://gitlab.torproject.org/tpo/anti-censorship/bridgedb/-/issues/33835
+If a user sends a multipart email to our autoresponder, we now only parse
+the part that has a text/plain encoding.
+
 * FIXES https://bugs.torproject.org/33647
 Fix broken link in the README and fix our Makefile's pylint target.
 
diff --git a/bridgedb/distributors/email/server.py 
b/bridgedb/distributors/email/server.py
index 54a8231..b2baf86 100644
--- a/bridgedb/distributors/email/server.py
+++ b/bridgedb/distributors/email/server.py
@@ -50,6 +50,7 @@ Servers which interface with clients and distribute bridges 
over SMTP.
 from __future__ import unicode_literals
 
 import email.message
+import email.policy
 import logging
 import io
 import socket
@@ -228,6 +229,20 @@ class SMTPMessage(object):
 if not self.ignoring:
 self.message = self.getIncomingMessage()
 self.responder.reply()
+
+# If a user sends a multipart email, we only consider the part whose
+# content type is text/plain.
+if self.message.is_multipart():
+has_plaintext = False
+for part in self.message.get_payload():
+if part.get_content_type() != "text/plain":
+continue
+self.lines = part.get_payload().split("\n")
+has_plaintext = True
+
+if not has_plaintext:
+logging.warning("User email had no text/plain content type.")
+
 return defer.succeed(None)
 
 def connectionLost(self):
@@ -242,7 +257,8 @@ class SMTPMessage(object):
 :returns: A ``Message`` comprised of all lines received thus far.
 """
 
-return email.message_from_string('\n'.join(self.lines))
+return email.message_from_string('\n'.join(self.lines),
+ policy=email.policy.compat32)
 
 
 @implementer(smtp.IMessageDelivery)
diff --git a/bridgedb/test/test_email_server.py 
b/bridgedb/test/test_email_server.py
index fb82cc0..e0aee18 100644
--- a/bridgedb/test/test_email_server.py
+++ b/bridgedb/test/test_email_server.py
@@ -100,6 +100,69 @@ class SMTPMessageTests(unittest.TestCase):
 self.assertIsInstance(self.message.getIncomingMessage(),
   email.message.Message)
 
+def test_SMTPMessage_multipart1(self):
+"""`eomReceived` should get rid of HTML multiparts."""
+
+# Gmail's web interface would send a message like this when replying to
+# one of BridgeDB's emails.
+multipartEmail = [
+'MIME-Version: 1.0',
+'Date: Mon, 1 Jun 2020 15:55:33 -0700',
+'Subject: Re: test',
+'From: Foo Bar ',
+'To: brid...@bridges.torproject.org',
+'Content-Type: multipart/alternative; 
boundary="41b34105a70db186"',
+'',
+'--41b34105a70db186',
+'Content-Type: text/plain; charset="UTF-8"',
+'',
+'This is plaintext.',
+'',
+'--41b34105a70db186',
+'Content-Type: text/html; charset="UTF-8"',
+'Content-Transfer-Encoding: quoted-printable',
+'',
+'This is HTML.',
+'',
+'--41b34105a70db186--']
+
+for line in multipartEmail:
+self.message.lineReceived(line)
+self.message.eomReceived()
+content = "".join(self.message.lines)
+self.assertTrue("This is plaintext." in content)
+self.assertFalse("This is HTML." in content)
+
+def test_SMTPMessage_multipart2(self):
+"""`eomReceived` should get rid of HTML multiparts."""
+
+# Outlook would send a message like this when replying to one of
+# BridgeDB's emails.
+multipartEmail = [
+'Content-Type: multipart/alternative;',
+'  
boundary="_000_VI1PR08MB4351A21D6C4A31C2B0FDA34F8CC10VI1PR08MB4351eurp_"',
+'',
+'--_000_VI1PR08MB4351A21D6C4A31C2B0FDA34F8CC10VI1PR08MB4351eurp_',
+'Content-Type: text/plain; charset="us-ascii"',
+'Content-Transfer-Encoding: quoted-printable',
+   

[tor-commits] [bridgedb/develop] Merge branch 'defect/33835' into 'develop'

2020-07-13 Thread phw
commit bd8b3796d9622101630687690ce672ec147ed21f
Merge: 95ee763 61e6387
Author: Philipp Winter 
Date:   Tue Jul 14 02:22:18 2020 +

Merge branch 'defect/33835' into 'develop'

Only process text/plain part of emails.

See merge request tpo/anti-censorship/bridgedb!10

 CHANGELOG |  4 +++
 bridgedb/distributors/email/server.py | 18 +-
 bridgedb/test/test_email_server.py| 63 +++
 3 files changed, 84 insertions(+), 1 deletion(-)

___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [bridgedb/develop] Make init hook compatible with Python 3.

2020-07-13 Thread phw
commit 04fd047378022592306b76b5a68ddf8fd2df39a0
Author: Philipp Winter 
Date:   Tue Jun 16 10:00:34 2020 -0700

Make init hook compatible with Python 3.

Running `make pylint` now works again.

This fixes issue #33647.
---
 .pylintrc | 2 +-
 CHANGELOG | 3 +++
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/.pylintrc b/.pylintrc
index 8bf60a0..5532cd7 100644
--- a/.pylintrc
+++ b/.pylintrc
@@ -6,7 +6,7 @@
 # Python code to execute, usually for sys.path manipulation such as
 # pygtk.require().
 #init-hook='import sys,os; venv = os.environ.get("VIRTUAL_ENV"); v = 
os.path.join(venv, "lib", "python" + str(sys.version_info.major) + "." + 
str(sys.version_info.micro), "site-packages") if venv is not None else None; 
sys.path.insert(0, v);'
-init-hook="import sys,os;a=os.getcwd();print a;sys.path.insert(0, a));"
+init-hook="import sys,os;a=os.getcwd();print(a);sys.path.insert(0, a);"
 
 # Profiled execution.
 profile=no
diff --git a/CHANGELOG b/CHANGELOG
index 1e6e730..860cbda 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,6 @@
+* FIXES https://bugs.torproject.org/33647
+Fix broken link in the README and fix our Makefile's pylint target.
+
 Changes in version 0.11.0 - 2020-07-08
 
 * FIXES https://bugs.torproject.org/31422



___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [bridgedb/develop] Changed the address to get-pip.py

2020-07-13 Thread phw
commit 4a649fe6bc8e4f2f2864f9187961587a7bc2bb3b
Author: agix 
Date:   Wed Apr 1 12:36:20 2020 +0200

Changed the address to get-pip.py

Signed-off-by: Philipp Winter 
---
 README.rst | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/README.rst b/README.rst
index a06c2cd..559f5e4 100644
--- a/README.rst
+++ b/README.rst
@@ -110,9 +110,9 @@ BridgeDB should work with or without a Python virtualenv.
 -  Install Pip 1.3.1 or later. Debian has this version, but if for some
reason that or a newer version isn't available, the easiest way to
install a newer Pip is to use the Pip development teams's `getpip
-   script `__::
+   script `__::
 
- wget https://raw.github.com/pypa/pip/master/contrib/get-pip.py
+ wget https://bootstrap.pypa.io/get-pip.py
  sudo python get-pip.py
 
 



___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [bridgedb/develop] Merge branch 'issue-33647' into 'develop'

2020-07-13 Thread phw
commit 95ee763cd5cb7761dd639b388541661c93e690d0
Merge: fb3cfa7 04fd047
Author: Philipp Winter 
Date:   Tue Jul 14 01:55:53 2020 +

Merge branch 'issue-33647' into 'develop'

Issue 33647

See merge request tpo/anti-censorship/bridgedb!5

 .pylintrc  | 2 +-
 CHANGELOG  | 3 +++
 README.rst | 4 ++--
 3 files changed, 6 insertions(+), 3 deletions(-)

___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [community/master] Add bridge deploy for windows

2020-07-09 Thread phw
commit e51d8af9fa0628b1c58f0b96cb11d3878609188d
Author: Nicolei Ocana 
Date:   Mon Jun 1 02:36:07 2020 +

Add bridge deploy for windows
---
 .../technical-setup/bridge/windows/contents.lr | 105 +
 1 file changed, 105 insertions(+)

diff --git 
a/content/relay-operations/technical-setup/bridge/windows/contents.lr 
b/content/relay-operations/technical-setup/bridge/windows/contents.lr
new file mode 100644
index 000..6f1e088
--- /dev/null
+++ b/content/relay-operations/technical-setup/bridge/windows/contents.lr
@@ -0,0 +1,105 @@
+_model: page
+---
+color: primary
+---
+title: Windows
+---
+html: two-columns-page.html
+---
+key: 10
+---
+body:
+
+### 1. Download the Windows Expert Bundle and the Tor Browser
+
+* [Windows Expert 
Bundle](https://www.torproject.org/dist/torbrowser/9.0.10/tor-win32-0.4.2.7.zip).
 Unzip the contents on the desktop.
+
+* [Tor Browser](https://www.torproject.org/download/#windows). Run the `.exe` 
and install with default settings.
+
+**Note: You will need to show hidden items and file name extensions. In your 
Explorer window, in the top-left, click on the View tab. In the Show/hide 
section furthest to the right, check the checkbox for Hidden items; check the 
checkbox for File name extensions.**
+
+### 2. Build files and relocate 
+
+Open up the Tor folder on your desktop. Double click `tor.exe`. Once the 
command prompt reads: `[notice] Bootstrapped 100% (done): Done`, close the 
window. This creates the folder `C:\Users\\AppData\Roaming\tor\` (where 
`` is your user name).
+
+From the Tor folder on your desktop, select all `.dll`'s and `.exe`'s and 
cut/paste them into the `C:\Users\\AppData\Roaming\tor\` folder.
+
+Open up the Data folder on your desktop. Inside that Tor folder, select both 
`geoip` and `geoip6` and cut/paste them into the 
`C:\Users\\AppData\Roaming\tor\` folder.
+
+Navigate to `C:\Users\\Desktop\Tor 
Browser\Browser\TorBrowser\Tor\PluggableTransports`. Select `obfs4proxy.exe` 
and cut/paste it into the `C:\Users\\AppData\Roaming\tor\` folder.
+
+### 3. Create and edit your Tor config file
+
+In the `C:\Users\\AppData\Roaming\tor\` folder, right-click on white 
space and select `New > Text Document`. Name the file `torrc`; there is no 
extension.
+
+Double-click on the `torrc` file. When prompted *How do you want to open this 
file?*, select `Notepad`. Add the following:
+
+```
+Log notice file C:\Users\\AppData\Roaming\tor\notice.log
+GeoIPFile C:\Users\\AppData\Roaming\tor\geoip
+GeoIPv6File C:\Users\\AppData\Roaming\tor\geoip6
+
+BridgeRelay 1
+
+# Replace "TODO1" with a Tor port of your choice.
+# This port must be externally reachable.
+# Avoid port 9001 because it's commonly associated with Tor and censors may be 
scanning the Internet for this port.
+ORPort TODO1
+
+ServerTransportPlugin obfs4 exec 
C:\Users\\AppData\Roaming\tor\obfs4proxy.exe
+
+# Replace "TODO2" with an obfs4 port of your choice.
+# This port must be externally reachable and must be different from the one 
specified for ORPort.
+# Avoid port 9001 because it's commonly associated with Tor and censors may be 
scanning the Internet for this port.
+ServerTransportListenAddr obfs4 0.0.0.0:TODO2
+
+# Local communication port between Tor and obfs4.  Always set this to "auto".
+# "Ext" means "extended", not "external".  Don't try to set a specific port 
number, nor listen on 0.0.0.0.
+ExtORPort auto
+
+# Replace "" with your email address so we can contact you 
if there are problems with your bridge.
+# This is optional but encouraged.
+ContactInfo 
+
+# Pick a nickname that you like for your bridge.  This is optional.
+Nickname PickANickname
+```
+
+Don't forget to change the `ORPort`, `ServerTransportListenAddr`, 
`ContactInfo`, ``, and `Nickname` options.
+
+* Use a fixed obfs4 port larger than 1024, still avoiding 9001.
+
+* Note that both Tor's OR port and its obfs4 port must be reachable.
+  If your bridge is behind a firewall or NAT, make sure to open both ports.
+  You can use [our reachability test](https://bridges.torproject.org/scan/) to 
see if your obfs4 port is reachable from the Internet.
+
+### 4. Start tor
+
+Open up the Command Prompt App. Change your directory with: `cd 
C:\Users\\AppData\Roaming\tor\`. Type: `tor.exe -f torrc`.
+
+### 5. Monitor your logs
+
+To confirm your bridge is running with no issues, you should see something 
like this in `C:\Users\\AppData\Roaming\tor\notice.log`.
+
+```
+[notice] Your Tor server's identity key fingerprint is ' 
'
+[notice] Your Tor bridge's hashed identity key fingerprint is ' 
'
+[notice] Registered server transport 'obfs4' at '[::]:46396'
+[notice] Tor has successfully opened a circuit. Looks like client 
functionality is working.
+[notice] Bootstrapped 100%: Done
+[notice] Now checking whether ORPort :3818 is reachable... (this may 
take up to 20 minutes -- look for log messages indicating success)
+[notice] Self-testing indicates your ORPort is reachable from the outside. 
Excellent. 

[tor-commits] [community/master] Merge branch 'windows-bridge' of github.com:nicoleiocana/community into windows-bridge

2020-07-09 Thread phw
commit 7a69881b47c74f796806b153343129d51cfa7249
Merge: 6ce05bb ec8fbba
Author: Philipp Winter 
Date:   Thu Jul 9 10:58:52 2020 -0700

Merge branch 'windows-bridge' of github.com:nicoleiocana/community into 
windows-bridge

 .../technical-setup/bridge/windows/contents.lr | 107 +
 1 file changed, 107 insertions(+)

___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [bridgedb/master] Merge branch 'enhancement/34260' into 'develop'

2020-07-08 Thread phw
commit ada3bdca87ff853a55e602beeffb4699ba9b2250
Merge: d8b73ec 5e0ed0a
Author: Philipp Winter 
Date:   Wed Jul 8 20:23:53 2020 +

Merge branch 'enhancement/34260' into 'develop'

Parse bridge blocking info from SQL database.

See merge request tpo/anti-censorship/bridgedb!7

 CHANGELOG |   3 +
 bridgedb/Storage.py   | 138 -
 bridgedb/main.py  |  26 +++
 bridgedb/test/test_Storage.py | 157 ++
 4 files changed, 321 insertions(+), 3 deletions(-)



___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [bridgedb/master] Merge branch 'enhancement/29184' into 'develop'

2020-07-08 Thread phw
commit 28c5479c455a499e4ac77203920dc8cc62981d29
Merge: 6d3e899 8d169fc
Author: Philipp Winter 
Date:   Tue Jun 23 23:08:36 2020 +

Merge branch 'enhancement/29184' into 'develop'

Avoid giving out bridges with broken tor versions.

See merge request tpo/anti-censorship/bridgedb!3

 CHANGELOG |  5 +
 bridgedb.conf | 10 ++
 bridgedb/bridges.py   | 15 +++
 bridgedb/main.py  |  7 +++
 bridgedb/parse/versions.py| 29 +
 bridgedb/test/test_bridges.py | 27 +++
 6 files changed, 93 insertions(+)



___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [bridgedb/master] Make BridgeDB export internal metrics.

2020-07-08 Thread phw
commit ce32921680158e8d977f72c16f05de1f9f69cc85
Author: Philipp Winter 
Date:   Mon Dec 2 15:23:25 2019 -0800

Make BridgeDB export internal metrics.

BridgeDB already exports usage metrics that help us understand how our
users interact with BridgeDB.  This commit adds internal metrics, which
shed light on BridgeDB's internals.  In particular, we add the following
internal metrics:

* Number of bridges per distributor subring.

* Number of empty responses per distributor.

* Number of IPv4/IPv6 handouts.

* Descriptive statistics on the number of bridge handouts (min, max,
  median, quartile 1, quartile 3, upper whisker, lower whisker).

* Number of unique bridges that were handed out.

This patch fixes tpo/anti-censorship/bridgedb#31422 and also bumps
BridgeDB's metrics format to version 2.
---
 CHANGELOG  |   4 +
 bridgedb/distributors/email/autoresponder.py   |  12 +-
 bridgedb/distributors/https/server.py  |  22 ++-
 bridgedb/distributors/moat/server.py   |  47 --
 bridgedb/main.py   |  17 +++
 bridgedb/metrics.py| 199 ++---
 bridgedb/test/test_distributors_moat_server.py |   8 +-
 bridgedb/test/test_metrics.py  | 132 
 doc/bridgedb-metrics-spec.txt  |  92 
 requirements.txt   |   1 +
 10 files changed, 455 insertions(+), 79 deletions(-)

diff --git a/CHANGELOG b/CHANGELOG
index 10012ce..8939ac4 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,7 @@
+* FIXES https://bugs.torproject.org/31422
+Make BridgeDB report internal metrics, like the median number of users that
+bridges were handed out to.
+
 * FIXES https://bugs.torproject.org/34260
 Parse bridge blocking information from SQL database.
 
diff --git a/bridgedb/distributors/email/autoresponder.py 
b/bridgedb/distributors/email/autoresponder.py
index 9b0ac53..94a8f75 100644
--- a/bridgedb/distributors/email/autoresponder.py
+++ b/bridgedb/distributors/email/autoresponder.py
@@ -62,9 +62,10 @@ from bridgedb.parse.addr import canonicalizeEmailDomain
 from bridgedb.util import levenshteinDistance
 from bridgedb import translations
 
-# We use our metrics singleton to keep track of BridgeDB metrics such as
+# We use our metrics singletons to keep track of BridgeDB metrics such as
 # "number of failed HTTPS bridge requests."
-metrix = metrics.EmailMetrics()
+emailMetrix = metrics.EmailMetrics()
+internalMetrix = metrics.InternalMetrics()
 
 
 def createResponseBody(lines, context, client, lang='en'):
@@ -113,6 +114,9 @@ def createResponseBody(lines, context, client, lang='en'):
 transport = bridgeRequest.justOnePTType()
 answer = "".join("  %s\r\n" % b.getBridgeLine(
 bridgeRequest, context.includeFingerprints) for b in bridges)
+internalMetrix.recordHandoutsPerBridge(bridgeRequest, bridges)
+else:
+internalMetrix.recordEmptyEmailResponse()
 return templates.buildAnswerMessage(translator, client, answer)
 
 def generateResponse(fromAddress, client, body, subject=None,
@@ -396,9 +400,9 @@ class SMTPAutoresponder(smtp.SMTPClient):
 # request.
 translator = translations.installTranslations(lang)
 if body is not None and translator.gettext(strings.EMAIL_MISC_TEXT[1]) 
in body:
-metrix.recordValidEmailRequest(self)
+emailMetrix.recordValidEmailRequest(self)
 else:
-metrix.recordInvalidEmailRequest(self)
+emailMetrix.recordInvalidEmailRequest(self)
 
 if not body: return  # The client was already warned.
 
diff --git a/bridgedb/distributors/https/server.py 
b/bridgedb/distributors/https/server.py
index 91757e7..fd3fc74 100644
--- a/bridgedb/distributors/https/server.py
+++ b/bridgedb/distributors/https/server.py
@@ -90,9 +90,10 @@ logging.debug("Set template root to %s" % TEMPLATE_DIR)
 #: A list of supported language tuples. Use getSortedLangList() to read this 
variable.
 supported_langs = []
 
-# We use our metrics singleton to keep track of BridgeDB metrics such as
+# We use our metrics singletons to keep track of BridgeDB metrics such as
 # "number of failed HTTPS bridge requests."
-metrix = metrics.HTTPSMetrics()
+httpsMetrix = metrics.HTTPSMetrics()
+internalMetrix = metrics.InternalMetrics()
 
 
 def stringifyRequestArgs(args):
@@ -574,7 +575,7 @@ class CaptchaProtectedResource(CustomErrorHandlingResource, 
CSPResource):
 
 try:
 if self.checkSolution(request) is True:
-metrix.recordValidHTTPSRequest(request)
+httpsMetrix.recordValidHTTPSRequest(request)
 return self.resource.render(request)
 except ValueError as err:
 logging.debug(str(err))
@@ -584,14 +585,14 @@ class 

[tor-commits] [bridgedb/master] Merge branch 'release-0.11.0'

2020-07-08 Thread phw
commit fb3cfa7edca3db9387bfa999efaa7021d9ce9de2
Merge: c45439c bd32dd7
Author: Philipp Winter 
Date:   Wed Jul 8 14:03:47 2020 -0700

Merge branch 'release-0.11.0'

 CHANGELOG  |  20 +++
 README.rst |  20 +--
 bridgedb.conf  |  10 ++
 bridgedb/Storage.py| 138 +-
 bridgedb/bridges.py|  15 ++
 bridgedb/distributors/email/autoresponder.py   |  12 +-
 bridgedb/distributors/https/server.py  |  22 ++-
 .../https/templates/assets/images/favicon.ico  | Bin 0 -> 4286 bytes
 bridgedb/distributors/https/templates/base.html|   1 +
 bridgedb/distributors/moat/server.py   |  47 +++--
 bridgedb/main.py   |  50 ++
 bridgedb/metrics.py| 199 ++---
 bridgedb/parse/options.py  |   2 -
 bridgedb/parse/versions.py |  29 +++
 bridgedb/test/test_Storage.py  | 157 
 bridgedb/test/test_bridges.py  |  27 +++
 bridgedb/test/test_distributors_moat_server.py |   8 +-
 bridgedb/test/test_metrics.py  | 132 ++
 doc/bridgedb-metrics-spec.txt  |  92 +++---
 requirements.txt   |   1 +
 setup.py   |   3 +-
 21 files changed, 885 insertions(+), 100 deletions(-)

___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [bridgedb/master] Merge branch 'bug/40002' into 'develop'

2020-07-08 Thread phw
commit d8b73ecd65664bf60f61a72b3fb4e233663a6bee
Merge: 387f2b4 c2f4661
Author: Philipp Winter 
Date:   Tue Jul 7 16:21:07 2020 +

Merge branch 'bug/40002' into 'develop'

Remove coverage and pypi link; update Travis CI.

See merge request tpo/anti-censorship/bridgedb!6

 README.rst | 16 +---
 1 file changed, 5 insertions(+), 11 deletions(-)



___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [bridgedb/master] Avoid giving out bridges with broken tor versions.

2020-07-08 Thread phw
commit 8d169fc45c8cfd7c8c9028d125bff4dbb3afafc6
Author: Philipp Winter 
Date:   Fri Jun 12 10:05:26 2020 -0700

Avoid giving out bridges with broken tor versions.

This patch makes BridgeDB avoid giving out bridges that are affected by
the following bug: 

This fixes .
---
 CHANGELOG |  5 +
 bridgedb.conf | 10 ++
 bridgedb/bridges.py   | 15 +++
 bridgedb/main.py  |  7 +++
 bridgedb/parse/versions.py| 29 +
 bridgedb/test/test_bridges.py | 27 +++
 6 files changed, 93 insertions(+)

diff --git a/CHANGELOG b/CHANGELOG
index 754e2f0..c712436 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,8 @@
+* FIXES https://bugs.torproject.org/29184
+Add a new configuration option, BLACKLISTED_TOR_VERSIONS, which contains a
+list of Tor versions.  BridgeDB won't hand out bridges whose Tor version
+is present in this blacklist.
+
 * FIXES https://bugs.torproject.org/19774
 Add a favicon to BridgeDB's web UI.
 
diff --git a/bridgedb.conf b/bridgedb.conf
index 31eb3fa..6d4839d 100644
--- a/bridgedb.conf
+++ b/bridgedb.conf
@@ -309,6 +309,16 @@ DEFAULT_TRANSPORT = 'obfs4'
 #   Accept-Language,[Kk]lingon
 BLACKLISTED_REQUEST_HEADERS_FILE="blacklisted-request-headers.csv"
 
+# List of tuples that specify blacklisted tor version ranges.  The first
+# element marks the start of the range and the second element marks the end.
+# Both the start *and* the end version are blocked too.  If you want to block a
+# single version, have the start and end range be identical.  BridgeDB won't
+# distribute bridges whose version falls within any version ranges.
+BLACKLISTED_TOR_VERSIONS = [
+('0.3.4', '0.3.4.9'), # See .
+('0.3.5', '0.3.5.6')
+]
+
 # Decoy bridges that we are handing out to bots that we detected using the
 # regular expressions in BLACKLISTED_REQUEST_HEADERS_FILE.  The CSV file must
 # have the following format:
diff --git a/bridgedb/bridges.py b/bridgedb/bridges.py
index cd01948..6ec864d 100644
--- a/bridgedb/bridges.py
+++ b/bridgedb/bridges.py
@@ -1825,3 +1825,18 @@ class Bridge(BridgeBackwardsCompatibility):
 logging.info("Removing dead transport for bridge %s: %s %s:%s %s" %
  (self, pt.methodname, pt.address, pt.port, 
pt.arguments))
 self.transports.remove(pt)
+
+def runsVersion(self, version_tuples):
+"""Return ``True`` if this bridge runs any of the given versions.
+
+:param list version_tuples: A list of tuples that contain a minimum and
+maximum version number (as :class:`stem.version.Version` objects),
+each.
+:rtype: bool
+:returns: ``True`` if this bridge runs any of the given Tor versions
+and ``False`` otherwise.
+"""
+for min_version, max_version in version_tuples:
+if min_version <= self.software <= max_version:
+return True
+return False
diff --git a/bridgedb/main.py b/bridgedb/main.py
index 70001a9..44d0668 100644
--- a/bridgedb/main.py
+++ b/bridgedb/main.py
@@ -38,6 +38,7 @@ from bridgedb.distributors.https.distributor import 
HTTPSDistributor
 from bridgedb.distributors.moat.distributor import MoatDistributor
 from bridgedb.parse import descriptors
 from bridgedb.parse.blacklist import parseBridgeBlacklistFile
+from bridgedb.parse.versions import parseVersionsList
 
 import bridgedb.Storage
 
@@ -211,6 +212,10 @@ def load(state, hashring, clear=False):
 elif bridge in blacklist.keys():
 logging.warn("Not distributing blacklisted Bridge %s %s:%s: 
%s" %
  (bridge, bridge.address, bridge.orPort, 
blacklist[bridge]))
+# Skip bridges that are running a blacklisted version of Tor.
+elif bridge.runsVersion(state.BLACKLISTED_TOR_VERSIONS):
+logging.warn("Not distributing bridge %s because it runs 
blacklisted "
+ "Tor version %s." % (router.fingerprint, 
bridge.software))
 else:
 # If the bridge is not running, then it is skipped during the
 # insertion process.
@@ -418,6 +423,8 @@ def run(options, reactor=reactor):
 proxy.loadProxiesFromFile(proxyfile, proxies, removeStale=True)
 metrics.setProxies(proxies)
 
+state.BLACKLISTED_TOR_VERSIONS = 
parseVersionsList(state.BLACKLISTED_TOR_VERSIONS)
+
 logging.info("Reloading blacklisted request headers...")
 
antibot.loadBlacklistedRequestHeaders(config.BLACKLISTED_REQUEST_HEADERS_FILE)
 logging.info("Reloading decoy bridges...")
diff --git a/bridgedb/parse/versions.py b/bridgedb/parse/versions.py
index 335e04c..832969e 100644
--- a/bridgedb/parse/versions.py
+++ 

[tor-commits] [bridgedb/master] Merge branch 'enhancement/19774' into develop

2020-07-08 Thread phw
commit 6d3e899925854b0994d66551fef25678e6f36561
Merge: c45439c 20f1049
Author: Philipp Winter 
Date:   Thu Jun 4 14:05:25 2020 -0700

Merge branch 'enhancement/19774' into develop

 CHANGELOG|   3 +++
 .../https/templates/assets/images/favicon.ico| Bin 0 -> 4286 bytes
 bridgedb/distributors/https/templates/base.html  |   1 +
 setup.py |   3 ++-
 4 files changed, 6 insertions(+), 1 deletion(-)



___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [bridgedb/master] Merge branch 'enhancement/31422' into 'develop'

2020-07-08 Thread phw
commit 35f1be4cee661fb6a23e37cc102379dace3dbc5e
Merge: ada3bdc ce32921
Author: Philipp Winter 
Date:   Wed Jul 8 20:52:39 2020 +

Merge branch 'enhancement/31422' into 'develop'

Make BridgeDB export internal metrics.

See merge request tpo/anti-censorship/bridgedb!8

 CHANGELOG  |   4 +
 bridgedb/distributors/email/autoresponder.py   |  12 +-
 bridgedb/distributors/https/server.py  |  22 ++-
 bridgedb/distributors/moat/server.py   |  47 --
 bridgedb/main.py   |  17 +++
 bridgedb/metrics.py| 199 ++---
 bridgedb/test/test_distributors_moat_server.py |   8 +-
 bridgedb/test/test_metrics.py  | 132 
 doc/bridgedb-metrics-spec.txt  |  92 
 requirements.txt   |   1 +
 10 files changed, 455 insertions(+), 79 deletions(-)



___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [bridgedb/master] Remove the --reload command line switch.

2020-07-08 Thread phw
commit 2351f8652bb99b908c36957edee1585319ff6fcb
Author: Philipp Winter 
Date:   Thu Jul 2 10:53:28 2020 -0700

Remove the --reload command line switch.

This fixes tpo/anti-censorship/bridgedb#40001.
---
 CHANGELOG | 3 +++
 README.rst| 4 
 bridgedb/parse/options.py | 2 --
 3 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/CHANGELOG b/CHANGELOG
index c712436..0351de7 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,6 @@
+* FIXES 
https://gitlab.torproject.org/tpo/anti-censorship/bridgedb/-/issues/40001
+Remove the --reload command line switch.  It doesn't actually do anything.
+
 * FIXES https://bugs.torproject.org/29184
 Add a new configuration option, BLACKLISTED_TOR_VERSIONS, which contains a
 list of Tor versions.  BridgeDB won't hand out bridges whose Tor version
diff --git a/README.rst b/README.rst
index 1b0a840..51eff40 100644
--- a/README.rst
+++ b/README.rst
@@ -318,10 +318,6 @@ Reloading Bridges From Their Descriptor Files:
 When you have new lists of bridges from the Bridge Authority, replace
 the old files and do::
 
-  bridgedb --reload
-
-Or just give it a SIGHUP::
-
   kill -s SIGHUP `cat .../run/bridgedb.pid`
 
 
diff --git a/bridgedb/parse/options.py b/bridgedb/parse/options.py
index c32ada3..83c0984 100644
--- a/bridgedb/parse/options.py
+++ b/bridgedb/parse/options.py
@@ -290,8 +290,6 @@ class SIGUSR1Options(BaseOptions):
 class MainOptions(BaseOptions):
 """Main commandline options parser for BridgeDB."""
 
-optFlags = [
-['reload', 'R', 'Reload bridge descriptors into running servers']]
 subCommands = [
 ['mock', None, MockOptions, "Generate a testing environment"],
 ['SIGHUP', None, SIGHUPOptions,



___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [bridgedb/master] Merge branch 'bug/40001' into 'develop'

2020-07-08 Thread phw
commit 387f2b403abf5ad1a4bec8f8132de5589ecdde23
Merge: 28c5479 2351f86
Author: Philipp Winter 
Date:   Tue Jul 7 16:02:06 2020 +

Merge branch 'bug/40001' into 'develop'

Remove the --reload command line switch.

See merge request tpo/anti-censorship/bridgedb!4

 CHANGELOG | 3 +++
 README.rst| 4 
 bridgedb/parse/options.py | 2 --
 3 files changed, 3 insertions(+), 6 deletions(-)



___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [bridgedb/master] Bump version number to 0.11.0.

2020-07-08 Thread phw
commit bd32dd76ba840ce18a80a4863dda7cf540632f1c
Author: Philipp Winter 
Date:   Wed Jul 8 14:03:17 2020 -0700

Bump version number to 0.11.0.
---
 CHANGELOG | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/CHANGELOG b/CHANGELOG
index 8939ac4..1e6e730 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,5 @@
+Changes in version 0.11.0 - 2020-07-08
+
 * FIXES https://bugs.torproject.org/31422
 Make BridgeDB report internal metrics, like the median number of users that
 bridges were handed out to.



___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [bridgedb/master] Add favicon to BridgeDB's web UI.

2020-07-08 Thread phw
commit 20f104955c6b798c7452d7ee09ae45fbbc99c62d
Author: Philipp Winter 
Date:   Thu May 28 13:50:02 2020 -0700

Add favicon to BridgeDB's web UI.

This fixes .
---
 CHANGELOG|   3 +++
 .../https/templates/assets/images/favicon.ico| Bin 0 -> 4286 bytes
 bridgedb/distributors/https/templates/base.html  |   1 +
 setup.py |   3 ++-
 4 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/CHANGELOG b/CHANGELOG
index 6dfa43c..754e2f0 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,6 @@
+* FIXES https://bugs.torproject.org/19774
+Add a favicon to BridgeDB's web UI.
+
 Changes in version 0.10.1 - 2020-05-27
 
 * FIXES https://bugs.torproject.org/33945
diff --git a/bridgedb/distributors/https/templates/assets/images/favicon.ico 
b/bridgedb/distributors/https/templates/assets/images/favicon.ico
new file mode 100644
index 000..2f24bf9
Binary files /dev/null and 
b/bridgedb/distributors/https/templates/assets/images/favicon.ico differ
diff --git a/bridgedb/distributors/https/templates/base.html 
b/bridgedb/distributors/https/templates/base.html
index 2f502a9..1f16ca0 100644
--- a/bridgedb/distributors/https/templates/base.html
+++ b/bridgedb/distributors/https/templates/base.html
@@ -13,6 +13,7 @@
 
 
 
+
 
 
 
diff --git a/setup.py b/setup.py
index 18c391b..74b6254 100644
--- a/setup.py
+++ b/setup.py
@@ -175,7 +175,8 @@ def get_template_files():
 'assets/font/*.svg',
 'assets/font/*.eot',
 'assets/js/*.js',
-'assets/images/*.svg']
+'assets/images/*.svg',
+'assets/images/*.ico']
 template_files = []
 
 for include_pattern in include_patterns:



___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [bridgedb/master] Parse bridge blocking info from SQL database.

2020-07-08 Thread phw
commit 5e0ed0af43e876c3305ab75c782ac67b51ea1eb9
Author: Philipp Winter 
Date:   Wed Jul 8 20:23:53 2020 +

Parse bridge blocking info from SQL database.

The plan currently is that wolpertinger will populate our SQL database
with bridge blocking info provided by OONI.  This patch adds code that
parses this data and adds it to our existing bridge objects.

This fixes tpo/anti-censorship/bridgedb#34260.
---
 CHANGELOG |   3 +
 bridgedb/Storage.py   | 138 -
 bridgedb/main.py  |  26 +++
 bridgedb/test/test_Storage.py | 157 ++
 4 files changed, 321 insertions(+), 3 deletions(-)

diff --git a/CHANGELOG b/CHANGELOG
index 0351de7..10012ce 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,6 @@
+* FIXES https://bugs.torproject.org/34260
+Parse bridge blocking information from SQL database.
+
 * FIXES 
https://gitlab.torproject.org/tpo/anti-censorship/bridgedb/-/issues/40001
 Remove the --reload command line switch.  It doesn't actually do anything.
 
diff --git a/bridgedb/Storage.py b/bridgedb/Storage.py
index 2859cf1..4ae3c9e 100644
--- a/bridgedb/Storage.py
+++ b/bridgedb/Storage.py
@@ -12,6 +12,7 @@ from functools import wraps
 from ipaddr import IPAddress
 from contextlib import contextmanager
 import sys
+import datetime
 
 from bridgedb.Stability import BridgeHistory
 import threading
@@ -19,6 +20,7 @@ import threading
 toHex = binascii.b2a_hex
 fromHex = binascii.a2b_hex
 HEX_ID_LEN = 40
+BRIDGE_REACHABLE, BRIDGE_BLOCKED = 0, 1
 
 def _escapeValue(v):
 return "'%s'" % v.replace("'", "''")
@@ -68,7 +70,7 @@ SCHEMA2_SCRIPT = """
 
  CREATE INDEX EmailedBridgesWhenMailed on EmailedBridges ( email );
 
- CREATE TABLE BlockedBridges (
+ CREATE TABLE BridgeMeasurements (
  id INTEGER PRIMARY KEY NOT NULL,
  hex_key,
  bridge_type,
@@ -77,10 +79,11 @@ SCHEMA2_SCRIPT = """
  blocking_country,
  blocking_asn,
  measured_by,
- last_measured
+ last_measured,
+ verdict INTEGER
  );
 
- CREATE INDEX BlockedBridgesBlockingCountry on BlockedBridges(hex_key);
+ CREATE INDEX BlockedBridgesBlockingCountry on BridgeMeasurements(hex_key);
 
  CREATE TABLE WarnedEmails (
  email PRIMARY KEY NOT NULL,
@@ -242,6 +245,34 @@ class Database(object):
 
 return retBridges
 
+def getBlockedBridges(self):
+"""Return a dictionary of bridges that are blocked.
+
+:rtype: dict
+:returns: A dictionary that maps bridge fingerprints (as strings) to a
+three-tuple that captures its blocking state: (country,  address,
+port).
+"""
+ms = self.__fetchBridgeMeasurements()
+return getBlockedBridgesFromSql(ms)
+
+def __fetchBridgeMeasurements(self):
+"""Return all bridge measurement rows from the last three years.
+
+We limit our search to three years for performance reasons because the
+bridge measurement table keeps growing and therefore slowing down
+queries.
+
+:rtype: list
+:returns: A list of tuples.
+"""
+cur = self._cur
+old_year = datetime.datetime.utcnow() - datetime.timedelta(days=365*3)
+cur.execute("SELECT * FROM BridgeMeasurements WHERE last_measured > "
+"'%s' ORDER BY blocking_country DESC" %
+old_year.strftime("%Y-%m-%d"))
+return cur.fetchall()
+
 def getBridgesForDistributor(self, distributor):
 """Return a list of BridgeData value classes of all bridges in the
database that are allocated to distributor 'distributor'
@@ -352,6 +383,107 @@ _LOCKED = 0
 _OPENED_DB = None
 _REFCOUNT = 0
 
+class BridgeMeasurement(object):
+def __init__(self, id, fingerprint, bridge_type, address, port,
+country, asn, measured_by, last_measured, verdict):
+self.fingerprint = fingerprint
+self.country = country
+self.address = address
+self.port = port
+try:
+self.date = datetime.datetime.strptime(last_measured, "%Y-%m-%d")
+except ValueError:
+logging.error("Could not convert SQL date string '%s' to "
+"datetime object." % last_measured)
+self.date = datetime.datetime(1970, 1, 1, 0, 0)
+self.verdict = verdict
+
+def compact(self):
+return (self.country, self.address, self.port)
+
+def __contains__(self, item):
+return (self.country == item.country and
+self.address == item.address and
+self.port == item.port)
+
+def newerThan(self, other):
+return self.date > other.date
+
+def conflicts(self, other):
+return (self.verdict != other.verdict and
+self.country == other.country and
+self.address == other.address and
+self.port == other.port)
+
+def 

[tor-commits] [bridgedb/master] Remove coverage and pypi link; update Travis CI.

2020-07-08 Thread phw
commit c2f4661aa40399efa2d6a596a219cabbd73acae8
Author: Philipp Winter 
Date:   Tue Jul 7 09:19:01 2020 -0700

Remove coverage and pypi link; update Travis CI.

Our Travis CI link still pointed to sysrqb's profile.  This commit
updates the link to use phw's profile.  I'm also removing the (outdated)
pypi and coverage links.

This fixes tpo/anti-censorship/bridgedb#40002.
---
 README.rst | 16 +---
 1 file changed, 5 insertions(+), 11 deletions(-)

diff --git a/README.rst b/README.rst
index 51eff40..a06c2cd 100644
--- a/README.rst
+++ b/README.rst
@@ -1,20 +1,14 @@
-**
-BridgeDB |Latest Version| |Build Status| |Coverage Status|
-**
+***
+BridgeDB |Build Status|
+***
 
 BridgeDB is a collection of backend servers used to distribute `Tor Bridges
 `__. Currently, it mainly consists of
 a webserver with `an HTTPS interface `__,
 `an email responder `__, and an SQLite database.
 
-.. |Latest Version| image:: 
https://pypip.in/version/bridgedb/badge.svg?style=flat
-   :target: https://pypi.python.org/pypi/bridgedb/
-.. |Build Status| image:: https://travis-ci.org/sysrqbci/bridgedb.svg
-   :target: https://travis-ci.org/sysrqbci/bridgedb
-.. |Coverage Status| image:: 
https://coveralls.io/repos/github/sysrqbci/bridgedb/badge.svg?branch=develop
-   :target: https://coveralls.io/github/sysrqbci/bridgedb?branch=develop
-
-
+.. |Build Status| image:: 
https://travis-ci.org/NullHypothesis/bridgedb.svg?branch=master
+   :target: https://travis-ci.org/github/NullHypothesis/bridgedb
 
 .. image:: doc/sphinx/source/_static/bay-bridge.jpg
:scale: 80%



___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [bridgedb/develop] Merge branch 'release-0.11.0'

2020-07-08 Thread phw
commit fb3cfa7edca3db9387bfa999efaa7021d9ce9de2
Merge: c45439c bd32dd7
Author: Philipp Winter 
Date:   Wed Jul 8 14:03:47 2020 -0700

Merge branch 'release-0.11.0'

 CHANGELOG  |  20 +++
 README.rst |  20 +--
 bridgedb.conf  |  10 ++
 bridgedb/Storage.py| 138 +-
 bridgedb/bridges.py|  15 ++
 bridgedb/distributors/email/autoresponder.py   |  12 +-
 bridgedb/distributors/https/server.py  |  22 ++-
 .../https/templates/assets/images/favicon.ico  | Bin 0 -> 4286 bytes
 bridgedb/distributors/https/templates/base.html|   1 +
 bridgedb/distributors/moat/server.py   |  47 +++--
 bridgedb/main.py   |  50 ++
 bridgedb/metrics.py| 199 ++---
 bridgedb/parse/options.py  |   2 -
 bridgedb/parse/versions.py |  29 +++
 bridgedb/test/test_Storage.py  | 157 
 bridgedb/test/test_bridges.py  |  27 +++
 bridgedb/test/test_distributors_moat_server.py |   8 +-
 bridgedb/test/test_metrics.py  | 132 ++
 doc/bridgedb-metrics-spec.txt  |  92 +++---
 requirements.txt   |   1 +
 setup.py   |   3 +-
 21 files changed, 885 insertions(+), 100 deletions(-)

___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [bridgedb/develop] Bump version number to 0.11.0.

2020-07-08 Thread phw
commit bd32dd76ba840ce18a80a4863dda7cf540632f1c
Author: Philipp Winter 
Date:   Wed Jul 8 14:03:17 2020 -0700

Bump version number to 0.11.0.
---
 CHANGELOG | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/CHANGELOG b/CHANGELOG
index 8939ac4..1e6e730 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,5 @@
+Changes in version 0.11.0 - 2020-07-08
+
 * FIXES https://bugs.torproject.org/31422
 Make BridgeDB report internal metrics, like the median number of users that
 bridges were handed out to.



___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [bridgedb/develop] Make BridgeDB export internal metrics.

2020-07-08 Thread phw
commit ce32921680158e8d977f72c16f05de1f9f69cc85
Author: Philipp Winter 
Date:   Mon Dec 2 15:23:25 2019 -0800

Make BridgeDB export internal metrics.

BridgeDB already exports usage metrics that help us understand how our
users interact with BridgeDB.  This commit adds internal metrics, which
shed light on BridgeDB's internals.  In particular, we add the following
internal metrics:

* Number of bridges per distributor subring.

* Number of empty responses per distributor.

* Number of IPv4/IPv6 handouts.

* Descriptive statistics on the number of bridge handouts (min, max,
  median, quartile 1, quartile 3, upper whisker, lower whisker).

* Number of unique bridges that were handed out.

This patch fixes tpo/anti-censorship/bridgedb#31422 and also bumps
BridgeDB's metrics format to version 2.
---
 CHANGELOG  |   4 +
 bridgedb/distributors/email/autoresponder.py   |  12 +-
 bridgedb/distributors/https/server.py  |  22 ++-
 bridgedb/distributors/moat/server.py   |  47 --
 bridgedb/main.py   |  17 +++
 bridgedb/metrics.py| 199 ++---
 bridgedb/test/test_distributors_moat_server.py |   8 +-
 bridgedb/test/test_metrics.py  | 132 
 doc/bridgedb-metrics-spec.txt  |  92 
 requirements.txt   |   1 +
 10 files changed, 455 insertions(+), 79 deletions(-)

diff --git a/CHANGELOG b/CHANGELOG
index 10012ce..8939ac4 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,7 @@
+* FIXES https://bugs.torproject.org/31422
+Make BridgeDB report internal metrics, like the median number of users that
+bridges were handed out to.
+
 * FIXES https://bugs.torproject.org/34260
 Parse bridge blocking information from SQL database.
 
diff --git a/bridgedb/distributors/email/autoresponder.py 
b/bridgedb/distributors/email/autoresponder.py
index 9b0ac53..94a8f75 100644
--- a/bridgedb/distributors/email/autoresponder.py
+++ b/bridgedb/distributors/email/autoresponder.py
@@ -62,9 +62,10 @@ from bridgedb.parse.addr import canonicalizeEmailDomain
 from bridgedb.util import levenshteinDistance
 from bridgedb import translations
 
-# We use our metrics singleton to keep track of BridgeDB metrics such as
+# We use our metrics singletons to keep track of BridgeDB metrics such as
 # "number of failed HTTPS bridge requests."
-metrix = metrics.EmailMetrics()
+emailMetrix = metrics.EmailMetrics()
+internalMetrix = metrics.InternalMetrics()
 
 
 def createResponseBody(lines, context, client, lang='en'):
@@ -113,6 +114,9 @@ def createResponseBody(lines, context, client, lang='en'):
 transport = bridgeRequest.justOnePTType()
 answer = "".join("  %s\r\n" % b.getBridgeLine(
 bridgeRequest, context.includeFingerprints) for b in bridges)
+internalMetrix.recordHandoutsPerBridge(bridgeRequest, bridges)
+else:
+internalMetrix.recordEmptyEmailResponse()
 return templates.buildAnswerMessage(translator, client, answer)
 
 def generateResponse(fromAddress, client, body, subject=None,
@@ -396,9 +400,9 @@ class SMTPAutoresponder(smtp.SMTPClient):
 # request.
 translator = translations.installTranslations(lang)
 if body is not None and translator.gettext(strings.EMAIL_MISC_TEXT[1]) 
in body:
-metrix.recordValidEmailRequest(self)
+emailMetrix.recordValidEmailRequest(self)
 else:
-metrix.recordInvalidEmailRequest(self)
+emailMetrix.recordInvalidEmailRequest(self)
 
 if not body: return  # The client was already warned.
 
diff --git a/bridgedb/distributors/https/server.py 
b/bridgedb/distributors/https/server.py
index 91757e7..fd3fc74 100644
--- a/bridgedb/distributors/https/server.py
+++ b/bridgedb/distributors/https/server.py
@@ -90,9 +90,10 @@ logging.debug("Set template root to %s" % TEMPLATE_DIR)
 #: A list of supported language tuples. Use getSortedLangList() to read this 
variable.
 supported_langs = []
 
-# We use our metrics singleton to keep track of BridgeDB metrics such as
+# We use our metrics singletons to keep track of BridgeDB metrics such as
 # "number of failed HTTPS bridge requests."
-metrix = metrics.HTTPSMetrics()
+httpsMetrix = metrics.HTTPSMetrics()
+internalMetrix = metrics.InternalMetrics()
 
 
 def stringifyRequestArgs(args):
@@ -574,7 +575,7 @@ class CaptchaProtectedResource(CustomErrorHandlingResource, 
CSPResource):
 
 try:
 if self.checkSolution(request) is True:
-metrix.recordValidHTTPSRequest(request)
+httpsMetrix.recordValidHTTPSRequest(request)
 return self.resource.render(request)
 except ValueError as err:
 logging.debug(str(err))
@@ -584,14 +585,14 @@ class 

[tor-commits] [bridgedb/develop] Merge branch 'enhancement/31422' into 'develop'

2020-07-08 Thread phw
commit 35f1be4cee661fb6a23e37cc102379dace3dbc5e
Merge: ada3bdc ce32921
Author: Philipp Winter 
Date:   Wed Jul 8 20:52:39 2020 +

Merge branch 'enhancement/31422' into 'develop'

Make BridgeDB export internal metrics.

See merge request tpo/anti-censorship/bridgedb!8

 CHANGELOG  |   4 +
 bridgedb/distributors/email/autoresponder.py   |  12 +-
 bridgedb/distributors/https/server.py  |  22 ++-
 bridgedb/distributors/moat/server.py   |  47 --
 bridgedb/main.py   |  17 +++
 bridgedb/metrics.py| 199 ++---
 bridgedb/test/test_distributors_moat_server.py |   8 +-
 bridgedb/test/test_metrics.py  | 132 
 doc/bridgedb-metrics-spec.txt  |  92 
 requirements.txt   |   1 +
 10 files changed, 455 insertions(+), 79 deletions(-)

___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [bridgedb/develop] Parse bridge blocking info from SQL database.

2020-07-08 Thread phw
commit 5e0ed0af43e876c3305ab75c782ac67b51ea1eb9
Author: Philipp Winter 
Date:   Wed Jul 8 20:23:53 2020 +

Parse bridge blocking info from SQL database.

The plan currently is that wolpertinger will populate our SQL database
with bridge blocking info provided by OONI.  This patch adds code that
parses this data and adds it to our existing bridge objects.

This fixes tpo/anti-censorship/bridgedb#34260.
---
 CHANGELOG |   3 +
 bridgedb/Storage.py   | 138 -
 bridgedb/main.py  |  26 +++
 bridgedb/test/test_Storage.py | 157 ++
 4 files changed, 321 insertions(+), 3 deletions(-)

diff --git a/CHANGELOG b/CHANGELOG
index 0351de7..10012ce 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,6 @@
+* FIXES https://bugs.torproject.org/34260
+Parse bridge blocking information from SQL database.
+
 * FIXES 
https://gitlab.torproject.org/tpo/anti-censorship/bridgedb/-/issues/40001
 Remove the --reload command line switch.  It doesn't actually do anything.
 
diff --git a/bridgedb/Storage.py b/bridgedb/Storage.py
index 2859cf1..4ae3c9e 100644
--- a/bridgedb/Storage.py
+++ b/bridgedb/Storage.py
@@ -12,6 +12,7 @@ from functools import wraps
 from ipaddr import IPAddress
 from contextlib import contextmanager
 import sys
+import datetime
 
 from bridgedb.Stability import BridgeHistory
 import threading
@@ -19,6 +20,7 @@ import threading
 toHex = binascii.b2a_hex
 fromHex = binascii.a2b_hex
 HEX_ID_LEN = 40
+BRIDGE_REACHABLE, BRIDGE_BLOCKED = 0, 1
 
 def _escapeValue(v):
 return "'%s'" % v.replace("'", "''")
@@ -68,7 +70,7 @@ SCHEMA2_SCRIPT = """
 
  CREATE INDEX EmailedBridgesWhenMailed on EmailedBridges ( email );
 
- CREATE TABLE BlockedBridges (
+ CREATE TABLE BridgeMeasurements (
  id INTEGER PRIMARY KEY NOT NULL,
  hex_key,
  bridge_type,
@@ -77,10 +79,11 @@ SCHEMA2_SCRIPT = """
  blocking_country,
  blocking_asn,
  measured_by,
- last_measured
+ last_measured,
+ verdict INTEGER
  );
 
- CREATE INDEX BlockedBridgesBlockingCountry on BlockedBridges(hex_key);
+ CREATE INDEX BlockedBridgesBlockingCountry on BridgeMeasurements(hex_key);
 
  CREATE TABLE WarnedEmails (
  email PRIMARY KEY NOT NULL,
@@ -242,6 +245,34 @@ class Database(object):
 
 return retBridges
 
+def getBlockedBridges(self):
+"""Return a dictionary of bridges that are blocked.
+
+:rtype: dict
+:returns: A dictionary that maps bridge fingerprints (as strings) to a
+three-tuple that captures its blocking state: (country,  address,
+port).
+"""
+ms = self.__fetchBridgeMeasurements()
+return getBlockedBridgesFromSql(ms)
+
+def __fetchBridgeMeasurements(self):
+"""Return all bridge measurement rows from the last three years.
+
+We limit our search to three years for performance reasons because the
+bridge measurement table keeps growing and therefore slowing down
+queries.
+
+:rtype: list
+:returns: A list of tuples.
+"""
+cur = self._cur
+old_year = datetime.datetime.utcnow() - datetime.timedelta(days=365*3)
+cur.execute("SELECT * FROM BridgeMeasurements WHERE last_measured > "
+"'%s' ORDER BY blocking_country DESC" %
+old_year.strftime("%Y-%m-%d"))
+return cur.fetchall()
+
 def getBridgesForDistributor(self, distributor):
 """Return a list of BridgeData value classes of all bridges in the
database that are allocated to distributor 'distributor'
@@ -352,6 +383,107 @@ _LOCKED = 0
 _OPENED_DB = None
 _REFCOUNT = 0
 
+class BridgeMeasurement(object):
+def __init__(self, id, fingerprint, bridge_type, address, port,
+country, asn, measured_by, last_measured, verdict):
+self.fingerprint = fingerprint
+self.country = country
+self.address = address
+self.port = port
+try:
+self.date = datetime.datetime.strptime(last_measured, "%Y-%m-%d")
+except ValueError:
+logging.error("Could not convert SQL date string '%s' to "
+"datetime object." % last_measured)
+self.date = datetime.datetime(1970, 1, 1, 0, 0)
+self.verdict = verdict
+
+def compact(self):
+return (self.country, self.address, self.port)
+
+def __contains__(self, item):
+return (self.country == item.country and
+self.address == item.address and
+self.port == item.port)
+
+def newerThan(self, other):
+return self.date > other.date
+
+def conflicts(self, other):
+return (self.verdict != other.verdict and
+self.country == other.country and
+self.address == other.address and
+self.port == other.port)
+
+def 

[tor-commits] [bridgedb/develop] Merge branch 'enhancement/34260' into 'develop'

2020-07-08 Thread phw
commit ada3bdca87ff853a55e602beeffb4699ba9b2250
Merge: d8b73ec 5e0ed0a
Author: Philipp Winter 
Date:   Wed Jul 8 20:23:53 2020 +

Merge branch 'enhancement/34260' into 'develop'

Parse bridge blocking info from SQL database.

See merge request tpo/anti-censorship/bridgedb!7

 CHANGELOG |   3 +
 bridgedb/Storage.py   | 138 -
 bridgedb/main.py  |  26 +++
 bridgedb/test/test_Storage.py | 157 ++
 4 files changed, 321 insertions(+), 3 deletions(-)

___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [bridgedb/develop] Remove coverage and pypi link; update Travis CI.

2020-07-07 Thread phw
commit c2f4661aa40399efa2d6a596a219cabbd73acae8
Author: Philipp Winter 
Date:   Tue Jul 7 09:19:01 2020 -0700

Remove coverage and pypi link; update Travis CI.

Our Travis CI link still pointed to sysrqb's profile.  This commit
updates the link to use phw's profile.  I'm also removing the (outdated)
pypi and coverage links.

This fixes tpo/anti-censorship/bridgedb#40002.
---
 README.rst | 16 +---
 1 file changed, 5 insertions(+), 11 deletions(-)

diff --git a/README.rst b/README.rst
index 51eff40..a06c2cd 100644
--- a/README.rst
+++ b/README.rst
@@ -1,20 +1,14 @@
-**
-BridgeDB |Latest Version| |Build Status| |Coverage Status|
-**
+***
+BridgeDB |Build Status|
+***
 
 BridgeDB is a collection of backend servers used to distribute `Tor Bridges
 `__. Currently, it mainly consists of
 a webserver with `an HTTPS interface `__,
 `an email responder `__, and an SQLite database.
 
-.. |Latest Version| image:: 
https://pypip.in/version/bridgedb/badge.svg?style=flat
-   :target: https://pypi.python.org/pypi/bridgedb/
-.. |Build Status| image:: https://travis-ci.org/sysrqbci/bridgedb.svg
-   :target: https://travis-ci.org/sysrqbci/bridgedb
-.. |Coverage Status| image:: 
https://coveralls.io/repos/github/sysrqbci/bridgedb/badge.svg?branch=develop
-   :target: https://coveralls.io/github/sysrqbci/bridgedb?branch=develop
-
-
+.. |Build Status| image:: 
https://travis-ci.org/NullHypothesis/bridgedb.svg?branch=master
+   :target: https://travis-ci.org/github/NullHypothesis/bridgedb
 
 .. image:: doc/sphinx/source/_static/bay-bridge.jpg
:scale: 80%



___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [bridgedb/develop] Merge branch 'bug/40002' into 'develop'

2020-07-07 Thread phw
commit d8b73ecd65664bf60f61a72b3fb4e233663a6bee
Merge: 387f2b4 c2f4661
Author: Philipp Winter 
Date:   Tue Jul 7 16:21:07 2020 +

Merge branch 'bug/40002' into 'develop'

Remove coverage and pypi link; update Travis CI.

See merge request tpo/anti-censorship/bridgedb!6

 README.rst | 16 +---
 1 file changed, 5 insertions(+), 11 deletions(-)

___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [bridgedb/develop] Remove the --reload command line switch.

2020-07-07 Thread phw
commit 2351f8652bb99b908c36957edee1585319ff6fcb
Author: Philipp Winter 
Date:   Thu Jul 2 10:53:28 2020 -0700

Remove the --reload command line switch.

This fixes tpo/anti-censorship/bridgedb#40001.
---
 CHANGELOG | 3 +++
 README.rst| 4 
 bridgedb/parse/options.py | 2 --
 3 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/CHANGELOG b/CHANGELOG
index c712436..0351de7 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,6 @@
+* FIXES 
https://gitlab.torproject.org/tpo/anti-censorship/bridgedb/-/issues/40001
+Remove the --reload command line switch.  It doesn't actually do anything.
+
 * FIXES https://bugs.torproject.org/29184
 Add a new configuration option, BLACKLISTED_TOR_VERSIONS, which contains a
 list of Tor versions.  BridgeDB won't hand out bridges whose Tor version
diff --git a/README.rst b/README.rst
index 1b0a840..51eff40 100644
--- a/README.rst
+++ b/README.rst
@@ -318,10 +318,6 @@ Reloading Bridges From Their Descriptor Files:
 When you have new lists of bridges from the Bridge Authority, replace
 the old files and do::
 
-  bridgedb --reload
-
-Or just give it a SIGHUP::
-
   kill -s SIGHUP `cat .../run/bridgedb.pid`
 
 
diff --git a/bridgedb/parse/options.py b/bridgedb/parse/options.py
index c32ada3..83c0984 100644
--- a/bridgedb/parse/options.py
+++ b/bridgedb/parse/options.py
@@ -290,8 +290,6 @@ class SIGUSR1Options(BaseOptions):
 class MainOptions(BaseOptions):
 """Main commandline options parser for BridgeDB."""
 
-optFlags = [
-['reload', 'R', 'Reload bridge descriptors into running servers']]
 subCommands = [
 ['mock', None, MockOptions, "Generate a testing environment"],
 ['SIGHUP', None, SIGHUPOptions,



___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [bridgedb/develop] Merge branch 'bug/40001' into 'develop'

2020-07-07 Thread phw
commit 387f2b403abf5ad1a4bec8f8132de5589ecdde23
Merge: 28c5479 2351f86
Author: Philipp Winter 
Date:   Tue Jul 7 16:02:06 2020 +

Merge branch 'bug/40001' into 'develop'

Remove the --reload command line switch.

See merge request tpo/anti-censorship/bridgedb!4

 CHANGELOG | 3 +++
 README.rst| 4 
 bridgedb/parse/options.py | 2 --
 3 files changed, 3 insertions(+), 6 deletions(-)

___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [bridgedb/develop] Merge branch 'enhancement/29184' into 'develop'

2020-06-23 Thread phw
commit 28c5479c455a499e4ac77203920dc8cc62981d29
Merge: 6d3e899 8d169fc
Author: Philipp Winter 
Date:   Tue Jun 23 23:08:36 2020 +

Merge branch 'enhancement/29184' into 'develop'

Avoid giving out bridges with broken tor versions.

See merge request tpo/anti-censorship/bridgedb!3

 CHANGELOG |  5 +
 bridgedb.conf | 10 ++
 bridgedb/bridges.py   | 15 +++
 bridgedb/main.py  |  7 +++
 bridgedb/parse/versions.py| 29 +
 bridgedb/test/test_bridges.py | 27 +++
 6 files changed, 93 insertions(+)

___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [bridgedb/develop] Avoid giving out bridges with broken tor versions.

2020-06-23 Thread phw
commit 8d169fc45c8cfd7c8c9028d125bff4dbb3afafc6
Author: Philipp Winter 
Date:   Fri Jun 12 10:05:26 2020 -0700

Avoid giving out bridges with broken tor versions.

This patch makes BridgeDB avoid giving out bridges that are affected by
the following bug: 

This fixes .
---
 CHANGELOG |  5 +
 bridgedb.conf | 10 ++
 bridgedb/bridges.py   | 15 +++
 bridgedb/main.py  |  7 +++
 bridgedb/parse/versions.py| 29 +
 bridgedb/test/test_bridges.py | 27 +++
 6 files changed, 93 insertions(+)

diff --git a/CHANGELOG b/CHANGELOG
index 754e2f0..c712436 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,8 @@
+* FIXES https://bugs.torproject.org/29184
+Add a new configuration option, BLACKLISTED_TOR_VERSIONS, which contains a
+list of Tor versions.  BridgeDB won't hand out bridges whose Tor version
+is present in this blacklist.
+
 * FIXES https://bugs.torproject.org/19774
 Add a favicon to BridgeDB's web UI.
 
diff --git a/bridgedb.conf b/bridgedb.conf
index 31eb3fa..6d4839d 100644
--- a/bridgedb.conf
+++ b/bridgedb.conf
@@ -309,6 +309,16 @@ DEFAULT_TRANSPORT = 'obfs4'
 #   Accept-Language,[Kk]lingon
 BLACKLISTED_REQUEST_HEADERS_FILE="blacklisted-request-headers.csv"
 
+# List of tuples that specify blacklisted tor version ranges.  The first
+# element marks the start of the range and the second element marks the end.
+# Both the start *and* the end version are blocked too.  If you want to block a
+# single version, have the start and end range be identical.  BridgeDB won't
+# distribute bridges whose version falls within any version ranges.
+BLACKLISTED_TOR_VERSIONS = [
+('0.3.4', '0.3.4.9'), # See .
+('0.3.5', '0.3.5.6')
+]
+
 # Decoy bridges that we are handing out to bots that we detected using the
 # regular expressions in BLACKLISTED_REQUEST_HEADERS_FILE.  The CSV file must
 # have the following format:
diff --git a/bridgedb/bridges.py b/bridgedb/bridges.py
index cd01948..6ec864d 100644
--- a/bridgedb/bridges.py
+++ b/bridgedb/bridges.py
@@ -1825,3 +1825,18 @@ class Bridge(BridgeBackwardsCompatibility):
 logging.info("Removing dead transport for bridge %s: %s %s:%s %s" %
  (self, pt.methodname, pt.address, pt.port, 
pt.arguments))
 self.transports.remove(pt)
+
+def runsVersion(self, version_tuples):
+"""Return ``True`` if this bridge runs any of the given versions.
+
+:param list version_tuples: A list of tuples that contain a minimum and
+maximum version number (as :class:`stem.version.Version` objects),
+each.
+:rtype: bool
+:returns: ``True`` if this bridge runs any of the given Tor versions
+and ``False`` otherwise.
+"""
+for min_version, max_version in version_tuples:
+if min_version <= self.software <= max_version:
+return True
+return False
diff --git a/bridgedb/main.py b/bridgedb/main.py
index 70001a9..44d0668 100644
--- a/bridgedb/main.py
+++ b/bridgedb/main.py
@@ -38,6 +38,7 @@ from bridgedb.distributors.https.distributor import 
HTTPSDistributor
 from bridgedb.distributors.moat.distributor import MoatDistributor
 from bridgedb.parse import descriptors
 from bridgedb.parse.blacklist import parseBridgeBlacklistFile
+from bridgedb.parse.versions import parseVersionsList
 
 import bridgedb.Storage
 
@@ -211,6 +212,10 @@ def load(state, hashring, clear=False):
 elif bridge in blacklist.keys():
 logging.warn("Not distributing blacklisted Bridge %s %s:%s: 
%s" %
  (bridge, bridge.address, bridge.orPort, 
blacklist[bridge]))
+# Skip bridges that are running a blacklisted version of Tor.
+elif bridge.runsVersion(state.BLACKLISTED_TOR_VERSIONS):
+logging.warn("Not distributing bridge %s because it runs 
blacklisted "
+ "Tor version %s." % (router.fingerprint, 
bridge.software))
 else:
 # If the bridge is not running, then it is skipped during the
 # insertion process.
@@ -418,6 +423,8 @@ def run(options, reactor=reactor):
 proxy.loadProxiesFromFile(proxyfile, proxies, removeStale=True)
 metrics.setProxies(proxies)
 
+state.BLACKLISTED_TOR_VERSIONS = 
parseVersionsList(state.BLACKLISTED_TOR_VERSIONS)
+
 logging.info("Reloading blacklisted request headers...")
 
antibot.loadBlacklistedRequestHeaders(config.BLACKLISTED_REQUEST_HEADERS_FILE)
 logging.info("Reloading decoy bridges...")
diff --git a/bridgedb/parse/versions.py b/bridgedb/parse/versions.py
index 335e04c..832969e 100644
--- a/bridgedb/parse/versions.py
+++ 

[tor-commits] [bridgedb/develop] Add favicon to BridgeDB's web UI.

2020-06-04 Thread phw
commit 20f104955c6b798c7452d7ee09ae45fbbc99c62d
Author: Philipp Winter 
Date:   Thu May 28 13:50:02 2020 -0700

Add favicon to BridgeDB's web UI.

This fixes .
---
 CHANGELOG|   3 +++
 .../https/templates/assets/images/favicon.ico| Bin 0 -> 4286 bytes
 bridgedb/distributors/https/templates/base.html  |   1 +
 setup.py |   3 ++-
 4 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/CHANGELOG b/CHANGELOG
index 6dfa43c..754e2f0 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,6 @@
+* FIXES https://bugs.torproject.org/19774
+Add a favicon to BridgeDB's web UI.
+
 Changes in version 0.10.1 - 2020-05-27
 
 * FIXES https://bugs.torproject.org/33945
diff --git a/bridgedb/distributors/https/templates/assets/images/favicon.ico 
b/bridgedb/distributors/https/templates/assets/images/favicon.ico
new file mode 100644
index 000..2f24bf9
Binary files /dev/null and 
b/bridgedb/distributors/https/templates/assets/images/favicon.ico differ
diff --git a/bridgedb/distributors/https/templates/base.html 
b/bridgedb/distributors/https/templates/base.html
index 2f502a9..1f16ca0 100644
--- a/bridgedb/distributors/https/templates/base.html
+++ b/bridgedb/distributors/https/templates/base.html
@@ -13,6 +13,7 @@
 
 
 
+
 
 
 
diff --git a/setup.py b/setup.py
index 18c391b..74b6254 100644
--- a/setup.py
+++ b/setup.py
@@ -175,7 +175,8 @@ def get_template_files():
 'assets/font/*.svg',
 'assets/font/*.eot',
 'assets/js/*.js',
-'assets/images/*.svg']
+'assets/images/*.svg',
+'assets/images/*.ico']
 template_files = []
 
 for include_pattern in include_patterns:



___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [bridgedb/develop] Merge branch 'enhancement/19774' into develop

2020-06-04 Thread phw
commit 6d3e899925854b0994d66551fef25678e6f36561
Merge: c45439c 20f1049
Author: Philipp Winter 
Date:   Thu Jun 4 14:05:25 2020 -0700

Merge branch 'enhancement/19774' into develop

 CHANGELOG|   3 +++
 .../https/templates/assets/images/favicon.ico| Bin 0 -> 4286 bytes
 bridgedb/distributors/https/templates/base.html  |   1 +
 setup.py |   3 ++-
 4 files changed, 6 insertions(+), 1 deletion(-)

___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [bridgedb/master] Update to latest requirements.

2020-05-27 Thread phw
commit 9199a4d4b9f9264f7791a7f7954d012f9fc69b25
Author: Philipp Winter 
Date:   Wed May 27 08:52:02 2020 -0700

Update to latest requirements.
---
 .test.requirements.txt   |  4 ++--
 .travis.requirements.txt | 18 +-
 requirements.txt | 12 ++--
 3 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/.test.requirements.txt b/.test.requirements.txt
index 82fbbd6..e72ed31 100644
--- a/.test.requirements.txt
+++ b/.test.requirements.txt
@@ -5,8 +5,8 @@
 # $ pip install -r .test.requirements.txt
 # $ make coverage
 #
-coverage==5.0.3
+coverage==5.1
 mechanize==0.4.5
 pep8==1.7.1
-pylint==2.4.4
+pylint==2.5.2
 sure==1.4.11
diff --git a/.travis.requirements.txt b/.travis.requirements.txt
index a74821a..940ba64 100644
--- a/.travis.requirements.txt
+++ b/.travis.requirements.txt
@@ -13,21 +13,21 @@
 # $ make coverage
 #
 #--
-attrs==19.2.0
+attrs==19.3.0
 Babel==2.8.0
-beautifulsoup4==4.8.2
-Mako==1.1.1
-pycryptodome==3.9.6
+beautifulsoup4==4.9.1
+Mako==1.1.2
+pycryptodome==3.9.7
 Twisted==20.3.0
-coverage==5.0.3
-coveralls==1.10.0
+coverage==5.1
+coveralls==2.0.0
 ipaddr==2.2.0
 mechanize==0.4.5
-Pillow==6.2.2
-pyOpenSSL==19.0.0
+Pillow==7.1.2
+pyOpenSSL==19.1.0
 pygeoip==0.3.2
 qrcode==6.1
 service_identity==18.1.0
 stem==1.8.0
 sure==1.4.11
-zope.interface==4.7.1
+zope.interface==5.1.0
diff --git a/requirements.txt b/requirements.txt
index 79bb01d..fdf1043 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,14 +1,14 @@
 Babel==2.8.0
-beautifulsoup4==4.8.2
-html5lib==1.0b8
-Mako==1.1.1
-pycryptodome==3.9.6
+beautifulsoup4==4.9.1
+html5lib==1.0.1
+Mako==1.1.2
+pycryptodome==3.9.7
 Twisted==20.3.0
 ipaddr==2.2.0
-Pillow==6.2.2
+Pillow==7.1.2
 pyOpenSSL==19.1.0
 pygeoip==0.3.2
 qrcode==6.1
 service_identity==18.1.0
 stem==1.8.0
-zope.interface==4.7.1
+zope.interface==5.1.0



___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [bridgedb/master] Merge branch 'enhancement/34154' into develop

2020-05-27 Thread phw
commit 19ba2da7b66cfccee014bde2804f10dafd0696b7
Merge: f25943e 3337b4a
Author: Philipp Winter 
Date:   Fri May 22 15:13:38 2020 -0700

Merge branch 'enhancement/34154' into develop

 CHANGELOG   | 4 
 bridgedb/Storage.py | 8 +++-
 2 files changed, 11 insertions(+), 1 deletion(-)



___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [bridgedb/master] Merge branch 'update-translations' into develop

2020-05-27 Thread phw
commit a6eb0d1c4bc782287d6054cead0d6850dd2d7c0c
Merge: 5c0b04e 1a42375
Author: Philipp Winter 
Date:   Fri May 22 15:56:33 2020 -0700

Merge branch 'update-translations' into develop

 bridgedb/i18n/ar/LC_MESSAGES/bridgedb.po| 367 ++--
 bridgedb/i18n/az/LC_MESSAGES/bridgedb.po| 356 ++-
 bridgedb/i18n/be/LC_MESSAGES/bridgedb.po| 361 ++--
 bridgedb/i18n/bg/LC_MESSAGES/bridgedb.po| 356 ++-
 bridgedb/i18n/bn/LC_MESSAGES/bridgedb.po| 358 ++-
 bridgedb/i18n/bs/LC_MESSAGES/bridgedb.po| 399 ++
 bridgedb/i18n/ca/LC_MESSAGES/bridgedb.po| 398 +++--
 bridgedb/i18n/cs/LC_MESSAGES/bridgedb.po| 360 ++-
 bridgedb/i18n/da/LC_MESSAGES/bridgedb.po| 399 +++---
 bridgedb/i18n/de/LC_MESSAGES/bridgedb.po| 360 ++-
 bridgedb/i18n/el/LC_MESSAGES/bridgedb.po| 360 ++-
 bridgedb/i18n/en_GB/LC_MESSAGES/bridgedb.po | 358 ++-
 bridgedb/i18n/eo/LC_MESSAGES/bridgedb.po| 359 +--
 bridgedb/i18n/es/LC_MESSAGES/bridgedb.po| 360 +--
 bridgedb/i18n/es_AR/LC_MESSAGES/bridgedb.po | 359 ++-
 bridgedb/i18n/es_MX/LC_MESSAGES/bridgedb.po | 356 ++-
 bridgedb/i18n/et/LC_MESSAGES/bridgedb.po| 359 ++-
 bridgedb/i18n/eu/LC_MESSAGES/bridgedb.po| 427 +++
 bridgedb/i18n/fa/LC_MESSAGES/bridgedb.po| 373 ++--
 bridgedb/i18n/fi/LC_MESSAGES/bridgedb.po| 358 ++-
 bridgedb/i18n/fr/LC_MESSAGES/bridgedb.po| 363 ++--
 bridgedb/i18n/ga/LC_MESSAGES/bridgedb.po| 358 ++-
 bridgedb/i18n/gd/LC_MESSAGES/bridgedb.po| 399 ++
 bridgedb/i18n/gl/LC_MESSAGES/bridgedb.po| 356 ++-
 bridgedb/i18n/gu/LC_MESSAGES/bridgedb.po| 399 ++
 bridgedb/i18n/he/LC_MESSAGES/bridgedb.po| 366 ++--
 bridgedb/i18n/hi/LC_MESSAGES/bridgedb.po| 356 ++-
 bridgedb/i18n/hr/LC_MESSAGES/bridgedb.po| 401 +++---
 bridgedb/i18n/hu/LC_MESSAGES/bridgedb.po| 361 ++--
 bridgedb/i18n/hy/LC_MESSAGES/bridgedb.po| 356 ++-
 bridgedb/i18n/id/LC_MESSAGES/bridgedb.po| 366 ++--
 bridgedb/i18n/is/LC_MESSAGES/bridgedb.po| 358 ++-
 bridgedb/i18n/it/LC_MESSAGES/bridgedb.po| 362 ++--
 bridgedb/i18n/ja/LC_MESSAGES/bridgedb.po| 380 +++--
 bridgedb/i18n/ka/LC_MESSAGES/bridgedb.po| 357 ++-
 bridgedb/i18n/kk/LC_MESSAGES/bridgedb.po| 358 ++-
 bridgedb/i18n/km/LC_MESSAGES/bridgedb.po| 513 +++-
 bridgedb/i18n/ko/LC_MESSAGES/bridgedb.po| 361 ++--
 bridgedb/i18n/lt/LC_MESSAGES/bridgedb.po| 406 ++
 bridgedb/i18n/lv/LC_MESSAGES/bridgedb.po| 356 ++-
 bridgedb/i18n/mk/LC_MESSAGES/bridgedb.po| 357 ++-
 bridgedb/i18n/ml/LC_MESSAGES/bridgedb.po| 404 ++
 bridgedb/i18n/mr/LC_MESSAGES/bridgedb.po| 400 ++
 bridgedb/i18n/ms_MY/LC_MESSAGES/bridgedb.po | 356 ++-
 bridgedb/i18n/nb/LC_MESSAGES/bridgedb.po| 366 ++--
 bridgedb/i18n/nl/LC_MESSAGES/bridgedb.po| 395 +++--
 bridgedb/i18n/nl_BE/LC_MESSAGES/bridgedb.po | 356 ++-
 bridgedb/i18n/nn/LC_MESSAGES/bridgedb.po| 356 ++-
 bridgedb/i18n/pa/LC_MESSAGES/bridgedb.po| 402 ++
 bridgedb/i18n/pl/LC_MESSAGES/bridgedb.po| 359 ++-
 bridgedb/i18n/pt_BR/LC_MESSAGES/bridgedb.po | 363 ++--
 bridgedb/i18n/pt_PT/LC_MESSAGES/bridgedb.po | 371 ++--
 bridgedb/i18n/ro/LC_MESSAGES/bridgedb.po| 358 ++-
 bridgedb/i18n/ru/LC_MESSAGES/bridgedb.po| 393 +++--
 bridgedb/i18n/sk/LC_MESSAGES/bridgedb.po| 357 ++-
 bridgedb/i18n/sl/LC_MESSAGES/bridgedb.po| 356 ++-
 bridgedb/i18n/sq/LC_MESSAGES/bridgedb.po| 378 ++--
 bridgedb/i18n/sr/LC_MESSAGES/bridgedb.po| 357 ++-
 bridgedb/i18n/sv/LC_MESSAGES/bridgedb.po| 370 ++--
 bridgedb/i18n/sw/LC_MESSAGES/bridgedb.po| 399 ++
 bridgedb/i18n/ta/LC_MESSAGES/bridgedb.po| 357 ++-
 bridgedb/i18n/th/LC_MESSAGES/bridgedb.po| 436 +++
 bridgedb/i18n/tr/LC_MESSAGES/bridgedb.po| 361 ++--
 bridgedb/i18n/uk/LC_MESSAGES/bridgedb.po| 356 ++-
 bridgedb/i18n/ur/LC_MESSAGES/bridgedb.po| 399 ++
 bridgedb/i18n/uz/LC_MESSAGES/bridgedb.po| 401 ++
 bridgedb/i18n/vi/LC_MESSAGES/bridgedb.po| 

[tor-commits] [bridgedb/master] Merge branch 'release-0.10.1'

2020-05-27 Thread phw
commit c45439ceb3a8dd43c658607606fb4a7aad57fd67
Merge: 2ccf7ef 64c29be
Author: Philipp Winter 
Date:   Wed May 27 10:05:59 2020 -0700

Merge branch 'release-0.10.1'

 .gnupg/TESTING.pub |  Bin 4622 -> 0 bytes
 .gnupg/TESTING.subkeys.sec |  Bin 7212 -> 0 bytes
 .gnupg/bridgedb-offline-key.pub.asc|  113 -
 .gnupg/bridgedb-online-key.pub.asc |  100 -
 .gnupg/gpg.conf|   96 -
 .gnupg/pubring.gpg |  Bin 4634 -> 0 bytes
 .gnupg/secring.gpg |  Bin 7224 -> 0 bytes
 .test.requirements.txt |4 +-
 .travis.requirements.txt   |   19 +-
 CHANGELOG  | 2427 ++--
 README.rst |   39 +-
 bridgedb.conf  |   45 -
 bridgedb/Storage.py|   71 +-
 bridgedb/{Bridges.py => bridgerings.py}|4 +-
 bridgedb/bridges.py|4 +-
 bridgedb/configure.py  |3 +-
 bridgedb/crypto.py |   99 +-
 bridgedb/distributors/email/autoresponder.py   |   51 +-
 bridgedb/distributors/email/distributor.py |   18 +-
 bridgedb/distributors/email/request.py |   42 +-
 bridgedb/distributors/email/server.py  |   12 +-
 bridgedb/distributors/email/templates.py   |  133 +-
 bridgedb/distributors/https/distributor.py |   11 +-
 bridgedb/distributors/https/request.py |5 +-
 bridgedb/distributors/https/server.py  |   13 +-
 .../https/templates/assets/css/main.css|4 +-
 bridgedb/distributors/https/templates/base.html|2 -
 bridgedb/distributors/https/templates/bridges.html |   13 +-
 .../distributors/https/templates/error-400.html|   30 +
 .../distributors/https/templates/error-500.html|4 +-
 bridgedb/distributors/moat/distributor.py  |5 +-
 bridgedb/i18n/ar/LC_MESSAGES/bridgedb.po   |  367 +--
 bridgedb/i18n/az/LC_MESSAGES/bridgedb.po   |  356 +--
 bridgedb/i18n/be/LC_MESSAGES/bridgedb.po   |  361 +--
 bridgedb/i18n/bg/LC_MESSAGES/bridgedb.po   |  356 +--
 bridgedb/i18n/bn/LC_MESSAGES/bridgedb.po   |  358 +--
 bridgedb/i18n/bs/LC_MESSAGES/bridgedb.po   |  399 
 bridgedb/i18n/ca/LC_MESSAGES/bridgedb.po   |  398 ++--
 bridgedb/i18n/cs/LC_MESSAGES/bridgedb.po   |  360 +--
 bridgedb/i18n/da/LC_MESSAGES/bridgedb.po   |  399 ++--
 bridgedb/i18n/de/LC_MESSAGES/bridgedb.po   |  360 +--
 bridgedb/i18n/el/LC_MESSAGES/bridgedb.po   |  360 +--
 bridgedb/i18n/en_GB/LC_MESSAGES/bridgedb.po|  358 +--
 bridgedb/i18n/eo/LC_MESSAGES/bridgedb.po   |  359 +--
 bridgedb/i18n/es/LC_MESSAGES/bridgedb.po   |  360 +--
 bridgedb/i18n/es_AR/LC_MESSAGES/bridgedb.po|  359 +--
 bridgedb/i18n/es_MX/LC_MESSAGES/bridgedb.po|  356 +--
 bridgedb/i18n/et/LC_MESSAGES/bridgedb.po   |  359 +--
 bridgedb/i18n/eu/LC_MESSAGES/bridgedb.po   |  427 +++-
 bridgedb/i18n/fa/LC_MESSAGES/bridgedb.po   |  373 +--
 bridgedb/i18n/fi/LC_MESSAGES/bridgedb.po   |  358 +--
 bridgedb/i18n/fr/LC_MESSAGES/bridgedb.po   |  363 +--
 bridgedb/i18n/ga/LC_MESSAGES/bridgedb.po   |  358 +--
 bridgedb/i18n/gd/LC_MESSAGES/bridgedb.po   |  399 
 bridgedb/i18n/gl/LC_MESSAGES/bridgedb.po   |  356 +--
 bridgedb/i18n/gu/LC_MESSAGES/bridgedb.po   |  399 
 bridgedb/i18n/he/LC_MESSAGES/bridgedb.po   |  366 +--
 bridgedb/i18n/hi/LC_MESSAGES/bridgedb.po   |  356 +--
 bridgedb/i18n/hr/LC_MESSAGES/bridgedb.po   |  401 ++--
 bridgedb/i18n/hu/LC_MESSAGES/bridgedb.po   |  361 +--
 bridgedb/i18n/hy/LC_MESSAGES/bridgedb.po   |  356 +--
 bridgedb/i18n/id/LC_MESSAGES/bridgedb.po   |  366 +--
 bridgedb/i18n/is/LC_MESSAGES/bridgedb.po   |  358 +--
 bridgedb/i18n/it/LC_MESSAGES/bridgedb.po   |  362 +--
 bridgedb/i18n/ja/LC_MESSAGES/bridgedb.po   |  380 +--
 bridgedb/i18n/ka/LC_MESSAGES/bridgedb.po   |  357 +--
 bridgedb/i18n/kk/LC_MESSAGES/bridgedb.po   |  358 +--
 bridgedb/i18n/km/LC_MESSAGES/bridgedb.po   |  513 +++--
 bridgedb/i18n/ko/LC_MESSAGES/bridgedb.po   |  361 +--
 bridgedb/i18n/lt/LC_MESSAGES/bridgedb.po   |  406 
 bridgedb/i18n/lv/LC_MESSAGES/bridgedb.po   |  356 +--
 bridgedb/i18n/mk/LC_MESSAGES/bridgedb.po   |  357 +--
 bridgedb/i18n/ml/LC_MESSAGES/bridgedb.po   |  404 
 bridgedb/i18n/mr/LC_MESSAGES/bridgedb.po   |  400 
 bridgedb/i18n/ms_MY/LC_MESSAGES/bridgedb.po|  356 +--
 bridgedb/i18n/nb/LC_MESSAGES/bridgedb.po   |  366 

[tor-commits] [bridgedb/master] Refactor script.

2020-05-27 Thread phw
commit 91af6c1bbad6a71663372642c5b6531cd197e806
Author: Philipp Winter 
Date:   Tue Feb 18 10:59:14 2020 -0800

Refactor script.
---
 scripts/nagios-email-check | 191 +
 scripts/nagios_email_check | 162 --
 2 files changed, 191 insertions(+), 162 deletions(-)

diff --git a/scripts/nagios-email-check b/scripts/nagios-email-check
new file mode 100755
index 000..7287646
--- /dev/null
+++ b/scripts/nagios-email-check
@@ -0,0 +1,191 @@
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+#
+# This file is part of  BridgeDB, a Tor bridge distribution system.
+#
+# This script sends an email request for bridges to BridgeDB and then checks if
+# it got a response.  The result is written to STATUS_FILE, which is consumed
+# by Nagios.  Whenever BridgeDB fails to respond with bridges, we will get a
+# Nagios alert.
+#
+# Run this script via crontab every three hours as follows:
+#   0 */3 * * * path/to/nagios-email-check $(cat path/to/gmail.key)
+
+
+import sys
+import smtplib
+import time
+import imaplib
+import email
+import email.utils
+
+# Standard Nagios return codes
+OK, WARNING, CRITICAL, UNKNOWN = range(4)
+
+FROM_EMAIL = "testbridgestorbrow...@gmail.com"
+TO_EMAIL = "brid...@torproject.org"
+SMTP_SERVER = "imap.gmail.com"
+SMTP_PORT = 993
+
+MESSAGE_FROM = TO_EMAIL
+MESSAGE_BODY = "Here are your bridges:"
+
+STATUS_FILE = "/srv/bridges.torproject.org/check/status"
+
+# This will contain our test email's message ID.  We later make sure that this
+# message ID is referenced in the In-Reply-To header of BridgeDB's response.
+MESSAGE_ID = None
+
+
+def log(*args, **kwargs):
+"""
+Generic log function.
+"""
+
+print("[+]", *args, file=sys.stderr, **kwargs)
+
+
+def get_email_response(password):
+"""
+Open our Gmail inbox and see if we got a response.
+"""
+
+log("Checking for email response.")
+mail = imaplib.IMAP4_SSL(SMTP_SERVER)
+try:
+mail.login(FROM_EMAIL, password)
+except Exception as e:
+return WARNING, str(e)
+
+mail.select("INBOX")
+
+_, data = mail.search(None, "ALL")
+email_ids = data[0].split()
+if len(email_ids) == 0:
+log("Found no response.")
+return CRITICAL, "No emails from BridgeDB found"
+
+return check_email(mail, email_ids)
+
+
+def check_email(mail, email_ids):
+"""
+Check if we got our expected email response.
+"""
+
+log("Checking {:,} emails.".format(len(email_ids)))
+for email_id in email_ids:
+_, data = mail.fetch(email_id, "(RFC822)")
+
+# The variable `data` contains the full email object fetched by imaplib
+# 
+# We are only interested in the response part containing the email
+# envelope.
+for response_part in data:
+if isinstance(response_part, tuple):
+m = str(response_part[1], "utf-8")
+msg = email.message_from_string(m)
+email_from = "{}".format(msg["From"])
+email_body = "{}".format(msg.as_string())
+email_reply_to = "{}".format(msg["In-Reply-To"])
+
+if (MESSAGE_FROM == email_from) and \
+   (MESSAGE_BODY in email_body) and \
+   (MESSAGE_ID == email_reply_to):
+mail.store(email_id, '+X-GM-LABELS', '\\Trash')
+mail.expunge()
+mail.close()
+mail.logout()
+log("Found correct response (referencing {})."
+.format(MESSAGE_ID))
+return OK, "BridgeDB's email responder works"
+else:
+mail.store(email_id, '+X-GM-LABELS', '\\Trash')
+mail.expunge()
+mail.close()
+mail.logout()
+log("Found no response.")
+return WARNING, "No emails from BridgeDB found"
+
+
+def send_email_request(password):
+"""
+Attempt to send a bridge request over Gmail.
+"""
+
+subject = "Bridges"
+body = "get bridges"
+
+log("Sending email.")
+global MESSAGE_ID
+MESSAGE_ID = email.utils.make_msgid(idstring="test-bridgedb",
+domain="gmail.com")
+email_text = "From: %s\r\nTo: %s\r\nMessage-ID: %s\r\nSubject: %s\r\n" \
+ "\r\n%s" % (FROM_EMAIL, TO_EMAIL, MESSAGE_ID, subject, body)
+
+try:
+mail = smtplib.SMTP_SSL("smtp.gmail.com", 465)
+mail.login(FROM_EMAIL, password)
+mail.sendmail(FROM_EMAIL, TO_EMAIL, email_text)
+mail.close()
+log("Email successfully sent (message ID: %s)." % MESSAGE_ID)
+return OK, "Sent email bridge request"
+except Exception as e:
+log("Error while sending email: %s" % err)
+return UNKNOWN, str(e)
+
+
+def write_status_file(status, message):
+"""
+Write the given `status` and 

[tor-commits] [bridgedb/master] Add new fields to BlockedBridges.

2020-05-27 Thread phw
commit 3337b4ac349cd9d4021f9b0616e179be99958c0a
Author: Philipp Winter 
Date:   Wed May 20 14:22:05 2020 -0700

Add new fields to BlockedBridges.

Our new tool wolpertinger will populate these fields after delegating
censorship measurement to OONI.

This fixes .
---
 CHANGELOG   | 4 
 bridgedb/Storage.py | 8 +++-
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/CHANGELOG b/CHANGELOG
index 5ac9e0b..80d3afa 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,7 @@
+* FIXES https://bugs.torproject.org/34154
+Add new fields to the SQLite table BlockedBridges in preparation for taking
+into account OONI's bridge measurement results.
+
 * FIXES https://bugs.torproject.org/31528
 BridgeDB's UI uses a bunch of obscure "chatspeak" references in its UI.  
One
 example is that it responds with "Uh oh, spaghettios!" if there are
diff --git a/bridgedb/Storage.py b/bridgedb/Storage.py
index d725fa3..0fe8851 100644
--- a/bridgedb/Storage.py
+++ b/bridgedb/Storage.py
@@ -70,7 +70,13 @@ SCHEMA2_SCRIPT = """
  CREATE TABLE BlockedBridges (
  id INTEGER PRIMARY KEY NOT NULL,
  hex_key,
- blocking_country
+ bridge_type,
+ address,
+ port,
+ blocking_country,
+ blocking_asn,
+ measured_by,
+ last_measured
  );
 
  CREATE INDEX BlockedBridgesBlockingCountry on BlockedBridges(hex_key);



___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [bridgedb/master] Merge branch 'defect/33945' into develop

2020-05-27 Thread phw
commit 5c0b04ed012cb81574d459f847db534086ce62d0
Merge: 19ba2da 2abd54a
Author: Philipp Winter 
Date:   Fri May 22 15:52:45 2020 -0700

Merge branch 'defect/33945' into develop

 CHANGELOG   |  4 
 bridgedb/Storage.py | 63 +
 2 files changed, 5 insertions(+), 62 deletions(-)



___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [bridgedb/master] Don't assume a line can be decoded as UTF-8.

2020-05-27 Thread phw
commit 8cdbbebdc458ff162e936ad5b979a38f433a01b5
Author: Philipp Winter 
Date:   Tue Apr 21 11:10:27 2020 -0700

Don't assume a line can be decoded as UTF-8.

For example, we may be dealing with text that's cp1252-encoded.
BridgeDB gets a lot of spam like that:

  b"Subject: Ich m\xf6chte Sie treffen"
  b'Subject: Wei\xdft du, wie man ein M\xe4dchen anmacht?'

Instead of trying really hard to figure out what encoding we're dealing
with, we simply ignore characters we cannot decode.
---
 bridgedb/distributors/email/server.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/bridgedb/distributors/email/server.py 
b/bridgedb/distributors/email/server.py
index f18a5ad..54a8231 100644
--- a/bridgedb/distributors/email/server.py
+++ b/bridgedb/distributors/email/server.py
@@ -212,7 +212,7 @@ class SMTPMessage(object):
 if self.nBytes > self.context.maximumSize:
 self.ignoring = True
 else:
-self.lines.append(line.decode('utf-8') if isinstance(line, bytes) 
else line)
+self.lines.append(line.decode('utf-8', 'ignore') if 
isinstance(line, bytes) else line)
 if not safelog.safe_logging:
 try:
 ln = line.rstrip("\r\n").encode('utf-8', 'replace')



___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [bridgedb/master] Add missing newline at the end of the file.

2020-05-27 Thread phw
commit 9f8e95de1bc7945869eda4bdde3755eafcdad6bd
Author: Philipp Winter 
Date:   Thu May 7 08:25:22 2020 -0700

Add missing newline at the end of the file.
---
 scripts/nagios-email-check | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/nagios-email-check b/scripts/nagios-email-check
index 7287646..b9fc831 100755
--- a/scripts/nagios-email-check
+++ b/scripts/nagios-email-check
@@ -149,7 +149,7 @@ def write_status_file(status, message):
 code = codes.get(status, UNKNOWN)
 
 with open(STATUS_FILE, "w") as fd:
-fd.write("{}\n{}: {}".format(code, status, message))
+fd.write("{}\n{}: {}\n".format(code, status, message))
 log("Wrote status='%s', message='%s' to status file." % (status, message))
 
 



___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [bridgedb/master] Add CHANGELOG entry for #31528.

2020-05-27 Thread phw
commit 77870a9d64d95facd5c3f79e223451640811871b
Author: Philipp Winter 
Date:   Thu May 14 14:20:31 2020 -0700

Add CHANGELOG entry for #31528.
---
 CHANGELOG | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/CHANGELOG b/CHANGELOG
index 7a7a524..cfee3f9 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,10 @@
+* FIXES https://bugs.torproject.org/31528
+BridgeDB's UI uses a bunch of obscure "chatspeak" references in its UI.
+One example is that it responds with "Uh oh, spaghettios!" if there are
+currently no bridges available.  While funny to some, this is difficult
+to translate and shouldn't be part of software that's used by an
+international audience.  This patch removes such references.
+
 * FIXES https://bugs.torproject.org/12802
 Add a script that sends a bridge request over email, and then checks if
 it received a response from BridgeDB.  We use this script as part of



___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [bridgedb/master] Feedback implmentation

2020-05-27 Thread phw
commit a2a37821da95e0195b35543c0772eadf0f854734
Author: agix 
Date:   Sat May 2 10:39:58 2020 +0200

Feedback implmentation

Removed link from error pages
Changed missed chatspeak string
---
 bridgedb/distributors/https/templates/error-400.html | 2 +-
 bridgedb/distributors/https/templates/error-500.html | 2 +-
 bridgedb/test/test_https_server.py   | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/bridgedb/distributors/https/templates/error-400.html 
b/bridgedb/distributors/https/templates/error-400.html
index 5f12dda..9430c00 100644
--- a/bridgedb/distributors/https/templates/error-400.html
+++ b/bridgedb/distributors/https/templates/error-400.html
@@ -22,7 +22,7 @@
 
 
   Bad Request
-  Your request was not understood by the server.BridgeDB
+  Your request was not understood by the server.
 
   
 
diff --git a/bridgedb/distributors/https/templates/error-500.html 
b/bridgedb/distributors/https/templates/error-500.html
index e17b2f4..1408293 100644
--- a/bridgedb/distributors/https/templates/error-500.html
+++ b/bridgedb/distributors/https/templates/error-500.html
@@ -28,7 +28,7 @@
 
 
   Internal Error
-  BridgeDB encountered an internal errorBridgeDB
+  BridgeDB encountered an internal error
 
   
 
diff --git a/bridgedb/test/test_https_server.py 
b/bridgedb/test/test_https_server.py
index 3b159ce..c523c1e 100644
--- a/bridgedb/test/test_https_server.py
+++ b/bridgedb/test/test_https_server.py
@@ -86,7 +86,7 @@ class ReplaceErrorPageTests(unittest.TestCase):
 ``replaceErrorPage`` should return custom hardcoded HTML error text.
 """
 request = DummyRequest([''])
-exc = Exception("vegan gümmibären")
+exc = Exception("Error while rendering")
 server.resource500 = None
 errorPage = server.replaceErrorPage(request, exc)
 self.assertNotSubstring(b"Bad Request", errorPage)



___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [bridgedb/master] Fix typos in comment.

2020-05-27 Thread phw
commit b718662658589c4baaecef7c87aa5c589ed5fb3b
Author: Philipp Winter 
Date:   Tue Apr 21 11:11:15 2020 -0700

Fix typos in comment.
---
 bridgedb/distributors/https/request.py | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/bridgedb/distributors/https/request.py 
b/bridgedb/distributors/https/request.py
index 3236bee..0add358 100644
--- a/bridgedb/distributors/https/request.py
+++ b/bridgedb/distributors/https/request.py
@@ -92,9 +92,8 @@ class HTTPSBridgeRequest(bridgerequest.BridgeRequestBase):
 :api:`request ` ``unblocked=`` HTTP GET
 parameter will be added to the :data:`notBlockedIn` list.
 
-If :data:`addClientCountryCode` is ``True``, the the client's own
-geolocated country code will be added to the to the
-:data`notBlockedIn` list.
+If :data:`addClientCountryCode` is ``True``, then the client's own
+geolocated country code will be added to the :data`notBlockedIn` list.
 
 :type request: :api:`twisted.web.http.Request`
 :param request: A ``Request`` object containing the HTTP method, full



___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [bridgedb/master] Bump version number to 0.10.1.

2020-05-27 Thread phw
commit 64c29beb19071271593363b957598fbc56ed4a3b
Author: Philipp Winter 
Date:   Wed May 27 10:05:16 2020 -0700

Bump version number to 0.10.1.
---
 CHANGELOG | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/CHANGELOG b/CHANGELOG
index aad33f2..6dfa43c 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,5 @@
+Changes in version 0.10.1 - 2020-05-27
+
 * FIXES https://bugs.torproject.org/33945
 This patch fixes a bug that caused the email autoresponder to fail after
 a while.



___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [bridgedb/master] Add CHANGELOG entry.

2020-05-27 Thread phw
commit 6e191f82b1451525b547c28f439180c4b7d25a4a
Author: Philipp Winter 
Date:   Mon Mar 23 17:31:52 2020 -0700

Add CHANGELOG entry.
---
 CHANGELOG | 5 +
 1 file changed, 5 insertions(+)

diff --git a/CHANGELOG b/CHANGELOG
index 7524344..7a7a524 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,8 @@
+* FIXES https://bugs.torproject.org/12802
+Add a script that sends a bridge request over email, and then checks if
+it received a response from BridgeDB.  We use this script as part of
+our nagios setup, so we notice when our autoresponder breaks.
+
 * FIXES https://bugs.torproject.org/17548
 This patch removes PGP support.  BridgeDB's signing key expired on
 2015-09-11.  Nobody ever complained and maintaining the bits and pieces



___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [bridgedb/master] Commit for #31528 (Get rid of BridgeDB's "chatspeak")

2020-05-27 Thread phw
commit 320ddd1747cd584dd6cf9d7a2ff3f571827d1089
Author: agix 
Date:   Thu Apr 30 10:18:46 2020 +0200

Commit for #31528 (Get rid of BridgeDB's "chatspeak")

Known chatspeak references have been removed or replaced
Malicious requests are now redirected with the status code 400
---
 README.rst | 12 -
 bridgedb/distributors/https/server.py  | 11 
 .../https/templates/assets/css/main.css|  4 +--
 bridgedb/distributors/https/templates/bridges.html | 13 ++
 .../distributors/https/templates/error-400.html| 30 ++
 .../distributors/https/templates/error-500.html|  4 +--
 bridgedb/test/test_https_server.py | 18 ++---
 7 files changed, 56 insertions(+), 36 deletions(-)

diff --git a/README.rst b/README.rst
index 858562e..1b0a840 100644
--- a/README.rst
+++ b/README.rst
@@ -78,8 +78,8 @@ Dependencies and installation
 
 BridgeDB requires the following OS-level dependencies:
 
--  python>=2.7
--  python-dev
+-  python>=3
+-  python3-dev
 -  `python3-dkim `__ (it contains the 
``dkimverify`` binary)
 -  build-essential
 -  OpenSSL>=1.0.1g
@@ -106,11 +106,11 @@ Deploying BridgeDB
 
 BridgeDB should work with or without a Python virtualenv.
 
--  Install Python 2.7, and other OS-level dependencies. On Debian, you
+-  Install Python 3, and other OS-level dependencies. On Debian, you
can do::
 
- sudo apt-get install build-essential openssl python python-dev \
-   python-setuptools sqlite3 libgeoip-dev geoip-database
+ sudo apt-get install build-essential openssl python3 python3-dev \
+   python3-setuptools sqlite3 gnupg2 libgeoip-dev geoip-database
 
 
 -  Install Pip 1.3.1 or later. Debian has this version, but if for some
@@ -146,7 +146,7 @@ BridgeDB should work with or without a Python virtualenv.
 -  **(virtualenv installs only)** To install, set PYTHONPATH to include the
root directory of the virtualenv::
 
- export 
PYTHONPATH=$PYTHONPATH:${VIRTUAL_ENV}/lib/python2.7/site-packages
+ export 
PYTHONPATH=$PYTHONPATH:${VIRTUAL_ENV}/lib/python3.7/site-packages
 
 
 -  Then, proceed as usual::
diff --git a/bridgedb/distributors/https/server.py 
b/bridgedb/distributors/https/server.py
index b2de4b1..91757e7 100644
--- a/bridgedb/distributors/https/server.py
+++ b/bridgedb/distributors/https/server.py
@@ -166,11 +166,9 @@ def replaceErrorPage(request, error, template_name=None, 
html=True):
 
 
 def redirectMaliciousRequest(request):
-'''Redirect the client to a "daring work of art" which "in true
-post-modern form, […] tends to raise more questions than answers."
-'''
-logging.debug("Redirecting %s to a daring work of art..." % 
getClientIP(request))
-request.write(redirectTo(base64.b64decode("aHR0cDovLzJnaXJsczFjdXAuY2Ev"), 
request))
+'''Setting the reponse code to 400 (Bad Request)'''
+logging.debug("Setting response code to 400 for %s" % getClientIP(request))
+request.setResponseCode(400)
 request.finish()
 return request
 
@@ -367,7 +365,7 @@ class ErrorResource(CSPResource):
 
 render_POST = render_GET
 
-
+resource400 = ErrorResource('error-400.html', code=400)
 resource404 = ErrorResource('error-404.html', code=404)
 resource500 = ErrorResource('error-500.html', code=500)
 maintenance = ErrorResource('error-503.html', code=503)
@@ -1157,6 +1155,7 @@ def addWebServer(config, distributor):
 root.putChild(b'info', info)
 root.putChild(b'maintenance', maintenance)
 root.putChild(b'error', resource500)
+root.putChild(b'malicious', resource400)
 root.putChild(CSPResource.reportURI, csp)
 
 if config.RECAPTCHA_ENABLED:
diff --git a/bridgedb/distributors/https/templates/assets/css/main.css 
b/bridgedb/distributors/https/templates/assets/css/main.css
index 72a3205..8ff1f07 100644
--- a/bridgedb/distributors/https/templates/assets/css/main.css
+++ b/bridgedb/distributors/https/templates/assets/css/main.css
@@ -373,11 +373,11 @@ div.bridge-lines.-webkit-scrollbar-thumb.horizontal{
   align-content: left;
 }
 
-#uh-oh-spaghettios {
+#error {
   width: 80%;
   margin: auto;
 }
-.uh-oh-spaghettios~p {
+.error~p {
   text-align: center;
   font-size: 115%;
 }
diff --git a/bridgedb/distributors/https/templates/bridges.html 
b/bridgedb/distributors/https/templates/bridges.html
index 55a9e79..1d672eb 100644
--- a/bridgedb/distributors/https/templates/bridges.html
+++ b/bridgedb/distributors/https/templates/bridges.html
@@ -60,11 +60,6 @@ ${bridgeline | h,trim}
   
 % else:
   
-## TRANSLATORS: Please translate this into some silly way to say
-##  "There was a problem!" in your language. For example,
-##  for Italian, you might translate this into "Mama mia!",
-##  or for French: "Sacrebleu!". :)
-${_("""Uh oh, spaghettios!""")}
 ${_("""It seems there was an error 

[tor-commits] [bridgedb/master] Re-flow indentation of bugfix items.

2020-05-27 Thread phw
commit 9ac52d508566a4200be37262e9dd1afa85f4ac8e
Author: Philipp Winter 
Date:   Thu May 14 14:33:31 2020 -0700

Re-flow indentation of bugfix items.

The excessive 8-character indentation has been bothering me forever.
This patch reduces indentation to four characters and re-flows all
bugfix items.
---
 CHANGELOG | 2443 ++---
 1 file changed, 1184 insertions(+), 1259 deletions(-)

diff --git a/CHANGELOG b/CHANGELOG
index cfee3f9..5ac9e0b 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,1549 +1,1474 @@
-* FIXES https://bugs.torproject.org/31528
-BridgeDB's UI uses a bunch of obscure "chatspeak" references in its UI.
-One example is that it responds with "Uh oh, spaghettios!" if there are
-currently no bridges available.  While funny to some, this is difficult
-to translate and shouldn't be part of software that's used by an
-international audience.  This patch removes such references.
-
-* FIXES https://bugs.torproject.org/12802
-Add a script that sends a bridge request over email, and then checks if
-it received a response from BridgeDB.  We use this script as part of
-our nagios setup, so we notice when our autoresponder breaks.
-
-* FIXES https://bugs.torproject.org/17548
-This patch removes PGP support.  BridgeDB's signing key expired on
-2015-09-11.  Nobody ever complained and maintaining the bits and pieces
-necessary to sign emails isn't worth the effort, so this patch removes
-that feature.
-
-* FIXES https://bugs.torproject.org/30941
-Make our email responder more usable.  This patch removes the concept 
of
-"valid" email commands and returns bridges (obfs4, for now) no matter
-what the user sends.  BridgeDB still supports email commands in case 
the
-user needs a vanilla or IPv6 bridge.
-
-* FIXES https://bugs.torproject.org/29686
-Rename files that contain "Bridges" to "bridgerings", to eliminate
-headache on file systems that are case insensitive.
+* FIXES https://bugs.torproject.org/31528
+BridgeDB's UI uses a bunch of obscure "chatspeak" references in its UI.  
One
+example is that it responds with "Uh oh, spaghettios!" if there are
+currently no bridges available.  While funny to some, this is difficult to
+translate and shouldn't be part of software that's used by an international
+audience.  This patch removes such references.
+
+* FIXES https://bugs.torproject.org/12802
+Add a script that sends a bridge request over email, and then checks if it
+received a response from BridgeDB.  We use this script as part of our 
nagios
+setup, so we notice when our autoresponder breaks.
+
+* FIXES https://bugs.torproject.org/17548
+This patch removes PGP support.  BridgeDB's signing key expired on
+2015-09-11.  Nobody ever complained and maintaining the bits and pieces
+necessary to sign emails isn't worth the effort, so this patch removes that
+feature.
+
+* FIXES https://bugs.torproject.org/30941
+Make our email responder more usable.  This patch removes the concept of
+"valid" email commands and returns bridges (obfs4, for now) no matter what
+the user sends.  BridgeDB still supports email commands in case the user
+needs a vanilla or IPv6 bridge.
+
+* FIXES https://bugs.torproject.org/29686
+Rename files that contain "Bridges" to "bridgerings", to eliminate headache
+on file systems that are case insensitive.
 
 Changes in version 0.10.0 - 2020-04-01
 
-* FIXES https://bugs.torproject.org/30317
-Update our "howto" box, which explains how one adds bridges to Tor
-Browser.  In addition to updating the instructions, this patch also
-links to instructions for Android.
+* FIXES https://bugs.torproject.org/30317
+Update our "howto" box, which explains how one adds bridges to Tor Browser.
+In addition to updating the instructions, this patch also links to
+instructions for Android.
 
-* FIXES https://bugs.torproject.org/33631
-So far, BridgeDB remembered only the first distribution mechanism it
-ever learned for a given bridge.  That means that if a bridge would
-change its mind and re-configure its distribution mechanism using
-BridgeDistribution, BridgeDB would ignore it.  This patch changes this
-behavior, so bridges can actually change their distribution mechanism.
+* FIXES https://bugs.torproject.org/33631
+So far, BridgeDB remembered only the first distribution mechanism it ever
+learned for a given bridge.  That means that if a bridge would change its
+mind and re-configure its distribution mechanism using BridgeDistribution,
+BridgeDB would ignore it.  This patch changes this behavior, so bridges can
+actually change their distribution 

[tor-commits] [bridgedb/master] Use contextlib's context manager.

2020-05-27 Thread phw
commit 2abd54a1b979c11153c41a51b884386fbd4635c4
Author: Philipp Winter 
Date:   Wed May 6 17:54:59 2020 -0700

Use contextlib's context manager.

So far, the email autoresponder fails after a while, raising the
following exception:

  File 
"/home/bridgedb/virtualenvs/bridgedb/lib/python3.7/site-packages/twisted/internet/posixbase.py",
 line 614, in _doReadOrWrite
why = selectable.doRead()
  File 
"/home/bridgedb/virtualenvs/bridgedb/lib/python3.7/site-packages/twisted/internet/tcp.py",
 line 243, in doRead
return self._dataReceived(data)
  File 
"/home/bridgedb/virtualenvs/bridgedb/lib/python3.7/site-packages/twisted/internet/tcp.py",
 line 249, in _dataReceived
rval = self.protocol.dataReceived(data)
  File 
"/home/bridgedb/virtualenvs/bridgedb/lib/python3.7/site-packages/twisted/protocols/basic.py",
 line 454, in dataReceived
self.lineReceived(line)
  File 
"/home/bridgedb/virtualenvs/bridgedb/lib/python3.7/site-packages/twisted/mail/smtp.py",
 line 445, in lineReceived
return getattr(self, 'state_' + self.mode)(line)
  File 
"/home/bridgedb/virtualenvs/bridgedb/lib/python3.7/site-packages/twisted/mail/smtp.py",
 line 705, in dataLineReceived
m.eomReceived() for m in self.__messages
  File 
"/home/bridgedb/virtualenvs/bridgedb/lib/python3.7/site-packages/twisted/mail/smtp.py",
 line 705, in 
m.eomReceived() for m in self.__messages
  File 
"/home/bridgedb/virtualenvs/bridgedb/lib/python3.7/site-packages/bridgedb-0.10.0+11.g4cdd6a61.dirty-py3.7.egg/bridgedb/distributors/email/server.py",
 line 230, in eomReceived
self.responder.reply()
  File 
"/home/bridgedb/virtualenvs/bridgedb/lib/python3.7/site-packages/bridgedb-0.10.0+11.g4cdd6a61.dirty-py3.7.egg/bridgedb/distributors/email/autoresponder.py",
 line 574, in reply
response = self.getMailData()
  File 
"/home/bridgedb/virtualenvs/bridgedb/lib/python3.7/site-packages/bridgedb-0.10.0+11.g4cdd6a61.dirty-py3.7.egg/bridgedb/distributors/email/autoresponder.py",
 line 392, in getMailData
client, lang)
  File 
"/home/bridgedb/virtualenvs/bridgedb/lib/python3.7/site-packages/bridgedb-0.10.0+11.g4cdd6a61.dirty-py3.7.egg/bridgedb/distributors/email/autoresponder.py",
 line 101, in createResponseBody
bridges = context.distributor.getBridges(bridgeRequest, interval)
  File 
"/home/bridgedb/virtualenvs/bridgedb/lib/python3.7/site-packages/bridgedb-0.10.0+11.g4cdd6a61.dirty-py3.7.egg/bridgedb/distributors/email/distributor.py",
 line 145, in getBridges
with bridgedb.Storage.getDB() as db:
  File 
"/home/bridgedb/virtualenvs/bridgedb/lib/python3.7/site-packages/bridgedb-0.10.0+11.g4cdd6a61.dirty-py3.7.egg/bridgedb/Storage.py",
 line 352, in __enter__
return next(self.gen)
  File 
"/home/bridgedb/virtualenvs/bridgedb/lib/python3.7/site-packages/bridgedb-0.10.0+11.g4cdd6a61.dirty-py3.7.egg/bridgedb/Storage.py",
 line 472, in getDB
assert _REFCOUNT == 0
builtins.AssertionError:

It's not clear what caused this regression but it may have been
introduced in commit c1a48d1, as part of our conversion to Python 3.

This fixes .
---
 CHANGELOG   |  4 
 bridgedb/Storage.py | 63 +
 2 files changed, 5 insertions(+), 62 deletions(-)

diff --git a/CHANGELOG b/CHANGELOG
index 80d3afa..aad33f2 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,7 @@
+* FIXES https://bugs.torproject.org/33945
+This patch fixes a bug that caused the email autoresponder to fail after
+a while.
+
 * FIXES https://bugs.torproject.org/34154
 Add new fields to the SQLite table BlockedBridges in preparation for taking
 into account OONI's bridge measurement results.
diff --git a/bridgedb/Storage.py b/bridgedb/Storage.py
index 0fe8851..2859cf1 100644
--- a/bridgedb/Storage.py
+++ b/bridgedb/Storage.py
@@ -10,6 +10,7 @@ import time
 import hashlib
 from functools import wraps
 from ipaddr import IPAddress
+from contextlib import contextmanager
 import sys
 
 from bridgedb.Stability import BridgeHistory
@@ -345,68 +346,6 @@ def openDatabase(sqlite_file):
 return conn
 
 
-class DBGeneratorContextManager(object):
-"""Helper for @contextmanager decorator.
-
-Overload __exit__() so we can call the generator many times
-"""
-
-def __init__(self, gen):
-  self.gen = gen
-
-def __enter__(self):
-  return next(self.gen)
-
-def __exit__(self, type, value, traceback):
-"""Handle exiting a with statement block
-
-Progress generator or throw exception
-
-Significantly based on contextlib.py
-
-:throws: `RuntimeError` if the generator doesn't stop after
-exception is thrown
-"""
-if type is None:
-try:
-next(self.gen)
-except StopIteration:
-

[tor-commits] [bridgedb/master] Merge branch 'enhancement/12802' into develop

2020-05-27 Thread phw
commit cc3277b7449fc4125c179b99962ef86e1b39b22c
Merge: 4cdd6a6 74b159e
Author: Philipp Winter 
Date:   Mon May 11 12:26:49 2020 -0700

Merge branch 'enhancement/12802' into develop

 CHANGELOG  |   5 +
 bridgedb/distributors/email/server.py  |   2 +-
 bridgedb/distributors/https/request.py |   5 +-
 scripts/nagios-email-check | 201 +
 4 files changed, 209 insertions(+), 4 deletions(-)



___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [bridgedb/master] Update our strings to get them translated.

2020-05-27 Thread phw
commit aba3c3465b63b1d2116132f00cb865b7f7b35c45
Author: Philipp Winter 
Date:   Thu May 14 14:21:59 2020 -0700

Update our strings to get them translated.
---
 bridgedb/i18n/templates/bridgedb.pot | 29 -
 1 file changed, 12 insertions(+), 17 deletions(-)

diff --git a/bridgedb/i18n/templates/bridgedb.pot 
b/bridgedb/i18n/templates/bridgedb.pot
index bb78824..273e1e4 100644
--- a/bridgedb/i18n/templates/bridgedb.pot
+++ b/bridgedb/i18n/templates/bridgedb.pot
@@ -5,18 +5,18 @@
 #
 msgid ""
 msgstr ""
-"Project-Id-Version: bridgedb 0.10.0+10.g96de503\n"
+"Project-Id-Version: bridgedb 0.10.0+25.g77870a9\n"
 "Report-Msgid-Bugs-To: "
 
"'https://trac.torproject.org/projects/tor/newticket?component=BridgeDB;
 "=bridgedb-reported,msgid=isis,sysrqb=isis'\n"
-"POT-Creation-Date: 2020-04-09 14:45-0700\n"
+"POT-Creation-Date: 2020-05-14 14:21-0700\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 "Last-Translator: FULL NAME \n"
 "Language-Team: LANGUAGE \n"
 "MIME-Version: 1.0\n"
 "Content-Type: text/plain; charset=utf-8\n"
 "Content-Transfer-Encoding: 8bit\n"
-"Generated-By: Babel 2.7.0\n"
+"Generated-By: Babel 2.8.0\n"
 
 #. -*- coding: utf-8 ; test-case-name: bridgedb.test.test_https_server -*-
 #. This file is part of BridgeDB, a Tor bridge distribution system.
@@ -78,31 +78,26 @@ msgstr ""
 msgid "QRCode for your bridge lines"
 msgstr ""
 
-#. TRANSLATORS: Please translate this into some silly way to say
-#. "There was a problem!" in your language. For example,
-#. for Italian, you might translate this into "Mama mia!",
-#. or for French: "Sacrebleu!". :)
-#: bridgedb/distributors/https/templates/bridges.html:67
-#: bridgedb/distributors/https/templates/bridges.html:119
-msgid "Uh oh, spaghettios!"
-msgstr ""
-
-#: bridgedb/distributors/https/templates/bridges.html:68
+#: bridgedb/distributors/https/templates/bridges.html:63
 msgid "It seems there was an error getting your QRCode."
 msgstr ""
 
-#: bridgedb/distributors/https/templates/bridges.html:73
+#: bridgedb/distributors/https/templates/bridges.html:68
 msgid ""
 "This QRCode contains your bridge lines. Scan it with a QRCode reader to copy "
 "your bridge lines onto mobile and other devices."
 msgstr ""
 
-#: bridgedb/distributors/https/templates/bridges.html:125
+#: bridgedb/distributors/https/templates/bridges.html:110
+msgid "BridgeDB encountered an error."
+msgstr ""
+
+#: bridgedb/distributors/https/templates/bridges.html:116
 msgid "There currently aren't any bridges available..."
 msgstr ""
 
-#: bridgedb/distributors/https/templates/bridges.html:127
-#: bridgedb/distributors/https/templates/bridges.html:131
+#: bridgedb/distributors/https/templates/bridges.html:118
+#: bridgedb/distributors/https/templates/bridges.html:122
 #, python-format
 msgid " Perhaps you should try %s going back %s and choosing a different 
bridge type!"
 msgstr ""



___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [bridgedb/master] Allow passing the Gmail key as env variable.

2020-05-27 Thread phw
commit 74b159e9c2c473f02b629cd4bf7152a363770666
Author: Philipp Winter 
Date:   Mon May 11 12:13:32 2020 -0700

Allow passing the Gmail key as env variable.
---
 scripts/nagios-email-check | 18 ++
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/scripts/nagios-email-check b/scripts/nagios-email-check
index b9fc831..51c63a1 100755
--- a/scripts/nagios-email-check
+++ b/scripts/nagios-email-check
@@ -10,8 +10,12 @@
 #
 # Run this script via crontab every three hours as follows:
 #   0 */3 * * * path/to/nagios-email-check $(cat path/to/gmail.key)
+#
+# You can provide the Gmail key as an argument (as exemplified above) or by
+# using the environment variable BRIDGEDB_GMAIL_KEY, e.g.:
+#   BRIDGEDB_GMAIL_KEY=foo path/to/nagios-email-check $(cat path/to/gmail.key)
 
-
+import os
 import sys
 import smtplib
 import time
@@ -161,9 +165,15 @@ if __name__ == "__main__":
 if len(sys.argv) == 2:
 password = sys.argv[1]
 else:
-log("No email password provided.")
-write_status_file(UNKNOWN, "No email password provided")
-sys.exit(1)
+
+# Try to find our password in an environment variable.
+
+try:
+password = os.environ["BRIDGEDB_GMAIL_KEY"]
+except KeyError:
+log("No email password provided.")
+write_status_file(UNKNOWN, "No email password provided")
+sys.exit(1)
 
 # Send an email request to BridgeDB.
 



___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [bridgedb/master] Merge branch 'defect/31528' into develop

2020-05-27 Thread phw
commit f25943ef8aabf8cc2b9b5bdfb32b422c2d4960ef
Merge: cc3277b 9ac52d5
Author: Philipp Winter 
Date:   Thu May 14 14:37:32 2020 -0700

Merge branch 'defect/31528' into develop

 CHANGELOG  | 2436 ++--
 README.rst |   12 +-
 bridgedb/distributors/https/server.py  |   11 +-
 .../https/templates/assets/css/main.css|4 +-
 bridgedb/distributors/https/templates/bridges.html |   13 +-
 .../distributors/https/templates/error-400.html|   30 +
 .../distributors/https/templates/error-500.html|4 +-
 bridgedb/i18n/templates/bridgedb.pot   |   29 +-
 bridgedb/test/test_https_server.py |   20 +-
 9 files changed, 1253 insertions(+), 1306 deletions(-)



___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [bridgedb/master] Merge branch 'defect/30941' into develop

2020-05-27 Thread phw
commit 208b49cd91ec64aaff623dfeef08d352beab6785
Merge: bca6496 8b4a087
Author: Philipp Winter 
Date:   Tue Apr 7 10:33:22 2020 -0700

Merge branch 'defect/30941' into develop

 bridgedb/i18n/templates/bridgedb.pot | 11 +--
 bridgedb/strings.py  |  4 +---
 2 files changed, 6 insertions(+), 9 deletions(-)



___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [bridgedb/master] Rename email check script and add information on how to run it

2020-05-27 Thread phw
commit ae07c0950be2ededc2c81b80137a63d85e68130d
Author: hiro 
Date:   Wed Jan 22 17:44:36 2020 +0100

Rename email check script and add information on how to run it
---
 scripts/{check_status => nagios_email_check} | 13 +
 1 file changed, 13 insertions(+)

diff --git a/scripts/check_status b/scripts/nagios_email_check
similarity index 91%
rename from scripts/check_status
rename to scripts/nagios_email_check
index 1784e6b..767d055 100644
--- a/scripts/check_status
+++ b/scripts/nagios_email_check
@@ -3,10 +3,23 @@
 #
 # This file is part of  BridgeDB, a Tor bridge distribution system.
 #
+# This scripts send an email to bridgedb requesting a bridge and check if the
+# service reply with a valid bridge. A status file is written in path specified
+# by STATUS_FILE.
+#
+# The STATUS_FILE is read by nagios that will send an alert whenever bridgedb
+# will not send a valid email response.
+#
+# Run via crontab
+# Ex: */10 * * * * /scripts/nagios_email_check $(cat 

 #   see also AUTHORS file
 #
 # :license: This is Free Software. See LICENSE for license information.
+#
+#
+
 
 import sys
 import smtplib



___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [bridgedb/master] Simplify command for requesting obfs4 bridges.

2020-05-27 Thread phw
commit 8b4a087cc2278883e1383ac786ebdee74adcd548
Author: Philipp Winter 
Date:   Tue Apr 7 10:15:29 2020 -0700

Simplify command for requesting obfs4 bridges.

Thanks to Roger for suggesting this.
---
 bridgedb/i18n/templates/bridgedb.pot | 11 +--
 bridgedb/strings.py  |  4 +---
 2 files changed, 6 insertions(+), 9 deletions(-)

diff --git a/bridgedb/i18n/templates/bridgedb.pot 
b/bridgedb/i18n/templates/bridgedb.pot
index 65f8ca6..85958bd 100644
--- a/bridgedb/i18n/templates/bridgedb.pot
+++ b/bridgedb/i18n/templates/bridgedb.pot
@@ -5,11 +5,11 @@
 #
 msgid ""
 msgstr ""
-"Project-Id-Version: bridgedb 0.10.0+8.g97621c0\n"
+"Project-Id-Version: bridgedb 0.10.0+7.gbca6496.dirty\n"
 "Report-Msgid-Bugs-To: "
 
"'https://trac.torproject.org/projects/tor/newticket?component=BridgeDB;
 "=bridgedb-reported,msgid=isis,sysrqb=isis'\n"
-"POT-Creation-Date: 2020-04-06 13:53-0700\n"
+"POT-Creation-Date: 2020-04-07 10:14-0700\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 "Last-Translator: FULL NAME \n"
 "Language-Team: LANGUAGE \n"
@@ -422,14 +422,13 @@ msgstr ""
 msgid "(Request IPv6 bridges.)"
 msgstr ""
 
-#. TRANSLATORS: Please DO NOT translate the word "TYPE".
-#: bridgedb/strings.py:185
-msgid "(Request obfuscated bridges. Replace TYPE with 'obfs4'.)"
+#: bridgedb/strings.py:184
+msgid "(Request obfs4 obfuscated bridges.)"
 msgstr ""
 
 #. TRANSLATORS: Please DO NOT translate "BridgeDB".
 #. TRANSLATORS: Please DO NOT translate "GnuPG".
-#: bridgedb/strings.py:189
+#: bridgedb/strings.py:187
 msgid "(Get a copy of BridgeDB's public GnuPG key.)"
 msgstr ""
 
diff --git a/bridgedb/strings.py b/bridgedb/strings.py
index f3ea849..6bccf81 100644
--- a/bridgedb/strings.py
+++ b/bridgedb/strings.py
@@ -181,9 +181,7 @@ bridge" field."""),
 EMAIL_COMMANDS = {
 "get bridges":  _("(Request unobfuscated Tor bridges.)"),
 "get ipv6": _("(Request IPv6 bridges.)"),
-# TRANSLATORS: Please DO NOT translate the word "TYPE".
-"get transport TYPE":   _("(Request obfuscated bridges. Replace TYPE with "
-  "'obfs4'.)"),
+"get transport obfs4":  _("(Request obfs4 obfuscated bridges.)"),
 # TRANSLATORS: Please DO NOT translate "BridgeDB".
 # TRANSLATORS: Please DO NOT translate "GnuPG".
 "get key":  _("(Get a copy of BridgeDB's public GnuPG key.)"),



___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [bridgedb/master] Remove PGP support.

2020-05-27 Thread phw
commit b366bb4af8786ca06437f7f7ce5e340c69f0f6e4
Author: Philipp Winter 
Date:   Mon Oct 14 20:49:03 2019 -0700

Remove PGP support.
---
 .gnupg/TESTING.pub  | Bin 4622 -> 0 bytes
 .gnupg/TESTING.subkeys.sec  | Bin 7212 -> 0 bytes
 .gnupg/bridgedb-offline-key.pub.asc | 113 --
 .gnupg/bridgedb-online-key.pub.asc  | 100 -
 .gnupg/gpg.conf |  96 -
 .gnupg/pubring.gpg  | Bin 4634 -> 0 bytes
 .gnupg/secring.gpg  | Bin 7224 -> 0 bytes
 .travis.requirements.txt|   1 -
 CHANGELOG   |   6 +
 README.rst  |  29 +--
 bridgedb.conf   |  45 
 bridgedb/configure.py   |   3 +-
 bridgedb/crypto.py  |  99 +
 bridgedb/distributors/email/autoresponder.py|  41 +---
 bridgedb/distributors/email/distributor.py  |   6 +-
 bridgedb/distributors/email/request.py  |  22 --
 bridgedb/distributors/email/server.py   |  10 -
 bridgedb/distributors/email/templates.py|   7 -
 bridgedb/distributors/https/server.py   |   2 -
 bridgedb/distributors/https/templates/base.html |   2 -
 bridgedb/i18n/templates/bridgedb.pot|  84 
 bridgedb/strings.py | 268 +---
 bridgedb/test/email_helpers.py  |  23 +-
 bridgedb/test/test_crypto.py| 137 
 bridgedb/test/test_email_autoresponder.py   |  15 --
 bridgedb/test/test_email_request.py |  36 +---
 bridgedb/test/test_email_templates.py   |  11 -
 bridgedb/test/test_main.py  |   5 -
 requirements.txt|   1 -
 scripts/setup-tests |   2 +-
 30 files changed, 63 insertions(+), 1101 deletions(-)

diff --git a/.gnupg/TESTING.pub b/.gnupg/TESTING.pub
deleted file mode 100644
index 764bf47..000
Binary files a/.gnupg/TESTING.pub and /dev/null differ
diff --git a/.gnupg/TESTING.subkeys.sec b/.gnupg/TESTING.subkeys.sec
deleted file mode 100644
index 688f7e9..000
Binary files a/.gnupg/TESTING.subkeys.sec and /dev/null differ
diff --git a/.gnupg/bridgedb-offline-key.pub.asc 
b/.gnupg/bridgedb-offline-key.pub.asc
deleted file mode 100644
index 47d1310..000
--- a/.gnupg/bridgedb-offline-key.pub.asc
+++ /dev/null
@@ -1,113 +0,0 @@
--BEGIN PGP PUBLIC KEY BLOCK-
-
-mQgNBFJZB+QBQADcx7laikgZOZXLm6WH2mClm7KrRChmQAHOmzvRYTElk+hVZJ6g
-qSUTdl8fvfhifZPCd3g7nJBtOhQAGlrHmJRXfdf4cTRuD73nggbYQ0NRR9VZ3MIK
-ToJDELBhgmWeNKpLcPsTpi2t9qrHf3xxM06OdxOs9lCGtW7XVYnKx3vaRNk6c0ln
-De82ZWnZr1eMoPzcjslw7AxI94hIgV1GDwTSpBndv/VwgLeBC5XNCKv0adhO/RSt
-fuZOHGT/HfI0U0C3fSTiIu4lJqEd9Qe8LUFQ7wRMrf3KSWwyWNb/OtyMfZ52PEg9
-SMWEfpr6aGwQu6yGPsE4SeHsiew5IqCMi64TZ9IcgY0fveiDzMSIAqnWQcxSL0SH
-YbwQPxuOc4Rxj/b1umjigBG/Y4rkrxCKIw6M+CRaz203zs9ntOsWfnary/w+hepA
-XLjC0yb0cP/oBB6qRyaCk2UTdqq1uWmJ2R/XhZHdZIDabxby6mvQbUQA/NEMOE/B
-VrDonP1HNo1xpnY8lltbxdFD/jDikdjIazckMWl/0fri0pyPSdiJdAK2JrUniP9Q
-eNbgcx3XvNnfjYjiQjTdqfxCTKpSmnsBNyYng6c4viOr5weBFXwEJq2Nl7+rP5pm
-TF1PeiF769z4l2Mrx3X5sQqavTzd2VBMQ6/Kmk9Emxb8e1zyQD6odqJyTi1BBAes
-F2BuKLMCVgZWOFSNGDOMoAUMZh0c6sRQtwz3KRBAuxUYm3wQPqG3XpDDcNM5YXgF
-wVU8SYVwdFpPYT5XJIv2J2u45XbPma5aR0ynGuAmNptzELHta5cgeWIMVsKQbnPN
-M6YTOy5auxLts3FZvKpTDyjBd/VRK6ihkKNKFY3gbP6RbwEK3ws/zOxqFau7sA5i
-NGv4siQTWMG++pClz/exbgHPgs3f8yO34ZbocEBdS1sDl1Lsq4qJYo2Kn5MMHCGs
-dqd7Y+E+ep6b74njb1m2UsySEE2cjj/FAFH91jfFy5PedNb/2Hx6BsPJVb7+N4eI
-pehKQQ46XAbsMq6vUtI4Y0rFiBnqvpERqATQ2QhnEh0UmH7wKVQc4MREZfeEqazV
-G/JFt5Qnt3jq8p6/qbWlOPKTLGUqGq3RXiJgEy/5i22R2ZDjafiGoG1KsZIVZg39
-N25fT8abjPWme6JI3Jv+6gKY8tURoePZcMp/rw0NFs1HtCKUAU6FEOh6uJO7KNie
-eE8qG8ItRXVYnP4f8MFyFkHZcJw27d0PT3IrCM1vJwjqgb2j2xWM/8GJDDuUyims
-jvLDH1E7ek600H3FT5c9xPcgwfMM8BOdBNu0Evm9sdZBZFket+ytXo6GKyS/d91D
-FWE+YL+25+sZJS71dnvSUWVneJrTLFasefvPfIR9/aLJoLVFHnN9sUHfVMj0KlGl
-8AuxL7QfNQawvyjoV8rw/sJOQOwwhof1gZz0ZyjuTKj0WekjmDxcRzVY0eX6BzTm
-o7r4jrHl1Mi75svnKCpXi0Vu/1ZqSnKjCjhRTXDLm7tb8b18jogsgDfs7UkUNwD/
-XF8EfTTU4KotLOODAZIW+soFJZgf8rXQZLRShQmre+PUJfADEUd3yyE9h0JIunPQ
-CxR8R8hVhK4yqFn662Ou7fEl3q8FYBBi1Ahn+263S7+WaZGo7ElwzfRb97gP1e77
-eYd8JwY7UBIQku83CxQdahdGOpAfyvhYW2mxCHVZLXObwc18VgRMa7vjCbkGRPSN
-5NecU5KGW6jU1dXuZk0jRt/9mqtYPjJ7K/EVJD9Yxmz+UdxH+BtsSRp3/5fDmHtW
-CB39a7fetp0ixN503FXPKQUvKAKykETwevmWOzHH3t6BpY/ZSjDCC35Y3dWeB54H
-qNta1r0pSWV6IARUoVteAOcuOU/l3HNzY80rL+iR0HiaszioBsd8k8u0rWXzM3BP
-3vhTzccaldSWfqoT86Jfx0YLX6EoocVS8Ka5KUA8VlJWufnPPXDlF3dULrb+ds/l
-zLazt9hF49HCpU1rZc3doRgmBYxMjYyrfK/3uarDefpfdnjbAVIoP26VpVXhLTEM
-oaD+WoTpIyLYfJQUDn1Q06Nu393JqZb8nRngyMeTs73MDJTzqdL4rZXyweeTrtYe
-4yy+Kc3CZdPlZqpkbuxP0cO0ivaTLdXsTCHDnpk16u4sDukcsmlaTF5d75nu/KIQ
-o3nk0g9NvoschDcQiExuqCUOXCkKcUvYVHsuglAuT+AqK692562JrDOVoGwkUVvm

[tor-commits] [bridgedb/master] Add more review feedback

2020-05-27 Thread phw
commit 0e5f3fef90090aba33e73702598bf4c4793bb0b1
Author: hiro 
Date:   Wed Dec 11 18:17:12 2019 +0100

Add more review feedback
---
 scripts/check_status | 89 ++--
 1 file changed, 51 insertions(+), 38 deletions(-)

diff --git a/scripts/check_status b/scripts/check_status
index 5032e33..1784e6b 100644
--- a/scripts/check_status
+++ b/scripts/check_status
@@ -25,7 +25,7 @@ SMTP_PORT   = 993
 
 MESSAGE_FROM = "brid...@torproject.org"
 MESSAGE_SUBJECT = "Bridges"
-MESSAGE_BODY = ":443"
+MESSAGE_BODY = "Here are your bridges:"
 
 STATUS_FILE = "/srv/bridgedb.torproject.org/check/status"
 
@@ -36,41 +36,54 @@ STATUS_FILE = "/srv/bridgedb.torproject.org/check/status"
 # 
 
 def test_email_from_gmail(password):
+mail = imaplib.IMAP4_SSL(SMTP_SERVER)
 try:
-mail = imaplib.IMAP4_SSL(SMTP_SERVER)
 mail.login(FROM_EMAIL, password)
-mail.select('INBOX')
+except Exception as e:
+return WARNING, str(e)
+
+mail.select('INBOX')
+
+_, data = mail.search(None, 'ALL')
+mail_ids = data[0]
+
+id_list = mail_ids.split()
+
+status, message = check_email(id_list)
+
+return status, message
+
+
+def check_email(id_list):
+first_email_id = int(str(id_list[0], 'utf-8'))
+latest_email_id = int(str(id_list[-1], 'utf-8'))
 
-type, data = mail.search(None, 'ALL')
-mail_ids = data[0]
+for i in range(int(latest_email_id), int(first_email_id), -1):
+_, data = mail.fetch(str(i), '(RFC822)')
 
-id_list = mail_ids.split()
-first_email_id = int(str(id_list[0], 'utf-8'))
-latest_email_id = int(str(id_list[-1], 'utf-8'))
 
-for i in range(int(latest_email_id), int(first_email_id), -1):
-typ, data = mail.fetch(str(i), '(RFC822)')
+# The variable data contains the full email object fetched by imaplib
+# https://docs.python.org/3/library/imaplib.html#imaplib.IMAP4.fetch
+# We are only interested in the response part containing the email 
envelope.
 
-for response_part in data:
-if isinstance(response_part, tuple):
-m = str(response_part[1], 'utf-8')
-msg = email.message_from_string(m)
-email_subject = "{}".format(msg['subject'])
-email_from = "{}".format(msg['from'])
-email_body = "{}".format(msg.as_string())
+for response_part in data:
+if isinstance(response_part, tuple):
+m = str(response_part[1], 'utf-8')
+msg = email.message_from_string(m)
+email_subject = "{}".format(msg['subject'])
+email_from = "{}".format(msg['from'])
+email_body = "{}".format(msg.as_string())
 
-if (MESSAGE_FROM == email_from) and (MESSAGE_SUBJECT == 
email_subject) and (MESSAGE_BODY in email_body):
-mail.store(str(i), '+FLAGS', '\\Deleted')
-mail.close()
-return OK, "Bridgedb is good and sending emails with 
working bridges"
-else:
-mail.store(str(i), '+FLAGS', '\\Deleted')
+if (MESSAGE_FROM == email_from) and (MESSAGE_SUBJECT == 
email_subject) and (MESSAGE_BODY in email_body):
+mail.store(str(i), '+FLAGS', '\\Deleted')
+mail.close()
+return OK, "Bridgedb is good and sending emails with 
working bridges"
+else:
+mail.store(str(i), '+FLAGS', '\\Deleted')
 
 mail.close()
 return WARNING, "No emails from gettor found"
 
-except Exception as e:
-return CRITICAL, str(e)
 
 def send_email_from_gmail(password):
 sent_from = FROM_EMAIL
@@ -95,11 +108,18 @@ if __name__ == "__main__":
 if len(sys.argv) == 2:
 password = sys.argv[1]
 else:
-password = "yourPassword"
+return UNKNOWN, "Empty email password"
 
-status_file = open(STATUS_FILE, 'r')
-message = status_file.read()
-status_file.close()
+try:
+status_file = open(STATUS_FILE, 'r')
+message = status_file.read()
+status_file.close()
+except OSError:
+status = UNKNOWN
+message = "Status file has been created {}".format(STATUS_FILE)
+status_file = open(STATUS_FILE,'w')
+status_file.write("UNKNOWN\n3: %s" % message)
+status_file.close()
 
 try:
 status, message = send_email_from_gmail(password)
@@ -120,16 +140,9 @@ if __name__ == "__main__":
 status = CRITICAL
 message = repr(e)
 finally:
+d = {0: "OK", 1: "WARNING", 2: "CRITICAL", 3: "UNKNOWN"}
 status_file = open(STATUS_FILE,'w')
-if status == OK:
-status_file.write("OK\n0: %s" % message)
-elif status == WARNING:
-   

[tor-commits] [bridgedb/master] Add review feedback

2020-05-27 Thread phw
commit 85b4a9cfe41308458b29356b1d771b192b4a7681
Author: hiro 
Date:   Wed Dec 11 17:31:17 2019 +0100

Add review feedback
---
 scripts/check_status | 91 ++--
 1 file changed, 45 insertions(+), 46 deletions(-)

diff --git a/scripts/check_status b/scripts/check_status
index 8f8f3e5..5032e33 100644
--- a/scripts/check_status
+++ b/scripts/check_status
@@ -82,7 +82,6 @@ def send_email_from_gmail(password):
 
 try:
 mail = smtplib.SMTP_SSL('smtp.gmail.com', 465)
-mail.ehlo()
 mail.login(sent_from, password)
 mail.sendmail(sent_from, sent_to, email_text)
 mail.close()
@@ -90,48 +89,48 @@ def send_email_from_gmail(password):
 except Exception as e:
 return UNKNOWN, str(e)
 
-if __name__ == "__main__":
-status, message = None, None
-
-if len(sys.argv) == 2:
-password = sys.argv[1]
-else:
-password = "yourPassword"
-
-status_file = open(STATUS_FILE, 'r')
-message = status_file.read()
-status_file.close()
-
-try:
-status, message = send_email_from_gmail(password)
-except Exception as e:
-status = UNKNOWN
-message = repr(e)
-status_file = open(STATUS_FILE,'w')
-status_file.write("UNKNOWN\n3: %s" % message)
-status_file.close()
-
-time.sleep(600)
-
-try:
-status, message = test_email_from_gmail(password)
-except KeyboardInterrupt:
-status, message = CRITICAL, "Caught Control-C..."
-except Exception as e:
-status = CRITICAL
-message = repr(e)
-finally:
-status_file = open(STATUS_FILE,'w')
-if status == OK:
-status_file.write("OK\n0: %s" % message)
-elif status == WARNING:
-status_file.write("WARNING\n1: %s" % message)
-elif status == CRITICAL:
-status_file.write("CRITICAL\n2: %s" % message)
-else:
-status_file.write("UNKNOWN\n3: %s" % message)
-status = UNKNOWN
-
-status_file.close()
-
-sys.exit(status)
+if __name__ == "__main__":
+status, message = None, None
+
+if len(sys.argv) == 2:
+password = sys.argv[1]
+else:
+password = "yourPassword"
+
+status_file = open(STATUS_FILE, 'r')
+message = status_file.read()
+status_file.close()
+
+try:
+status, message = send_email_from_gmail(password)
+except Exception as e:
+status = UNKNOWN
+message = repr(e)
+status_file = open(STATUS_FILE,'w')
+status_file.write("UNKNOWN\n3: %s" % message)
+status_file.close()
+
+time.sleep(600)
+
+try:
+status, message = test_email_from_gmail(password)
+except KeyboardInterrupt:
+status, message = CRITICAL, "Caught Control-C..."
+except Exception as e:
+status = CRITICAL
+message = repr(e)
+finally:
+status_file = open(STATUS_FILE,'w')
+if status == OK:
+status_file.write("OK\n0: %s" % message)
+elif status == WARNING:
+status_file.write("WARNING\n1: %s" % message)
+elif status == CRITICAL:
+status_file.write("CRITICAL\n2: %s" % message)
+else:
+status_file.write("UNKNOWN\n3: %s" % message)
+status = UNKNOWN
+
+status_file.close()
+
+sys.exit(status)



___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [bridgedb/master] Remove silly email footer.

2020-05-27 Thread phw
commit bcfe39f5f04adfed266490e523fe6d5e9b585047
Author: Philipp Winter 
Date:   Fri Mar 27 13:16:01 2020 -0700

Remove silly email footer.
---
 bridgedb/distributors/email/templates.py | 43 
 bridgedb/test/test_email_templates.py| 10 
 2 files changed, 53 deletions(-)

diff --git a/bridgedb/distributors/email/templates.py 
b/bridgedb/distributors/email/templates.py
index 570341a..d618c37 100644
--- a/bridgedb/distributors/email/templates.py
+++ b/bridgedb/distributors/email/templates.py
@@ -102,45 +102,8 @@ def addHowto(template):
 howToTBB += u'\n\n'
 return howToTBB
 
-def addFooter(template, clientAddress=None):
-"""Add a footer::
-
---
-<3 BridgeDB
-   
-   Public Keys: https://bridges.torproject.org/keys
-
-   This email was generated with rainbows, unicorns, and sparkles
-   for al...@example.com on Friday, 09 May, 2014 at 18:59:39.
-
-
-:type template: ``gettext.NullTranslation`` or ``gettext.GNUTranslation``
-:param template: A gettext translations instance, optionally with fallback
-languages set.
-:type clientAddress: :api:`twisted.mail.smtp.Address`
-:param clientAddress: The client's email address which should be in the
-``To:`` header of the response email.
-"""
-now = datetime.utcnow()
-clientAddr = clientAddress.addrstr
-
-footer  = u' --\n'
-footer += u' <3 BridgeDB\n'
-footer += u'_' * 70
-footer += u'\n'
-footer += template.gettext(strings.EMAIL_MISC_TEXT[8])
-footer += u': https://bridges.torproject.org/keys\n'
-footer += template.gettext(strings.EMAIL_MISC_TEXT[9]) \
-  % (clientAddr,
- now.strftime('%A, %d %B, %Y'),
- now.strftime('%H:%M:%S'))
-footer += u'\n\n'
-
-return footer
-
 def buildKeyMessage(template, clientAddress=None):
 message  = addKeyfile(template)
-message += addFooter(template, clientAddress)
 return message
 
 def buildWelcomeText(template, clientAddress=None):
@@ -159,8 +122,6 @@ def buildWelcomeText(template, clientAddress=None):
 message  = u"\n\n".join(sections)
 # Add the markdown links at the end:
 message += strings.EMAIL_REFERENCE_LINKS.get("WELCOME0")
-message += u"\n\n"
-message += addFooter(template, clientAddress)
 
 return message
 
@@ -171,8 +132,6 @@ def buildAnswerMessage(template, clientAddress=None, 
answer=None):
 message += addHowto(template)
 message += u'\n\n'
 message += addCommands(template)
-message += u'\n\n'
-message += addFooter(template, clientAddress)
 except Exception as error:  # pragma: no cover
 logging.error("Error while formatting email message template:")
 logging.exception(error)
@@ -187,8 +146,6 @@ def buildSpamWarning(template, clientAddress=None):
 message += u"\n\n"
 message += template.gettext(strings.EMAIL_MISC_TEXT[2]) \
% str(MAX_EMAIL_RATE / 3600)
-message += u"\n\n"
-message += addFooter(template, clientAddress)
 except Exception as error:  # pragma: no cover
 logging.error("Error while formatting email spam template:")
 logging.exception(error)
diff --git a/bridgedb/test/test_email_templates.py 
b/bridgedb/test/test_email_templates.py
index 4703019..1d55dd9 100644
--- a/bridgedb/test/test_email_templates.py
+++ b/bridgedb/test/test_email_templates.py
@@ -54,9 +54,6 @@ class EmailTemplatesTests(unittest.TestCase):
 def shouldIncludeKey(self, text):
 self.assertSubstring('-BEGIN PGP PUBLIC KEY BLOCK-', text)
 
-def shouldIncludeFooter(self, text):
-self.assertSubstring('rainbows, unicorns, and sparkles', text)
-
 def test_templates_addCommands(self):
 text = templates.addCommands(self.t)
 self.shouldIncludeCommands(text)
@@ -90,16 +87,11 @@ class EmailTemplatesTests(unittest.TestCase):
 text = templates.addBridgeAnswer(self.t, self.answer)
 self.shouldIncludeBridges(text)
 
-def test_templates_addFooter(self):
-text = templates.addFooter(self.t, self.client)
-self.shouldIncludeFooter(text)
-
 def test_templates_buildAnswerMessage(self):
 text = templates.buildAnswerMessage(self.t, self.client, self.answer)
 self.assertSubstring(self.answer, text)
 self.shouldIncludeAutomationNotice(text)
 self.shouldIncludeCommands(text)
-self.shouldIncludeFooter(text)
 
 def test_templates_buildKeyMessage(self):
 text = templates.buildKeyMessage(self.t, self.client)
@@ -110,10 +102,8 @@ class EmailTemplatesTests(unittest.TestCase):
 self.shouldIncludeGreeting(text)
 self.assertSubstring('Welcome to BridgeDB!', text)
 self.shouldIncludeCommands(text)
-self.shouldIncludeFooter(text)
 
 def 

[tor-commits] [bridgedb/master] Rename Bridges.py to bridgerings.py.

2020-05-27 Thread phw
commit 6ee87fb70e887c06af8f93335a6731d1bc608b9f
Author: Philipp Winter 
Date:   Thu Mar 26 20:12:11 2020 -0700

Rename Bridges.py to bridgerings.py.

On file systems that are case insensitive (i.e., Mac OS and Windows),
these filenames are conflicting and cause a lot of development pain.

This fixes .
---
 CHANGELOG  |  4 
 bridgedb/{Bridges.py => bridgerings.py}|  4 ++--
 bridgedb/bridges.py|  4 ++--
 bridgedb/distributors/email/distributor.py |  8 
 bridgedb/distributors/https/distributor.py | 11 ++-
 bridgedb/distributors/moat/distributor.py  |  5 +++--
 bridgedb/main.py   | 18 +-
 bridgedb/persistent.py | 11 +++
 bridgedb/test/deprecated.py|  4 ++--
 bridgedb/test/legacy_Tests.py  | 12 ++--
 bridgedb/test/test_Tests.py| 10 +-
 bridgedb/test/test_bridgedb_script.py  |  1 +
 .../test/{test_Bridges.py => test_bridgerings.py}  | 22 +++---
 bridgedb/test/test_bridges.py  | 12 ++--
 bridgedb/test/test_https_distributor.py|  4 ++--
 bridgedb/test/util.py  |  4 ++--
 ...idgedb.Bridges.rst => bridgedb.bridgerings.rst} |  6 +++---
 doc/sphinx/source/bridgedb.rst |  2 +-
 doc/sphinx/source/conf.py  |  2 +-
 19 files changed, 77 insertions(+), 67 deletions(-)

diff --git a/CHANGELOG b/CHANGELOG
index a92824c..3e179e1 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,7 @@
+* FIXES https://bugs.torproject.org/29686
+Rename files that contain "Bridges" to "bridgerings", to eliminate
+headache on file systems that are case insensitive.
+
 Changes in version 0.10.0 - 2020-04-01
 
 * FIXES https://bugs.torproject.org/30317
diff --git a/bridgedb/Bridges.py b/bridgedb/bridgerings.py
similarity index 99%
rename from bridgedb/Bridges.py
rename to bridgedb/bridgerings.py
index 2126a7d..5b55610 100644
--- a/bridgedb/Bridges.py
+++ b/bridgedb/bridgerings.py
@@ -199,7 +199,7 @@ class BridgeRing(object):
 If the (presumably same) bridge is already at that determined position
 in this hashring, replace the old one.
 
-:type bridge: :class:`~bridgedb.Bridges.Bridge`
+:type bridge: :class:`~bridgedb.bridges.Bridge`
 :param bridge: The bridge to insert into this hashring.
 """
 for tp, val, _, subring in self.subrings:
@@ -257,7 +257,7 @@ class BridgeRing(object):
 first position after this one which has a bridge assigned to it.
 :param int N: The number of bridges to return.
 :rtype: list
-:returns: A list of :class:`~bridgedb.Bridges.Bridge`s.
+:returns: A list of :class:`~bridgedb.bridges.Bridge`s.
 """
 assert len(pos) == DIGEST_LEN
 if N >= len(self.sortedKeys):
diff --git a/bridgedb/bridges.py b/bridgedb/bridges.py
index 1dc32af..cd01948 100644
--- a/bridgedb/bridges.py
+++ b/bridgedb/bridges.py
@@ -814,12 +814,12 @@ class BridgeBackwardsCompatibility(BridgeBase):
 This method is provided for backwards compatibility and should not
 be relied upon.
 
-The old ``bridgedb.Bridges.Bridge.getConfigLine()`` method didn't know
+The old ``bridgedb.bridges.Bridge.getConfigLine()`` method didn't know
 about :class:`~bridgedb.bridgerequest.BridgeRequestBase`s, and so this
 modified version is backwards compatible by creating a
 :class:`~bridgedb.bridgerequest.BridgeRequestBase` for
 :meth:`getBridgeLine`. The default parameters are the same as they
-were in the old ``bridgedb.Bridges.Bridge`` class.
+were in the old ``bridgedb.bridges.Bridge`` class.
 
 :param bool includeFingerprint: If ``True``, include the
 ``fingerprint`` of this :class:`Bridge` in the returned bridge
diff --git a/bridgedb/distributors/email/distributor.py 
b/bridgedb/distributors/email/distributor.py
index fbf1a50..a90e725 100644
--- a/bridgedb/distributors/email/distributor.py
+++ b/bridgedb/distributors/email/distributor.py
@@ -29,8 +29,8 @@ import time
 
 import bridgedb.Storage
 
-from bridgedb.Bridges import BridgeRing
-from bridgedb.Bridges import FilteredBridgeSplitter
+from bridgedb.bridgerings import BridgeRing
+from bridgedb.bridgerings import FilteredBridgeSplitter
 from bridgedb.crypto import getHMAC
 from bridgedb.crypto import getHMACFunc
 from bridgedb.distribute import Distributor
@@ -67,7 +67,7 @@ class EmailDistributor(Distributor):
 """Object that hands out bridges based on the email address of an incoming
 request and the current time period.
 
-:type hashring: 

[tor-commits] [bridgedb/master] Make script Python 3-compatible.

2020-05-27 Thread phw
commit e608e771fce3e484f7c2419c07892a0119826802
Author: Philipp Winter 
Date:   Thu Mar 26 21:16:02 2020 -0700

Make script Python 3-compatible.

...by changing "urllib.quote" to "urllib.parse.quote".
---
 doc/sphinx/ext/traclinks.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/doc/sphinx/ext/traclinks.py b/doc/sphinx/ext/traclinks.py
index 732295d..90f596c 100644
--- a/doc/sphinx/ext/traclinks.py
+++ b/doc/sphinx/ext/traclinks.py
@@ -16,6 +16,7 @@ Adapted from recipe here_.
 """
 
 import urllib
+import urllib.parse
 from docutils import nodes, utils
 
 def make_trac_link(name, rawtext, text, lineno, inliner,
@@ -33,7 +34,7 @@ def make_trac_link(name, rawtext, text, lineno, inliner,
 env = inliner.document.settings.env
 base_url =  env.config.traclinks_base_url
 label = utils.unescape('ticket #' + label)
-ref = base_url + urllib.quote(full_name, safe='')
+ref = base_url + urllib.parse.quote(full_name, safe='')
 node = nodes.reference(rawtext, label, refuri=ref, **options)
 
 return [node],[]



___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [bridgedb/develop] Merge branch 'release-0.10.1'

2020-05-27 Thread phw
commit c45439ceb3a8dd43c658607606fb4a7aad57fd67
Merge: 2ccf7ef 64c29be
Author: Philipp Winter 
Date:   Wed May 27 10:05:59 2020 -0700

Merge branch 'release-0.10.1'

 .gnupg/TESTING.pub |  Bin 4622 -> 0 bytes
 .gnupg/TESTING.subkeys.sec |  Bin 7212 -> 0 bytes
 .gnupg/bridgedb-offline-key.pub.asc|  113 -
 .gnupg/bridgedb-online-key.pub.asc |  100 -
 .gnupg/gpg.conf|   96 -
 .gnupg/pubring.gpg |  Bin 4634 -> 0 bytes
 .gnupg/secring.gpg |  Bin 7224 -> 0 bytes
 .test.requirements.txt |4 +-
 .travis.requirements.txt   |   19 +-
 CHANGELOG  | 2427 ++--
 README.rst |   39 +-
 bridgedb.conf  |   45 -
 bridgedb/Storage.py|   71 +-
 bridgedb/{Bridges.py => bridgerings.py}|4 +-
 bridgedb/bridges.py|4 +-
 bridgedb/configure.py  |3 +-
 bridgedb/crypto.py |   99 +-
 bridgedb/distributors/email/autoresponder.py   |   51 +-
 bridgedb/distributors/email/distributor.py |   18 +-
 bridgedb/distributors/email/request.py |   42 +-
 bridgedb/distributors/email/server.py  |   12 +-
 bridgedb/distributors/email/templates.py   |  133 +-
 bridgedb/distributors/https/distributor.py |   11 +-
 bridgedb/distributors/https/request.py |5 +-
 bridgedb/distributors/https/server.py  |   13 +-
 .../https/templates/assets/css/main.css|4 +-
 bridgedb/distributors/https/templates/base.html|2 -
 bridgedb/distributors/https/templates/bridges.html |   13 +-
 .../distributors/https/templates/error-400.html|   30 +
 .../distributors/https/templates/error-500.html|4 +-
 bridgedb/distributors/moat/distributor.py  |5 +-
 bridgedb/i18n/ar/LC_MESSAGES/bridgedb.po   |  367 +--
 bridgedb/i18n/az/LC_MESSAGES/bridgedb.po   |  356 +--
 bridgedb/i18n/be/LC_MESSAGES/bridgedb.po   |  361 +--
 bridgedb/i18n/bg/LC_MESSAGES/bridgedb.po   |  356 +--
 bridgedb/i18n/bn/LC_MESSAGES/bridgedb.po   |  358 +--
 bridgedb/i18n/bs/LC_MESSAGES/bridgedb.po   |  399 
 bridgedb/i18n/ca/LC_MESSAGES/bridgedb.po   |  398 ++--
 bridgedb/i18n/cs/LC_MESSAGES/bridgedb.po   |  360 +--
 bridgedb/i18n/da/LC_MESSAGES/bridgedb.po   |  399 ++--
 bridgedb/i18n/de/LC_MESSAGES/bridgedb.po   |  360 +--
 bridgedb/i18n/el/LC_MESSAGES/bridgedb.po   |  360 +--
 bridgedb/i18n/en_GB/LC_MESSAGES/bridgedb.po|  358 +--
 bridgedb/i18n/eo/LC_MESSAGES/bridgedb.po   |  359 +--
 bridgedb/i18n/es/LC_MESSAGES/bridgedb.po   |  360 +--
 bridgedb/i18n/es_AR/LC_MESSAGES/bridgedb.po|  359 +--
 bridgedb/i18n/es_MX/LC_MESSAGES/bridgedb.po|  356 +--
 bridgedb/i18n/et/LC_MESSAGES/bridgedb.po   |  359 +--
 bridgedb/i18n/eu/LC_MESSAGES/bridgedb.po   |  427 +++-
 bridgedb/i18n/fa/LC_MESSAGES/bridgedb.po   |  373 +--
 bridgedb/i18n/fi/LC_MESSAGES/bridgedb.po   |  358 +--
 bridgedb/i18n/fr/LC_MESSAGES/bridgedb.po   |  363 +--
 bridgedb/i18n/ga/LC_MESSAGES/bridgedb.po   |  358 +--
 bridgedb/i18n/gd/LC_MESSAGES/bridgedb.po   |  399 
 bridgedb/i18n/gl/LC_MESSAGES/bridgedb.po   |  356 +--
 bridgedb/i18n/gu/LC_MESSAGES/bridgedb.po   |  399 
 bridgedb/i18n/he/LC_MESSAGES/bridgedb.po   |  366 +--
 bridgedb/i18n/hi/LC_MESSAGES/bridgedb.po   |  356 +--
 bridgedb/i18n/hr/LC_MESSAGES/bridgedb.po   |  401 ++--
 bridgedb/i18n/hu/LC_MESSAGES/bridgedb.po   |  361 +--
 bridgedb/i18n/hy/LC_MESSAGES/bridgedb.po   |  356 +--
 bridgedb/i18n/id/LC_MESSAGES/bridgedb.po   |  366 +--
 bridgedb/i18n/is/LC_MESSAGES/bridgedb.po   |  358 +--
 bridgedb/i18n/it/LC_MESSAGES/bridgedb.po   |  362 +--
 bridgedb/i18n/ja/LC_MESSAGES/bridgedb.po   |  380 +--
 bridgedb/i18n/ka/LC_MESSAGES/bridgedb.po   |  357 +--
 bridgedb/i18n/kk/LC_MESSAGES/bridgedb.po   |  358 +--
 bridgedb/i18n/km/LC_MESSAGES/bridgedb.po   |  513 +++--
 bridgedb/i18n/ko/LC_MESSAGES/bridgedb.po   |  361 +--
 bridgedb/i18n/lt/LC_MESSAGES/bridgedb.po   |  406 
 bridgedb/i18n/lv/LC_MESSAGES/bridgedb.po   |  356 +--
 bridgedb/i18n/mk/LC_MESSAGES/bridgedb.po   |  357 +--
 bridgedb/i18n/ml/LC_MESSAGES/bridgedb.po   |  404 
 bridgedb/i18n/mr/LC_MESSAGES/bridgedb.po   |  400 
 bridgedb/i18n/ms_MY/LC_MESSAGES/bridgedb.po|  356 +--
 bridgedb/i18n/nb/LC_MESSAGES/bridgedb.po   |  366 

[tor-commits] [bridgedb/master] Merge branch 'defect/17548' into develop

2020-05-27 Thread phw
commit 4cdd6a61d01ae6d7c755e870acd8a7eb139d22e7
Merge: 208b49c b366bb4
Author: Philipp Winter 
Date:   Wed Apr 15 09:34:59 2020 -0700

Merge branch 'defect/17548' into develop

 .gnupg/TESTING.pub  | Bin 4622 -> 0 bytes
 .gnupg/TESTING.subkeys.sec  | Bin 7212 -> 0 bytes
 .gnupg/bridgedb-offline-key.pub.asc | 113 --
 .gnupg/bridgedb-online-key.pub.asc  | 100 -
 .gnupg/gpg.conf |  96 -
 .gnupg/pubring.gpg  | Bin 4634 -> 0 bytes
 .gnupg/secring.gpg  | Bin 7224 -> 0 bytes
 .travis.requirements.txt|   1 -
 CHANGELOG   |   6 +
 README.rst  |  29 +--
 bridgedb.conf   |  45 
 bridgedb/configure.py   |   3 +-
 bridgedb/crypto.py  |  99 +
 bridgedb/distributors/email/autoresponder.py|  41 +---
 bridgedb/distributors/email/distributor.py  |   6 +-
 bridgedb/distributors/email/request.py  |  22 --
 bridgedb/distributors/email/server.py   |  10 -
 bridgedb/distributors/email/templates.py|   7 -
 bridgedb/distributors/https/server.py   |   2 -
 bridgedb/distributors/https/templates/base.html |   2 -
 bridgedb/i18n/templates/bridgedb.pot|  84 
 bridgedb/strings.py | 268 +---
 bridgedb/test/email_helpers.py  |  23 +-
 bridgedb/test/test_crypto.py| 137 
 bridgedb/test/test_email_autoresponder.py   |  15 --
 bridgedb/test/test_email_request.py |  36 +---
 bridgedb/test/test_email_templates.py   |  11 -
 bridgedb/test/test_main.py  |   5 -
 requirements.txt|   1 -
 scripts/setup-tests |   2 +-
 30 files changed, 63 insertions(+), 1101 deletions(-)



___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [bridgedb/master] Give BridgeDB more time to start before unit test.

2020-05-27 Thread phw
commit 8105032e2ab876d1c7d31471b828a0690f2bf6f3
Author: Philipp Winter 
Date:   Mon Apr 6 09:41:45 2020 -0700

Give BridgeDB more time to start before unit test.

The renaming of test_Bridges.py to test_bridgerings.py means that
test_bridgedb_script.py is now run earlier (because tests are executed
in alphabetic order), which means less time for BridgeDB to start.  This
commit adds an extra sleep to a unit test, so we can be reasonably sure
that BridgeDB is already running when unlinking its assignments file.
---
 bridgedb/test/test_bridgedb_script.py | 1 +
 1 file changed, 1 insertion(+)

diff --git a/bridgedb/test/test_bridgedb_script.py 
b/bridgedb/test/test_bridgedb_script.py
index 76b4001..b58e016 100644
--- a/bridgedb/test/test_bridgedb_script.py
+++ b/bridgedb/test/test_bridgedb_script.py
@@ -79,6 +79,7 @@ class BridgeDBCliTest(unittest.TestCase):
 if not self.pid or not processExists(self.pid):
 raise SkipTest("Can't run test: no BridgeDB process running.")
 
+self.doSleep()
 os.unlink(self.assignmentsFile)
 os.kill(self.pid, signal.SIGHUP)
 self.doSleep()



___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [bridgedb/master] Merge branch 'defect/30941' into develop

2020-05-27 Thread phw
commit bca64964a255cf959489c7049c66e5eb70b5291c
Merge: 7afbe7e 1958bbb
Author: Philipp Winter 
Date:   Mon Apr 6 15:30:12 2020 -0700

Merge branch 'defect/30941' into develop

 CHANGELOG|   6 ++
 bridgedb/distributors/email/autoresponder.py |  10 --
 bridgedb/distributors/email/distributor.py   |   6 +-
 bridgedb/distributors/email/request.py   |  20 ++--
 bridgedb/distributors/email/templates.py | 126 +--
 bridgedb/i18n/templates/bridgedb.pot | 143 +++
 bridgedb/metrics.py  |   7 +-
 bridgedb/strings.py  |  49 -
 bridgedb/test/test_email_autoresponder.py|   5 +-
 bridgedb/test/test_email_request.py  |  46 -
 bridgedb/test/test_email_templates.py|  41 +---
 11 files changed, 151 insertions(+), 308 deletions(-)



___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [bridgedb/master] Add service status check

2020-05-27 Thread phw
commit 2ae19e5c25dca6acdb0307c147dc93f73e257f7e
Author: hiro 
Date:   Mon Oct 21 19:54:50 2019 +0200

Add service status check
---
 scripts/check_status | 137 +++
 1 file changed, 137 insertions(+)

diff --git a/scripts/check_status b/scripts/check_status
new file mode 100644
index 000..8f8f3e5
--- /dev/null
+++ b/scripts/check_status
@@ -0,0 +1,137 @@
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+#
+# This file is part of  BridgeDB, a Tor bridge distribution system.
+#
+# :authors: hiro 
+#   see also AUTHORS file
+#
+# :license: This is Free Software. See LICENSE for license information.
+
+import sys
+import smtplib
+import time
+import imaplib
+import email
+import time
+
+# Standard Nagios return codes
+OK, WARNING, CRITICAL, UNKNOWN = range(4)
+
+ORG_EMAIL   = "@gmail.com"
+FROM_EMAIL  = "test.bridges.browser" + ORG_EMAIL
+SMTP_SERVER = "imap.gmail.com"
+SMTP_PORT   = 993
+
+MESSAGE_FROM = "brid...@torproject.org"
+MESSAGE_SUBJECT = "Bridges"
+MESSAGE_BODY = ":443"
+
+STATUS_FILE = "/srv/bridgedb.torproject.org/check/status"
+
+# -
+#
+# Utility to read email from Gmail Using Python
+#
+# 
+
+def test_email_from_gmail(password):
+try:
+mail = imaplib.IMAP4_SSL(SMTP_SERVER)
+mail.login(FROM_EMAIL, password)
+mail.select('INBOX')
+
+type, data = mail.search(None, 'ALL')
+mail_ids = data[0]
+
+id_list = mail_ids.split()
+first_email_id = int(str(id_list[0], 'utf-8'))
+latest_email_id = int(str(id_list[-1], 'utf-8'))
+
+for i in range(int(latest_email_id), int(first_email_id), -1):
+typ, data = mail.fetch(str(i), '(RFC822)')
+
+for response_part in data:
+if isinstance(response_part, tuple):
+m = str(response_part[1], 'utf-8')
+msg = email.message_from_string(m)
+email_subject = "{}".format(msg['subject'])
+email_from = "{}".format(msg['from'])
+email_body = "{}".format(msg.as_string())
+
+if (MESSAGE_FROM == email_from) and (MESSAGE_SUBJECT == 
email_subject) and (MESSAGE_BODY in email_body):
+mail.store(str(i), '+FLAGS', '\\Deleted')
+mail.close()
+return OK, "Bridgedb is good and sending emails with 
working bridges"
+else:
+mail.store(str(i), '+FLAGS', '\\Deleted')
+
+mail.close()
+return WARNING, "No emails from gettor found"
+
+except Exception as e:
+return CRITICAL, str(e)
+
+def send_email_from_gmail(password):
+sent_from = FROM_EMAIL
+sent_to = ["{}".format(MESSAGE_FROM)]
+subject = 'Bridges'
+body = 'get bridges'
+
+email_text = """From: %s\nTo: %s\nSubject: %s\n\n%s""" % (sent_from, ", 
".join(sent_to), subject, body)
+
+try:
+mail = smtplib.SMTP_SSL('smtp.gmail.com', 465)
+mail.ehlo()
+mail.login(sent_from, password)
+mail.sendmail(sent_from, sent_to, email_text)
+mail.close()
+return OK, "Test email sent"
+except Exception as e:
+return UNKNOWN, str(e)
+
+if __name__ == "__main__":
+status, message = None, None
+
+if len(sys.argv) == 2:
+password = sys.argv[1]
+else:
+password = "yourPassword"
+
+status_file = open(STATUS_FILE, 'r')
+message = status_file.read()
+status_file.close()
+
+try:
+status, message = send_email_from_gmail(password)
+except Exception as e:
+status = UNKNOWN
+message = repr(e)
+status_file = open(STATUS_FILE,'w')
+status_file.write("UNKNOWN\n3: %s" % message)
+status_file.close()
+
+time.sleep(600)
+
+try:
+status, message = test_email_from_gmail(password)
+except KeyboardInterrupt:
+status, message = CRITICAL, "Caught Control-C..."
+except Exception as e:
+status = CRITICAL
+message = repr(e)
+finally:
+status_file = open(STATUS_FILE,'w')
+if status == OK:
+status_file.write("OK\n0: %s" % message)
+elif status == WARNING:
+status_file.write("WARNING\n1: %s" % message)
+elif status == CRITICAL:
+status_file.write("CRITICAL\n2: %s" % message)
+else:
+status_file.write("UNKNOWN\n3: %s" % message)
+status = UNKNOWN
+
+status_file.close()
+
+sys.exit(status)




[tor-commits] [bridgedb/develop] Bump version number to 0.10.1.

2020-05-27 Thread phw
commit 64c29beb19071271593363b957598fbc56ed4a3b
Author: Philipp Winter 
Date:   Wed May 27 10:05:16 2020 -0700

Bump version number to 0.10.1.
---
 CHANGELOG | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/CHANGELOG b/CHANGELOG
index aad33f2..6dfa43c 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,5 @@
+Changes in version 0.10.1 - 2020-05-27
+
 * FIXES https://bugs.torproject.org/33945
 This patch fixes a bug that caused the email autoresponder to fail after
 a while.



___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [bridgedb/master] Merge branch 'defect/29686' into develop

2020-05-27 Thread phw
commit 7afbe7e2866c7628bc5e40b15618105843486c80
Merge: 2ccf7ef 8105032
Author: Philipp Winter 
Date:   Mon Apr 6 10:24:31 2020 -0700

Merge branch 'defect/29686' into develop

 CHANGELOG  |  4 
 bridgedb/{Bridges.py => bridgerings.py}|  4 ++--
 bridgedb/bridges.py|  4 ++--
 bridgedb/distributors/email/distributor.py |  8 
 bridgedb/distributors/https/distributor.py | 11 ++-
 bridgedb/distributors/moat/distributor.py  |  5 +++--
 bridgedb/main.py   | 18 +-
 bridgedb/persistent.py | 11 +++
 bridgedb/test/deprecated.py|  4 ++--
 bridgedb/test/legacy_Tests.py  | 12 ++--
 bridgedb/test/test_Tests.py| 10 +-
 bridgedb/test/test_bridgedb_script.py  |  2 ++
 .../test/{test_Bridges.py => test_bridgerings.py}  | 22 +++---
 bridgedb/test/test_bridges.py  | 12 ++--
 bridgedb/test/test_https_distributor.py|  4 ++--
 bridgedb/test/util.py  |  4 ++--
 doc/sphinx/ext/traclinks.py|  3 ++-
 ...idgedb.Bridges.rst => bridgedb.bridgerings.rst} |  6 +++---
 doc/sphinx/source/bridgedb.rst |  2 +-
 doc/sphinx/source/conf.py  |  2 +-
 20 files changed, 80 insertions(+), 68 deletions(-)



___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [bridgedb/master] Make our email autoresponder more usable.

2020-05-27 Thread phw
commit 1958bbb7e95df0f810e219955595f353933e1302
Author: Philipp Winter 
Date:   Tue Mar 31 09:37:37 2020 -0700

Make our email autoresponder more usable.

So far, our autoresponder would only send you bridges if your request
was valid.  Unfortunately, it's not very easy to figure out what a
correct request looks like.  This patch returns bridges regardless of if
the request was valid or not.  We also remove the "help" autoresponse
because there's no longer a need for it, and we simplify BridgeDB's auto
response, hopefully making it less frustrating for users.

This fixes .
---
 CHANGELOG|   6 ++
 bridgedb/distributors/email/autoresponder.py |  10 --
 bridgedb/distributors/email/distributor.py   |   6 +-
 bridgedb/distributors/email/request.py   |  20 ++--
 bridgedb/distributors/email/templates.py |  83 +---
 bridgedb/i18n/templates/bridgedb.pot | 143 +++
 bridgedb/metrics.py  |   7 +-
 bridgedb/strings.py  |  49 -
 bridgedb/test/test_email_autoresponder.py|   5 +-
 bridgedb/test/test_email_request.py  |  46 -
 bridgedb/test/test_email_templates.py|  31 +-
 11 files changed, 151 insertions(+), 255 deletions(-)

diff --git a/CHANGELOG b/CHANGELOG
index 3e179e1..f85283b 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,9 @@
+* FIXES https://bugs.torproject.org/30941
+Make our email responder more usable.  This patch removes the concept 
of
+"valid" email commands and returns bridges (obfs4, for now) no matter
+what the user sends.  BridgeDB still supports email commands in case 
the
+user needs a vanilla or IPv6 bridge.
+
 * FIXES https://bugs.torproject.org/29686
 Rename files that contain "Bridges" to "bridgerings", to eliminate
 headache on file systems that are case insensitive.
diff --git a/bridgedb/distributors/email/autoresponder.py 
b/bridgedb/distributors/email/autoresponder.py
index 3711eae..5e1fcd0 100644
--- a/bridgedb/distributors/email/autoresponder.py
+++ b/bridgedb/distributors/email/autoresponder.py
@@ -55,7 +55,6 @@ from bridgedb import safelog
 from bridgedb.distributors.email import dkim
 from bridgedb.distributors.email import request
 from bridgedb.distributors.email import templates
-from bridgedb.distributors.email.distributor import EmailRequestedHelp
 from bridgedb.distributors.email.distributor import EmailRequestedKey
 from bridgedb.distributors.email.distributor import TooSoonEmail
 from bridgedb.distributors.email.distributor import IgnoreEmail
@@ -98,18 +97,9 @@ def createResponseBody(lines, context, client, lang='en'):
 bridgeRequest = request.determineBridgeRequestOptions(lines)
 bridgeRequest.client = str(client)
 
-# The request was invalid, respond with a help email which explains
-# valid email commands:
-if not bridgeRequest.isValid():
-raise EmailRequestedHelp("Email request from '%s' was invalid."
- % str(client))
-
 # Otherwise they must have requested bridges:
 interval = context.schedule.intervalStart(time.time())
 bridges = context.distributor.getBridges(bridgeRequest, interval)
-except EmailRequestedHelp as error:
-logging.info(error)
-return templates.buildWelcomeText(translator, client)
 except EmailRequestedKey as error:
 logging.info(error)
 return templates.buildKeyMessage(translator, client)
diff --git a/bridgedb/distributors/email/distributor.py 
b/bridgedb/distributors/email/distributor.py
index a90e725..c6ac2fd 100644
--- a/bridgedb/distributors/email/distributor.py
+++ b/bridgedb/distributors/email/distributor.py
@@ -20,7 +20,7 @@ bridgedb.distributors.email.autoresponder
 A :class:`~bridgedb.distribute.Distributor` which hands out :class:`bridges
 ` to clients via an email interface.
 
-.. inheritance-diagram:: IgnoreEmail TooSoonEmail EmailRequestedHelp 
EmailRequestedKey EmailDistributor
+.. inheritance-diagram:: IgnoreEmail TooSoonEmail EmailRequestedKey 
EmailDistributor
 :parts: 1
 """
 
@@ -55,10 +55,6 @@ class TooSoonEmail(addr.BadEmail):
 """Raised when we got a request from this address too recently."""
 
 
-class EmailRequestedHelp(Exception):
-"""Raised when a client has emailed requesting help."""
-
-
 class EmailRequestedKey(Exception):
 """Raised when an incoming email requested a copy of our GnuPG keys."""
 
diff --git a/bridgedb/distributors/email/request.py 
b/bridgedb/distributors/email/request.py
index 83c203d..90576c1 100644
--- a/bridgedb/distributors/email/request.py
+++ b/bridgedb/distributors/email/request.py
@@ -43,8 +43,8 @@ from __future__ import unicode_literals
 import logging
 import re
 
+from bridgedb import strings
 from bridgedb import 

[tor-commits] [bridgedb/develop] Update to latest requirements.

2020-05-27 Thread phw
commit 9199a4d4b9f9264f7791a7f7954d012f9fc69b25
Author: Philipp Winter 
Date:   Wed May 27 08:52:02 2020 -0700

Update to latest requirements.
---
 .test.requirements.txt   |  4 ++--
 .travis.requirements.txt | 18 +-
 requirements.txt | 12 ++--
 3 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/.test.requirements.txt b/.test.requirements.txt
index 82fbbd6..e72ed31 100644
--- a/.test.requirements.txt
+++ b/.test.requirements.txt
@@ -5,8 +5,8 @@
 # $ pip install -r .test.requirements.txt
 # $ make coverage
 #
-coverage==5.0.3
+coverage==5.1
 mechanize==0.4.5
 pep8==1.7.1
-pylint==2.4.4
+pylint==2.5.2
 sure==1.4.11
diff --git a/.travis.requirements.txt b/.travis.requirements.txt
index a74821a..940ba64 100644
--- a/.travis.requirements.txt
+++ b/.travis.requirements.txt
@@ -13,21 +13,21 @@
 # $ make coverage
 #
 #--
-attrs==19.2.0
+attrs==19.3.0
 Babel==2.8.0
-beautifulsoup4==4.8.2
-Mako==1.1.1
-pycryptodome==3.9.6
+beautifulsoup4==4.9.1
+Mako==1.1.2
+pycryptodome==3.9.7
 Twisted==20.3.0
-coverage==5.0.3
-coveralls==1.10.0
+coverage==5.1
+coveralls==2.0.0
 ipaddr==2.2.0
 mechanize==0.4.5
-Pillow==6.2.2
-pyOpenSSL==19.0.0
+Pillow==7.1.2
+pyOpenSSL==19.1.0
 pygeoip==0.3.2
 qrcode==6.1
 service_identity==18.1.0
 stem==1.8.0
 sure==1.4.11
-zope.interface==4.7.1
+zope.interface==5.1.0
diff --git a/requirements.txt b/requirements.txt
index 79bb01d..fdf1043 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,14 +1,14 @@
 Babel==2.8.0
-beautifulsoup4==4.8.2
-html5lib==1.0b8
-Mako==1.1.1
-pycryptodome==3.9.6
+beautifulsoup4==4.9.1
+html5lib==1.0.1
+Mako==1.1.2
+pycryptodome==3.9.7
 Twisted==20.3.0
 ipaddr==2.2.0
-Pillow==6.2.2
+Pillow==7.1.2
 pyOpenSSL==19.1.0
 pygeoip==0.3.2
 qrcode==6.1
 service_identity==18.1.0
 stem==1.8.0
-zope.interface==4.7.1
+zope.interface==5.1.0



___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [bridgedb/develop] Merge branch 'defect/33945' into develop

2020-05-22 Thread phw
commit 5c0b04ed012cb81574d459f847db534086ce62d0
Merge: 19ba2da 2abd54a
Author: Philipp Winter 
Date:   Fri May 22 15:52:45 2020 -0700

Merge branch 'defect/33945' into develop

 CHANGELOG   |  4 
 bridgedb/Storage.py | 63 +
 2 files changed, 5 insertions(+), 62 deletions(-)



___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [bridgedb/develop] Merge branch 'update-translations' into develop

2020-05-22 Thread phw
commit a6eb0d1c4bc782287d6054cead0d6850dd2d7c0c
Merge: 5c0b04e 1a42375
Author: Philipp Winter 
Date:   Fri May 22 15:56:33 2020 -0700

Merge branch 'update-translations' into develop

 bridgedb/i18n/ar/LC_MESSAGES/bridgedb.po| 367 ++--
 bridgedb/i18n/az/LC_MESSAGES/bridgedb.po| 356 ++-
 bridgedb/i18n/be/LC_MESSAGES/bridgedb.po| 361 ++--
 bridgedb/i18n/bg/LC_MESSAGES/bridgedb.po| 356 ++-
 bridgedb/i18n/bn/LC_MESSAGES/bridgedb.po| 358 ++-
 bridgedb/i18n/bs/LC_MESSAGES/bridgedb.po| 399 ++
 bridgedb/i18n/ca/LC_MESSAGES/bridgedb.po| 398 +++--
 bridgedb/i18n/cs/LC_MESSAGES/bridgedb.po| 360 ++-
 bridgedb/i18n/da/LC_MESSAGES/bridgedb.po| 399 +++---
 bridgedb/i18n/de/LC_MESSAGES/bridgedb.po| 360 ++-
 bridgedb/i18n/el/LC_MESSAGES/bridgedb.po| 360 ++-
 bridgedb/i18n/en_GB/LC_MESSAGES/bridgedb.po | 358 ++-
 bridgedb/i18n/eo/LC_MESSAGES/bridgedb.po| 359 +--
 bridgedb/i18n/es/LC_MESSAGES/bridgedb.po| 360 +--
 bridgedb/i18n/es_AR/LC_MESSAGES/bridgedb.po | 359 ++-
 bridgedb/i18n/es_MX/LC_MESSAGES/bridgedb.po | 356 ++-
 bridgedb/i18n/et/LC_MESSAGES/bridgedb.po| 359 ++-
 bridgedb/i18n/eu/LC_MESSAGES/bridgedb.po| 427 +++
 bridgedb/i18n/fa/LC_MESSAGES/bridgedb.po| 373 ++--
 bridgedb/i18n/fi/LC_MESSAGES/bridgedb.po| 358 ++-
 bridgedb/i18n/fr/LC_MESSAGES/bridgedb.po| 363 ++--
 bridgedb/i18n/ga/LC_MESSAGES/bridgedb.po| 358 ++-
 bridgedb/i18n/gd/LC_MESSAGES/bridgedb.po| 399 ++
 bridgedb/i18n/gl/LC_MESSAGES/bridgedb.po| 356 ++-
 bridgedb/i18n/gu/LC_MESSAGES/bridgedb.po| 399 ++
 bridgedb/i18n/he/LC_MESSAGES/bridgedb.po| 366 ++--
 bridgedb/i18n/hi/LC_MESSAGES/bridgedb.po| 356 ++-
 bridgedb/i18n/hr/LC_MESSAGES/bridgedb.po| 401 +++---
 bridgedb/i18n/hu/LC_MESSAGES/bridgedb.po| 361 ++--
 bridgedb/i18n/hy/LC_MESSAGES/bridgedb.po| 356 ++-
 bridgedb/i18n/id/LC_MESSAGES/bridgedb.po| 366 ++--
 bridgedb/i18n/is/LC_MESSAGES/bridgedb.po| 358 ++-
 bridgedb/i18n/it/LC_MESSAGES/bridgedb.po| 362 ++--
 bridgedb/i18n/ja/LC_MESSAGES/bridgedb.po| 380 +++--
 bridgedb/i18n/ka/LC_MESSAGES/bridgedb.po| 357 ++-
 bridgedb/i18n/kk/LC_MESSAGES/bridgedb.po| 358 ++-
 bridgedb/i18n/km/LC_MESSAGES/bridgedb.po| 513 +++-
 bridgedb/i18n/ko/LC_MESSAGES/bridgedb.po| 361 ++--
 bridgedb/i18n/lt/LC_MESSAGES/bridgedb.po| 406 ++
 bridgedb/i18n/lv/LC_MESSAGES/bridgedb.po| 356 ++-
 bridgedb/i18n/mk/LC_MESSAGES/bridgedb.po| 357 ++-
 bridgedb/i18n/ml/LC_MESSAGES/bridgedb.po| 404 ++
 bridgedb/i18n/mr/LC_MESSAGES/bridgedb.po| 400 ++
 bridgedb/i18n/ms_MY/LC_MESSAGES/bridgedb.po | 356 ++-
 bridgedb/i18n/nb/LC_MESSAGES/bridgedb.po| 366 ++--
 bridgedb/i18n/nl/LC_MESSAGES/bridgedb.po| 395 +++--
 bridgedb/i18n/nl_BE/LC_MESSAGES/bridgedb.po | 356 ++-
 bridgedb/i18n/nn/LC_MESSAGES/bridgedb.po| 356 ++-
 bridgedb/i18n/pa/LC_MESSAGES/bridgedb.po| 402 ++
 bridgedb/i18n/pl/LC_MESSAGES/bridgedb.po| 359 ++-
 bridgedb/i18n/pt_BR/LC_MESSAGES/bridgedb.po | 363 ++--
 bridgedb/i18n/pt_PT/LC_MESSAGES/bridgedb.po | 371 ++--
 bridgedb/i18n/ro/LC_MESSAGES/bridgedb.po| 358 ++-
 bridgedb/i18n/ru/LC_MESSAGES/bridgedb.po| 393 +++--
 bridgedb/i18n/sk/LC_MESSAGES/bridgedb.po| 357 ++-
 bridgedb/i18n/sl/LC_MESSAGES/bridgedb.po| 356 ++-
 bridgedb/i18n/sq/LC_MESSAGES/bridgedb.po| 378 ++--
 bridgedb/i18n/sr/LC_MESSAGES/bridgedb.po| 357 ++-
 bridgedb/i18n/sv/LC_MESSAGES/bridgedb.po| 370 ++--
 bridgedb/i18n/sw/LC_MESSAGES/bridgedb.po| 399 ++
 bridgedb/i18n/ta/LC_MESSAGES/bridgedb.po| 357 ++-
 bridgedb/i18n/th/LC_MESSAGES/bridgedb.po| 436 +++
 bridgedb/i18n/tr/LC_MESSAGES/bridgedb.po| 361 ++--
 bridgedb/i18n/uk/LC_MESSAGES/bridgedb.po| 356 ++-
 bridgedb/i18n/ur/LC_MESSAGES/bridgedb.po| 399 ++
 bridgedb/i18n/uz/LC_MESSAGES/bridgedb.po| 401 ++
 bridgedb/i18n/vi/LC_MESSAGES/bridgedb.po| 

[tor-commits] [bridgedb/develop] Use contextlib's context manager.

2020-05-22 Thread phw
commit 2abd54a1b979c11153c41a51b884386fbd4635c4
Author: Philipp Winter 
Date:   Wed May 6 17:54:59 2020 -0700

Use contextlib's context manager.

So far, the email autoresponder fails after a while, raising the
following exception:

  File 
"/home/bridgedb/virtualenvs/bridgedb/lib/python3.7/site-packages/twisted/internet/posixbase.py",
 line 614, in _doReadOrWrite
why = selectable.doRead()
  File 
"/home/bridgedb/virtualenvs/bridgedb/lib/python3.7/site-packages/twisted/internet/tcp.py",
 line 243, in doRead
return self._dataReceived(data)
  File 
"/home/bridgedb/virtualenvs/bridgedb/lib/python3.7/site-packages/twisted/internet/tcp.py",
 line 249, in _dataReceived
rval = self.protocol.dataReceived(data)
  File 
"/home/bridgedb/virtualenvs/bridgedb/lib/python3.7/site-packages/twisted/protocols/basic.py",
 line 454, in dataReceived
self.lineReceived(line)
  File 
"/home/bridgedb/virtualenvs/bridgedb/lib/python3.7/site-packages/twisted/mail/smtp.py",
 line 445, in lineReceived
return getattr(self, 'state_' + self.mode)(line)
  File 
"/home/bridgedb/virtualenvs/bridgedb/lib/python3.7/site-packages/twisted/mail/smtp.py",
 line 705, in dataLineReceived
m.eomReceived() for m in self.__messages
  File 
"/home/bridgedb/virtualenvs/bridgedb/lib/python3.7/site-packages/twisted/mail/smtp.py",
 line 705, in 
m.eomReceived() for m in self.__messages
  File 
"/home/bridgedb/virtualenvs/bridgedb/lib/python3.7/site-packages/bridgedb-0.10.0+11.g4cdd6a61.dirty-py3.7.egg/bridgedb/distributors/email/server.py",
 line 230, in eomReceived
self.responder.reply()
  File 
"/home/bridgedb/virtualenvs/bridgedb/lib/python3.7/site-packages/bridgedb-0.10.0+11.g4cdd6a61.dirty-py3.7.egg/bridgedb/distributors/email/autoresponder.py",
 line 574, in reply
response = self.getMailData()
  File 
"/home/bridgedb/virtualenvs/bridgedb/lib/python3.7/site-packages/bridgedb-0.10.0+11.g4cdd6a61.dirty-py3.7.egg/bridgedb/distributors/email/autoresponder.py",
 line 392, in getMailData
client, lang)
  File 
"/home/bridgedb/virtualenvs/bridgedb/lib/python3.7/site-packages/bridgedb-0.10.0+11.g4cdd6a61.dirty-py3.7.egg/bridgedb/distributors/email/autoresponder.py",
 line 101, in createResponseBody
bridges = context.distributor.getBridges(bridgeRequest, interval)
  File 
"/home/bridgedb/virtualenvs/bridgedb/lib/python3.7/site-packages/bridgedb-0.10.0+11.g4cdd6a61.dirty-py3.7.egg/bridgedb/distributors/email/distributor.py",
 line 145, in getBridges
with bridgedb.Storage.getDB() as db:
  File 
"/home/bridgedb/virtualenvs/bridgedb/lib/python3.7/site-packages/bridgedb-0.10.0+11.g4cdd6a61.dirty-py3.7.egg/bridgedb/Storage.py",
 line 352, in __enter__
return next(self.gen)
  File 
"/home/bridgedb/virtualenvs/bridgedb/lib/python3.7/site-packages/bridgedb-0.10.0+11.g4cdd6a61.dirty-py3.7.egg/bridgedb/Storage.py",
 line 472, in getDB
assert _REFCOUNT == 0
builtins.AssertionError:

It's not clear what caused this regression but it may have been
introduced in commit c1a48d1, as part of our conversion to Python 3.

This fixes .
---
 CHANGELOG   |  4 
 bridgedb/Storage.py | 63 +
 2 files changed, 5 insertions(+), 62 deletions(-)

diff --git a/CHANGELOG b/CHANGELOG
index 80d3afa..aad33f2 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,7 @@
+* FIXES https://bugs.torproject.org/33945
+This patch fixes a bug that caused the email autoresponder to fail after
+a while.
+
 * FIXES https://bugs.torproject.org/34154
 Add new fields to the SQLite table BlockedBridges in preparation for taking
 into account OONI's bridge measurement results.
diff --git a/bridgedb/Storage.py b/bridgedb/Storage.py
index 0fe8851..2859cf1 100644
--- a/bridgedb/Storage.py
+++ b/bridgedb/Storage.py
@@ -10,6 +10,7 @@ import time
 import hashlib
 from functools import wraps
 from ipaddr import IPAddress
+from contextlib import contextmanager
 import sys
 
 from bridgedb.Stability import BridgeHistory
@@ -345,68 +346,6 @@ def openDatabase(sqlite_file):
 return conn
 
 
-class DBGeneratorContextManager(object):
-"""Helper for @contextmanager decorator.
-
-Overload __exit__() so we can call the generator many times
-"""
-
-def __init__(self, gen):
-  self.gen = gen
-
-def __enter__(self):
-  return next(self.gen)
-
-def __exit__(self, type, value, traceback):
-"""Handle exiting a with statement block
-
-Progress generator or throw exception
-
-Significantly based on contextlib.py
-
-:throws: `RuntimeError` if the generator doesn't stop after
-exception is thrown
-"""
-if type is None:
-try:
-next(self.gen)
-except StopIteration:
-

[tor-commits] [bridgedb/develop] Merge branch 'enhancement/34154' into develop

2020-05-22 Thread phw
commit 19ba2da7b66cfccee014bde2804f10dafd0696b7
Merge: f25943e 3337b4a
Author: Philipp Winter 
Date:   Fri May 22 15:13:38 2020 -0700

Merge branch 'enhancement/34154' into develop

 CHANGELOG   | 4 
 bridgedb/Storage.py | 8 +++-
 2 files changed, 11 insertions(+), 1 deletion(-)

___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [bridgedb/develop] Add new fields to BlockedBridges.

2020-05-22 Thread phw
commit 3337b4ac349cd9d4021f9b0616e179be99958c0a
Author: Philipp Winter 
Date:   Wed May 20 14:22:05 2020 -0700

Add new fields to BlockedBridges.

Our new tool wolpertinger will populate these fields after delegating
censorship measurement to OONI.

This fixes .
---
 CHANGELOG   | 4 
 bridgedb/Storage.py | 8 +++-
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/CHANGELOG b/CHANGELOG
index 5ac9e0b..80d3afa 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,7 @@
+* FIXES https://bugs.torproject.org/34154
+Add new fields to the SQLite table BlockedBridges in preparation for taking
+into account OONI's bridge measurement results.
+
 * FIXES https://bugs.torproject.org/31528
 BridgeDB's UI uses a bunch of obscure "chatspeak" references in its UI.  
One
 example is that it responds with "Uh oh, spaghettios!" if there are
diff --git a/bridgedb/Storage.py b/bridgedb/Storage.py
index d725fa3..0fe8851 100644
--- a/bridgedb/Storage.py
+++ b/bridgedb/Storage.py
@@ -70,7 +70,13 @@ SCHEMA2_SCRIPT = """
  CREATE TABLE BlockedBridges (
  id INTEGER PRIMARY KEY NOT NULL,
  hex_key,
- blocking_country
+ bridge_type,
+ address,
+ port,
+ blocking_country,
+ blocking_asn,
+ measured_by,
+ last_measured
  );
 
  CREATE INDEX BlockedBridgesBlockingCountry on BlockedBridges(hex_key);



___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [bridgedb/develop] Merge branch 'defect/31528' into develop

2020-05-14 Thread phw
commit f25943ef8aabf8cc2b9b5bdfb32b422c2d4960ef
Merge: cc3277b 9ac52d5
Author: Philipp Winter 
Date:   Thu May 14 14:37:32 2020 -0700

Merge branch 'defect/31528' into develop

 CHANGELOG  | 2436 ++--
 README.rst |   12 +-
 bridgedb/distributors/https/server.py  |   11 +-
 .../https/templates/assets/css/main.css|4 +-
 bridgedb/distributors/https/templates/bridges.html |   13 +-
 .../distributors/https/templates/error-400.html|   30 +
 .../distributors/https/templates/error-500.html|4 +-
 bridgedb/i18n/templates/bridgedb.pot   |   29 +-
 bridgedb/test/test_https_server.py |   20 +-
 9 files changed, 1253 insertions(+), 1306 deletions(-)

___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [bridgedb/develop] Update our strings to get them translated.

2020-05-14 Thread phw
commit aba3c3465b63b1d2116132f00cb865b7f7b35c45
Author: Philipp Winter 
Date:   Thu May 14 14:21:59 2020 -0700

Update our strings to get them translated.
---
 bridgedb/i18n/templates/bridgedb.pot | 29 -
 1 file changed, 12 insertions(+), 17 deletions(-)

diff --git a/bridgedb/i18n/templates/bridgedb.pot 
b/bridgedb/i18n/templates/bridgedb.pot
index bb78824..273e1e4 100644
--- a/bridgedb/i18n/templates/bridgedb.pot
+++ b/bridgedb/i18n/templates/bridgedb.pot
@@ -5,18 +5,18 @@
 #
 msgid ""
 msgstr ""
-"Project-Id-Version: bridgedb 0.10.0+10.g96de503\n"
+"Project-Id-Version: bridgedb 0.10.0+25.g77870a9\n"
 "Report-Msgid-Bugs-To: "
 
"'https://trac.torproject.org/projects/tor/newticket?component=BridgeDB;
 "=bridgedb-reported,msgid=isis,sysrqb=isis'\n"
-"POT-Creation-Date: 2020-04-09 14:45-0700\n"
+"POT-Creation-Date: 2020-05-14 14:21-0700\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 "Last-Translator: FULL NAME \n"
 "Language-Team: LANGUAGE \n"
 "MIME-Version: 1.0\n"
 "Content-Type: text/plain; charset=utf-8\n"
 "Content-Transfer-Encoding: 8bit\n"
-"Generated-By: Babel 2.7.0\n"
+"Generated-By: Babel 2.8.0\n"
 
 #. -*- coding: utf-8 ; test-case-name: bridgedb.test.test_https_server -*-
 #. This file is part of BridgeDB, a Tor bridge distribution system.
@@ -78,31 +78,26 @@ msgstr ""
 msgid "QRCode for your bridge lines"
 msgstr ""
 
-#. TRANSLATORS: Please translate this into some silly way to say
-#. "There was a problem!" in your language. For example,
-#. for Italian, you might translate this into "Mama mia!",
-#. or for French: "Sacrebleu!". :)
-#: bridgedb/distributors/https/templates/bridges.html:67
-#: bridgedb/distributors/https/templates/bridges.html:119
-msgid "Uh oh, spaghettios!"
-msgstr ""
-
-#: bridgedb/distributors/https/templates/bridges.html:68
+#: bridgedb/distributors/https/templates/bridges.html:63
 msgid "It seems there was an error getting your QRCode."
 msgstr ""
 
-#: bridgedb/distributors/https/templates/bridges.html:73
+#: bridgedb/distributors/https/templates/bridges.html:68
 msgid ""
 "This QRCode contains your bridge lines. Scan it with a QRCode reader to copy "
 "your bridge lines onto mobile and other devices."
 msgstr ""
 
-#: bridgedb/distributors/https/templates/bridges.html:125
+#: bridgedb/distributors/https/templates/bridges.html:110
+msgid "BridgeDB encountered an error."
+msgstr ""
+
+#: bridgedb/distributors/https/templates/bridges.html:116
 msgid "There currently aren't any bridges available..."
 msgstr ""
 
-#: bridgedb/distributors/https/templates/bridges.html:127
-#: bridgedb/distributors/https/templates/bridges.html:131
+#: bridgedb/distributors/https/templates/bridges.html:118
+#: bridgedb/distributors/https/templates/bridges.html:122
 #, python-format
 msgid " Perhaps you should try %s going back %s and choosing a different 
bridge type!"
 msgstr ""



___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [bridgedb/develop] Feedback implmentation

2020-05-14 Thread phw
commit a2a37821da95e0195b35543c0772eadf0f854734
Author: agix 
Date:   Sat May 2 10:39:58 2020 +0200

Feedback implmentation

Removed link from error pages
Changed missed chatspeak string
---
 bridgedb/distributors/https/templates/error-400.html | 2 +-
 bridgedb/distributors/https/templates/error-500.html | 2 +-
 bridgedb/test/test_https_server.py   | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/bridgedb/distributors/https/templates/error-400.html 
b/bridgedb/distributors/https/templates/error-400.html
index 5f12dda..9430c00 100644
--- a/bridgedb/distributors/https/templates/error-400.html
+++ b/bridgedb/distributors/https/templates/error-400.html
@@ -22,7 +22,7 @@
 
 
   Bad Request
-  Your request was not understood by the server.BridgeDB
+  Your request was not understood by the server.
 
   
 
diff --git a/bridgedb/distributors/https/templates/error-500.html 
b/bridgedb/distributors/https/templates/error-500.html
index e17b2f4..1408293 100644
--- a/bridgedb/distributors/https/templates/error-500.html
+++ b/bridgedb/distributors/https/templates/error-500.html
@@ -28,7 +28,7 @@
 
 
   Internal Error
-  BridgeDB encountered an internal errorBridgeDB
+  BridgeDB encountered an internal error
 
   
 
diff --git a/bridgedb/test/test_https_server.py 
b/bridgedb/test/test_https_server.py
index 3b159ce..c523c1e 100644
--- a/bridgedb/test/test_https_server.py
+++ b/bridgedb/test/test_https_server.py
@@ -86,7 +86,7 @@ class ReplaceErrorPageTests(unittest.TestCase):
 ``replaceErrorPage`` should return custom hardcoded HTML error text.
 """
 request = DummyRequest([''])
-exc = Exception("vegan gümmibären")
+exc = Exception("Error while rendering")
 server.resource500 = None
 errorPage = server.replaceErrorPage(request, exc)
 self.assertNotSubstring(b"Bad Request", errorPage)



___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [bridgedb/develop] Re-flow indentation of bugfix items.

2020-05-14 Thread phw
commit 9ac52d508566a4200be37262e9dd1afa85f4ac8e
Author: Philipp Winter 
Date:   Thu May 14 14:33:31 2020 -0700

Re-flow indentation of bugfix items.

The excessive 8-character indentation has been bothering me forever.
This patch reduces indentation to four characters and re-flows all
bugfix items.
---
 CHANGELOG | 2443 ++---
 1 file changed, 1184 insertions(+), 1259 deletions(-)

diff --git a/CHANGELOG b/CHANGELOG
index cfee3f9..5ac9e0b 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,1549 +1,1474 @@
-* FIXES https://bugs.torproject.org/31528
-BridgeDB's UI uses a bunch of obscure "chatspeak" references in its UI.
-One example is that it responds with "Uh oh, spaghettios!" if there are
-currently no bridges available.  While funny to some, this is difficult
-to translate and shouldn't be part of software that's used by an
-international audience.  This patch removes such references.
-
-* FIXES https://bugs.torproject.org/12802
-Add a script that sends a bridge request over email, and then checks if
-it received a response from BridgeDB.  We use this script as part of
-our nagios setup, so we notice when our autoresponder breaks.
-
-* FIXES https://bugs.torproject.org/17548
-This patch removes PGP support.  BridgeDB's signing key expired on
-2015-09-11.  Nobody ever complained and maintaining the bits and pieces
-necessary to sign emails isn't worth the effort, so this patch removes
-that feature.
-
-* FIXES https://bugs.torproject.org/30941
-Make our email responder more usable.  This patch removes the concept 
of
-"valid" email commands and returns bridges (obfs4, for now) no matter
-what the user sends.  BridgeDB still supports email commands in case 
the
-user needs a vanilla or IPv6 bridge.
-
-* FIXES https://bugs.torproject.org/29686
-Rename files that contain "Bridges" to "bridgerings", to eliminate
-headache on file systems that are case insensitive.
+* FIXES https://bugs.torproject.org/31528
+BridgeDB's UI uses a bunch of obscure "chatspeak" references in its UI.  
One
+example is that it responds with "Uh oh, spaghettios!" if there are
+currently no bridges available.  While funny to some, this is difficult to
+translate and shouldn't be part of software that's used by an international
+audience.  This patch removes such references.
+
+* FIXES https://bugs.torproject.org/12802
+Add a script that sends a bridge request over email, and then checks if it
+received a response from BridgeDB.  We use this script as part of our 
nagios
+setup, so we notice when our autoresponder breaks.
+
+* FIXES https://bugs.torproject.org/17548
+This patch removes PGP support.  BridgeDB's signing key expired on
+2015-09-11.  Nobody ever complained and maintaining the bits and pieces
+necessary to sign emails isn't worth the effort, so this patch removes that
+feature.
+
+* FIXES https://bugs.torproject.org/30941
+Make our email responder more usable.  This patch removes the concept of
+"valid" email commands and returns bridges (obfs4, for now) no matter what
+the user sends.  BridgeDB still supports email commands in case the user
+needs a vanilla or IPv6 bridge.
+
+* FIXES https://bugs.torproject.org/29686
+Rename files that contain "Bridges" to "bridgerings", to eliminate headache
+on file systems that are case insensitive.
 
 Changes in version 0.10.0 - 2020-04-01
 
-* FIXES https://bugs.torproject.org/30317
-Update our "howto" box, which explains how one adds bridges to Tor
-Browser.  In addition to updating the instructions, this patch also
-links to instructions for Android.
+* FIXES https://bugs.torproject.org/30317
+Update our "howto" box, which explains how one adds bridges to Tor Browser.
+In addition to updating the instructions, this patch also links to
+instructions for Android.
 
-* FIXES https://bugs.torproject.org/33631
-So far, BridgeDB remembered only the first distribution mechanism it
-ever learned for a given bridge.  That means that if a bridge would
-change its mind and re-configure its distribution mechanism using
-BridgeDistribution, BridgeDB would ignore it.  This patch changes this
-behavior, so bridges can actually change their distribution mechanism.
+* FIXES https://bugs.torproject.org/33631
+So far, BridgeDB remembered only the first distribution mechanism it ever
+learned for a given bridge.  That means that if a bridge would change its
+mind and re-configure its distribution mechanism using BridgeDistribution,
+BridgeDB would ignore it.  This patch changes this behavior, so bridges can
+actually change their distribution 

[tor-commits] [bridgedb/develop] Add CHANGELOG entry for #31528.

2020-05-14 Thread phw
commit 77870a9d64d95facd5c3f79e223451640811871b
Author: Philipp Winter 
Date:   Thu May 14 14:20:31 2020 -0700

Add CHANGELOG entry for #31528.
---
 CHANGELOG | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/CHANGELOG b/CHANGELOG
index 7a7a524..cfee3f9 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,10 @@
+* FIXES https://bugs.torproject.org/31528
+BridgeDB's UI uses a bunch of obscure "chatspeak" references in its UI.
+One example is that it responds with "Uh oh, spaghettios!" if there are
+currently no bridges available.  While funny to some, this is difficult
+to translate and shouldn't be part of software that's used by an
+international audience.  This patch removes such references.
+
 * FIXES https://bugs.torproject.org/12802
 Add a script that sends a bridge request over email, and then checks if
 it received a response from BridgeDB.  We use this script as part of



___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [bridgedb/develop] Commit for #31528 (Get rid of BridgeDB's "chatspeak")

2020-05-14 Thread phw
commit 320ddd1747cd584dd6cf9d7a2ff3f571827d1089
Author: agix 
Date:   Thu Apr 30 10:18:46 2020 +0200

Commit for #31528 (Get rid of BridgeDB's "chatspeak")

Known chatspeak references have been removed or replaced
Malicious requests are now redirected with the status code 400
---
 README.rst | 12 -
 bridgedb/distributors/https/server.py  | 11 
 .../https/templates/assets/css/main.css|  4 +--
 bridgedb/distributors/https/templates/bridges.html | 13 ++
 .../distributors/https/templates/error-400.html| 30 ++
 .../distributors/https/templates/error-500.html|  4 +--
 bridgedb/test/test_https_server.py | 18 ++---
 7 files changed, 56 insertions(+), 36 deletions(-)

diff --git a/README.rst b/README.rst
index 858562e..1b0a840 100644
--- a/README.rst
+++ b/README.rst
@@ -78,8 +78,8 @@ Dependencies and installation
 
 BridgeDB requires the following OS-level dependencies:
 
--  python>=2.7
--  python-dev
+-  python>=3
+-  python3-dev
 -  `python3-dkim `__ (it contains the 
``dkimverify`` binary)
 -  build-essential
 -  OpenSSL>=1.0.1g
@@ -106,11 +106,11 @@ Deploying BridgeDB
 
 BridgeDB should work with or without a Python virtualenv.
 
--  Install Python 2.7, and other OS-level dependencies. On Debian, you
+-  Install Python 3, and other OS-level dependencies. On Debian, you
can do::
 
- sudo apt-get install build-essential openssl python python-dev \
-   python-setuptools sqlite3 libgeoip-dev geoip-database
+ sudo apt-get install build-essential openssl python3 python3-dev \
+   python3-setuptools sqlite3 gnupg2 libgeoip-dev geoip-database
 
 
 -  Install Pip 1.3.1 or later. Debian has this version, but if for some
@@ -146,7 +146,7 @@ BridgeDB should work with or without a Python virtualenv.
 -  **(virtualenv installs only)** To install, set PYTHONPATH to include the
root directory of the virtualenv::
 
- export 
PYTHONPATH=$PYTHONPATH:${VIRTUAL_ENV}/lib/python2.7/site-packages
+ export 
PYTHONPATH=$PYTHONPATH:${VIRTUAL_ENV}/lib/python3.7/site-packages
 
 
 -  Then, proceed as usual::
diff --git a/bridgedb/distributors/https/server.py 
b/bridgedb/distributors/https/server.py
index b2de4b1..91757e7 100644
--- a/bridgedb/distributors/https/server.py
+++ b/bridgedb/distributors/https/server.py
@@ -166,11 +166,9 @@ def replaceErrorPage(request, error, template_name=None, 
html=True):
 
 
 def redirectMaliciousRequest(request):
-'''Redirect the client to a "daring work of art" which "in true
-post-modern form, […] tends to raise more questions than answers."
-'''
-logging.debug("Redirecting %s to a daring work of art..." % 
getClientIP(request))
-request.write(redirectTo(base64.b64decode("aHR0cDovLzJnaXJsczFjdXAuY2Ev"), 
request))
+'''Setting the reponse code to 400 (Bad Request)'''
+logging.debug("Setting response code to 400 for %s" % getClientIP(request))
+request.setResponseCode(400)
 request.finish()
 return request
 
@@ -367,7 +365,7 @@ class ErrorResource(CSPResource):
 
 render_POST = render_GET
 
-
+resource400 = ErrorResource('error-400.html', code=400)
 resource404 = ErrorResource('error-404.html', code=404)
 resource500 = ErrorResource('error-500.html', code=500)
 maintenance = ErrorResource('error-503.html', code=503)
@@ -1157,6 +1155,7 @@ def addWebServer(config, distributor):
 root.putChild(b'info', info)
 root.putChild(b'maintenance', maintenance)
 root.putChild(b'error', resource500)
+root.putChild(b'malicious', resource400)
 root.putChild(CSPResource.reportURI, csp)
 
 if config.RECAPTCHA_ENABLED:
diff --git a/bridgedb/distributors/https/templates/assets/css/main.css 
b/bridgedb/distributors/https/templates/assets/css/main.css
index 72a3205..8ff1f07 100644
--- a/bridgedb/distributors/https/templates/assets/css/main.css
+++ b/bridgedb/distributors/https/templates/assets/css/main.css
@@ -373,11 +373,11 @@ div.bridge-lines.-webkit-scrollbar-thumb.horizontal{
   align-content: left;
 }
 
-#uh-oh-spaghettios {
+#error {
   width: 80%;
   margin: auto;
 }
-.uh-oh-spaghettios~p {
+.error~p {
   text-align: center;
   font-size: 115%;
 }
diff --git a/bridgedb/distributors/https/templates/bridges.html 
b/bridgedb/distributors/https/templates/bridges.html
index 55a9e79..1d672eb 100644
--- a/bridgedb/distributors/https/templates/bridges.html
+++ b/bridgedb/distributors/https/templates/bridges.html
@@ -60,11 +60,6 @@ ${bridgeline | h,trim}
   
 % else:
   
-## TRANSLATORS: Please translate this into some silly way to say
-##  "There was a problem!" in your language. For example,
-##  for Italian, you might translate this into "Mama mia!",
-##  or for French: "Sacrebleu!". :)
-${_("""Uh oh, spaghettios!""")}
 ${_("""It seems there was an error 

[tor-commits] [community/master] Remove outdated and redundant paragraphs.

2020-05-13 Thread phw
commit 3f4665b232c82d718fdee019fbb651d0fc8dff50
Author: Philipp Winter 
Date:   Wed May 13 08:51:46 2020 -0700

Remove outdated and redundant paragraphs.
---
 .../technical-setup/bridge/docker/contents.lr  | 30 +-
 1 file changed, 6 insertions(+), 24 deletions(-)

diff --git a/content/relay-operations/technical-setup/bridge/docker/contents.lr 
b/content/relay-operations/technical-setup/bridge/docker/contents.lr
index 48208ca..7c964f8 100644
--- a/content/relay-operations/technical-setup/bridge/docker/contents.lr
+++ b/content/relay-operations/technical-setup/bridge/docker/contents.lr
@@ -6,18 +6,9 @@ title: Docker
 ---
 body:
 
-### 1. Pull the image
+### 1. Deploy a container
 
-We are maintaining a docker image that runs an obfs4 bridge.
-First, download the image:
-
-```
-docker pull phwinter/obfs4-bridge:latest
-```
-
-### 2. Deploy a container
-
-We provide a docker-compose.yml file that helps you deploy the container.
+We provide a docker-compose file that helps you deploy the container.
 First,
 [download 
docker-compose.yml](https://dip.torproject.org/torproject/anti-censorship/docker-obfs4-bridge/raw/master/docker-compose.yml),
 and then write your bridge configuration to a new file, `.env`, which is in the
@@ -36,7 +27,8 @@ EMAIL=Z
 Replace `X` with your desired OR port, `Y` with your obfs4 port (make sure that
 **both** ports are forwarded in your firewall), and `Z` with your email 
address,
 which allows us to get in touch with you if there are problems with your 
bridge.
-With your bridge configuration in place, you can now deploy the container:
+With your bridge configuration in place, you can now deploy the container by
+running:
 
 ```
 docker-compose up -d obfs4-bridge
@@ -53,17 +45,7 @@ Starting docker-obfs4-bridge_obfs4-bridge_1 ... done
 
 That's it! Your container is now bootstrapping your new obfs4 bridge.
 
-If you want to run multiple bridges on your machine, you need to create more
-bridge configuration files with different sets of ports, and run `make deploy`
-again, like so:
-
-```
-source bridge-1.sh && make deploy
-source bridge-2.sh && make deploy
-...
-```
-
-### 3. Upgrade your container
+### 2. Upgrade your container
 
 Upgrading to the latest version of our image is as simple as running:
 
@@ -75,7 +57,7 @@ Note that your bridge's data directory (which includes its 
key material) is stor
 If you are running multiple bridges on your computer, you need to repeat this 
step for each bridge.
 We will announce new image versions on the 
[tor-dev](https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-dev) 
mailing list.
 
-### 4. Monitor your logs
+### 3. Monitor your logs
 
 You can inspect your bridge's logs by running:
 

___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [community/master] Update docs to reflect switch to docker-compose.

2020-05-12 Thread phw
commit dd27ae88c83585f062c0975b978a59ba16fbae8b
Author: Philipp Winter 
Date:   Tue May 12 12:39:30 2020 -0700

Update docs to reflect switch to docker-compose.
---
 .../technical-setup/bridge/docker/contents.lr  | 40 +-
 1 file changed, 23 insertions(+), 17 deletions(-)

diff --git a/content/relay-operations/technical-setup/bridge/docker/contents.lr 
b/content/relay-operations/technical-setup/bridge/docker/contents.lr
index 4f88a69..48208ca 100644
--- a/content/relay-operations/technical-setup/bridge/docker/contents.lr
+++ b/content/relay-operations/technical-setup/bridge/docker/contents.lr
@@ -17,36 +17,45 @@ docker pull phwinter/obfs4-bridge:latest
 
 ### 2. Deploy a container
 
-We provide a Makefile that helps you deploy the container.
-First, [download the 
Makefile](https://dip.torproject.org/torproject/anti-censorship/docker-obfs4-bridge/raw/master/Makefile),
 and then write your bridge configuration to a new file, bridge.sh.
-Here's a template:
+We provide a docker-compose.yml file that helps you deploy the container.
+First,
+[download 
docker-compose.yml](https://dip.torproject.org/torproject/anti-censorship/docker-obfs4-bridge/raw/master/docker-compose.yml),
+and then write your bridge configuration to a new file, `.env`, which is in the
+same directory as `docker-compose.yml`. Here's a
+template:
 
 ```
 # Your bridge's Tor port.
-export OR_PORT=X
+OR_PORT=X
 # Your bridge's obfs4 port.
-export PT_PORT=Y
+PT_PORT=Y
 # Your email address.
-export EMAIL=Z
+EMAIL=Z
 ```
 
-Replace `X` with your desired OR port, `Y` with your obfs4 port (make sure 
that **both** ports are forwarded in your firewall), and `Z` with your email 
address, which allows us to get in touch with you if there are problems with 
your bridge.
+Replace `X` with your desired OR port, `Y` with your obfs4 port (make sure that
+**both** ports are forwarded in your firewall), and `Z` with your email 
address,
+which allows us to get in touch with you if there are problems with your 
bridge.
 With your bridge configuration in place, you can now deploy the container:
 
 ```
-source bridge.sh && make deploy
+docker-compose up -d obfs4-bridge
 ```
 
+This command will automatically load your `docker-compose.yml` file while
+considering the environment variables in `.env`.
+
 You should now see output similar to the following:
 
 ```
-201fbd2b4d28e6f226978f27547edd79272871c5949bf8aab3872c983156a108
-Make sure that port X and Y are forwarded in your firewall.
+Starting docker-obfs4-bridge_obfs4-bridge_1 ... done
 ```
 
-That's it! Your container (identified by the first line of output) is now 
bootstrapping your new obfs4 bridge.
+That's it! Your container is now bootstrapping your new obfs4 bridge.
 
-If you want to run multiple bridges on your machine, you need to create more 
bridge configuration files with different sets of ports, and run `make deploy` 
again, like so:
+If you want to run multiple bridges on your machine, you need to create more
+bridge configuration files with different sets of ports, and run `make deploy`
+again, like so:
 
 ```
 source bridge-1.sh && make deploy
@@ -56,13 +65,10 @@ source bridge-2.sh && make deploy
 
 ### 3. Upgrade your container
 
-To upgrade to the latest version of our image, you need to stop your existing 
container, delete it, pull the latest image, and finally deploy it again:
+Upgrading to the latest version of our image is as simple as running:
 
 ```
-docker stop CONTAINER_ID
-docker rm CONTAINER_ID
-docker pull phwinter/obfs4-bridge:latest
-source bridge.sh && make deploy
+docker-compose up -d obfs4-bridge
 ```
 
 Note that your bridge's data directory (which includes its key material) is 
stored in a docker volume, so you won't lose your bridge's identity when 
upgrading to the latest docker image.

___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [bridgedb/develop] Add CHANGELOG entry.

2020-05-11 Thread phw
commit 6e191f82b1451525b547c28f439180c4b7d25a4a
Author: Philipp Winter 
Date:   Mon Mar 23 17:31:52 2020 -0700

Add CHANGELOG entry.
---
 CHANGELOG | 5 +
 1 file changed, 5 insertions(+)

diff --git a/CHANGELOG b/CHANGELOG
index 7524344..7a7a524 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,8 @@
+* FIXES https://bugs.torproject.org/12802
+Add a script that sends a bridge request over email, and then checks if
+it received a response from BridgeDB.  We use this script as part of
+our nagios setup, so we notice when our autoresponder breaks.
+
 * FIXES https://bugs.torproject.org/17548
 This patch removes PGP support.  BridgeDB's signing key expired on
 2015-09-11.  Nobody ever complained and maintaining the bits and pieces



___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [bridgedb/develop] Merge branch 'enhancement/12802' into develop

2020-05-11 Thread phw
commit cc3277b7449fc4125c179b99962ef86e1b39b22c
Merge: 4cdd6a6 74b159e
Author: Philipp Winter 
Date:   Mon May 11 12:26:49 2020 -0700

Merge branch 'enhancement/12802' into develop

 CHANGELOG  |   5 +
 bridgedb/distributors/email/server.py  |   2 +-
 bridgedb/distributors/https/request.py |   5 +-
 scripts/nagios-email-check | 201 +
 4 files changed, 209 insertions(+), 4 deletions(-)

___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [bridgedb/develop] Add missing newline at the end of the file.

2020-05-11 Thread phw
commit 9f8e95de1bc7945869eda4bdde3755eafcdad6bd
Author: Philipp Winter 
Date:   Thu May 7 08:25:22 2020 -0700

Add missing newline at the end of the file.
---
 scripts/nagios-email-check | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/nagios-email-check b/scripts/nagios-email-check
index 7287646..b9fc831 100755
--- a/scripts/nagios-email-check
+++ b/scripts/nagios-email-check
@@ -149,7 +149,7 @@ def write_status_file(status, message):
 code = codes.get(status, UNKNOWN)
 
 with open(STATUS_FILE, "w") as fd:
-fd.write("{}\n{}: {}".format(code, status, message))
+fd.write("{}\n{}: {}\n".format(code, status, message))
 log("Wrote status='%s', message='%s' to status file." % (status, message))
 
 



___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [bridgedb/develop] Add service status check

2020-05-11 Thread phw
commit 2ae19e5c25dca6acdb0307c147dc93f73e257f7e
Author: hiro 
Date:   Mon Oct 21 19:54:50 2019 +0200

Add service status check
---
 scripts/check_status | 137 +++
 1 file changed, 137 insertions(+)

diff --git a/scripts/check_status b/scripts/check_status
new file mode 100644
index 000..8f8f3e5
--- /dev/null
+++ b/scripts/check_status
@@ -0,0 +1,137 @@
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+#
+# This file is part of  BridgeDB, a Tor bridge distribution system.
+#
+# :authors: hiro 
+#   see also AUTHORS file
+#
+# :license: This is Free Software. See LICENSE for license information.
+
+import sys
+import smtplib
+import time
+import imaplib
+import email
+import time
+
+# Standard Nagios return codes
+OK, WARNING, CRITICAL, UNKNOWN = range(4)
+
+ORG_EMAIL   = "@gmail.com"
+FROM_EMAIL  = "test.bridges.browser" + ORG_EMAIL
+SMTP_SERVER = "imap.gmail.com"
+SMTP_PORT   = 993
+
+MESSAGE_FROM = "brid...@torproject.org"
+MESSAGE_SUBJECT = "Bridges"
+MESSAGE_BODY = ":443"
+
+STATUS_FILE = "/srv/bridgedb.torproject.org/check/status"
+
+# -
+#
+# Utility to read email from Gmail Using Python
+#
+# 
+
+def test_email_from_gmail(password):
+try:
+mail = imaplib.IMAP4_SSL(SMTP_SERVER)
+mail.login(FROM_EMAIL, password)
+mail.select('INBOX')
+
+type, data = mail.search(None, 'ALL')
+mail_ids = data[0]
+
+id_list = mail_ids.split()
+first_email_id = int(str(id_list[0], 'utf-8'))
+latest_email_id = int(str(id_list[-1], 'utf-8'))
+
+for i in range(int(latest_email_id), int(first_email_id), -1):
+typ, data = mail.fetch(str(i), '(RFC822)')
+
+for response_part in data:
+if isinstance(response_part, tuple):
+m = str(response_part[1], 'utf-8')
+msg = email.message_from_string(m)
+email_subject = "{}".format(msg['subject'])
+email_from = "{}".format(msg['from'])
+email_body = "{}".format(msg.as_string())
+
+if (MESSAGE_FROM == email_from) and (MESSAGE_SUBJECT == 
email_subject) and (MESSAGE_BODY in email_body):
+mail.store(str(i), '+FLAGS', '\\Deleted')
+mail.close()
+return OK, "Bridgedb is good and sending emails with 
working bridges"
+else:
+mail.store(str(i), '+FLAGS', '\\Deleted')
+
+mail.close()
+return WARNING, "No emails from gettor found"
+
+except Exception as e:
+return CRITICAL, str(e)
+
+def send_email_from_gmail(password):
+sent_from = FROM_EMAIL
+sent_to = ["{}".format(MESSAGE_FROM)]
+subject = 'Bridges'
+body = 'get bridges'
+
+email_text = """From: %s\nTo: %s\nSubject: %s\n\n%s""" % (sent_from, ", 
".join(sent_to), subject, body)
+
+try:
+mail = smtplib.SMTP_SSL('smtp.gmail.com', 465)
+mail.ehlo()
+mail.login(sent_from, password)
+mail.sendmail(sent_from, sent_to, email_text)
+mail.close()
+return OK, "Test email sent"
+except Exception as e:
+return UNKNOWN, str(e)
+
+if __name__ == "__main__":
+status, message = None, None
+
+if len(sys.argv) == 2:
+password = sys.argv[1]
+else:
+password = "yourPassword"
+
+status_file = open(STATUS_FILE, 'r')
+message = status_file.read()
+status_file.close()
+
+try:
+status, message = send_email_from_gmail(password)
+except Exception as e:
+status = UNKNOWN
+message = repr(e)
+status_file = open(STATUS_FILE,'w')
+status_file.write("UNKNOWN\n3: %s" % message)
+status_file.close()
+
+time.sleep(600)
+
+try:
+status, message = test_email_from_gmail(password)
+except KeyboardInterrupt:
+status, message = CRITICAL, "Caught Control-C..."
+except Exception as e:
+status = CRITICAL
+message = repr(e)
+finally:
+status_file = open(STATUS_FILE,'w')
+if status == OK:
+status_file.write("OK\n0: %s" % message)
+elif status == WARNING:
+status_file.write("WARNING\n1: %s" % message)
+elif status == CRITICAL:
+status_file.write("CRITICAL\n2: %s" % message)
+else:
+status_file.write("UNKNOWN\n3: %s" % message)
+status = UNKNOWN
+
+status_file.close()
+
+sys.exit(status)




[tor-commits] [bridgedb/develop] Don't assume a line can be decoded as UTF-8.

2020-05-11 Thread phw
commit 8cdbbebdc458ff162e936ad5b979a38f433a01b5
Author: Philipp Winter 
Date:   Tue Apr 21 11:10:27 2020 -0700

Don't assume a line can be decoded as UTF-8.

For example, we may be dealing with text that's cp1252-encoded.
BridgeDB gets a lot of spam like that:

  b"Subject: Ich m\xf6chte Sie treffen"
  b'Subject: Wei\xdft du, wie man ein M\xe4dchen anmacht?'

Instead of trying really hard to figure out what encoding we're dealing
with, we simply ignore characters we cannot decode.
---
 bridgedb/distributors/email/server.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/bridgedb/distributors/email/server.py 
b/bridgedb/distributors/email/server.py
index f18a5ad..54a8231 100644
--- a/bridgedb/distributors/email/server.py
+++ b/bridgedb/distributors/email/server.py
@@ -212,7 +212,7 @@ class SMTPMessage(object):
 if self.nBytes > self.context.maximumSize:
 self.ignoring = True
 else:
-self.lines.append(line.decode('utf-8') if isinstance(line, bytes) 
else line)
+self.lines.append(line.decode('utf-8', 'ignore') if 
isinstance(line, bytes) else line)
 if not safelog.safe_logging:
 try:
 ln = line.rstrip("\r\n").encode('utf-8', 'replace')



___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [bridgedb/develop] Allow passing the Gmail key as env variable.

2020-05-11 Thread phw
commit 74b159e9c2c473f02b629cd4bf7152a363770666
Author: Philipp Winter 
Date:   Mon May 11 12:13:32 2020 -0700

Allow passing the Gmail key as env variable.
---
 scripts/nagios-email-check | 18 ++
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/scripts/nagios-email-check b/scripts/nagios-email-check
index b9fc831..51c63a1 100755
--- a/scripts/nagios-email-check
+++ b/scripts/nagios-email-check
@@ -10,8 +10,12 @@
 #
 # Run this script via crontab every three hours as follows:
 #   0 */3 * * * path/to/nagios-email-check $(cat path/to/gmail.key)
+#
+# You can provide the Gmail key as an argument (as exemplified above) or by
+# using the environment variable BRIDGEDB_GMAIL_KEY, e.g.:
+#   BRIDGEDB_GMAIL_KEY=foo path/to/nagios-email-check $(cat path/to/gmail.key)
 
-
+import os
 import sys
 import smtplib
 import time
@@ -161,9 +165,15 @@ if __name__ == "__main__":
 if len(sys.argv) == 2:
 password = sys.argv[1]
 else:
-log("No email password provided.")
-write_status_file(UNKNOWN, "No email password provided")
-sys.exit(1)
+
+# Try to find our password in an environment variable.
+
+try:
+password = os.environ["BRIDGEDB_GMAIL_KEY"]
+except KeyError:
+log("No email password provided.")
+write_status_file(UNKNOWN, "No email password provided")
+sys.exit(1)
 
 # Send an email request to BridgeDB.
 



___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [bridgedb/develop] Refactor script.

2020-05-11 Thread phw
commit 91af6c1bbad6a71663372642c5b6531cd197e806
Author: Philipp Winter 
Date:   Tue Feb 18 10:59:14 2020 -0800

Refactor script.
---
 scripts/nagios-email-check | 191 +
 scripts/nagios_email_check | 162 --
 2 files changed, 191 insertions(+), 162 deletions(-)

diff --git a/scripts/nagios-email-check b/scripts/nagios-email-check
new file mode 100755
index 000..7287646
--- /dev/null
+++ b/scripts/nagios-email-check
@@ -0,0 +1,191 @@
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+#
+# This file is part of  BridgeDB, a Tor bridge distribution system.
+#
+# This script sends an email request for bridges to BridgeDB and then checks if
+# it got a response.  The result is written to STATUS_FILE, which is consumed
+# by Nagios.  Whenever BridgeDB fails to respond with bridges, we will get a
+# Nagios alert.
+#
+# Run this script via crontab every three hours as follows:
+#   0 */3 * * * path/to/nagios-email-check $(cat path/to/gmail.key)
+
+
+import sys
+import smtplib
+import time
+import imaplib
+import email
+import email.utils
+
+# Standard Nagios return codes
+OK, WARNING, CRITICAL, UNKNOWN = range(4)
+
+FROM_EMAIL = "testbridgestorbrow...@gmail.com"
+TO_EMAIL = "brid...@torproject.org"
+SMTP_SERVER = "imap.gmail.com"
+SMTP_PORT = 993
+
+MESSAGE_FROM = TO_EMAIL
+MESSAGE_BODY = "Here are your bridges:"
+
+STATUS_FILE = "/srv/bridges.torproject.org/check/status"
+
+# This will contain our test email's message ID.  We later make sure that this
+# message ID is referenced in the In-Reply-To header of BridgeDB's response.
+MESSAGE_ID = None
+
+
+def log(*args, **kwargs):
+"""
+Generic log function.
+"""
+
+print("[+]", *args, file=sys.stderr, **kwargs)
+
+
+def get_email_response(password):
+"""
+Open our Gmail inbox and see if we got a response.
+"""
+
+log("Checking for email response.")
+mail = imaplib.IMAP4_SSL(SMTP_SERVER)
+try:
+mail.login(FROM_EMAIL, password)
+except Exception as e:
+return WARNING, str(e)
+
+mail.select("INBOX")
+
+_, data = mail.search(None, "ALL")
+email_ids = data[0].split()
+if len(email_ids) == 0:
+log("Found no response.")
+return CRITICAL, "No emails from BridgeDB found"
+
+return check_email(mail, email_ids)
+
+
+def check_email(mail, email_ids):
+"""
+Check if we got our expected email response.
+"""
+
+log("Checking {:,} emails.".format(len(email_ids)))
+for email_id in email_ids:
+_, data = mail.fetch(email_id, "(RFC822)")
+
+# The variable `data` contains the full email object fetched by imaplib
+# 
+# We are only interested in the response part containing the email
+# envelope.
+for response_part in data:
+if isinstance(response_part, tuple):
+m = str(response_part[1], "utf-8")
+msg = email.message_from_string(m)
+email_from = "{}".format(msg["From"])
+email_body = "{}".format(msg.as_string())
+email_reply_to = "{}".format(msg["In-Reply-To"])
+
+if (MESSAGE_FROM == email_from) and \
+   (MESSAGE_BODY in email_body) and \
+   (MESSAGE_ID == email_reply_to):
+mail.store(email_id, '+X-GM-LABELS', '\\Trash')
+mail.expunge()
+mail.close()
+mail.logout()
+log("Found correct response (referencing {})."
+.format(MESSAGE_ID))
+return OK, "BridgeDB's email responder works"
+else:
+mail.store(email_id, '+X-GM-LABELS', '\\Trash')
+mail.expunge()
+mail.close()
+mail.logout()
+log("Found no response.")
+return WARNING, "No emails from BridgeDB found"
+
+
+def send_email_request(password):
+"""
+Attempt to send a bridge request over Gmail.
+"""
+
+subject = "Bridges"
+body = "get bridges"
+
+log("Sending email.")
+global MESSAGE_ID
+MESSAGE_ID = email.utils.make_msgid(idstring="test-bridgedb",
+domain="gmail.com")
+email_text = "From: %s\r\nTo: %s\r\nMessage-ID: %s\r\nSubject: %s\r\n" \
+ "\r\n%s" % (FROM_EMAIL, TO_EMAIL, MESSAGE_ID, subject, body)
+
+try:
+mail = smtplib.SMTP_SSL("smtp.gmail.com", 465)
+mail.login(FROM_EMAIL, password)
+mail.sendmail(FROM_EMAIL, TO_EMAIL, email_text)
+mail.close()
+log("Email successfully sent (message ID: %s)." % MESSAGE_ID)
+return OK, "Sent email bridge request"
+except Exception as e:
+log("Error while sending email: %s" % err)
+return UNKNOWN, str(e)
+
+
+def write_status_file(status, message):
+"""
+Write the given `status` and 

[tor-commits] [bridgedb/develop] Add review feedback

2020-05-11 Thread phw
commit 85b4a9cfe41308458b29356b1d771b192b4a7681
Author: hiro 
Date:   Wed Dec 11 17:31:17 2019 +0100

Add review feedback
---
 scripts/check_status | 91 ++--
 1 file changed, 45 insertions(+), 46 deletions(-)

diff --git a/scripts/check_status b/scripts/check_status
index 8f8f3e5..5032e33 100644
--- a/scripts/check_status
+++ b/scripts/check_status
@@ -82,7 +82,6 @@ def send_email_from_gmail(password):
 
 try:
 mail = smtplib.SMTP_SSL('smtp.gmail.com', 465)
-mail.ehlo()
 mail.login(sent_from, password)
 mail.sendmail(sent_from, sent_to, email_text)
 mail.close()
@@ -90,48 +89,48 @@ def send_email_from_gmail(password):
 except Exception as e:
 return UNKNOWN, str(e)
 
-if __name__ == "__main__":
-status, message = None, None
-
-if len(sys.argv) == 2:
-password = sys.argv[1]
-else:
-password = "yourPassword"
-
-status_file = open(STATUS_FILE, 'r')
-message = status_file.read()
-status_file.close()
-
-try:
-status, message = send_email_from_gmail(password)
-except Exception as e:
-status = UNKNOWN
-message = repr(e)
-status_file = open(STATUS_FILE,'w')
-status_file.write("UNKNOWN\n3: %s" % message)
-status_file.close()
-
-time.sleep(600)
-
-try:
-status, message = test_email_from_gmail(password)
-except KeyboardInterrupt:
-status, message = CRITICAL, "Caught Control-C..."
-except Exception as e:
-status = CRITICAL
-message = repr(e)
-finally:
-status_file = open(STATUS_FILE,'w')
-if status == OK:
-status_file.write("OK\n0: %s" % message)
-elif status == WARNING:
-status_file.write("WARNING\n1: %s" % message)
-elif status == CRITICAL:
-status_file.write("CRITICAL\n2: %s" % message)
-else:
-status_file.write("UNKNOWN\n3: %s" % message)
-status = UNKNOWN
-
-status_file.close()
-
-sys.exit(status)
+if __name__ == "__main__":
+status, message = None, None
+
+if len(sys.argv) == 2:
+password = sys.argv[1]
+else:
+password = "yourPassword"
+
+status_file = open(STATUS_FILE, 'r')
+message = status_file.read()
+status_file.close()
+
+try:
+status, message = send_email_from_gmail(password)
+except Exception as e:
+status = UNKNOWN
+message = repr(e)
+status_file = open(STATUS_FILE,'w')
+status_file.write("UNKNOWN\n3: %s" % message)
+status_file.close()
+
+time.sleep(600)
+
+try:
+status, message = test_email_from_gmail(password)
+except KeyboardInterrupt:
+status, message = CRITICAL, "Caught Control-C..."
+except Exception as e:
+status = CRITICAL
+message = repr(e)
+finally:
+status_file = open(STATUS_FILE,'w')
+if status == OK:
+status_file.write("OK\n0: %s" % message)
+elif status == WARNING:
+status_file.write("WARNING\n1: %s" % message)
+elif status == CRITICAL:
+status_file.write("CRITICAL\n2: %s" % message)
+else:
+status_file.write("UNKNOWN\n3: %s" % message)
+status = UNKNOWN
+
+status_file.close()
+
+sys.exit(status)



___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [bridgedb/develop] Fix typos in comment.

2020-05-11 Thread phw
commit b718662658589c4baaecef7c87aa5c589ed5fb3b
Author: Philipp Winter 
Date:   Tue Apr 21 11:11:15 2020 -0700

Fix typos in comment.
---
 bridgedb/distributors/https/request.py | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/bridgedb/distributors/https/request.py 
b/bridgedb/distributors/https/request.py
index 3236bee..0add358 100644
--- a/bridgedb/distributors/https/request.py
+++ b/bridgedb/distributors/https/request.py
@@ -92,9 +92,8 @@ class HTTPSBridgeRequest(bridgerequest.BridgeRequestBase):
 :api:`request ` ``unblocked=`` HTTP GET
 parameter will be added to the :data:`notBlockedIn` list.
 
-If :data:`addClientCountryCode` is ``True``, the the client's own
-geolocated country code will be added to the to the
-:data`notBlockedIn` list.
+If :data:`addClientCountryCode` is ``True``, then the client's own
+geolocated country code will be added to the :data`notBlockedIn` list.
 
 :type request: :api:`twisted.web.http.Request`
 :param request: A ``Request`` object containing the HTTP method, full



___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [bridgedb/develop] Add more review feedback

2020-05-11 Thread phw
commit 0e5f3fef90090aba33e73702598bf4c4793bb0b1
Author: hiro 
Date:   Wed Dec 11 18:17:12 2019 +0100

Add more review feedback
---
 scripts/check_status | 89 ++--
 1 file changed, 51 insertions(+), 38 deletions(-)

diff --git a/scripts/check_status b/scripts/check_status
index 5032e33..1784e6b 100644
--- a/scripts/check_status
+++ b/scripts/check_status
@@ -25,7 +25,7 @@ SMTP_PORT   = 993
 
 MESSAGE_FROM = "brid...@torproject.org"
 MESSAGE_SUBJECT = "Bridges"
-MESSAGE_BODY = ":443"
+MESSAGE_BODY = "Here are your bridges:"
 
 STATUS_FILE = "/srv/bridgedb.torproject.org/check/status"
 
@@ -36,41 +36,54 @@ STATUS_FILE = "/srv/bridgedb.torproject.org/check/status"
 # 
 
 def test_email_from_gmail(password):
+mail = imaplib.IMAP4_SSL(SMTP_SERVER)
 try:
-mail = imaplib.IMAP4_SSL(SMTP_SERVER)
 mail.login(FROM_EMAIL, password)
-mail.select('INBOX')
+except Exception as e:
+return WARNING, str(e)
+
+mail.select('INBOX')
+
+_, data = mail.search(None, 'ALL')
+mail_ids = data[0]
+
+id_list = mail_ids.split()
+
+status, message = check_email(id_list)
+
+return status, message
+
+
+def check_email(id_list):
+first_email_id = int(str(id_list[0], 'utf-8'))
+latest_email_id = int(str(id_list[-1], 'utf-8'))
 
-type, data = mail.search(None, 'ALL')
-mail_ids = data[0]
+for i in range(int(latest_email_id), int(first_email_id), -1):
+_, data = mail.fetch(str(i), '(RFC822)')
 
-id_list = mail_ids.split()
-first_email_id = int(str(id_list[0], 'utf-8'))
-latest_email_id = int(str(id_list[-1], 'utf-8'))
 
-for i in range(int(latest_email_id), int(first_email_id), -1):
-typ, data = mail.fetch(str(i), '(RFC822)')
+# The variable data contains the full email object fetched by imaplib
+# https://docs.python.org/3/library/imaplib.html#imaplib.IMAP4.fetch
+# We are only interested in the response part containing the email 
envelope.
 
-for response_part in data:
-if isinstance(response_part, tuple):
-m = str(response_part[1], 'utf-8')
-msg = email.message_from_string(m)
-email_subject = "{}".format(msg['subject'])
-email_from = "{}".format(msg['from'])
-email_body = "{}".format(msg.as_string())
+for response_part in data:
+if isinstance(response_part, tuple):
+m = str(response_part[1], 'utf-8')
+msg = email.message_from_string(m)
+email_subject = "{}".format(msg['subject'])
+email_from = "{}".format(msg['from'])
+email_body = "{}".format(msg.as_string())
 
-if (MESSAGE_FROM == email_from) and (MESSAGE_SUBJECT == 
email_subject) and (MESSAGE_BODY in email_body):
-mail.store(str(i), '+FLAGS', '\\Deleted')
-mail.close()
-return OK, "Bridgedb is good and sending emails with 
working bridges"
-else:
-mail.store(str(i), '+FLAGS', '\\Deleted')
+if (MESSAGE_FROM == email_from) and (MESSAGE_SUBJECT == 
email_subject) and (MESSAGE_BODY in email_body):
+mail.store(str(i), '+FLAGS', '\\Deleted')
+mail.close()
+return OK, "Bridgedb is good and sending emails with 
working bridges"
+else:
+mail.store(str(i), '+FLAGS', '\\Deleted')
 
 mail.close()
 return WARNING, "No emails from gettor found"
 
-except Exception as e:
-return CRITICAL, str(e)
 
 def send_email_from_gmail(password):
 sent_from = FROM_EMAIL
@@ -95,11 +108,18 @@ if __name__ == "__main__":
 if len(sys.argv) == 2:
 password = sys.argv[1]
 else:
-password = "yourPassword"
+return UNKNOWN, "Empty email password"
 
-status_file = open(STATUS_FILE, 'r')
-message = status_file.read()
-status_file.close()
+try:
+status_file = open(STATUS_FILE, 'r')
+message = status_file.read()
+status_file.close()
+except OSError:
+status = UNKNOWN
+message = "Status file has been created {}".format(STATUS_FILE)
+status_file = open(STATUS_FILE,'w')
+status_file.write("UNKNOWN\n3: %s" % message)
+status_file.close()
 
 try:
 status, message = send_email_from_gmail(password)
@@ -120,16 +140,9 @@ if __name__ == "__main__":
 status = CRITICAL
 message = repr(e)
 finally:
+d = {0: "OK", 1: "WARNING", 2: "CRITICAL", 3: "UNKNOWN"}
 status_file = open(STATUS_FILE,'w')
-if status == OK:
-status_file.write("OK\n0: %s" % message)
-elif status == WARNING:
-   

  1   2   3   4   5   6   7   >