[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [bridgedb/main] Provide bridges of the configure transport by default on email distributor



commit b973b84b6c92ae9d95ed59da468ffe7a14c386fc
Author: meskio <meskio@xxxxxxxxxxxxxx>
Date:   Tue Aug 24 11:06:32 2021 +0200

    Provide bridges of the configure transport by default on email distributor
    
    The default command 'get bridges' now now answers with 'DEFAULT_TRANSPORT'
    (obfs4 for now) bridges. Adding a new command 'get vanilla' to be able
    to get vanilla bridges if this is really the intent of the requester.
    
    Closes: #40019
---
 bridgedb/distributors/email/request.py | 17 ++++++++++++-----
 bridgedb/strings.py                    |  7 ++++---
 2 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/bridgedb/distributors/email/request.py b/bridgedb/distributors/email/request.py
index 6484fe3..0fee7c7 100644
--- a/bridgedb/distributors/email/request.py
+++ b/bridgedb/distributors/email/request.py
@@ -64,6 +64,8 @@ GET_LINE       = re.compile("([^>].*)?get")
 IPV6_LINE      = re.compile("([^>].*)?ipv6")
 TRANSPORT_LINE = re.compile("([^>].*)?transport")
 UNBLOCKED_LINE = re.compile("([^>].*)?unblocked")
+VANILLA_LINE = re.compile("([^>].*)?vanilla")
+
 
 def determineBridgeRequestOptions(lines):
     """Figure out which :mod:`~bridgedb.filters` to apply.
@@ -80,6 +82,7 @@ def determineBridgeRequestOptions(lines):
     """
     request = EmailBridgeRequest()
     skippedHeaders = False
+    requested_transport = False
 
     for line in lines:
         line = line.strip().lower()
@@ -93,20 +96,24 @@ def determineBridgeRequestOptions(lines):
         if IPV6_LINE.match(line) is not None:
             request.withIPv6()
         if TRANSPORT_LINE.match(line) is not None:
+            requested_transport = True
             request.withPluggableTransportType(line)
         if UNBLOCKED_LINE.match(line) is not None:
             request.withoutBlockInCountry(line)
+        if VANILLA_LINE.match(line) is not None:
+            requested_transport = True
+
+    # If not transport requested we will respond with our default transport protocol.
+    if not requested_transport:
+        # Note that this variable must satisfy TRANSPORT_PATTERN.
+        default_transport = "transport %s" % strings._getDefaultTransport()
+        request.withPluggableTransportType(default_transport)
 
     # We cannot expect all users to understand BridgeDB's commands, so we will
     # return bridges even if the request was invalid.
     if not request.isValid():
         logging.debug("Email request was invalid.")
         request.isValid(True)
-        # We will respond with our default transport protocol.
-        if not len(request.transports):
-            # Note that this variable must satisfy TRANSPORT_PATTERN.
-            default_transport = "transport %s" % strings._getDefaultTransport()
-            request.withPluggableTransportType(default_transport)
 
     logging.debug("Generating hashring filters for request.")
     request.generateFilters()
diff --git a/bridgedb/strings.py b/bridgedb/strings.py
index 2a1e60d..09eb91b 100644
--- a/bridgedb/strings.py
+++ b/bridgedb/strings.py
@@ -170,9 +170,10 @@ bridge" field."""),
 }
 
 EMAIL_COMMANDS = {
-    "get bridges":          _("(Request unobfuscated Tor bridges.)"),
-    "get ipv6":             _("(Request IPv6 bridges.)"),
-    "get transport obfs4":  _("(Request obfs4 obfuscated bridges.)"),
+    "get bridges": _("(Request default Tor bridges.)"),
+    "get ipv6": _("(Request IPv6 bridges.)"),
+    "get transport obfs4": _("(Request obfs4 obfuscated bridges.)"),
+    "get vanilla": _("(Request unobfuscated Tor bridges.)"),
     # TRANSLATORS: Please DO NOT translate "BridgeDB".
 }
 



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