Commit Graph

14 Commits

Author SHA1 Message Date
Cemre Mengu
6e2b003bff
Add ability to set TTL (#186) 2021-10-14 19:03:14 +01:00
Ben Kochie
3818264768 Use a UUID for packet tracking
Replace the random 8 byte tracker with a 16 byte UUID.
* Implement as a slice so that it can be extended later.
* Deprecate the exported `Pinger.Tracker` value.

https://github.com/go-ping/ping/issues/142

Signed-off-by: Ben Kochie <superq@gmail.com>
2021-09-11 16:15:12 +01:00
Marcelo Magallon
ff8be33200
Provide an abstraction over icmp.PacketConn (#166)
The differences between IPv4 and IPv6 APIs can be moved to a single type so that we don't need to keep track of them all over the code. We can also split Run() into two parts: the top one sets up the listener and the bottom one sends and receives packets. In this way, the bottom part can be tested using a mock packet connection.
2021-05-07 00:38:00 +01:00
Jean Raby
5f9dd908cc
Fix packet matching; compute statistics as packets are received (#150)
* Fix unprivileged packet matching on Linux
* Compute statistics on-the-fly as packets are received

Signed-off-by: Jean Raby <jean@raby.sh>
Signed-off-by: Charlie Jonas <charlie@charliejonas.co.uk>
Co-authored-by: Charlie Jonas <charlie@charliejonas.co.uk>
2021-03-11 22:01:31 +00:00
Charlie Jonas
62f79f1f4f
Make Tracker uint64 and check for both UDP and ICMP (#134) 2021-02-07 22:15:49 +00:00
Steven Soroka
30a8f08ad2
Process duplicate packets and make seeds goroutine-safe (#130)
Duplicate ICMP packets are now detected and processed using a separate callback and field in the statistics struct.

Co-authored-by: Charlie Jonas <charlie@charliejonas.co.uk>
Co-authored-by: Ben Kochie <superq@gmail.com>
2021-01-31 13:15:27 +00:00
Rob Collier
acac328aae Update the test to use an always invalid hostname (under the .invalid tld) 2020-11-14 14:44:32 -08:00
Rob Collier
145e7e44ad TLD 'wtf' now exists, use 'wtfh' instead in TestNewPingerInvalid 2020-11-14 14:44:32 -08:00
Lifei Chen
e8ae07c3ce
Return an error when addr is empty 2020-09-18 13:04:29 +01:00
Ben Kochie
8e89829cd5
Don't resolve when creating Pinger (#65)
Move the DNS resolver out of the NewPinger() function in order to allow
adjusting of IPv4 vs IPv6 DNS resolution before running. This also
allows the user to verify resolution.
* Create new `New()` method that returns a bare default struct.
* Create new `Resolve()` method.
* Call `Resolve()` from `SetAddr()`.
* Call `Resolve()` automatically from `Run()`.
* Remove unecessary private `run()` method.

Update ping command for simplifed return values of `NewPinger()`.

Signed-off-by: Ben Kochie <superq@gmail.com>
2020-09-14 07:41:27 +02:00
Cam
e33cfb8ae7 Add processPacket unit tests
Add vet and unit test to circleci job
2019-06-04 11:15:55 -07:00
Greg
56df11e077 Make processPacket more performant (#59)
* Make processPacket more performant

* Add more info for debugging to returned error

* remove old benchmark

* change print statement to error return
2019-06-03 16:11:21 -07:00
Cameron Sparr
416e72114c Add integration tests in circle 2016-02-08 09:29:08 -07:00
Cameron Sparr
dae25ab260 Write unit tests 2016-02-07 14:15:39 -07:00