Skip to content

Commit 68dd53a

Browse files
committed
Merge pull request atheme-legacy#5 from DarthGandalf/ssl
Add SSL support for IRC
2 parents a31afe9 + 0acf5f6 commit 68dd53a

File tree

4 files changed

+17
-1
lines changed

4 files changed

+17
-1
lines changed

iris.conf.example

+3
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ server: irc.myserver.com
4444
# PORT: Port of IRC server to connect to.
4545
port: 6667
4646

47+
# SSL: Use SSL to connect to IRC server or not
48+
ssl: false
49+
4750
# REALNAME: The realname field for clients connecting through the
4851
# webclient.
4952
realname: http://moo.com/

qwebirc/config.py

+6
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,12 @@ def __interpret_config():
121121
else:
122122
ui["privacy"] = True
123123

124+
if irc["ssl"]:
125+
try:
126+
from twisted.internet.ssl import ClientContextFactory
127+
except ImportError:
128+
raise ConfigException("Configuration error: SSL support not installed")
129+
124130

125131
def js_config():
126132
f = frontend.copy()

qwebirc/config_options.py

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
("frontend", "prompt"),
2222
("frontend", "chan_prompt"),
2323
("frontend", "chan_autoconnect"),
24+
("irc", "ssl"),
2425
("ui", "dedicated_msg_window"),
2526
("ui", "dedicated_notice_window"),
2627
("ui", "hide_joinparts"),

qwebirc/ircclient.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,13 @@ def clientConnectionFailed(self, connector, reason):
223223

224224
def createIRC(*args, **kwargs):
225225
f = QWebIRCFactory(*args, **kwargs)
226-
reactor.connectTCP(config.irc["server"], config.irc["port"], f)
226+
server = config.irc["server"]
227+
port = config.irc["port"]
228+
if config.irc["ssl"]:
229+
from twisted.internet.ssl import ClientContextFactory
230+
reactor.connectSSL(server, port, f, ClientContextFactory())
231+
else:
232+
reactor.connectTCP(server, port, f)
227233
return f
228234

229235
if __name__ == "__main__":

0 commit comments

Comments
 (0)