From ff361f10ff77e9b8ffb7e2d2f1191541fd1183a4 Mon Sep 17 00:00:00 2001 From: "Guillaume \"Elektordi\" Genty" Date: Mon, 4 Aug 2025 18:19:56 +0200 Subject: [PATCH 1/2] Fix ip address used in tests --- fastping_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fastping_test.go b/fastping_test.go index c708b82..b608a79 100644 --- a/fastping_test.go +++ b/fastping_test.go @@ -165,7 +165,7 @@ func TestRun(t *testing.T) { t.Fatalf("AddIP failed: %v", err) } - if err := p.AddIP("127.0.0.100"); err != nil { + if err := p.AddIP("198.51.100.100"); err != nil { t.Fatalf("AddIP failed: %v", err) } @@ -179,7 +179,7 @@ func TestRun(t *testing.T) { called = true if ip.String() == "127.0.0.1" { found1 = true - } else if ip.String() == "127.0.0.100" { + } else if ip.String() == "198.51.100.100" { found100 = true } else if ip.String() == "::1" { foundv6 = true @@ -204,7 +204,7 @@ func TestRun(t *testing.T) { t.Fatalf("Pinger `127.0.0.1` didn't respond") } if found100 { - t.Fatalf("Pinger `127.0.0.100` responded") + t.Fatalf("Pinger `198.51.100.100` responded") } if !foundv6 { t.Fatalf("Pinger `::1` didn't responded") From c35d5b4dadfc141818055bf594c28cb4b990d5e6 Mon Sep 17 00:00:00 2001 From: "Guillaume \"Elektordi\" Genty" Date: Mon, 4 Aug 2025 18:32:08 +0200 Subject: [PATCH 2/2] Update README to add fix for UDP ping on Linux --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index d77a261..730c105 100644 --- a/README.md +++ b/README.md @@ -47,6 +47,11 @@ please see "cmd/ping/ping.go". This package implements ICMP ping using both raw socket and UDP. If your program uses this package in raw socket mode, it needs to be run as a root user. +If you are using the UDP socket on Linux, you may also need to allow UDP pings (even root is not allowed by default on debian for example): +``` +sudo sysctl -w net.ipv4.ping_group_range="0 2147483647" +``` + ## License go-fastping is under MIT License. See the [LICENSE][license] file for details.