From 290e822176c52ee63a98a137ad3140ecd7b17b76 Mon Sep 17 00:00:00 2001 From: Dominik Pataky Date: Sun, 26 Jan 2020 13:28:39 +0100 Subject: [PATCH] Add IPv6 local interface address handling With the '--host' flag, a local interface IP address can be set on which the collector listens for incoming flows. Since now, this only worked with IPv4 addresses (using the default 0.0.0.0 interface). The commit adds handling of passed-in IPv6 addresses by identifying ":" and then switching to the AF_INET6 socket family. --- main.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/main.py b/main.py index 4604339..df2c2a2 100755 --- a/main.py +++ b/main.py @@ -15,6 +15,7 @@ import gzip import json import logging import sys +import socket import socketserver import threading import time @@ -44,6 +45,11 @@ class QueuingUDPListener(socketserver.ThreadingUDPServer): """ def __init__(self, interface, queue): self.queue = queue + + # If IPv6 interface addresses are used, override the default AF_INET family + if ":" in interface[0]: + self.address_family = socket.AF_INET6 + super().__init__(interface, QueuingRequestHandler)