Opened 6 years ago

Closed 3 years ago

#11770 closed defect (wontfix)

Print a warning if python-gmpy is not found

Reported by: asn Owned by: asn
Priority: Medium Milestone:
Component: Archived/Obfsproxy Version:
Severity: Normal Keywords:
Cc: Actual Points:
Parent ID: Points:
Reviewer: Sponsor:


I just noticed that my bridge didn't have python-gmpy installed, and that was one of the reasons obfsproxy was taking more CPU than needed.

We should add a warning message to ask people to install python-gmpy if it was not found installed. obfsproxy/common/ is where it's at.

Child Tickets

Change History (2)

comment:1 Changed 6 years ago by asn

diff --git a/obfsproxy/common/ b/obfsproxy/common/
index 3f90ea8..b6a9784 100644
--- a/obfsproxy/common/
+++ b/obfsproxy/common/
@@ -1,9 +1,19 @@
+# Try to use gmpy to do modular exponentiations. It's faster and better.
+# If gmpy cannot be found, fall back to the default Python pow() function.
     from gmpy2 import mpz as mpz
 except ImportError:
         from gmpy import mpz as mpz
     except ImportError:
+        # Log a warning so that the bridge operator installs gmpy.
+        import obfsproxy.common.log as logging
+        log = logging.get_obfslogger()
+        log.warning("python-gmpy could not be found. Please consider installing it. " \
+                    "Till then I will use Python's default modular exponentiation " \
+                    "function which is slower and heavier.")
         def mpz( x ):
             return x

FWIW, I tried the obvious patch above, but I think that the log file has not been set as of that point, and the warning actually goes to stdout. We should make sure that the warning goes to the log file.

comment:2 Changed 3 years ago by dcf

Resolution: wontfix
Severity: Normal
Status: newclosed

Closing because Python-based obfsproxy is not current anymore.

Note: See TracTickets for help on using tickets.