Update InFlightPackets comment

This commit is contained in:
Hampton Moore 2021-08-27 12:09:14 -04:00 committed by thatmattlove
parent 9e634db39b
commit 58ebcd5b44

10
ping.go
View File

@ -90,7 +90,7 @@ func New(addr string) *Pinger {
r := rand.New(rand.NewSource(getSeed())) r := rand.New(rand.NewSource(getSeed()))
firstUUID := uuid.New() firstUUID := uuid.New()
var firstSequence = map[uuid.UUID]map[int]InFlightPacket{} var firstSequence = map[uuid.UUID]map[int]InFlightPacket{}
firstSequence[firstUUID] = make(map[int]InFlightPacket{}) firstSequence[firstUUID] = make(map[int]InFlightPacket)
return &Pinger{ return &Pinger{
Count: -1, Count: -1,
Interval: time.Second, Interval: time.Second,
@ -108,7 +108,7 @@ func New(addr string) *Pinger {
ipv4: false, ipv4: false,
network: "ip", network: "ip",
protocol: "udp", protocol: "udp",
InFlightPackets: map[int]InFlightPacket{}, InFlightPackets: firstSequence,
TTL: 64, TTL: 64,
logger: StdLogger{Logger: log.New(log.Writer(), log.Prefix(), log.Flags())}, logger: StdLogger{Logger: log.New(log.Writer(), log.Prefix(), log.Flags())},
} }
@ -206,7 +206,7 @@ type Pinger struct {
id int id int
sequence int sequence int
// awaitingSequences are in-flight sequence numbers we keep track of to help remove duplicate receipts // awaitingSequences are in-flight sequence numbers we keep track of to help remove duplicate receipts
awaitingSequences map[uuid.UUID]map[int]InFlightPacket InFlightPackets map[uuid.UUID]map[int]InFlightPacket
// network is one of "ip", "ip4", or "ip6". // network is one of "ip", "ip4", or "ip6".
network string network string
// protocol is "icmp" or "udp". // protocol is "icmp" or "udp".
@ -788,7 +788,7 @@ func (p *Pinger) sendICMP(conn packetConn) error {
handler(outPkt) handler(outPkt)
} }
// mark this sequence as in-flight // mark this sequence as in-flight
p.awaitingSequences[currentUUID][p.sequence] = InFlightPacket{ p.InFlightPackets[currentUUID][p.sequence] = InFlightPacket{
DispatchedTime: time.Now(), DispatchedTime: time.Now(),
Seq: p.sequence, Seq: p.sequence,
} }
@ -797,7 +797,7 @@ func (p *Pinger) sendICMP(conn packetConn) error {
if p.sequence > 65535 { if p.sequence > 65535 {
newUUID := uuid.New() newUUID := uuid.New()
p.trackerUUIDs = append(p.trackerUUIDs, newUUID) p.trackerUUIDs = append(p.trackerUUIDs, newUUID)
p.awaitingSequences[newUUID] = make(map[int]InFlightPacket) p.InFlightPackets[newUUID] = make(map[int]InFlightPacket)
p.sequence = 0 p.sequence = 0
} }
break break