diff options
author | l-n-s <supervillain@riseup.net> | 2017-07-04 09:57:59 -0400 |
---|---|---|
committer | Joel Rosdahl <joel@rosdahl.net> | 2017-07-13 21:11:06 +0200 |
commit | c1d59f3946e523aee605ed7b23a8acbef1ca507c (patch) | |
tree | 8fe1e420a5d0425b21b649d5f6033e46bf7c4519 /miniircd | |
parent | 3f256291e0ca19aac9af40526bdaa2ed37403fd4 (diff) | |
download | miniircd-c1d59f3946e523aee605ed7b23a8acbef1ca507c.tar.gz miniircd-c1d59f3946e523aee605ed7b23a8acbef1ca507c.zip |
Added IPv6 support
Diffstat (limited to 'miniircd')
-rwxr-xr-x | miniircd | 18 |
1 files changed, 15 insertions, 3 deletions
@@ -135,7 +135,10 @@ class Client(object): self.nickname = None self.user = None self.realname = None - (self.host, self.port) = socket.getpeername() + if self.server.ipv6: + (self.host, self.port, _, _) = socket.getpeername() + else: + (self.host, self.port) = socket.getpeername() self.__timestamp = time.time() self.__readbuffer = "" self.__writebuffer = "" @@ -685,6 +688,7 @@ class Server(object): self.ssl_pem_file = options.ssl_pem_file self.motdfile = options.motd self.verbose = options.verbose + self.ipv6 = options.ipv6 self.debug = options.debug self.channel_log_dir = options.channel_log_dir self.chroot = options.chroot @@ -707,7 +711,10 @@ class Server(object): self.ssl_pem_file = os.path.abspath(self.ssl_pem_file) # else: might exist in the chroot jail, so just continue - if options.listen: + if options.listen and self.ipv6: + self.address = socket.getaddrinfo( + options.listen, None, proto=socket.IPPROTO_TCP)[0][4][0] + elif options.listen: self.address = socket.gethostbyname(options.listen) else: self.address = "" @@ -821,7 +828,8 @@ class Server(object): def start(self): serversockets = [] for port in self.ports: - s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + s = socket.socket(socket.AF_INET6 if self.ipv6 else socket.AF_INET, + socket.SOCK_STREAM) s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) try: s.bind((self.address, port)) @@ -938,6 +946,10 @@ def main(argv): action="store_true", help="fork and become a daemon") op.add_option( + "--ipv6", + action="store_true", + help="use IPv6") + op.add_option( "--debug", action="store_true", help="print debug messages to stdout") |