[or-cvs] [torflow/master 79/92] snakeinspector: SMTP authentication and TLS/STARTTLS
mikeperry at torproject.org
mikeperry at torproject.org
Sat Aug 21 05:14:01 UTC 2010
Author: John M. Schanck <john at anomos.info>
Date: Sun, 15 Aug 2010 00:23:30 -0400
Subject: snakeinspector: SMTP authentication and TLS/STARTTLS
Commit: 92bd2acaf40df61930cb81fc33fe7386a348304d
---
NetworkScanners/ExitAuthority/snakeinspector.py | 26 ++++++++++++++++++----
NetworkScanners/ExitAuthority/soat_config.py | 11 ++++++++-
2 files changed, 31 insertions(+), 6 deletions(-)
diff --git a/NetworkScanners/ExitAuthority/snakeinspector.py b/NetworkScanners/ExitAuthority/snakeinspector.py
index 6a59dd9..135ad18 100755
--- a/NetworkScanners/ExitAuthority/snakeinspector.py
+++ b/NetworkScanners/ExitAuthority/snakeinspector.py
@@ -121,7 +121,7 @@ class SIConf(object):
except ValueError:
self.statuscode = RESULT_CODES[a]
-def send_mail(fro, to, subject, text, server, files=[]):
+def send_mail(fro, to, subject, text, files=[]):
assert type(to)==list
assert type(files)==list
@@ -141,9 +141,25 @@ def send_mail(fro, to, subject, text, server, files=[]):
% os.path.basename(f))
msg.attach(part)
- smtp = smtplib.SMTP(server)
- smtp.sendmail(fro, to, msg.as_string() )
- smtp.close()
+ if mail_auth and not (mail_tls or mail_starttls):
+ print "You've requested authentication but have not set"
+ print "mail_tls or mail_starttls to True. As a friend,"
+ print "I just can't let you do that to yourself."
+ return
+
+ try:
+ if mail_tls:
+ smtp = smtplib.SMTP_SSL(host=mail_server)
+ else:
+ smtp = smtplib.SMTP(host=mail_server)
+ if mail_starttls:
+ smtp.starttls()
+ if mail_auth:
+ smtp.login(mail_user, mail_password)
+ smtp.sendmail(fro, to, msg.as_string() )
+ smtp.close()
+ except smtplib.SMTPException, e:
+ print e
def main(argv):
now = time.time()
@@ -204,7 +220,7 @@ def main(argv):
text += traceback.format_exc()
# TODO: Attach files? Or is that too much.. Maybe serve
# them via http and include links?
- send_mail(from_email, to_email, subject, text, mail_server)
+ send_mail(from_email, to_email, subject, text)
if __name__ == "__main__":
main(sys.argv)
diff --git a/NetworkScanners/ExitAuthority/soat_config.py b/NetworkScanners/ExitAuthority/soat_config.py
index c2ecb39..255301c 100644
--- a/NetworkScanners/ExitAuthority/soat_config.py
+++ b/NetworkScanners/ExitAuthority/soat_config.py
@@ -46,8 +46,17 @@ refetch_ip = "4.4.4.4"
# Email settings for email scans.
from_email = "Tor Exit Scanner <noreply at torproject.org>"
to_email = ["Tor Exit Scanner List <root at localhost>"]
-mail_server = "127.0.0.1"
mail_interval = 24*60*60 # Remember to change your crontab too!
+mail_server = "127.0.0.1"
+# Email authentication
+# If your smtp server requires a username and password, set
+# mail_auth to True. In this case, one of mail_tls or
+# mail_starttls must also be set to True.
+mail_auth = False
+mail_user = "user at example.com"
+mail_password = "password"
+mail_tls = False
+mail_starttls = False
# What percentage of tested nodes must disagree with our local fetches before
# we ignore the target site/url
--
1.7.1
More information about the tor-commits
mailing list