add ipv6 support
parent
06133ef0c3
commit
8d601d52bd
|
@ -34,7 +34,7 @@ def run_phenny(config):
|
||||||
|
|
||||||
def connect(config):
|
def connect(config):
|
||||||
p = bot.Phenny(config)
|
p = bot.Phenny(config)
|
||||||
p.run(config.host, config.port, config.ssl)
|
p.run(config.host, config.port, config.ssl, config.ipv6)
|
||||||
|
|
||||||
try: Watcher()
|
try: Watcher()
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
|
|
12
irc.py
12
irc.py
|
@ -67,14 +67,18 @@ class Bot(asynchat.async_chat):
|
||||||
self.__write(args, text)
|
self.__write(args, text)
|
||||||
except Exception, e: pass
|
except Exception, e: pass
|
||||||
|
|
||||||
def run(self, host, port=6667, ssl=False):
|
def run(self, host, port=6667, ssl=False, ipv6=False):
|
||||||
self.initiate_connect(host, port, ssl)
|
self.initiate_connect(host, port, ssl, ipv6)
|
||||||
|
|
||||||
def initiate_connect(self, host, port, ssl):
|
def initiate_connect(self, host, port, ssl, ipv6):
|
||||||
if self.verbose:
|
if self.verbose:
|
||||||
message = 'Connecting to %s:%s...' % (host, port)
|
message = 'Connecting to %s:%s...' % (host, port)
|
||||||
print >> sys.stderr, message,
|
print >> sys.stderr, message,
|
||||||
self.create_socket(socket.AF_INET, socket.SOCK_STREAM)
|
if ipv6 and socket.has_ipv6:
|
||||||
|
af = socket.AF_INET6
|
||||||
|
else:
|
||||||
|
af = socket.AF_INET
|
||||||
|
self.create_socket(af, socket.SOCK_STREAM)
|
||||||
self.connect((host, port))
|
self.connect((host, port))
|
||||||
if ssl:
|
if ssl:
|
||||||
import ssl
|
import ssl
|
||||||
|
|
4
phenny
4
phenny
|
@ -29,6 +29,7 @@ def create_default_config(fn):
|
||||||
host = 'irc.example.net'
|
host = 'irc.example.net'
|
||||||
port = 6667
|
port = 6667
|
||||||
ssl = False
|
ssl = False
|
||||||
|
ipv6 = False
|
||||||
channels = ['#example', '#test']
|
channels = ['#example', '#test']
|
||||||
owner = 'yournickname'
|
owner = 'yournickname'
|
||||||
|
|
||||||
|
@ -144,6 +145,9 @@ def main(argv=None):
|
||||||
if not hasattr(module, 'ssl'):
|
if not hasattr(module, 'ssl'):
|
||||||
module.ssl = False
|
module.ssl = False
|
||||||
|
|
||||||
|
if not hasattr(module, 'ipv6'):
|
||||||
|
module.ipv6 = False
|
||||||
|
|
||||||
if not hasattr(module, 'password'):
|
if not hasattr(module, 'password'):
|
||||||
module.password = None
|
module.password = None
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue