digineo / go-ping

A simple ping library using ICMP echo requests.
MIT License
234 stars 32 forks source link

Add ability to change the ICMP ID and seq counter #19

Closed foogod closed 5 months ago

foogod commented 2 years ago

It is sometimes valuable to be able to change the ICMP echo identifier field (in particular, this is often used by NAT gateways to tie packets to a particular NAT session, and it may not be desirable for all pingers in the same program to be associated wth the same NAT session).

This change exposes the ID as a field in Pinger which can be overridden by the caller (defaults to PID as before). It can actually even be changed while the pinger is running without issues.

Also, since one can now have different pingers with different identifiers, it might be desirable to have them use independent sequence values, so the ability to override the sequence counter used has also been added (since it was easy).

(This change is actually required for some improvements I am working on to the Prometheus ping_exporter..)

outofrange commented 1 year ago

Is there anything stopping this PR? It would be very useful to have this functionality for ping_exporter.