mirror of
https://github.com/go-ping/ping.git
synced 2025-09-20 17:59:49 +00:00
Change size to Size to make it exportable (#18)
I have made Size exportable as i require the ability to change the packetsize on a per host basis
This commit is contained in:
15
ping.go
15
ping.go
@@ -93,7 +93,7 @@ func NewPinger(addr string) (*Pinger, error) {
|
|||||||
|
|
||||||
network: "udp",
|
network: "udp",
|
||||||
ipv4: ipv4,
|
ipv4: ipv4,
|
||||||
size: timeSliceLength,
|
Size: timeSliceLength,
|
||||||
|
|
||||||
done: make(chan bool),
|
done: make(chan bool),
|
||||||
}, nil
|
}, nil
|
||||||
@@ -131,15 +131,18 @@ type Pinger struct {
|
|||||||
// OnFinish is called when Pinger exits
|
// OnFinish is called when Pinger exits
|
||||||
OnFinish func(*Statistics)
|
OnFinish func(*Statistics)
|
||||||
|
|
||||||
|
// Size of packet being sent
|
||||||
|
Size int
|
||||||
|
|
||||||
// stop chan bool
|
// stop chan bool
|
||||||
done chan bool
|
done chan bool
|
||||||
|
|
||||||
ipaddr *net.IPAddr
|
ipaddr *net.IPAddr
|
||||||
addr string
|
addr string
|
||||||
|
|
||||||
ipv4 bool
|
ipv4 bool
|
||||||
source string
|
source string
|
||||||
size int
|
|
||||||
sequence int
|
sequence int
|
||||||
network string
|
network string
|
||||||
}
|
}
|
||||||
@@ -466,8 +469,8 @@ func (p *Pinger) sendICMP(conn *icmp.PacketConn) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
t := timeToBytes(time.Now())
|
t := timeToBytes(time.Now())
|
||||||
if p.size-timeSliceLength != 0 {
|
if p.Size-timeSliceLength != 0 {
|
||||||
t = append(t, byteSliceOfSize(p.size-timeSliceLength)...)
|
t = append(t, byteSliceOfSize(p.Size-timeSliceLength)...)
|
||||||
}
|
}
|
||||||
bytes, err := (&icmp.Message{
|
bytes, err := (&icmp.Message{
|
||||||
Type: typ, Code: 0,
|
Type: typ, Code: 0,
|
||||||
|
Reference in New Issue
Block a user