From 096a9b17ac3445daa11e7e1b2e702c70bd0e4ee4 Mon Sep 17 00:00:00 2001 From: euxane Date: Sat, 30 Nov 2024 09:27:40 +0100 Subject: ping: use current sender address at each request The sending IP address can change after the start of the program. That's happening regularly with IPv6 SLAAC privacy extensions. --- ping.nim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'ping.nim') diff --git a/ping.nim b/ping.nim index b09d5f1..dd41882 100644 --- a/ping.nim +++ b/ping.nim @@ -217,11 +217,11 @@ proc initPingMonitor*(target: IpAddress, ident: uint16): PingMonitor = PingMonitor( socket: newSocket(domain, SOCK_RAW, proto), target: target, - source: getPrimaryIPAddr(target), ident: ident, ) -func buildEchoRequest(mon: PingMonitor): ICMPPacket = +proc buildEchoRequest(mon: PingMonitor): ICMPPacket = + mon.source = getPrimaryIPAddr(dest=mon.target) buildEchoRequest(mon.source, mon.target, mon.ident, mon.seqNum, mon.payload) proc sendEchoRequest(mon: PingMonitor, timeout: Duration) = -- cgit v1.2.3