{"id":19124743,"url":"https://github.com/mitinarseny/pingo","last_synced_at":"2025-05-05T19:29:27.625Z","repository":{"id":43647025,"uuid":"369811198","full_name":"mitinarseny/pingo","owner":"mitinarseny","description":"Ping library for Golang with multi-host support","archived":false,"fork":false,"pushed_at":"2022-07-07T10:52:52.000Z","size":1576,"stargazers_count":41,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-19T11:48:53.607Z","etag":null,"topics":["icmp","icmp-sockets","linux","ping"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mitinarseny.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-05-22T13:10:26.000Z","updated_at":"2024-07-21T15:44:18.000Z","dependencies_parsed_at":"2022-07-09T15:02:19.079Z","dependency_job_id":null,"html_url":"https://github.com/mitinarseny/pingo","commit_stats":null,"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mitinarseny%2Fpingo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mitinarseny%2Fpingo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mitinarseny%2Fpingo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mitinarseny%2Fpingo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mitinarseny","download_url":"https://codeload.github.com/mitinarseny/pingo/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252562507,"owners_count":21768305,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["icmp","icmp-sockets","linux","ping"],"created_at":"2024-11-09T05:30:21.337Z","updated_at":"2025-05-05T19:29:27.604Z","avatar_url":"https://github.com/mitinarseny.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# pingo [![Go Reference](https://pkg.go.dev/badge/github.com/mitinarseny/pingo.svg)](https://pkg.go.dev/github.com/mitinarseny/pingo) [![Go](https://github.com/mitinarseny/pingo/actions/workflows/go.yml/badge.svg)](https://github.com/mitinarseny/pingo/actions/workflows/go.yml)\n\nFast and lightweight ping library for Golang with multi-host support.\n\n## Features\n\n* [ICMP sockets](https://lwn.net/Articles/420800):\n  * UDP port 0 means \"let the kernel pick a free number\"\n  * ICMP Echo Message ID is UDP port, so multiple instances of Pinger do not collide\n* Support for custom [setsockopt(2)](https://man7.org/linux/man-pages/man2/getsockopt.2.html)\n  and [sendmsg(2)](https://man7.org/linux/man-pages/man2/sendmsg.2.html) options\n* Support for Linux kernel RX and TX timestamps with\n  [SO_TIMESTAMPING](https://www.kernel.org/doc/Documentation/networking/timestamping.txt)\n* IPv4 and IPv6 support\n* ICMP sequence numbers manager (no random): O(1) time, 256kB of memory\n* [Context](https://pkg.go.dev/context) awareness\n\n## Requirements\n\n* go \u003e= 1.18\n* Linux kernel \u003e= 3.11\n\nYou may need to adjust\n[`ping_group_range`](https://www.kernel.org/doc/Documentation/networking/ip-sysctl.txt)\nsysfs to allow the creation of ICMP sockets:\n```sh\n$ echo 0 2147483647 \u003e /proc/sys/net/ipv4/ping_group_range\n```\n\n## Example\n\nHere is a simple [traceroute(8)](https://man7.org/linux/man-pages/man8/traceroute.8.html)\nimplementation:\n\n```go\ndst := net.IPv4(8, 8, 8, 8)\n\np, err := New(nil)\nif err != nil {\n\tfmt.Println(err)\n\treturn\n}\ndefer p.Close()\n\nctx, cancel := context.WithCancel(context.Background())\nvar g errgroup.Group\ng.Go(func() error {\n\treturn p.Listen(ctx)\n})\ndefer func() {\n\tcancel()\n\tif err := g.Wait(); !errors.Is(err, context.Canceled) {\n\t\tfmt.Println(err)\n\t}\n}()\n\nfor ttl := uint8(1); ttl \u003c math.MaxUint8-1; ttl++ {\n\tfmt.Printf(\"%3d: \", ttl)\n\tr, err := p.PingContextTimeout(ctx, dst, 1*time.Second, TTL(ttl))\n\tif errors.Is(err, context.DeadlineExceeded) {\n\t\t// no answer from current hop\n\t\tfmt.Println(\"...\")\n\t\tcontinue\n\t}\n\tfrom := dst\n\tswitch err := err.(type) {\n\tcase nil:\n\tcase TimeExceededError:\n\t\tfrom = err.From()\n\tdefault:\n\t\tfmt.Println(err)\n\t\treturn\n\t}\n\tfmt.Printf(\"%-15s %s\\n\", from, r.RTT)\n\tif err == nil {\n\t\treturn\n\t}\n}\nfmt.Println(\"TTL maxed out\")\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmitinarseny%2Fpingo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmitinarseny%2Fpingo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmitinarseny%2Fpingo/lists"}