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.
This commit is contained in:
parent
647f4b3748
commit
290e822176
6
main.py
6
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)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue