{"id":50147073,"url":"https://github.com/creamlike1024/dn42-autopeer-daemon","last_synced_at":"2026-05-24T05:35:01.827Z","repository":{"id":326718253,"uuid":"1106623110","full_name":"creamlike1024/dn42-autopeer-daemon","owner":"creamlike1024","description":null,"archived":false,"fork":false,"pushed_at":"2026-03-21T06:28:03.000Z","size":97,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2026-03-21T22:25:09.278Z","etag":null,"topics":["autopeer","dn42"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/creamlike1024.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-11-29T16:05:21.000Z","updated_at":"2026-03-21T06:27:38.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/creamlike1024/dn42-autopeer-daemon","commit_stats":null,"previous_names":["creamlike1024/dn42-autopeer-daemon"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/creamlike1024/dn42-autopeer-daemon","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/creamlike1024%2Fdn42-autopeer-daemon","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/creamlike1024%2Fdn42-autopeer-daemon/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/creamlike1024%2Fdn42-autopeer-daemon/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/creamlike1024%2Fdn42-autopeer-daemon/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/creamlike1024","download_url":"https://codeload.github.com/creamlike1024/dn42-autopeer-daemon/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/creamlike1024%2Fdn42-autopeer-daemon/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33423284,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-23T22:14:44.296Z","status":"online","status_checked_at":"2026-05-24T02:00:06.296Z","response_time":57,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["autopeer","dn42"],"created_at":"2026-05-24T05:35:00.770Z","updated_at":"2026-05-24T05:35:01.817Z","avatar_url":"https://github.com/creamlike1024.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# dn42-autopeer-daemon\n\nA small daemon that automates adding and removing dn42 peers, and provides a simple API.\n\n## Build\n\nThe program uses a bundled version of SQLite, so a C compiler is required.\n\nYou can use [cargo-zigbuild](https://github.com/rust-cross/cargo-zigbuild) to easily build the musl version.\n\n```\ncargo zigbuild --release --target x86_64-unknown-linux-musl\n```\n\n## Requirements\n- Linux with `systemd` or Alpine Linux\n- `wireguard-tools-openrc` package installed(for Alpine Linux)\n- `wg-quick` is available\n- BIRD2 installed\n- Run as root (or grant sufficient permissions to complete all operations)\n\n## How It Works\nThe program assumes that you have a `/etc/bird/peers` folder based on the BIRD2 configuration from the DN42 wiki.\n\nIt does the following:\n- Writes peer info to `peers.db`\n- Generates WireGuard and BIRD configurations and places them in `/etc/wireguard` and `/etc/bird/peers`\n- On systemd-based Linux, runs `systemctl start wg-quick@\u003cinterface_name\u003e` to start the tunnel and `systemctl enable wg-quick@\u003cinterface_name\u003e` to enable autostart\n- On Alpine Linux (OpenRC), create per-interface symlink `ln -s /etc/init.d/wg-quick /etc/init.d/wg-quick.\u003cinterface_name\u003e`, then run `rc-service wg-quick.\u003cinterface_name\u003e start` to start the tunnel and `rc-update add wg-quick.\u003cinterface_name\u003e default` to enable autostart\n- Runs `birdc configure` to reload the BIRD configuration\n\n\n## Limitations\nThe templates are limited to using WireGuard tunnels and BIRD with MP-BGP. This is currently the popular peering method in the DN42 community.\n\nI have only tested on Debian and Alpine Linux.\n\n## Configuration\nFill in `config.toml`\n\n\n## API\n- Base URL: `http://\u003clisten_address\u003e:\u003capi_port\u003e`\n- Auth: add `Authorization: Bearer \u003csecret\u003e` when `API.secret` is set. If the header is missing or invalid, the response is `401 Unauthorized` with body `Unauthorized`.\n\n### POST `/add`\n\n```bash\ncurl -sS -X POST http://127.0.0.1:4242/add \\\n  -H \"Authorization: Bearer $SECRET\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\n        \"asn\": 4242421234,\n        \"wireguard_endpoint\": null,\n        \"wireguard_link_local\": \"fe80::beef\",\n        \"wireguard_public_key\": \"\u003cpeer_public_key\u003e\",\n        \"wireguard_preshared_key\": \"\u003coptional_preshared_key\u003e\",\n        \"mtu\": 1420\n      }'\n```\n\n**Notes on Optional Fields:**\n- `wireguard_endpoint`: (Optional) If omitted or set to `null`, the daemon configures the connection in **passive mode** (it listens for incoming connections but does not actively connect). If a valid endpoint address is provided (e.g., `\"peer.example.net:51820\"`), it operates in **active mode**. Empty strings or invalid formats are rejected.\n- `wireguard_preshared_key`: (Optional) If omitted or set to `null`, the connection will be established without a Pre-Shared Key. If a valid 32-byte Base64 encoded key is provided, the WireGuard configuration will utilize it (`PresharedKey`). Empty strings (`\"\"`) or incorrectly formatted keys are rejected.\n\nResponses:\n  - `200 OK`\n  - `400 Bad Request`\n  - `401 Unauthorized`\n  - `409 Conflict`\n  - `500 Internal Server Error`\n\n### POST `/del`\n\nCurl:\n```bash\ncurl -sS -X POST http://127.0.0.1:4242/del \\\n  -H \"Authorization: Bearer $SECRET\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{ \"asn\": 4242421234 }'\n```\n\nResponses:\n  - `200 OK`\n  - `400 Bad Request`\n  - `401 Unauthorized`\n  - `404 Not Found`\n  - `500 Internal Server Error`\n\n\n### POST `/get`\n\n\nCurl:\n```bash\ncurl -sS -X POST http://127.0.0.1:4242/get \\\n  -H \"Authorization: Bearer $SECRET\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{ \"asn\": 4242421234 }'\n```\nResponses:\n  - `200 OK` header: `Content-Type: application/json; charset=utf-8`; body is the peer object:\n    ```json\n    {\n      \"asn\": 4242420253,\n      \"wireguard_endpoint\": null,\n      \"wireguard_link_local\": \"fe80::abcd\",\n      \"wireguard_public_key\": \"\u003cpeer_public_key\u003e\",\n      \"wireguard_preshared_key\": null,\n      \"mtu\": 1420\n    }\n    ```\n  - `400 Bad Request`\n  - `401 Unauthorized` \n  - `404 Not Found`\n  - `500 Internal Server Error`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcreamlike1024%2Fdn42-autopeer-daemon","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcreamlike1024%2Fdn42-autopeer-daemon","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcreamlike1024%2Fdn42-autopeer-daemon/lists"}