mirror of
https://github.com/go-ping/ping.git
synced 2025-09-13 05:29:24 +00:00
Include adddress in Packet (#38)
Include the original address in the Packet type for use in `pinger.OnRecv()`.
This commit is contained in:
committed by
Cameron Sparr
parent
74b9e0e9f9
commit
687023bdc7
4
ping.go
4
ping.go
@@ -158,6 +158,9 @@ type Packet struct {
|
|||||||
// IPAddr is the address of the host being pinged.
|
// IPAddr is the address of the host being pinged.
|
||||||
IPAddr *net.IPAddr
|
IPAddr *net.IPAddr
|
||||||
|
|
||||||
|
// Addr is the string address of the host being pinged.
|
||||||
|
Addr string
|
||||||
|
|
||||||
// NBytes is the number of bytes in the message.
|
// NBytes is the number of bytes in the message.
|
||||||
Nbytes int
|
Nbytes int
|
||||||
|
|
||||||
@@ -436,6 +439,7 @@ func (p *Pinger) processPacket(recv *packet) error {
|
|||||||
outPkt := &Packet{
|
outPkt := &Packet{
|
||||||
Nbytes: recv.nbytes,
|
Nbytes: recv.nbytes,
|
||||||
IPAddr: p.ipaddr,
|
IPAddr: p.ipaddr,
|
||||||
|
Addr: p.addr,
|
||||||
}
|
}
|
||||||
|
|
||||||
switch pkt := m.Body.(type) {
|
switch pkt := m.Body.(type) {
|
||||||
|
Reference in New Issue
Block a user