From 5a3db5ab7cb519a37f8921b2793a30500dd5cefb Mon Sep 17 00:00:00 2001 From: Jan Philipp Timme Date: Sun, 6 Dec 2015 19:14:18 +0100 Subject: [PATCH] [TASK] Add ssl support. --- fdskun.py | 8 ++++++-- requirements.txt | 1 + settings.ini.example | 2 ++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/fdskun.py b/fdskun.py index ec4b865..c6c53bc 100644 --- a/fdskun.py +++ b/fdskun.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- from twisted.words.protocols import irc -from twisted.internet import reactor, protocol +from twisted.internet import reactor, protocol, ssl from twisted.python import usage, log from twisted.internet import inotify from twisted.python import filepath @@ -141,6 +141,7 @@ if __name__ == '__main__': host = config.get('irc', 'host') port = int(config.get('irc', 'port')) + ssl_switch = config.get('irc', 'ssl') channel = config.get('irc', 'channel') nickname = config.get('irc', 'nickname') nickserv_pw = config.get('irc', 'nickserv_pw') @@ -153,7 +154,10 @@ if __name__ == '__main__': f = MonitorBotFactory(nickname, channel, nickserv_pw, fsmon) # connect factory to this host and port - reactor.connectTCP(host, port, f) + if ssl_switch == 'no': + reactor.connectTCP(host, port, f) + else: + reactor.connectSSL(host, port, f, ssl.ClientContextFactory()) # run bot reactor.run() diff --git a/requirements.txt b/requirements.txt index b8644b3..83de952 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,4 @@ coverage pyopenssl twisted +service_identity diff --git a/settings.ini.example b/settings.ini.example index 06cd86e..68d1ffe 100644 --- a/settings.ini.example +++ b/settings.ini.example @@ -1,6 +1,8 @@ [irc] host = irc.euirc.net port = 6667 +ssl = no +ssl = yes nickName = FDS-kun realName = bot: provides tracking of an ftp folder channel = #JPT