commit d412a5fedfdf2e227ac88311e7dfa3691c0fd5ae Author: Christian Fromme kaner@strace.org Date: Tue Feb 22 16:02:01 2011 +0100
Clean up the whole i18n infrastructure. More clean & straightforward now. --- README | 90 ++++--- lib/gettor/constants.py | 703 ----------------------------------------------- lib/gettor/i18n.py | 546 ++++++++++++++++++++++++++++++++++++ lib/gettor/requests.py | 4 +- lib/gettor/responses.py | 117 +++++++-- 5 files changed, 689 insertions(+), 771 deletions(-)
diff --git a/README b/README index 0f335c7..1988a61 100644 --- a/README +++ b/README @@ -68,7 +68,7 @@ Finally, you need to setup email forwarding to the GetTor bot like so:
gettor@hostname:~$ echo "|python /home/g/opt/gettor/GetTor.py" > ~/.forward
-Now GetTor.py is installed, prepared and ready to serve files. Send it email! +Now GetTor is installed, prepared and ready to serve files. Send it email!
TRANSLATION FILES ----------------- @@ -95,20 +95,20 @@ and should look similar to this: MAIL_FROM = "GetTor gettor@torproject.org"
# Where it is all based at. Subdirs for GetTor start from here. - BASEDIR = "/tmp" + BASEDIR = "/home/gettor/gettor"
# Should we send a `Your package will arrive soon, be patient' mail? DELAY_ALERT = True
# Basename of the GetTor log files. Will be expandet to # $LOGFILE-YYYY-MM-DD.log - LOGFILE = "/tmp/gettorlog" + LOGFILE = "gettor_log"
# The file containing the hashed command password PASSFILE = "gettor.pass"
# Where do we dump erronous emails? - DUMPFILE = "./gettor.dump" + DUMPFILE = "gettor.dump"
# Do we send every mail type to every user only once before we blacklist # them for it? @@ -138,38 +138,6 @@ and should look similar to this: ("tor-browser-.*_en-US.exe$", "tor-browser-.*_en-US_split"), }
-WHAT'S DKIM / WHY DKIM? ------------------------ - -People who send mail to gettor need to either use a mail provider that -signs outgoing mail with DKIM, or have their email address or domain -added to the whitelist. - -"DomainKeys Identified Mail", aka DKIM, is a mechanism that lets the mail -provider prove that the mail is really coming from the domain and sender -it claims to be from. - -Currently GMail and Yahoo both support DKIM, along with other more -esoteric domains like paypal, AOL, earthlink, linkedin, etc. You can -check if your mail provider uses DKIM by examining the headers of emails -you send. If there's a "DomainKey-Signature:" header, then you're in -good shape. - -If we didn't check the DKIM signature, people could abuse gettor into -mailbombing innocent email addresses -- one short email resulting in a -15MB attachment sent to an address of their choice is quite an attack -multiplier. - -There are a few other alternative options (for example, Microsoft uses its -own proprietary design called 'Sender ID'), but since GMail is already -very common for users in blocked countries, we figured DKIM was a good -starting point. - -And last, be aware that the set of domains that technically support -DKIM is probably not exactly the same set that we should recommend for -our users, due to other properties of each mail provider like their -privacy policies. - VALIDATION OF REQUESTED FILES -----------------------------
@@ -198,9 +166,10 @@ to hammer innocent inboxes with huge amounts of tor packages. First of all, there is a DKIM checker (see "WHAT'S DKIM / WHY DKIM" above) that prevents GetTor from answering useless spam emails. On top of that, there are some hard-coded checks being performed on the sender address. Only mails coming -from yahoo.com.cn, yahoo.com and gmail.com are allowed. However, DKIM checking -and hard-coded domain checks are currently disabled in GetTor. Mails from all -addresses are being passed to GetTor processing. +from yahoo.com and gmail.com are allowed. However, DKIM checking and hard-coded +domain checks are currently disabled in GetTor. Mails from all addresses are +being passed to GetTor processing. But note that besides GMail and Yahoo, only +vry few mail providers allow attachments of the size that GetTor will send out.
On top of that, there is a blacklisting mechanism. It works as follows: Each unique email address is allowed to mail GetTor the same type of mail once each @@ -220,13 +189,13 @@ directories. In reality, that looks as follows: 0154d8584c0afa6290e21098e7ab4cc635b7d50a 02a33e16feece8671f1274de62de32068a67cf20
-In addition to this automatic whitelisting, there is the possibility to add -blacklist entries by hand as follows: +In addition to this automatic blacklisting mechanism, there is the possibility +to add blacklist entries by hand as follows:
gettor@hostname:~/opt/gettor$ python GetTor.py -b someone@evil.org
Email addresses that are added this way, go to the general/ directory in the -blacklist directory. +blacklist directory and will therefore be blocked from using GetTor in any way.
Besides the blacklisting mechanism, there is a whitelisting mechanism. It works analogous to the manual blacklisting mechanism: @@ -235,3 +204,40 @@ analogous to the manual blacklisting mechanism:
Whitelisting wins over blacklisting. If a user if blacklisted for X, but also whitelisted, he will be allowed to do X. + +WHAT'S DKIM / WHY DKIM? +----------------------- + +NOTE THAT THIS SECTION IS CURRENTLY OUTDATED, BECAUSE GETTOR DOESN'T DO DKIM +CHECK ITSELF ANYMORE. IT RELIES ON THAT BEING DONE SOMEWHERE ELSE BEFORE THE +EMAIL ARRIVES AT GETTOR. + +People who send mail to gettor need to either use a mail provider that +signs outgoing mail with DKIM, or have their email address or domain +added to the whitelist. + +"DomainKeys Identified Mail", aka DKIM, is a mechanism that lets the mail +provider prove that the mail is really coming from the domain and sender +it claims to be from. + +Currently GMail and Yahoo both support DKIM, along with other more +esoteric domains like paypal, AOL, earthlink, linkedin, etc. You can +check if your mail provider uses DKIM by examining the headers of emails +you send. If there's a "DomainKey-Signature:" header, then you're in +good shape. + +If we didn't check the DKIM signature, people could abuse gettor into +mailbombing innocent email addresses -- one short email resulting in a +15MB attachment sent to an address of their choice is quite an attack +multiplier. + +There are a few other alternative options (for example, Microsoft uses its +own proprietary design called 'Sender ID'), but since GMail is already +very common for users in blocked countries, we figured DKIM was a good +starting point. + +And last, be aware that the set of domains that technically support +DKIM is probably not exactly the same set that we should recommend for +our users, due to other properties of each mail provider like their +privacy policies. + diff --git a/lib/gettor/constants.py b/lib/gettor/constants.py deleted file mode 100644 index 179137a..0000000 --- a/lib/gettor/constants.py +++ /dev/null @@ -1,703 +0,0 @@ -# Copyright (c) 2008 - 2011, Jacob Appelbaum jacob@appelbaum.net, -# Christian Fromme kaner@strace.org -# This is Free Software. See LICENSE for license information. - -# Giant multi language help message. Add more translations as they become ready -multilangpackagehelpmsg = """ - Hello, This is the "GetTor" robot. - - I will mail you a Tor package, if you tell me which one you want. - Please select one of the following package names: - - tor-browser-bundle - macosx-i386-bundle - macosx-ppc-bundle - linux-browser-bundle-i386 - linux-browser-bundle-x86_64 - source-bundle - - Please reply to this mail (to gettor), and tell me - a single package name anywhere in the body of your email. - - OBTAINING LOCALIZED VERSIONS OF TOR - =================================== - - To get a version of Tor translated into your language, specify the - language you want in the address you send the mail to: - - gettor+zh - - This example will give you the requested package in a localized - version for Chinese. Check below for a list of supported language - codes. - - List of supported locales: - ------------------------- - - Here is a list of all available languages: - - gettor+ar: Arabic - gettor+de: German - gettor+en: English - gettor+es: Spanish - gettor+fa: Farsi (Iran) - gettor+fr: French - gettor+it: Italian - gettor+nl: Dutch - gettor+pl: Polish - gettor+ru: Russian - gettor+zh: Chinese - - If you select no language, you will receive the English version. - - SUPPORT - ======= - - If you have any questions or it doesn't work, you can contact a - human at this support email address: tor-assistants - - -- - - مرحبا، أنا روبوت "احصل على تور". - - سأرسل لك حزمة برامج تور، إذا أخبرتني أيها تريد. - رجاء اختر إحدى أسماء الحزم التالية: - - tor-browser-bundle - macosx-i386-bundle - macosx-ppc-bundle - linux-browser-bundle-i386 - linux-browser-bundle-x86_64 - source-bundle - - يرجى أن ترد على هذه الرسالة (إلى gettor@torproject.org)، وتخبرني - باسم حزمة واحدة فقط في أي مكان ضمن رسالة الرد. - - الحصول على إصدارات مترجمة من تور - ======================== - - لتحصل على إصدار تور مترجم إلى لغتك، يرجى أن تحدد - اللغة التي تريد ضمن العنوان الذي سترسل الرسالة الإلكترونية إليه: - - gettor+zh@torproject.org - - هذا المثال يعطيك الحزمة المطلوبة مترجمة - للغة الصينية. تحقق من القائمة أدناه لتجد رموز اللغات - المدعومة. - - قائمة اللغات المدعومة: - ------------------- - - ها هي قائمة اللغات المتوفرة: - - gettor+ar@torproject.org: العربية - gettor+de@torproject.org: الألمانية - gettor+en@torproject.org: الإنكليزية - gettor+es@torproject.org: الإسبانية - gettor+fa@torproject.org: الفارسية - gettor+fr@torproject.org: الفرنسية - gettor+it@torproject.org: الإيطالية - gettor+nl@torproject.org: الهولندية - gettor+pl@torproject.org: البولندية - gettor+ru@torproject.org: الروسية - gettor+zh@torproject.org: الصينية - - إن لم تقم باختيار لغة فستحصل على الإصدارة الإنكليزية. - - الدعم الفني - ======= - - إن كانت لديك أية أسئلة أو إذا لم يعمل هذا الحل يمكنك الاتصال بكائن - بشري على عنوان الدعم الفني التالي: tor-assistants@torproject.org - - -- - - سلام! روبات "GetTor" در خدمت شماست. - - چنانچه به من بگویید که به کدامیک از بسته های Tor نیاز دارید، آن را برای شما - ارسال خواهم کرد. - لطفا یکی از بسته های را زیر با ذکر نام انتخاب کنید: - - tor-browser-bundle - macosx-i386-bundle - macosx-ppc-bundle - linux-browser-bundle-i386 - linux-browser-bundle-x86_64 - source-bundle - - لطفا به این نامه پاسخ داده ( به آدرس gettor@torproject.org ) و در قسمتی از - متن ایمیل خود نام یکی از بسته های فوق را ذکر کنید. - - تهیه نسخه ترجمه شده TOR - =================================== - - برای دریافت نسخه ای از TOR ترجمه شده به زبان محلی شما، می بایستی زبان مورد - نظر خود را در آدرس گیرنده ایمیل ذکر کنید. بعنوان مثال: - - gettor+zh@torproject.org - - در این مثال، فرستنده خواهان نسخه ترجمه شده به زبان چینی می باشد. برای آگاهی - از کدهای مربوط به زبانهای قابل پشتیبانی توسط Tor ، فهرست زیر را مطالعه کنید: - فهرست زبانهای پشتیانی شده - ------------------------- - - gettor+ar@torproject.org: Arabic - gettor+de@torproject.org: German - gettor+en@torproject.org: English - gettor+es@torproject.org: Spanish - gettor+fa@torproject.org: Farsi (Iran) - gettor+fr@torproject.org: French - gettor+it@torproject.org: Italian - gettor+nl@torproject.org: Dutch - gettor+pl@torproject.org: Polish - gettor+ru@torproject.org: Russian - gettor+zh@torproject.org: Chinese - - چنانچه هیچیک از زبانهای فوق را انتخاب نکنید، نسخه انگلیسی برای شما ارسال - خواهد شد. - - پشتیبانی - ======= - - چنانچه سوالی دارید یا برنامه دچار اشکال بوده و کار نمی کند ، با قسمت - پشتیبانی با آدرس زیر تماس بگیرید تا یک انسان به سوال شما پاسخ دهد: tor-assistants@torproject.org - - -- - - Hei, dette er "GetTor"-roboten - - Jeg kommer til å sende deg en Tor-pakke, hvis du forteller meg hvilken du - vil ha. - Vennligst velg en av følgende pakkenavn: - - tor-browser-bundle - macosx-i386-bundle - macosx-ppc-bundle - linux-browser-bundle-i386 - linux-browser-bundle-x86_64 - source-bundle - - Vennligst svar til denne eposten (til gettor@torproject.org), og nevn - kun et enkelt pakkenavn i tekstområdet til eposten din. - - SKAFFE LOKALISERTE VERSJONER AV TOR - =================================== - - For å skaffe en versjon av Tor som har blitt oversatt til ditt språk, - spesifiser språket du vil i epostadressen du sender eposten til: - - gettor+zh@torproject.org - - Dette eksempelet vil gi deg en forespurt pakke som er en oversatt - versjon for kinesisk. Se listen nedenfor for hvilke språk det er støtte for. - - Liste av støttede språk: - ------------------------- - - Her er en liste av språkene som er tilgjengelig: - - gettor+ar@torproject.org: Arabisk - gettor+de@torproject.org: Tysk - gettor+en@torproject.org: Engelsk - gettor+es@torproject.org: Spansk - gettor+fa@torproject.org: Farsi (Iran) - gettor+fr@torproject.org: Fransk - gettor+it@torproject.org: Italiensk - gettor+nl@torproject.org: Nederlandsk - gettor+pl@torproject.org: Polsk - gettor+ru@torproject.org: Russisk - gettor+zh@torproject.org: Kinesisk - - Hvis du ikke spesifiserer noen språk vil du motta standard Engelsk - versjon - - STØTTE - ======= - - Hvis du har noen spørsmål eller det ikke virker, kan du kontakte et - menneske på denne support-eposten: tor-assistants@torproject.org - - -- - - Olá! Este é o robot "GetTor". - - Eu envio-lhe um pacote Tor, bastando para isso dizer qual o que quer. - Escolha um dos seguintes pacotes: - - tor-browser-bundle - macosx-i386-bundle - macosx-ppc-bundle - linux-browser-bundle-i386 - linux-browser-bundle-x86_64 - source-bundle - - Por favor responda a esta email (para gettor@torproject.org), e diga qual o - pacote que deseja, colocando o seu nome no corpo do seu email. - - OBTER VERSÕES TRADUZIDAS DO TOR - =================================== - - Para lhe ser enviado uma versão traduzida do Tor, especifique a língua no - destinatário do seu email: - - gettor+zh@torproject.org - - Este exemplo vai enviar o pacote traduzido para Chinês Simplificado. Veja a - lista de endereços de email existentes que pode utilizar: - - Lista de endereços de email suportados: - ------------------------- - - gettor+pt@torproject.org: Português - gettor+ar@torproject.org: Arábico - gettor+de@torproject.org: Alemão - gettor+en@torproject.org: Inglês - gettor+es@torproject.org: Espanhol - gettor+fa@torproject.org: Farsi (Irão) - gettor+fr@torproject.org: Francês - gettor+it@torproject.org: Italiano - gettor+nl@torproject.org: Holandês - gettor+pl@torproject.org: Polaco - gettor+ru@torproject.org: Russo - gettor+zh@torproject.org: Chinês - - Se não escolher nenhuma língua, receberá o Tor em Inglês. - - SUPORTE - ======= - - Se tiver alguma dúvida, pode contactar um humano através do seguinte - endereço: tor-assistants@torproject.org - - -- - - Здравствуйте! Это "робот GetTor". - - Я отошлю вам пакет Tor если вы укажете который вы хотите. - Пожалуйста выберите один из пакетов: - - tor-browser-bundle - macosx-i386-bundle - macosx-ppc-bundle - linux-browser-bundle-i386 - linux-browser-bundle-x86_64 - source-bundle - - Пожалуйста свяжитесь с нами по этой элктронной почте - (gettor@torproject.org), и укажите - название одного из пакетов в любом месте в "теле" вашего письма. - - ПОЛУЧЕНИЕ ЛОКАЛИЗИРОВАННЫХ ВЕРСИЙ TOR - =================================== - - Чтобы получить версию Tor переведенную на ваш язык,укажите - предпочитаемый язык в адресной строке куда вы отослали электронную почту: - - gettor+zh@torproject.org - - Вышеуказанный пример даст вам запрошенный пакет в локализированной - версии китайского языка. Проверьте ниже список кодов поддерживаемых - языков. - - Список поддерживаемых регионов - ------------------------- - - Ниже указан список всех доступных языков: - - gettor+ar@torproject.org: арабский - gettor+de@torproject.org: немецкий - gettor+en@torproject.org: английский - gettor+es@torproject.org: испанский - gettor+fa@torproject.org: фарси (Иран) - gettor+fr@torproject.org: французский - gettor+it@torproject.org: итальянский - gettor+nl@torproject.org: голландский - gettor+pl@torproject.org: польский - gettor+ru@torproject.org: русский - gettor+zh@torproject.org: китайский - - Если вы не выберите язык, вы получите версию на английском языке. - - ПОДДЕРЖКА - ======= - - Если у вас вопросы или что то не сработало, вы можете связаться - с живым представителем по этому электронному адресу:tor-assistants@torproject.org - - -- - - 你好, 这里是"GetTor"自动回复。 - - 您从这里可以得到Tor套件, 请告诉我您需要的套件种类. - 请选择套件名称: - - tor-browser-bundle - (Tor+Firefox浏览器) - macosx-i386-bundle - (Tor for MacOS) - macosx-ppc-bundle - (Tor for MacOS on PowerPC ) - linux-browser-bundle-i386 - linux-browser-bundle-x86_64 - (Tor for Linux) - source-bundle - (源码包) - - 请直接回复本邮件(gettor@torproject.org), - 并在信的正文中写好您所需要的套件名称(不包括括号内的中文)。 - - 获取其他语言的Tor套件 - =================================== - - 在收件人地址中指定语言代码可以获得本对应语言的版本,例如: - - gettor+zh@torproject.org - - 本例中,您将得到中文版的Tor套件,下面是目前支持的语种代码: - - 支持语言列表: - ------------------------- - - 全部可用语言列表: - - gettor+ar@torproject.org: Arabic - gettor+de@torproject.org: German - gettor+en@torproject.org: English - gettor+es@torproject.org: Spanish - gettor+fa@torproject.org: Farsi (Iran) - gettor+fr@torproject.org: French - gettor+it@torproject.org: Italian - gettor+nl@torproject.org: Dutch - gettor+pl@torproject.org: Polish - gettor+ru@torproject.org: Russian - gettor+zh@torproject.org: 中文 - - 如果您未指定语言代码,您将收到英文版。 - - 支持 - ======= - - 如果您遇到困难或服务出现问题,请联系我们的 - 技术支持邮箱: tor-assistants@torproject.org - - -- - """ - -# Short string to build mails follow -hello_gettor = _(""" - Hello, This is the "GetTor" robot. - - Thank you for your request. - - """) -help_dkim_1 = _(""" - Unfortunately, we won't answer you at this address. You should make - an account with GMAIL.COM or YAHOO.CN and send the mail from - one of those. - - """) -help_dkim_2 = _(""" - We only process requests from email services that support "DKIM", - which is an email feature that lets us verify that the address in the - "From" line is actually the one who sent the mail. - - """) -help_dkim_3 = _(""" - (We apologize if you didn't ask for this mail. Since your email is from - a service that doesn't use DKIM, we're sending a short explanation, - and then we'll ignore this email address for the next day or so.) - - """) -help_dkim_4 = _(""" - Please note that currently, we can't process HTML emails or base 64 - mails. You will need to send plain text. - - """) - -help_dkim_5 = _(""" - If you have any questions or it doesn't work, you can contact a - human at this support email address: tor-assistants@torproject.org - - """) -choose_package_1 = _(""" - I will mail you a Tor package, if you tell me which one you want. - Please select one of the following package names: - - """) -avail_packs = """ - tor-browser-bundle - macosx-i386-bundle - macosx-ppc-bundle - linux-browser-bundle-i386 - linux-browser-bundle-x86_64 - source-bundle - - """ -choose_package_2 = _(""" - Please reply to this mail (to gettor@torproject.org), and tell me - a single package name anywhere in the body of your email. - - """) -obtain_localized_head = _(""" - OBTAINING LOCALIZED VERSIONS OF TOR - """) -obtain_localized_underline = """ - =================================== - - """ -obtain_localized_1 = _(""" - To get a version of Tor translated into your language, specify the - language you want in the address you send the mail to: - - """) -obtain_localized_2 = """ - gettor+zh@torproject.org - - """ -obtain_localized_3 = _(""" - This example will give you the requested package in a localized - version for Chinese. Check below for a list of supported language - codes. - - """) -list_of_langs_head = _(""" - List of supported locales: - """) -list_of_langs_underline = """ - ------------------------- - - """ -list_of_langs_1 = _(""" - Here is a list of all available languages: - - """) -list_of_langs_2 = _(""" - gettor+ar@torproject.org: Arabic - gettor+de@torproject.org: German - gettor+en@torproject.org: English - gettor+es@torproject.org: Spanish - gettor+fa@torproject.org: Farsi (Iran) - gettor+fr@torproject.org: French - gettor+it@torproject.org: Italian - gettor+nl@torproject.org: Dutch - gettor+pl@torproject.org: Polish - gettor+ru@torproject.org: Russian - gettor+zh@torproject.org: Chinese - - """) -list_of_langs_3 = _(""" - If you select no language, you will receive the English version. - - """) - -split_help_head = _(""" - SMALLER SIZED PACKAGES - """) -split_help_underline = """ - ====================== - """ -split_help_1 = _(""" - If your bandwith is low or your provider doesn't allow you to - receive large attachments in your email, there is a feature of - GetTor you can use to make it send you a number of small packages - instead of one big one. - - """) -split_help_2 = _(""" - Simply include the keyword 'split' somewhere in your email like so: - """) -split_help_3 = """ - - tor-browser-bundle - split - - """ -split_help_4 = _(""" - Sending this text in an email to GetTor will cause it to send you - the Tor Browser Bundle in a number of 1,4MB attachments. - - """) -split_help_5 = _(""" - After having received all parts, you need to re-assemble them to - one package again. This is done as follows: - - """) -split_help_6 = _(""" - 1.) Save all received attachments into one folder on your disk. - - """) -split_help_7 = _(""" - 2.) Unzip all files ending in ".z". If you saved all attachments to - a fresh folder before, simply unzip all files in that folder. - - """) -split_help_8 = _(""" - 3.) Rename the file ending in ".ex_RENAME" to end in ".exe" and - also rename the file ending in ".ex_RENAME.asc" to end in - ".exe.asc" - - """) -split_help_9 = _(""" - 4.) Verify all files as described in the mail you received with - each package. (gpg --verify) - - """) -split_help_10 = _(""" - 5.) Now use a program that can unrar multivolume RAR archives. On - Windows, this usually is WinRAR. If you don't have that - installed on you computer yet, get it here: - - """) -split_help_11 = """ - http://www.win-rar.com/download.html - - """ -split_help_12 = _(""" - To unpack your Tor package, simply doubleclick the ".exe" file. - - """) -split_help_13 = _(""" - 6.) After unpacking is finished, you should find a newly created - ".exe" file in your destination folder. Simply doubleclick - that and Tor Browser Bundle should start within a few seconds. - - """) -split_help_14 = _(""" - 7.) That's it. You're done. Thanks for using Tor and have fun! - - """) -support = _(""" - SUPPORT - """) -support_underline = """ - ======= - """ -support_email = _(""" - If you have any questions or it doesn't work, you can contact a - human at this support email address: tor-assistants@torproject.org - - """) -package_mail_1 = _(""" - Here's your requested software as a zip file. Please unzip the - package and verify the signature. - - """) -package_mail_2 = _(""" - Hint: If your computer has GnuPG installed, use the gpg - commandline tool as follows after unpacking the zip file: - - """) -package_mail_3 = _(""" - gpg --verify <packagename>.asc <packagename> - - """) -package_mail_4 = _(""" - The output should look somewhat like this: - - """) -package_mail_5 = """ - gpg: Good signature from "Roger Dingledine arma@mit.edu" - - """ -package_mail_6 = _(""" - If you're not familiar with commandline tools, try looking for - a graphical user interface for GnuPG on this website: - - """) -package_mail_7 = """ - http://www.gnupg.org/related_software/frontends.html - - """ -package_mail_8 = _(""" - If your Internet connection blocks access to the Tor network, you - may need a bridge relay. Bridge relays (or "bridges" for short) - are Tor relays that aren't listed in the main directory. Since there - is no complete public list of them, even if your ISP is filtering - connections to all the known Tor relays, they probably won't be able - to block all the bridges. - - """) -package_mail_9 = _(""" - You can acquire a bridge by sending an email that contains "get bridges" - in the body of the email to the following email address: - bridges@torproject.org - - """) -package_mail_10 = _(""" - It is also possible to fetch bridges with a web browser at the following - url: https://bridges.torproject.org/ - - """) -split_package_1 = _(""" - IMPORTANT NOTE: - Since this is part of a split-file request, you need to wait for - all split files to be received by you before you can save them all - into the same directory and unpack them by double-clicking the - first file. - - """) -split_package_2 = _(""" - Packages might come out of order! Please make sure you received - all packages before you attempt to unpack them! - - """) -delay_alert_1 = _(""" - Thank you for your request. It was successfully understood. Your request is - currently being processed. Your package should arrive within the next ten - minutes. - - """) -delay_alert_2 = _(""" - If it doesn't arrive, the package might be too big for your mail provider. - Try resending the mail from a gmail.com or yahoo.cn account. Also, - try asking for tor-browser-bundle rather than tor-im-browser-bundle, - since it's smaller. - - """) -error_mail = _(""" - Unfortunately we are currently experiencing problems and we can't fulfill - your request right now. Please be patient as we try to resolve this issue. - - """) - -# Build the actual mail texts -packagehelpmsg = hello_gettor + choose_package_1 + avail_packs + choose_package_2 + \ - obtain_localized_head + obtain_localized_underline + \ - obtain_localized_1 + obtain_localized_2 + obtain_localized_3 + \ - list_of_langs_head + list_of_langs_underline + \ - list_of_langs_1 + list_of_langs_2 + list_of_langs_3 + \ - split_help_head + split_help_underline + \ - split_help_1 + split_help_2 + split_help_3 + split_help_4 + \ - split_help_5 + split_help_6 + split_help_7 + split_help_8 + \ - split_help_9 + split_help_10 + split_help_11 + split_help_12 + \ - split_help_13 + split_help_14 + \ - support + support_underline + support_email - -helpmsg = hello_gettor + \ - help_dkim_1 + help_dkim_2 + help_dkim_3 + help_dkim_4 + help_dkim_5 + \ - support_email - - -packagemsg = hello_gettor + \ - package_mail_1 + package_mail_2 + package_mail_3 + package_mail_4 + \ - package_mail_5 + package_mail_6 + package_mail_7 + package_mail_8 + \ - package_mail_9 + package_mail_10 + \ - support_email - - -splitpackagemsg = hello_gettor + \ - split_package_1 + split_package_2 + \ - package_mail_1 + package_mail_2 + package_mail_3 + package_mail_4 + \ - package_mail_5 + package_mail_6 + package_mail_7 + package_mail_8 + \ - package_mail_9 + package_mail_10 + \ - support_email - - -delayalertmsg = hello_gettor + \ - delay_alert_1 + delay_alert_2 + \ - support_email - -mailfailmsg = hello_gettor + \ - support_email - - diff --git a/lib/gettor/i18n.py b/lib/gettor/i18n.py new file mode 100644 index 0000000..92a2165 --- /dev/null +++ b/lib/gettor/i18n.py @@ -0,0 +1,546 @@ +# Copyright (c) 2008 - 2011, Jacob Appelbaum jacob@appelbaum.net, +# Christian Fromme kaner@strace.org +# This is Free Software. See LICENSE for license information. + +import os +import gettext + +def getLang(lang, localedir=os.path.expanduser("~") + "/gettor/i18n"): + """Return the Translation instance for a given language. If no Translation + instance is found, return the one for 'en' + """ + return gettext.translation("gettor", localedir=localedir, + languages=[lang], fallback="en") + +def _(text): + """This is necessary because strings are translated when they're imported. + Otherwise this would make it impossible to switch languages more than + once + """ + return text + +# Giant multi language help message. Add more translations as they become ready +MULTILANGHELP = """ + Hello, This is the "GetTor" robot. + + I will mail you a Tor package, if you tell me which one you want. + Please select one of the following package names: + + tor-browser-bundle + macosx-i386-bundle + macosx-ppc-bundle + linux-browser-bundle-i386 + linux-browser-bundle-x86_64 + source-bundle + + Please reply to this mail (to gettor), and tell me + a single package name anywhere in the body of your email. + + OBTAINING LOCALIZED VERSIONS OF TOR + =================================== + + To get a version of Tor translated into your language, specify the + language you want in the address you send the mail to: + + gettor+zh + + This example will give you the requested package in a localized + version for Chinese. Check below for a list of supported language + codes. + + List of supported locales: + ------------------------- + + Here is a list of all available languages: + + gettor+ar: Arabic + gettor+de: German + gettor+en: English + gettor+es: Spanish + gettor+fa: Farsi (Iran) + gettor+fr: French + gettor+it: Italian + gettor+nl: Dutch + gettor+pl: Polish + gettor+ru: Russian + gettor+zh: Chinese + + If you select no language, you will receive the English version. + + SUPPORT + ======= + + If you have any questions or it doesn't work, you can contact a + human at this support email address: tor-assistants + + -- + + مرحبا، أنا روبوت "احصل على تور". + + سأرسل لك حزمة برامج تور، إذا أخبرتني أيها تريد. + رجاء اختر إحدى أسماء الحزم التالية: + + tor-browser-bundle + macosx-i386-bundle + macosx-ppc-bundle + linux-browser-bundle-i386 + linux-browser-bundle-x86_64 + source-bundle + + يرجى أن ترد على هذه الرسالة (إلى gettor@torproject.org)، وتخبرني + باسم حزمة واحدة فقط في أي مكان ضمن رسالة الرد. + + الحصول على إصدارات مترجمة من تور + ======================== + + لتحصل على إصدار تور مترجم إلى لغتك، يرجى أن تحدد + اللغة التي تريد ضمن العنوان الذي سترسل الرسالة الإلكترونية إليه: + + gettor+zh@torproject.org + + هذا المثال يعطيك الحزمة المطلوبة مترجمة + للغة الصينية. تحقق من القائمة أدناه لتجد رموز اللغات + المدعومة. + + قائمة اللغات المدعومة: + ------------------- + + ها هي قائمة اللغات المتوفرة: + + gettor+ar@torproject.org: العربية + gettor+de@torproject.org: الألمانية + gettor+en@torproject.org: الإنكليزية + gettor+es@torproject.org: الإسبانية + gettor+fa@torproject.org: الفارسية + gettor+fr@torproject.org: الفرنسية + gettor+it@torproject.org: الإيطالية + gettor+nl@torproject.org: الهولندية + gettor+pl@torproject.org: البولندية + gettor+ru@torproject.org: الروسية + gettor+zh@torproject.org: الصينية + + إن لم تقم باختيار لغة فستحصل على الإصدارة الإنكليزية. + + الدعم الفني + ======= + + إن كانت لديك أية أسئلة أو إذا لم يعمل هذا الحل يمكنك الاتصال بكائن + بشري على عنوان الدعم الفني التالي: tor-assistants@torproject.org + + -- + + سلام! روبات "GetTor" در خدمت شماست. + + چنانچه به من بگویید که به کدامیک از بسته های Tor نیاز دارید، آن را برای شما + ارسال خواهم کرد. + لطفا یکی از بسته های را زیر با ذکر نام انتخاب کنید: + + tor-browser-bundle + macosx-i386-bundle + macosx-ppc-bundle + linux-browser-bundle-i386 + linux-browser-bundle-x86_64 + source-bundle + + لطفا به این نامه پاسخ داده ( به آدرس gettor@torproject.org ) و در قسمتی از + متن ایمیل خود نام یکی از بسته های فوق را ذکر کنید. + + تهیه نسخه ترجمه شده TOR + =================================== + + برای دریافت نسخه ای از TOR ترجمه شده به زبان محلی شما، می بایستی زبان مورد + نظر خود را در آدرس گیرنده ایمیل ذکر کنید. بعنوان مثال: + + gettor+zh@torproject.org + + در این مثال، فرستنده خواهان نسخه ترجمه شده به زبان چینی می باشد. برای آگاهی + از کدهای مربوط به زبانهای قابل پشتیبانی توسط Tor ، فهرست زیر را مطالعه کنید: + فهرست زبانهای پشتیانی شده + ------------------------- + + gettor+ar@torproject.org: Arabic + gettor+de@torproject.org: German + gettor+en@torproject.org: English + gettor+es@torproject.org: Spanish + gettor+fa@torproject.org: Farsi (Iran) + gettor+fr@torproject.org: French + gettor+it@torproject.org: Italian + gettor+nl@torproject.org: Dutch + gettor+pl@torproject.org: Polish + gettor+ru@torproject.org: Russian + gettor+zh@torproject.org: Chinese + + چنانچه هیچیک از زبانهای فوق را انتخاب نکنید، نسخه انگلیسی برای شما ارسال + خواهد شد. + + پشتیبانی + ======= + + چنانچه سوالی دارید یا برنامه دچار اشکال بوده و کار نمی کند ، با قسمت + پشتیبانی با آدرس زیر تماس بگیرید تا یک انسان به سوال شما پاسخ دهد: tor-assistants@torproject.org + + -- + + Hei, dette er "GetTor"-roboten + + Jeg kommer til å sende deg en Tor-pakke, hvis du forteller meg hvilken du + vil ha. + Vennligst velg en av følgende pakkenavn: + + tor-browser-bundle + macosx-i386-bundle + macosx-ppc-bundle + linux-browser-bundle-i386 + linux-browser-bundle-x86_64 + source-bundle + + Vennligst svar til denne eposten (til gettor@torproject.org), og nevn + kun et enkelt pakkenavn i tekstområdet til eposten din. + + SKAFFE LOKALISERTE VERSJONER AV TOR + =================================== + + For å skaffe en versjon av Tor som har blitt oversatt til ditt språk, + spesifiser språket du vil i epostadressen du sender eposten til: + + gettor+zh@torproject.org + + Dette eksempelet vil gi deg en forespurt pakke som er en oversatt + versjon for kinesisk. Se listen nedenfor for hvilke språk det er støtte for. + + Liste av støttede språk: + ------------------------- + + Her er en liste av språkene som er tilgjengelig: + + gettor+ar@torproject.org: Arabisk + gettor+de@torproject.org: Tysk + gettor+en@torproject.org: Engelsk + gettor+es@torproject.org: Spansk + gettor+fa@torproject.org: Farsi (Iran) + gettor+fr@torproject.org: Fransk + gettor+it@torproject.org: Italiensk + gettor+nl@torproject.org: Nederlandsk + gettor+pl@torproject.org: Polsk + gettor+ru@torproject.org: Russisk + gettor+zh@torproject.org: Kinesisk + + Hvis du ikke spesifiserer noen språk vil du motta standard Engelsk + versjon + + STØTTE + ======= + + Hvis du har noen spørsmål eller det ikke virker, kan du kontakte et + menneske på denne support-eposten: tor-assistants@torproject.org + + -- + + Olá! Este é o robot "GetTor". + + Eu envio-lhe um pacote Tor, bastando para isso dizer qual o que quer. + Escolha um dos seguintes pacotes: + + tor-browser-bundle + macosx-i386-bundle + macosx-ppc-bundle + linux-browser-bundle-i386 + linux-browser-bundle-x86_64 + source-bundle + + Por favor responda a esta email (para gettor@torproject.org), e diga qual o + pacote que deseja, colocando o seu nome no corpo do seu email. + + OBTER VERSÕES TRADUZIDAS DO TOR + =================================== + + Para lhe ser enviado uma versão traduzida do Tor, especifique a língua no + destinatário do seu email: + + gettor+zh@torproject.org + + Este exemplo vai enviar o pacote traduzido para Chinês Simplificado. Veja a + lista de endereços de email existentes que pode utilizar: + + Lista de endereços de email suportados: + ------------------------- + + gettor+pt@torproject.org: Português + gettor+ar@torproject.org: Arábico + gettor+de@torproject.org: Alemão + gettor+en@torproject.org: Inglês + gettor+es@torproject.org: Espanhol + gettor+fa@torproject.org: Farsi (Irão) + gettor+fr@torproject.org: Francês + gettor+it@torproject.org: Italiano + gettor+nl@torproject.org: Holandês + gettor+pl@torproject.org: Polaco + gettor+ru@torproject.org: Russo + gettor+zh@torproject.org: Chinês + + Se não escolher nenhuma língua, receberá o Tor em Inglês. + + SUPORTE + ======= + + Se tiver alguma dúvida, pode contactar um humano através do seguinte + endereço: tor-assistants@torproject.org + + -- + + Здравствуйте! Это "робот GetTor". + + Я отошлю вам пакет Tor если вы укажете который вы хотите. + Пожалуйста выберите один из пакетов: + + tor-browser-bundle + macosx-i386-bundle + macosx-ppc-bundle + linux-browser-bundle-i386 + linux-browser-bundle-x86_64 + source-bundle + + Пожалуйста свяжитесь с нами по этой элктронной почте + (gettor@torproject.org), и укажите + название одного из пакетов в любом месте в "теле" вашего письма. + + ПОЛУЧЕНИЕ ЛОКАЛИЗИРОВАННЫХ ВЕРСИЙ TOR + =================================== + + Чтобы получить версию Tor переведенную на ваш язык,укажите + предпочитаемый язык в адресной строке куда вы отослали электронную почту: + + gettor+zh@torproject.org + + Вышеуказанный пример даст вам запрошенный пакет в локализированной + версии китайского языка. Проверьте ниже список кодов поддерживаемых + языков. + + Список поддерживаемых регионов + ------------------------- + + Ниже указан список всех доступных языков: + + gettor+ar@torproject.org: арабский + gettor+de@torproject.org: немецкий + gettor+en@torproject.org: английский + gettor+es@torproject.org: испанский + gettor+fa@torproject.org: фарси (Иран) + gettor+fr@torproject.org: французский + gettor+it@torproject.org: итальянский + gettor+nl@torproject.org: голландский + gettor+pl@torproject.org: польский + gettor+ru@torproject.org: русский + gettor+zh@torproject.org: китайский + + Если вы не выберите язык, вы получите версию на английском языке. + + ПОДДЕРЖКА + ======= + + Если у вас вопросы или что то не сработало, вы можете связаться + с живым представителем по этому электронному адресу:tor-assistants@torproject.org + + -- + + 你好, 这里是"GetTor"自动回复。 + + 您从这里可以得到Tor套件, 请告诉我您需要的套件种类. + 请选择套件名称: + + tor-browser-bundle + (Tor+Firefox浏览器) + macosx-i386-bundle + (Tor for MacOS) + macosx-ppc-bundle + (Tor for MacOS on PowerPC ) + linux-browser-bundle-i386 + linux-browser-bundle-x86_64 + (Tor for Linux) + source-bundle + (源码包) + + 请直接回复本邮件(gettor@torproject.org), + 并在信的正文中写好您所需要的套件名称(不包括括号内的中文)。 + + 获取其他语言的Tor套件 + =================================== + + 在收件人地址中指定语言代码可以获得本对应语言的版本,例如: + + gettor+zh@torproject.org + + 本例中,您将得到中文版的Tor套件,下面是目前支持的语种代码: + + 支持语言列表: + ------------------------- + + 全部可用语言列表: + + gettor+ar@torproject.org: Arabic + gettor+de@torproject.org: German + gettor+en@torproject.org: English + gettor+es@torproject.org: Spanish + gettor+fa@torproject.org: Farsi (Iran) + gettor+fr@torproject.org: French + gettor+it@torproject.org: Italian + gettor+nl@torproject.org: Dutch + gettor+pl@torproject.org: Polish + gettor+ru@torproject.org: Russian + gettor+zh@torproject.org: 中文 + + 如果您未指定语言代码,您将收到英文版。 + + 支持 + ======= + + 如果您遇到困难或服务出现问题,请联系我们的 + 技术支持邮箱: tor-assistants@torproject.org + + -- + """ + +GETTOR_TEXT = [ + # GETTOR_TEXT[0] +_("""Hello, This is the "GetTor" robot. + +Thank you for your request."""), + # GETTOR_TEXT[1] +_(""" Unfortunately, we won't answer you at this address. You should make +an account with GMAIL.COM or YAHOO.CN and send the mail from +one of those."""), + # GETTOR_TEXT[2] +_("""We only process requests from email services that support "DKIM", +which is an email feature that lets us verify that the address in the +"From" line is actually the one who sent the mail."""), + # GETTOR_TEXT[3] +_("""(We apologize if you didn't ask for this mail. Since your email is from +a service that doesn't use DKIM, we're sending a short explanation, +and then we'll ignore this email address for the next day or so.)"""), + # GETTOR_TEXT[4] +_("""Please note that currently, we can't process HTML emails or base 64 +mails. You will need to send plain text."""), + # GETTOR_TEXT[5] +_("""If you have any questions or it doesn't work, you can contact a +human at this support email address: tor-assistants@torproject.org"""), + # GETTOR_TEXT[6] +_("""I will mail you a Tor package, if you tell me which one you want. +Please select one of the following package names:"""), + # GETTOR_TEXT[7] +_("""Please reply to this mail (to gettor@torproject.org), and tell me +a single package name anywhere in the body of your email."""), + # GETTOR_TEXT[8] +_(""" OBTAINING LOCALIZED VERSIONS OF TOR +==================================="""), + # GETTOR_TEXT[9] +_("""To get a version of Tor translated into your language, specify the +language you want in the address you send the mail to:"""), + # GETTOR_TEXT[10] +_("""This example will give you the requested package in a localized +version for Chinese. Check below for a list of supported language +codes. """), + # GETTOR_TEXT[11] +_(""" List of supported locales: +-------------------------"""), + # GETTOR_TEXT[12] +_("""Here is a list of all available languages:"""), + # GETTOR_TEXT[13] +_(""" gettor+ar@torproject.org: Arabic + gettor+de@torproject.org: German + gettor+en@torproject.org: English + gettor+es@torproject.org: Spanish + gettor+fa@torproject.org: Farsi (Iran) + gettor+fr@torproject.org: French + gettor+it@torproject.org: Italian + gettor+nl@torproject.org: Dutch + gettor+pl@torproject.org: Polish + gettor+ru@torproject.org: Russian + gettor+zh@torproject.org: Chinese"""), + # GETTOR_TEXT[14] +_("""If you select no language, you will receive the English version."""), + # GETTOR_TEXT[15] +_("""SMALLER SIZED PACKAGES +======================"""), + # GETTOR_TEXT[16] +_("""If your bandwith is low or your provider doesn't allow you to +receive large attachments in your email, there is a feature of +GetTor you can use to make it send you a number of small packages +instead of one big one."""), + # GETTOR_TEXT[17] +_("""Simply include the keyword 'split' somewhere in your email like so:"""), + # GETTOR_TEXT[18] +_("""Sending this text in an email to GetTor will cause it to send you +the Tor Browser Bundle in a number of 1,4MB attachments."""), + # GETTOR_TEXT[19] +_("""After having received all parts, you need to re-assemble them to +one package again. This is done as follows:"""), + # GETTOR_TEXT[20] +_("""1.) Save all received attachments into one folder on your disk."""), + # GETTOR_TEXT[21] +_("""2.) Unzip all files ending in ".z". If you saved all attachments to +a fresh folder before, simply unzip all files in that folder."""), + # GETTOR_TEXT[22] +_("""3.) Verify all files as described in the mail you received with +each package. (gpg --verify)"""), + # GETTOR_TEXT[23] +_("""4.) Now use a program that can unrar multivolume RAR archives. On +Windows, this usually is WinRAR. If you don't have that +installed on you computer yet, get it here:"""), + # GETTOR_TEXT[24] +_("""To unpack your Tor package, simply doubleclick the ".exe" file."""), + # GETTOR_TEXT[25] +_("""5.) After unpacking is finished, you should find a newly created +".exe" file in your destination folder. Simply doubleclick +that and Tor Browser Bundle should start within a few seconds."""), + # GETTOR_TEXT[26] +_("""6.) That's it. You're done. Thanks for using Tor and have fun!"""), + # GETTOR_TEXT[27] +_("""SUPPORT +======="""), + # GETTOR_TEXT[28] +_("""If you have any questions or it doesn't work, you can contact a +human at this support email address: tor-assistants@torproject.org"""), + # GETTOR_TEXT[29] +_(""" Here's your requested software as a zip file. Please unzip the +package and verify the signature."""), + # GETTOR_TEXT[30] +_("""Hint: If your computer has GnuPG installed, use the gpg +commandline tool as follows after unpacking the zip file:"""), + # GETTOR_TEXT[31] +_("""The output should look somewhat like this:"""), + # GETTOR_TEXT[32] +_("""If you're not familiar with commandline tools, try looking for +a graphical user interface for GnuPG on this website:"""), + # GETTOR_TEXT[33] +_("""If your Internet connection blocks access to the Tor network, you +may need a bridge relay. Bridge relays (or "bridges" for short) +are Tor relays that aren't listed in the main directory. Since there +is no complete public list of them, even if your ISP is filtering +connections to all the known Tor relays, they probably won't be able +to block all the bridges."""), + # GETTOR_TEXT[34] +_("""You can acquire a bridge by sending an email that contains "get bridges" +in the body of the email to the following email address:"""), + # GETTOR_TEXT[35] +_("""It is also possible to fetch bridges with a web browser at the following +url: https://bridges.torproject.org/"""), + # GETTOR_TEXT[36] +_("""IMPORTANT NOTE: +Since this is part of a split-file request, you need to wait for +all split files to be received by you before you can save them all +into the same directory and unpack them by double-clicking the +first file."""), + # GETTOR_TEXT[37] +_("""Packages mighit come out of order! Please make sure you received +all packages before you attempt to unpack them!"""), + # GETTOR_TEXT[38] +_("""Thank you for your request. +It was successfully understood. Your request is currently being processed. +Your package should arrive within the next ten minutes."""), + # GETTOR_TEXT[39] +_("""If it doesn't arrive, the package might be too big for your mail provider. +Try resending the mail from a GMAIL.COM or YAHOO.COM account."""), + # GETTOR_TEXT[40] +_("""Unfortunately we are currently experiencing problems and we can't fulfill +your request right now. Please be patient as we try to resolve this issue.""") +] diff --git a/lib/gettor/requests.py b/lib/gettor/requests.py index bcf461f..a61ac14 100644 --- a/lib/gettor/requests.py +++ b/lib/gettor/requests.py @@ -23,7 +23,6 @@ class requestMail: self.request['user'] = self.parsedMessage["Return-Path"] self.request['ouraddr'] = self.getRealTo(self.parsedMessage["to"]) self.request['locale'] = self.getLocaleInTo(self.request['ouraddr']) - self.request['plus'] = False # Was this a gettor+lang@ request? self.request['package'] = None self.request['split'] = False self.request['forward'] = None @@ -52,7 +51,7 @@ class requestMail: if match: locale = match.group(3) logging.debug("User requested language %s" % locale) - return locale + return self.checkAndGetLocale(locale) else: logging.debug("Not a 'plus' address") return self.config.DEFAULT_LOCALE @@ -147,7 +146,6 @@ class requestMail: """ for (lang, aliases) in self.config.SUPP_LANGS.items(): if lang == locale: - logging.debug("User requested lang %s" % lang) return locale if aliases is not None: if locale in aliases: diff --git a/lib/gettor/responses.py b/lib/gettor/responses.py index f0f11b7..248c0ac 100644 --- a/lib/gettor/responses.py +++ b/lib/gettor/responses.py @@ -15,8 +15,88 @@ from email.mime.base import MIMEBase from email.mime.text import MIMEText
import gettor.blacklist +import gettor.i18n as i18n
-trans = None +def getPackageHelpMsg(t): + return t.gettext(i18n.GETTOR_TEXT[0]) + "\n\n" \ + + t.gettext(i18n.GETTOR_TEXT[6]) + "\n\n" \ + + """ tor-browser-bundle + macosx-i386-bundle + macosx-ppc-bundle + linux-browser-bundle-i386 + linux-browser-bundle-x86_64 + source-bundle""" + "\n\n" \ + + t.gettext(i18n.GETTOR_TEXT[7]) + "\n\n" \ + + t.gettext(i18n.GETTOR_TEXT[8]) + "\n\n" \ + + t.gettext(i18n.GETTOR_TEXT[9]) + "\n\n" \ + + " gettor+zh_CN@torproject.org" + "\n\n" \ + + t.gettext(i18n.GETTOR_TEXT[10]) + "\n\n" \ + + t.gettext(i18n.GETTOR_TEXT[11]) + "\n\n" \ + + t.gettext(i18n.GETTOR_TEXT[12]) + "\n\n" \ + + t.gettext(i18n.GETTOR_TEXT[13]) + "\n\n" \ + + t.gettext(i18n.GETTOR_TEXT[14]) + "\n\n" \ + + t.gettext(i18n.GETTOR_TEXT[15]) + "\n\n" \ + + t.gettext(i18n.GETTOR_TEXT[16]) + "\n\n" \ + + t.gettext(i18n.GETTOR_TEXT[17]) + "\n\n" \ + + " tor-browser-bundle" + "\n" \ + + " split" + "\n\n" \ + + t.gettext(i18n.GETTOR_TEXT[18]) + "\n\n" \ + + t.gettext(i18n.GETTOR_TEXT[19]) + "\n\n" \ + + t.gettext(i18n.GETTOR_TEXT[20]) + "\n\n" \ + + t.gettext(i18n.GETTOR_TEXT[21]) + "\n\n" \ + + t.gettext(i18n.GETTOR_TEXT[22]) + "\n\n" \ + + t.gettext(i18n.GETTOR_TEXT[23]) + "\n\n" \ + + " http://www.win-rar.com/download.html" + "\n\n" \ + + t.gettext(i18n.GETTOR_TEXT[23]) + "\n\n" \ + + t.gettext(i18n.GETTOR_TEXT[24]) + "\n\n" \ + + t.gettext(i18n.GETTOR_TEXT[25]) + "\n\n" \ + + t.gettext(i18n.GETTOR_TEXT[26]) + "\n\n" \ + + t.gettext(i18n.GETTOR_TEXT[27]) + "\n\n" \ + + t.gettext(i18n.GETTOR_TEXT[28]) + "\n\n" \ + + t.gettext(i18n.GETTOR_TEXT[33]) + "\n\n" \ + + t.gettext(i18n.GETTOR_TEXT[34]) + "\n\n" \ + + " bridges@torproject.org" + "\n\n" \ + + t.gettext(i18n.GETTOR_TEXT[34]) + "\n\n" \ + + t.gettext(i18n.GETTOR_TEXT[35]) + "\n" + +def getPackageMsg(t): + return t.gettext(i18n.GETTOR_TEXT[0]) + "\n\n" \ + + t.gettext(i18n.GETTOR_TEXT[29]) + "\n\n" \ + + t.gettext(i18n.GETTOR_TEXT[30]) + "\n\n" \ + + t.gettext(i18n.GETTOR_TEXT[31]) + "\n\n" \ + + " gpg: Good signature from 'Roger Dingledine arma@mit.edu'" \ + + "\n\n" \ + + t.gettext(i18n.GETTOR_TEXT[32]) + "\n\n" \ + + " http://www.gnupg.org/related_software/frontends.html" \ + + "\n\n" \ + + t.gettext(i18n.GETTOR_TEXT[33]) + "\n\n" \ + + t.gettext(i18n.GETTOR_TEXT[34]) + "\n\n" \ + + t.gettext(i18n.GETTOR_TEXT[35]) + "\n\n" \ + + t.gettext(i18n.GETTOR_TEXT[27]) + "\n\n" \ + + t.gettext(i18n.GETTOR_TEXT[28]) + "\n" + +def getSplitPackageMsg(t): + return t.gettext(i18n.GETTOR_TEXT[0]) + "\n\n" \ + + t.gettext(i18n.GETTOR_TEXT[36]) + "\n\n" \ + + t.gettext(i18n.GETTOR_TEXT[37]) + "\n\n" \ + + t.gettext(i18n.GETTOR_TEXT[19]) + "\n\n" \ + + t.gettext(i18n.GETTOR_TEXT[20]) + "\n\n" \ + + t.gettext(i18n.GETTOR_TEXT[21]) + "\n\n" \ + + t.gettext(i18n.GETTOR_TEXT[22]) + "\n\n" \ + + t.gettext(i18n.GETTOR_TEXT[23]) + "\n\n" \ + + " http://www.win-rar.com/download.html" + "\n\n" \ + + t.gettext(i18n.GETTOR_TEXT[24]) + "\n\n" \ + + t.gettext(i18n.GETTOR_TEXT[25]) + "\n\n" \ + + t.gettext(i18n.GETTOR_TEXT[26]) + "\n\n" \ + + t.gettext(i18n.GETTOR_TEXT[27]) + "\n\n" \ + + t.gettext(i18n.GETTOR_TEXT[28]) + "\n" + +def getDelayAlertMsg(t): + return t.gettext(i18n.GETTOR_TEXT[0]) + "\n\n" \ + + t.gettext(i18n.GETTOR_TEXT[38]) + "\n\n" \ + + t.gettext(i18n.GETTOR_TEXT[39]) + "\n\n" \ + + t.gettext(i18n.GETTOR_TEXT[27]) + "\n\n" \ + + t.gettext(i18n.GETTOR_TEXT[28]) + "\n"
class Response: def __init__(self, config, reqInfo): @@ -29,28 +109,15 @@ class Response: # Dump info logging.info(str(self.reqInfo))
- # Initialize the reply language usage - try: - localeDir = os.path.join(self.config.BASEDIR, "i18n") - t = gettext.translation("gettor", localeDir, [reqInfo['locale']]) - t.install() - # OMG TEH HACK!! Constants need to be imported *after* we've - # initialized the locale/gettext subsystem - import gettor.constants - except IOError: - logging.error("Translation fail. Trying running with -r.") - raise + # Initialize locale subsystem + gettext.install("gettor", unicode=True) + self.t = i18n.getLang(self.reqInfo['locale'])
# Init black & whitelists wlStateDir = os.path.join(self.config.BASEDIR, "wl") blStateDir = os.path.join(self.config.BASEDIR, "bl") self.wList = gettor.blacklist.BWList(wlStateDir) self.bList = gettor.blacklist.BWList(blStateDir) - # Check blacklist section 'general' list & Drop if necessary - # XXX: This should learn wildcards - bListed = self.bList.lookupListEntry(self.reqInfo['user'], "general") - assert bListed is not True, \ - "Mail from blacklisted user %s" % self.reqInfo['user']
def sendReply(self): """All routing decisions take place here. Sending of mails takes place @@ -89,6 +156,10 @@ class Response: if self.wList.lookupListEntry(self.reqInfo['user'], "general"): logging.info("Whitelisted user " + self.reqInfo['user']) return False + # Now check general and specific blacklists, in that order + if self.bList.lookupListEntry(self.reqInfo['user'], "general"): + logging.info("Blacklisted user " + self.reqInfo['user']) + return True # Create a unique dir name for the requested routine self.bList.createSublist(fname) if self.bList.lookupListEntry(self.reqInfo['user'], fname): @@ -110,7 +181,7 @@ class Response: return False logging.info("Sending out %s to %s." % (pack, to)) f = os.path.join(self.config.BASEDIR, "packages", pack + ".z") - txt = gettor.constants.packagemsg + txt = getPackageMsg(self.t) msg = self.makeMsg(txt, to, fileName=f) try: status = self.sendEmail(to, msg) @@ -130,7 +201,7 @@ class Response: to = self.reqInfo['user'] logging.info("Sending out %s to %s." % (pack, fwd)) f = os.path.join(self.config.BASEDIR, "packages", pack + ".z") - text = gettor.constants.packagemsg + text = getPackageMsg(self.t) msg = self.makeMsg(text, fwd, fileName=f) try: status = self.sendEmail(fwd, msg) @@ -172,7 +243,7 @@ class Response: path = os.path.join(splitDir, filename) num = num + 1 sub = "[GetTor] Split package [%02d / %02d] " % (num, nFiles) - txt = gettor.constants.splitpackagemsg + txt = getSplitPackageMsg(self.t) msg = self.makeMsg(txt, sub, self.reqInfo['user'], fileName=path) try: status = self.sendEmail(self.reqInfo['user'], msg) @@ -193,7 +264,7 @@ class Response: # Don't send anything return False logging.info("Sending delay alert to %s" % self.reqInfo['user']) - return self.sendTextEmail(gettor.constants.delayalertmsg) + return self.sendTextEmail(getDelayAlertMsg(self.t))
def sendHelp(self): """Send a help mail. This happens when a user sent us a request we @@ -203,7 +274,7 @@ class Response: # Don't send anything return False logging.info("Sending out help message to %s" % self.reqInfo['user']) - return self.sendTextEmail(gettor.constants.helpmsg) + return self.sendTextEmail(getPackageHelpMsg(self.t))
def sendPackageHelp(self): """Send a helpful message to the user interacting with us about @@ -213,7 +284,7 @@ class Response: # Don't send anything return False logging.info("Sending package help to %s" % self.reqInfo['user']) - return self.sendTextEmail(gettor.constants.multilangpackagehelpmsg) + return self.sendTextEmail(i18n.MULTILANGHELP)
def sendTextEmail(self, text): """Generic text message sending routine.
tor-commits@lists.torproject.org