mirror of
https://github.com/go-ping/ping.git
synced 2025-08-31 12:52:04 +00:00
Add size flag to demo pinger
Adds a command line flag to the demo pinger which lets the user set the the size of the ICMP payload. This is useful for testing. The default is set at 16 which is the default for an unconfigured pinger. Signed-off-by: Charlie Jonas <charlie@charliejonas.co.uk>
This commit is contained in:
@@ -31,12 +31,16 @@ Examples:
|
||||
|
||||
# Send a privileged raw ICMP ping
|
||||
sudo ping --privileged www.google.com
|
||||
|
||||
# Send ICMP messages with a 100-byte payload
|
||||
ping -s 100 1.1.1.1
|
||||
`
|
||||
|
||||
func main() {
|
||||
timeout := flag.Duration("t", time.Second*100000, "")
|
||||
interval := flag.Duration("i", time.Second, "")
|
||||
count := flag.Int("c", -1, "")
|
||||
size := flag.Int("s", 16, "")
|
||||
privileged := flag.Bool("privileged", false, "")
|
||||
flag.Usage = func() {
|
||||
fmt.Print(usage)
|
||||
@@ -81,6 +85,7 @@ func main() {
|
||||
}
|
||||
|
||||
pinger.Count = *count
|
||||
pinger.Size = *size
|
||||
pinger.Interval = *interval
|
||||
pinger.Timeout = *timeout
|
||||
pinger.SetPrivileged(*privileged)
|
||||
|
Reference in New Issue
Block a user