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

[or-cvs] r14456: This includes all of the changes that Nick suggested. Furthe (check/trunk/cgi-bin)



Author: ioerror
Date: 2008-04-24 23:34:06 -0400 (Thu, 24 Apr 2008)
New Revision: 14456

Added:
   check/trunk/cgi-bin/TorCheck.pot
Modified:
   check/trunk/cgi-bin/index.py
Log:
This includes all of the changes that Nick suggested. Furthermore, while it still includes debug information, it now properly sets up the i18n stuff. This checkin also includes a template for translation.


Added: check/trunk/cgi-bin/TorCheck.pot
===================================================================
--- check/trunk/cgi-bin/TorCheck.pot	                        (rev 0)
+++ check/trunk/cgi-bin/TorCheck.pot	2008-04-25 03:34:06 UTC (rev 14456)
@@ -0,0 +1,63 @@
+# TorCheck gettext template
+# Copyright (C) 2008 Jacob Appelbaum
+# Jacob Appelbaum <jacob@xxxxxxxxxxxxx>, 2008
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: TorCheck untagged beta\n"
+"POT-Creation-Date: 2008-04-24 20:28+PDT\n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: Jacob Appelbaum <jacob@xxxxxxxxxxxxx>\n"
+"Language-Team: Tor Translation <tor-translation@xxxxxxxxxxxxxx>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=CHARSET\n"
+"Content-Transfer-Encoding: ENCODING\n"
+"Generated-By: pygettext.py 1.5\n"
+
+
+#: index.py:145
+msgid "Congratulations. You are using Tor.<br><br>"
+msgstr ""
+
+#: index.py:149
+msgid ""
+"Please refer to the <a href=\"https://www.torproject.org/\";>Tor website</a> for further information about using Tor safely.<br><br>\n"
+msgstr ""
+
+#: index.py:157
+msgid ""
+"Sorry. You are not using Tor.\n"
+"<br><br>"
+msgstr ""
+
+#: index.py:160
+msgid "If you are attempting to use a Tor client, please refer to the <a href=\"https://www.torproject.org/\";>Tor website</a> and specifically the <a href=\"https://wiki.torproject.org/noreply/TheOnionRouter/TorFAQ#ItDoesntWork\";>instructions for configuring your Tor client</a>.<br><br>"
+msgstr ""
+
+#: index.py:176
+msgid ""
+"Sorry, your query failed or an unexpected response was received.\n"
+"<br>"
+msgstr ""
+
+#: index.py:178
+msgid "A temporary service outage prevents us from determining if your source IP address is a <a href=\"https://www.torproject.org/\";>Tor</a> node.  For other ways to test whether you are using Tor, please visit <a href=\"https://wiki.torproject.org/noreply/TheOnionRouter/TorFAQ#IsMyConnectionPrivate\";>this FAQ entry</a>.<br><br>"
+msgstr ""
+
+#: index.py:185
+msgid ""
+"Additional information:<br>\n"
+msgstr ""
+
+#: index.py:187
+msgid "Your IP appears to be: "
+msgstr ""
+
+#: index.py:190
+msgid "This small script is powered by <a href=\"http://exitlist.torproject.org/\";>tordnsel</a><br><br>"
+msgstr ""
+
+#: index.py:192
+msgid "This server does not log <i>any</i> information about visitors.<br>"
+msgstr ""
+

Modified: check/trunk/cgi-bin/index.py
===================================================================
--- check/trunk/cgi-bin/index.py	2008-04-24 21:29:47 UTC (rev 14455)
+++ check/trunk/cgi-bin/index.py	2008-04-25 03:34:06 UTC (rev 14456)
@@ -16,20 +16,14 @@
 
 # Unused for now
 # import antigravity
+import DNS 
 # This is pydns and can be downloaded from http://pydns.sourceforge.net/ 
 # Or use the Debian package listed above
-import DNS 
 from mod_python import apache
 from mod_python import util
 import cgitb; cgitb.enable()
 import gettext
 
-# i18n with Unicode!
-# We need to make some TorCheck.{po,pot,mo} files
-gettext.install('TorCheck','.', unicode=1)
-gettext.bind_textdomain_codeset('TorCheck', 'en_US')
-_ = gettext.gettext
-
 # We could also explictly query the remote EL server
 # This is not as good as using a cache for obvious reasons
 DNS.DiscoverNameServers()
@@ -56,46 +50,23 @@
     # Ask the question and load the data into our answer
     answer=request.req()
 
-    # TODO: Don't make this a single point of return
-
     # Parse the answer and decide if it's allowing exits
     # 127.0.0.2 is an exit and NXDOMAIN is not
     if answer.header['status'] == "NXDOMAIN":
-	UsingTor=1
+        # We're not exiting from a Tor exit
+        return 1
     else:
-	if answer.answers:
-	   for i in answer.answers:
-	       if i['data'] == "127.0.0.2":
-		   UsingTor=0
-	       else:
-		   # We're getting unexpected data - fail closed
-	           UsingTor=2
-	else:
-		# We're getting unexpected data - fail closed
-	        UsingTor=2
+	if not answer.answers:
+	    # We're getting unexpected data - fail closed
+	    return 2
+	for a in answer.answers:
+	    if a['data'] != "127.0.0.2":
+	        return 2
+	# If we're here, we've had a positive exit answer
+	return 0
 
-    return UsingTor
+def parseLang(req):
 
-# Now that we know everything we need, lets print the website
-def handler(req):
-
-    # Make a DNS request to the EL and decide what to tell the user
-    UsingTor = isUsingTor(req.connection.remote_ip)
-
-    # This is where we need to parse out lang:
-    # req.subprocess_env['QUERY_STRING'] = fa-IR
-    # Then, depending on what we have, we should compare it to a tuple
-
-    req.send_http_header()
-    req.content_type = 'text/html ;charset=utf-8'
-
-    # First lets construct the simple webpage:
-    req.write('<html>\n')
-    req.write('<body>\n')
-
-    req.write('Debug info: <br>')
-    req.write('UsingTor is set to: %s<br>' % UsingTor )
-
     queryString = req.subprocess_env['QUERY_STRING']
     user_supplied_lang = None
 
@@ -138,6 +109,30 @@
     if locale != user_supplied_lang: 
         req.write("We have selected the locale of: %s \n<br>\n" % locale)
 
+    # i18n with Unicode!
+    # We need to make some TorCheck.{po,pot,mo} files
+    gettext.install('TorCheck','.', unicode=1)
+    gettext.bind_textdomain_codeset('TorCheck', locale)
+    _ = gettext.gettext
+
+# Now that we know everything we need, lets print the website
+def handler(req):
+
+    # Make a DNS request to the EL and decide what to tell the user
+    UsingTor = isUsingTor(req.connection.remote_ip)
+
+    req.send_http_header()
+    req.content_type = 'text/html ;charset=utf-8'
+
+    # First lets construct the simple webpage:
+    req.write('<html>\n')
+    req.write('<body>\n')
+
+    req.write('Debug info: <br>')
+    req.write('UsingTor is set to: %s<br>' % UsingTor )
+
+    parseLang(req)
+
     req.write("\n<br><br>\n")
 
     req.write('<title>Are you using Tor?</title>\n')
@@ -148,29 +143,29 @@
 	req.write('<img src="https://check.torproject.org/tor-on.png";>\n<br>')
 	req.write('<h1 style="color: #0A0">\n')
 	req.write(_('Congratulations. You are using Tor.<br><br>'))
-	req.write('ﻡژﺪﻫ. ﺶﻣﺍ (ﺎﺤﺘﻣﺍﻻ) ﺩﺭ ﺡﺎﻟ ﺎﺴﺘﻓﺍﺪﻫ ﺍﺯ ﺕُﺭ ﻡی ﺏﺎﺷیﺩ.')
+	#req.write('ﻡژﺪﻫ. ﺶﻣﺍ (ﺎﺤﺘﻣﺍﻻ) ﺩﺭ ﺡﺎﻟ ﺎﺴﺘﻓﺍﺪﻫ ﺍﺯ ﺕُﺭ ﻡی ﺏﺎﺷیﺩ.')
 	req.write('<br>\n<br>\n')
 	req.write('</h1>\n')
-	req.write('Please refer to the <a href="https://www.torproject.org/";>Tor website</a> for further information about using Tor safely.<br><br>\n')
-	req.write('ﺥﻭﺎﻬﺸﻤﻧﺩ ﺎﺴﺗ ﻡﺭﺎﺠﻌﻫ کﻥیﺩ ﺐﻫ <a href="https://www.torproject.org/";>ﻮﺑ ﺱﺍیﺕ ﺕُﺭ</a>  ﺏﺭی ﺎﻃﻼﻋﺎﺗ ﺏیﺶﺗﺭ ﺩﺮﻣﻭﺭﺩ ﺎﺴﺘﻓﺪﻫ ﺍیﻢﻧ ﺍﺯ ﺕُﺭ<br><bbr>')
+	req.write(_('Please refer to the <a href="https://www.torproject.org/";>Tor website</a> for further information about using Tor safely.<br><br>\n'))
+	#req.write('ﺥﻭﺎﻬﺸﻤﻧﺩ ﺎﺴﺗ ﻡﺭﺎﺠﻌﻫ کﻥیﺩ ﺐﻫ <a href="https://www.torproject.org/";>ﻮﺑ ﺱﺍیﺕ ﺕُﺭ</a>  ﺏﺭی ﺎﻃﻼﻋﺎﺗ ﺏیﺶﺗﺭ ﺩﺮﻣﻭﺭﺩ ﺎﺴﺘﻓﺪﻫ ﺍیﻢﻧ ﺍﺯ ﺕُﺭ<br><bbr>')
     
     # This is the case where we have an NXDOMAIN and they aren't using Tor
     elif UsingTor == 1:
         req.write('\n')
         req.write('<img src="https://check.torproject.org/tor-off.png";>\n<br>')
         req.write('<h1 style="color: #A00">')
-        req.write('Sorry. You are not using Tor.\n<br><br>')
-        req.write('پﻭﺰﺷ. ﺶﻣﺍ (ﺎﺤﺘﻣﺍﻻ) ﺩﺭ ﺡﺎﻟ ﺎﺴﺘﻓﺍﺪﻫ ﺍﺯ ﺕُﺭ ﻦﻣی ﺏﺎﺷیﺩ.\n<br><br>')
+        req.write(_('Sorry. You are not using Tor.\n<br><br>'))
+        #req.write('پﻭﺰﺷ. ﺶﻣﺍ (ﺎﺤﺘﻣﺍﻻ) ﺩﺭ ﺡﺎﻟ ﺎﺴﺘﻓﺍﺪﻫ ﺍﺯ ﺕُﺭ ﻦﻣی ﺏﺎﺷیﺩ.\n<br><br>')
         req.write('</h1>')
-        req.write('If you are attempting to use a Tor client, please refer to the <a href="https://www.torproject.org/";>Tor website</a> and specifically the <a href="https://wiki.torproject.org/noreply/TheOnionRouter/TorFAQ#ItDoesntWork";>instructions for configuring your Tor client</a>.<br><br>')
-        req.write('ﺍگﺭ ﺲﻋی ﺩﺭ ﺎﺴﺘﻓﺍﺪﻫ ﺍﺯ یک کﺍﺮﺧﻭﺎﻫ ﺕُﺭ ﺭﺍ ﺩﺍﺭیﺩ, ﺥﻭﺎﻬﺸﻤﻧﺩ ﺎﺴﺗ ﻡﺭﺎﺠﻌﻫ کﻥیﺩ ﺐﻫ ')
-        req.write('<a href="https://www.torproject.org/";>')
-	req.write('ﻮﺑ ﺱﺍیﺕ ﺕُﺭ')
-        req.write('</a> ')
-        req.write('ﻭ ﺏﻭیژﻩ ')
-        req.write('<a href="https://wiki.noreply.org/noreply/TheOnionRouter/TorFAQ#ItDoesntWork";>')
-	req.write('ﺪﺴﺗﻭﺭﺎﺗ ﺏﺭﺍی پیکﺮﺒﻧﺩی کﺍﺮﺧﻭﺎﻫ ﺕُﺭ.')
-        req.write('</a><br><br>')
+        req.write(_('If you are attempting to use a Tor client, please refer to the <a href="https://www.torproject.org/";>Tor website</a> and specifically the <a href="https://wiki.torproject.org/noreply/TheOnionRouter/TorFAQ#ItDoesntWork";>instructions for configuring your Tor client</a>.<br><br>'))
+        #req.write('ﺍگﺭ ﺲﻋی ﺩﺭ ﺎﺴﺘﻓﺍﺪﻫ ﺍﺯ یک کﺍﺮﺧﻭﺎﻫ ﺕُﺭ ﺭﺍ ﺩﺍﺭیﺩ, ﺥﻭﺎﻬﺸﻤﻧﺩ ﺎﺴﺗ ﻡﺭﺎﺠﻌﻫ کﻥیﺩ ﺐﻫ ')
+        #req.write('<a href="https://www.torproject.org/";>')
+	#req.write('ﻮﺑ ﺱﺍیﺕ ﺕُﺭ')
+        #req.write('</a> ')
+        #req.write('ﻭ ﺏﻭیژﻩ ')
+        #req.write('<a href="https://wiki.noreply.org/noreply/TheOnionRouter/TorFAQ#ItDoesntWork";>')
+	#req.write('ﺪﺴﺗﻭﺭﺎﺗ ﺏﺭﺍی پیکﺮﺒﻧﺩی کﺍﺮﺧﻭﺎﻫ ﺕُﺭ.')
+        #req.write('</a><br><br>')
 
     # This means we have some strange data response we don't understand
     # It's better that we fail closed and let the user know everything went wrong
@@ -178,31 +173,29 @@
         req.write('\n')
         req.write('<img src="https://check.torproject.org/tor-off.png";>\n<br>')
         req.write('<h1 style="color: #A00">\n')
-        req.write('Sorry, your query failed or an unexpected response was received.\n<br>')
+        req.write(_('Sorry, your query failed or an unexpected response was received.\n<br>'))
 	req.write('</h1>')
-        req.write('A temporary service outage prevents us from determining if your source IP address is a <a href="https://www.torproject.org/";>Tor</a> node.  For other ways to test whether you are using Tor, please visit <a href="https://wiki.torproject.org/noreply/TheOnionRouter/TorFAQ#IsMyConnectionPrivate";>this FAQ entry</a>.<br><br>')
+        req.write(_('A temporary service outage prevents us from determining if your source IP address is a <a href="https://www.torproject.org/";>Tor</a> node.  For other ways to test whether you are using Tor, please visit <a href="https://wiki.torproject.org/noreply/TheOnionRouter/TorFAQ#IsMyConnectionPrivate";>this FAQ entry</a>.<br><br>'))
 
-
     # Now we'll close up this html rat hole
     req.write('\n')
     req.write('<br>\n');
     req.write('<small>\n')
     req.write('<p><tt>')
-    req.write('Additional information:<br>\n')
-    req.write('ﺎﻃﻼﻋﺎﺗ ﺕکﻡیﻝی:<br>\n')
-    req.write('Your IP appears to be: <b>%s</b><br>\n' % req.connection.remote_ip )
-    req.write('ﺁﺩﺮﺳ ﺁی پی ﺶﻣﺍ: <b>%s</b><br>\n' % req.connection.remote_ip )
-    req.write('This small script is powered by <a href="http://exitlist.torproject.org/";>tordnsel</a><br><br>')
-    req.write('ﺍیﻥ ﺪﺴﺗ<200c>ﻧﻮﺸﺘﻫ کﻭچک ﺍﺭﺎﺌﻫ ﻡی ﺵﻭﺩ ﺏﻮﺳیﻞﻫ <a href="http://exitlist.torproject.org/";>tordnsel</a><br><br>')
-    req.write('This server does not log <i>any</i> information about visitors.<br>')
-    req.write('ﺍیﻥ پیﺵکﺍﺭ ﻩیچ ﺎﻃﻼﻋﺎﺗی ﺩﺮﻣﻭﺭﺩ کﺍﺮﺑﺭﺎﻧ ﻢﻬﻣﺎﻧ ﺭﺍ ﺚﺒﺗ ﻦﻣی کﻥﺩ.<br>')
+    req.write(_('Additional information:<br>\n'))
+    #req.write('ﺎﻃﻼﻋﺎﺗ ﺕکﻡیﻝی:<br>\n')
+    req.write(_('Your IP appears to be: '))
+    req.write('<b>%s</b><br>\n' % req.connection.remote_ip )
+    #req.write('ﺁﺩﺮﺳ ﺁی پی ﺶﻣﺍ: <b>%s</b><br>\n' % req.connection.remote_ip )
+    req.write(_('This small script is powered by <a href="http://exitlist.torproject.org/";>tordnsel</a><br><br>'))
+    #req.write('ﺍیﻥ ﺪﺴﺗ<200c>ﻧﻮﺸﺘﻫ کﻭچک ﺍﺭﺎﺌﻫ ﻡی ﺵﻭﺩ ﺏﻮﺳیﻞﻫ <a href="http://exitlist.torproject.org/";>tordnsel</a><br><br>')
+    req.write(_('This server does not log <i>any</i> information about visitors.<br>'))
+    #req.write('ﺍیﻥ پیﺵکﺍﺭ ﻩیچ ﺎﻃﻼﻋﺎﺗی ﺩﺮﻣﻭﺭﺩ کﺍﺮﺑﺭﺎﻧ ﻢﻬﻣﺎﻧ ﺭﺍ ﺚﺒﺗ ﻦﻣی کﻥﺩ.<br>')
     req.write('\n<br>\n')
-    req.write('It appears that you\'re trying to instruct us to use the following l10n:' + req.subprocess_env['QUERY_STRING'])
     req.write('</tt></p>')
     req.write('</small>')
     req.write('</center>\n')
     req.write('</body>')
     req.write('</html>')
 
-    # We'll i18n the output to make this cleaner
     return apache.OK