Add OnSetup callback (#155)

Signed-off-by: Marcelo E. Magallon <marcelo.magallon@grafana.com>
Merged-by: Charlie Jonas <charlie@charliejonas.co.uk>
This commit is contained in:
Marcelo Magallon 2021-03-25 17:48:16 -06:00 committed by GitHub
parent d90f3778a8
commit df22d52de1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -152,6 +152,9 @@ type Pinger struct {
// rtts is all of the Rtts
rtts []time.Duration
// OnSetup is called when Pinger has finished setting up the listening socket
OnSetup func()
// OnSend is called when Pinger sends a packet
OnSend func(*Packet)
@ -400,6 +403,10 @@ func (p *Pinger) Run() error {
//nolint:errcheck
go p.recvICMP(conn, recv, &wg)
if handler := p.OnSetup; handler != nil {
handler()
}
err = p.sendICMP(conn)
if err != nil {
return err