mirror of
https://github.com/go-ping/ping.git
synced 2025-08-17 12:36:41 +00:00
feat: add configurable ICMP identifier
This commit is contained in:
parent
6e2b003bff
commit
27679364c9
14
ping.go
14
ping.go
@ -232,6 +232,9 @@ type Packet struct {
|
||||
|
||||
// TTL is the Time To Live on the packet.
|
||||
Ttl int
|
||||
|
||||
// ID is the ICMP identifier.
|
||||
ID int
|
||||
}
|
||||
|
||||
// Statistics represent the stats of a currently running or finished
|
||||
@ -385,6 +388,16 @@ func (p *Pinger) SetLogger(logger Logger) {
|
||||
p.logger = logger
|
||||
}
|
||||
|
||||
// SetID sets the ICMP identifier.
|
||||
func (p *Pinger) SetID(id int) {
|
||||
p.id = id
|
||||
}
|
||||
|
||||
// ID returns the ICMP identifier.
|
||||
func (p *Pinger) ID() int {
|
||||
return p.id
|
||||
}
|
||||
|
||||
// Run runs the pinger. This is a blocking function that will exit when it's
|
||||
// done. If Count or Interval are not specified, it will run continuously until
|
||||
// it is interrupted.
|
||||
@ -641,6 +654,7 @@ func (p *Pinger) processPacket(recv *packet) error {
|
||||
IPAddr: p.ipaddr,
|
||||
Addr: p.addr,
|
||||
Ttl: recv.ttl,
|
||||
ID: p.id,
|
||||
}
|
||||
|
||||
switch pkt := m.Body.(type) {
|
||||
|
Loading…
Reference in New Issue
Block a user