Support IPv6 connections
This commit is contained in:
parent
9f64b13489
commit
e7cdf1eb50
@ -21,6 +21,7 @@ import sys
|
|||||||
import threading
|
import threading
|
||||||
import time
|
import time
|
||||||
import traceback
|
import traceback
|
||||||
|
import os
|
||||||
|
|
||||||
from oyoyo.parse import parse_raw_irc_command
|
from oyoyo.parse import parse_raw_irc_command
|
||||||
|
|
||||||
@ -99,7 +100,7 @@ class IRCClient(object):
|
|||||||
To enable blocking pass blocking=True.
|
To enable blocking pass blocking=True.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
self.socket = None
|
||||||
self.nickname = ""
|
self.nickname = ""
|
||||||
self.hostmask = ""
|
self.hostmask = ""
|
||||||
self.ident = ""
|
self.ident = ""
|
||||||
@ -120,10 +121,6 @@ class IRCClient(object):
|
|||||||
|
|
||||||
self.__dict__.update(kwargs)
|
self.__dict__.update(kwargs)
|
||||||
self.command_handler = cmd_handler
|
self.command_handler = cmd_handler
|
||||||
|
|
||||||
if self.use_ssl:
|
|
||||||
self.socket = ssl.wrap_socket(self.socket)
|
|
||||||
|
|
||||||
self._end = 0
|
self._end = 0
|
||||||
|
|
||||||
def send(self, *args, **kwargs):
|
def send(self, *args, **kwargs):
|
||||||
@ -177,13 +174,17 @@ class IRCClient(object):
|
|||||||
retries = 0
|
retries = 0
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
self.socket.connect(("{0}".format(self.host), self.port))
|
self.socket = socket.create_connection(("{0}".format(self.host), self.port))
|
||||||
break
|
break
|
||||||
except socket.error as e:
|
except socket.error as e:
|
||||||
retries += 1
|
retries += 1
|
||||||
self.stream_handler('Error: {0}'.format(e), level="warning")
|
self.stream_handler('Error: {0}'.format(e), level="warning")
|
||||||
if retries > 3:
|
if retries > 3:
|
||||||
break
|
exit(os.EX_UNAVAILABLE)
|
||||||
|
|
||||||
|
if self.use_ssl:
|
||||||
|
self.socket = ssl.wrap_socket(self.socket)
|
||||||
|
|
||||||
if not self.blocking:
|
if not self.blocking:
|
||||||
self.socket.setblocking(0)
|
self.socket.setblocking(0)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user