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

[tor-commits] [obfsproxy/master] Use more readable error messages.



commit b498fe6feffda4a4d73112a099ecc9cdc134ffb6
Author: Philipp Winter <phw@xxxxxxxxxxxxxx>
Date:   Sun Mar 9 00:45:27 2014 +0100

    Use more readable error messages.
    
    To a user, it's not immediately clear that a given password was not well
    formed.  The refactored error messages should fix that.  See bug
    <https://bugs.torproject.org/11143> for context.
---
 obfsproxy/transports/scramblesuit/scramblesuit.py |   28 +++++++++++++++------
 1 file changed, 21 insertions(+), 7 deletions(-)

diff --git a/obfsproxy/transports/scramblesuit/scramblesuit.py b/obfsproxy/transports/scramblesuit/scramblesuit.py
index 87a7370..8e04cc5 100644
--- a/obfsproxy/transports/scramblesuit/scramblesuit.py
+++ b/obfsproxy/transports/scramblesuit/scramblesuit.py
@@ -117,8 +117,16 @@ class ScrambleSuitTransport( base.BaseTransport ):
         if cls.weAreServer and not cls.weAreExternal:
             cfg  = transportConfig.getServerTransportOptions()
             if cfg and "password" in cfg:
-                cls.uniformDHSecret = base64.b32decode(util.sanitiseBase32(
-                        cfg["password"]))
+                try:
+                    cls.uniformDHSecret = base64.b32decode(util.sanitiseBase32(
+                            cfg["password"]))
+                except TypeError as error:
+                    log.error(error.message)
+                    raise base.PluggableTransportError("Given password '%s' " \
+                            "is not valid Base32!  Run " \
+                            "'generate_password.py' to generate a good " \
+                            "password." % cfg["password"])
+
                 cls.uniformDHSecret = cls.uniformDHSecret.strip()
 
     @classmethod
@@ -562,9 +570,9 @@ class ScrambleSuitTransport( base.BaseTransport ):
                                      args.uniformDHSecret))
         except (TypeError, AttributeError) as error:
             log.error(error.message)
-            raise base.PluggableTransportError(
-                "UniformDH password '%s' isn't valid base32!"
-                % args.uniformDHSecret)
+            raise base.PluggableTransportError("Given password '%s' is not " \
+                    "valid Base32!  Run 'generate_password.py' to generate " \
+                    "a good password." % args.uniformDHSecret)
 
         parentalApproval = super(
             ScrambleSuitTransport, cls).validate_external_mode_cli(args)
@@ -611,8 +619,14 @@ class ScrambleSuitTransport( base.BaseTransport ):
             log.warning("A UniformDH password was already specified over "
                         "the command line.  Using the SOCKS secret instead.")
 
-        self.uniformDHSecret = base64.b32decode(util.sanitiseBase32(
-                                      args[0].split('=')[1].strip()))
+        try:
+            self.uniformDHSecret = base64.b32decode(util.sanitiseBase32(
+                                          args[0].split('=')[1].strip()))
+        except TypeError as error:
+            log.error(error.message)
+            raise base.PluggableTransportError("Given password '%s' is not " \
+                    "valid Base32!  Run 'generate_password.py' to generate " \
+                    "a good password." % args[0].split('=')[1].strip())
 
         rawLength = len(self.uniformDHSecret)
         if rawLength != const.SHARED_SECRET_LENGTH:



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