From 4e732f5f7730237c042da6920b77dcb0ad5a104d Mon Sep 17 00:00:00 2001 From: Jesse Kleemann Date: Sun, 20 Aug 2023 01:05:51 +0200 Subject: [PATCH] fix Windows DF option --- pythonping/__init__.py | 5 ++++- pythonping/network.py | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/pythonping/__init__.py b/pythonping/__init__.py index 2b3c29e..9254477 100644 --- a/pythonping/__init__.py +++ b/pythonping/__init__.py @@ -66,7 +66,10 @@ def ping(target, provider = payload_provider.Repeat(payload, count) options = () if df: - options = network.Socket.DONT_FRAGMENT + if sys.platform.startswith('win'): + options = network.Socket.DONT_FRAGMENT_WIN + else: + options = network.Socket.DONT_FRAGMENT # Fix to allow for pythonping multithreaded usage; # no need to protect this loop as no one will ever surpass 0xFFFF amount of threads diff --git a/pythonping/network.py b/pythonping/network.py index 080b9b0..30e5cd8 100644 --- a/pythonping/network.py +++ b/pythonping/network.py @@ -5,6 +5,7 @@ class Socket: DONT_FRAGMENT = (socket.SOL_IP, 10, 1) # Option value for raw socket + DONT_FRAGMENT_WIN = (socket.IPPROTO_IP, 14, 1) # use IP_DONTFRAGMENT 14 from ws2ipdef.h PROTO_LOOKUP = {"icmp": socket.IPPROTO_ICMP, "tcp": socket.IPPROTO_TCP, "udp": socket.IPPROTO_UDP, "ip": socket.IPPROTO_IP, "raw": socket.IPPROTO_RAW}