aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoreuxane2024-11-30 09:27:40 +0100
committereuxane2024-11-30 09:27:40 +0100
commit096a9b17ac3445daa11e7e1b2e702c70bd0e4ee4 (patch)
tree7c006f9df8949c9cf272489b9a1e6b874122e047
parent9df9f0c41ea6aa59cb34151c0505f6fae36ef12e (diff)
downloadtickwatch-096a9b17ac3445daa11e7e1b2e702c70bd0e4ee4.tar.gz
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.
-rw-r--r--ping.nim4
1 files changed, 2 insertions, 2 deletions
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 =
217 PingMonitor( 217 PingMonitor(
218 socket: newSocket(domain, SOCK_RAW, proto), 218 socket: newSocket(domain, SOCK_RAW, proto),
219 target: target, 219 target: target,
220 source: getPrimaryIPAddr(target),
221 ident: ident, 220 ident: ident,
222 ) 221 )
223 222
224func buildEchoRequest(mon: PingMonitor): ICMPPacket = 223proc buildEchoRequest(mon: PingMonitor): ICMPPacket =
224 mon.source = getPrimaryIPAddr(dest=mon.target)
225 buildEchoRequest(mon.source, mon.target, mon.ident, mon.seqNum, mon.payload) 225 buildEchoRequest(mon.source, mon.target, mon.ident, mon.seqNum, mon.payload)
226 226
227proc sendEchoRequest(mon: PingMonitor, timeout: Duration) = 227proc sendEchoRequest(mon: PingMonitor, timeout: Duration) =