aboutsummaryrefslogtreecommitdiff
path: root/IRCServer.py
diff options
context:
space:
mode:
authorGravatar jesopo2017-11-01 14:04:49 +0000
committerGravatar jesopo2017-11-01 14:04:49 +0000
commit4779c885c85a30f45b5ce1420160b9b0877a7a37 (patch)
tree7dad52ccc29fa4c054ab15110017aff36ecd8386 /IRCServer.py
parentDon't put non-kwargs after unpacked list, handle ConnectionResetError (diff)
signature
Handle versions of python that don't have ssl.PROTOCOL_TLS
Diffstat (limited to 'IRCServer.py')
-rw-r--r--IRCServer.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/IRCServer.py b/IRCServer.py
index 2c17ed11..fcd4bb5f 100644
--- a/IRCServer.py
+++ b/IRCServer.py
@@ -1,6 +1,10 @@
import collections, socket, ssl, sys, time
import IRCChannel, IRCLineHandler, IRCUser
+OUR_TLS_PROTOCOL = ssl.PROTOCOL_SSLv23
+if hasattr(ssl, "PROTOCOL_TLS"):
+ OUR_TLS_PROTOCOL = ssl.PROTOCOL_TLS
+
class Server(object):
def __init__(self, id, hostname, port, password, ipv4, tls,
nickname, username, realname, bot):
@@ -38,7 +42,7 @@ class Server(object):
self.socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEPORT, 1)
self.socket.settimeout(5.0)
if self.tls:
- context = ssl.SSLContext(ssl.PROTOCOL_TLS)
+ context = ssl.SSLContext(OUR_TLS_PROTOCOL)
context.options |= ssl.OP_NO_SSLv2
context.options |= ssl.OP_NO_SSLv3
self.socket = context.wrap_socket(self.socket)