Permalink
Browse files

Add ssl_config kwarg to Socket Connection

  • Loading branch information...
fmoo committed Nov 30, 2011
1 parent c8e01b0 commit 0d95c63ee1504f84a760fc74cfdf7e2eb92dd784
Showing with 12 additions and 4 deletions.
  1. +12 −4 irclib.py
View
@@ -380,7 +380,8 @@ def __init__(self, irclibobj):
self.ssl = None
def connect(self, server, port, nickname, password=None, username=None,
- ircname=None, localaddress="", localport=0, ssl=False, ipv6=False):
+ ircname=None, localaddress="", localport=0, ssl=False,
+ ipv6=False, ssl_config=None):
"""Connect/reconnect to a server.
Arguments:
@@ -405,6 +406,8 @@ def connect(self, server, port, nickname, password=None, username=None,
ipv6 -- Enable support for ipv6.
+ ssl_config -- additional kwargs for ssl.wrap_socket
+
This function can be called to reconnect a closed connection.
Returns the ServerConnection object.
@@ -425,6 +428,7 @@ def connect(self, server, port, nickname, password=None, username=None,
self.localaddress = localaddress
self.localport = localport
self.localhost = socket.gethostname()
+ self.ssl_config = ssl_config or {}
if ipv6:
self.socket = socket.socket(socket.AF_INET6, socket.SOCK_STREAM)
else:
@@ -433,7 +437,7 @@ def connect(self, server, port, nickname, password=None, username=None,
self.socket.bind((self.localaddress, self.localport))
self.socket.connect((self.server, self.port))
if ssl:
- self.ssl = ssl_.wrap_socket(self.socket)
+ self.ssl = ssl_.wrap_socket(self.socket, **self.ssl_config)
except socket.error, x:
self.socket.close()
self.socket = None
@@ -1053,7 +1057,8 @@ def _dcc_disconnect(self, c, e):
self.dcc_connections.remove(c)
def connect(self, server, port, nickname, password=None, username=None,
- ircname=None, localaddress="", localport=0, ssl=False, ipv6=False):
+ ircname=None, localaddress="", localport=0, ssl=False,
+ ipv6=False, ssl_config=None):
"""Connect/reconnect to a server.
Arguments:
@@ -1078,11 +1083,14 @@ def connect(self, server, port, nickname, password=None, username=None,
ipv6 -- Enable support for ipv6.
+ ssl_config -- additional kwargs for ssl.wrap_socket
+
This function can be called to reconnect a closed connection.
"""
self.connection.connect(server, port, nickname,
password, username, ircname,
- localaddress, localport, ssl, ipv6)
+ localaddress, localport, ssl, ipv6,
+ ssl_config)
def dcc_connect(self, address, port, dcctype="chat"):
"""Connect to a DCC peer.

0 comments on commit 0d95c63

Please sign in to comment.