aboutsummaryrefslogtreecommitdiff
path: root/IRCServer.py
diff options
context:
space:
mode:
authorGravatar jesopo2018-09-07 16:34:51 +0100
committerGravatar jesopo2018-09-07 16:34:51 +0100
commita4f0d1bf287762f6097c570ed11cc92ab5ef7131 (patch)
treed21dfe1510fa21794c9c4da91f5d44ac617cb41e /IRCServer.py
parentListen for 903 for sasl success, not 900 (diff)
signature
Support IRCv3's tls/STARTTLS
Diffstat (limited to 'IRCServer.py')
-rw-r--r--IRCServer.py15
1 files changed, 10 insertions, 5 deletions
diff --git a/IRCServer.py b/IRCServer.py
index 30e29580..8059a9a5 100644
--- a/IRCServer.py
+++ b/IRCServer.py
@@ -65,11 +65,7 @@ class Server(object):
self.socket.settimeout(5.0)
if self.tls:
- context = ssl.SSLContext(OUR_TLS_PROTOCOL)
- context.options |= ssl.OP_NO_SSLv2
- context.options |= ssl.OP_NO_SSLv3
- context.options |= ssl.OP_NO_TLSv1
- self.socket = context.wrap_socket(self.socket)
+ self.tls_wrap()
self.cached_fileno = self.socket.fileno()
self.events.on("timer").on("rejoin").hook(self.try_rejoin)
@@ -82,6 +78,13 @@ class Server(object):
fileno = self.socket.fileno()
return self.cached_fileno if fileno == -1 else fileno
+ def tls_wrap(self):
+ context = ssl.SSLContext(OUR_TLS_PROTOCOL)
+ context.options |= ssl.OP_NO_SSLv2
+ context.options |= ssl.OP_NO_SSLv3
+ context.options |= ssl.OP_NO_TLSv1
+ self.socket = context.wrap_socket(self.socket)
+
def connect(self):
self.socket.connect((self.target_hostname, self.port))
self.send_capibility_ls()
@@ -297,6 +300,8 @@ class Server(object):
self.send("CAP END")
def send_authenticate(self, text):
self.send("AUTHENTICATE %s" % text)
+ def send_starttls(self):
+ self.send("STARTTLS")
def waiting_for_capabilities(self):
return bool(len(self._capabilities_waiting))