{"id":18341762,"url":"https://github.com/jerluc/pir","last_synced_at":"2025-04-06T06:31:52.551Z","repository":{"id":57600551,"uuid":"42378709","full_name":"jerluc/pir","owner":"jerluc","description":"A simple multicast LAN discovery library","archived":false,"fork":false,"pushed_at":"2015-09-14T01:45:55.000Z","size":176,"stargazers_count":6,"open_issues_count":5,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-21T18:51:49.511Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jerluc.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":"2015-09-13T00:54:33.000Z","updated_at":"2020-09-15T20:55:25.000Z","dependencies_parsed_at":"2022-09-26T19:53:35.225Z","dependency_job_id":null,"html_url":"https://github.com/jerluc/pir","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jerluc%2Fpir","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jerluc%2Fpir/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jerluc%2Fpir/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jerluc%2Fpir/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jerluc","download_url":"https://codeload.github.com/jerluc/pir/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247445649,"owners_count":20939952,"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":[],"created_at":"2024-11-05T20:28:24.763Z","updated_at":"2025-04-06T06:31:52.269Z","avatar_url":"https://github.com/jerluc.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"Pir\n===\n[![GoDoc](https://godoc.org/github.com/jerluc/pir?status.svg)](https://godoc.org/github.com/jerluc/pir) [![Build Status](https://travis-ci.org/jerluc/pir.svg)](https://travis-ci.org/jerluc/pir)\n\nPir is a simple library for facilitating in device discovery on a LAN.\n\n### Installation\n\n##### Using `go get`\n\n```bash\ngo get github.com/jerluc/pir\n```\n\n##### From source\n\n```bash\ngit clone https://github.com/jerluc/pir.git\ncd pir\ngo install\n```\n\n### Example usage\n\n##### Basic usage ([full source](examples/basic))\n```go\n// Start a healthcheck server\nhealthcheck := pir.NewHealthCheck()\nhealthcheck.Start()\n\n// Create a new peer\npeer, _ := pir.NewPeer(\"tcp://10.1.1.1:80\", healthcheck.URISpec())\n\n// Join the group on port 9999\ngroup := pir.NewGroup(group, 9999)\npeer.Join(group)\n```\n\n##### Receiving membership updates\n```go\ngroup.AddListener(func(event pir.MembershipEvent) bool {\n  fmt.Println(\"Membership change event has occurred:\", event)\n  return true\n})\n```\n\n### Discovery protocol\nPresently, this is done using a fairly common discovery protocol:\n\n* New peers join a group by connecting to a multicast UDP broadcast address.\n  * Once joined, each peer broadcasts a simple payload consisting of the participating group, peer ID, healthcheck URI, and communications URI: `GROUP_NAME|UUID4|proto://x.x.x.x:xxxxx|proto://x.x.x.x:xxxxx`\n* Each participating peer in the group consumes these broadcasts, creating and updating peer trackers. Trackers are updated by attempting to send and receive data over the healthcheck URI:\n  * Each successful send+receive improves tracker health\n  * Each failure or timeout degrades tracker health\n* When tracker health degrades beyond a certain threshold, the tracker is removed, rendering the tracked peer invisible to the tracker\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjerluc%2Fpir","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjerluc%2Fpir","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjerluc%2Fpir/lists"}