From 2029d53e2a1c75e5e5aff0f0e2a4a71dd3f9fa10 Mon Sep 17 00:00:00 2001 From: Ruakij Date: Mon, 2 Aug 2021 11:54:45 +0200 Subject: [PATCH] Added ipv4/ipv6 check --- daemon.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/daemon.py b/daemon.py index 29a5a55..66dda7a 100755 --- a/daemon.py +++ b/daemon.py @@ -23,7 +23,13 @@ def main(args): startListen(s) def setupSocket(address, port): - s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) + # IPv4/IPv6-check + if address == "" or ":" in address: + family = socket.AF_INET6 + else: + family = socket.AF_INET + + s = socket.socket(family, socket.SOCK_DGRAM) s.bind((address, port)) return s