- Rust 96.1%
- Shell 3.9%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
|
All checks were successful
ci / test (push) Successful in 5m6s
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> |
||
| .forgejo/workflows | ||
| contrib | ||
| docs | ||
| scripts | ||
| src | ||
| .gitattributes | ||
| .gitignore | ||
| Cargo.lock | ||
| Cargo.toml | ||
| install.sh | ||
| LICENSE | ||
| README.md | ||
yggpick
Keeps a Yggdrasil node on its best public peer, with a standby ready for when it drops.
yggpick ranks peers the way the core picks a parent in the tree: latency × (depth to the root + 1). It keeps exactly one active peer in the config and one standby in reserve, and switches to the standby when the active peer goes down.
It works with Yggdrasil-ng (/etc/yggdrasil.toml) and yggdrasil-go 0.5 (/etc/yggdrasil.conf, HJSON or JSON) on Linux x86_64, aarch64 and armv7. One static binary, no runtime dependencies.
Quick start
curl -fsSL https://git.shd.company/bubblegum/yggpick/raw/branch/main/install.sh | sudo sh
sudo yggpick pick --dry-run # what it would choose; changes nothing
sudo yggpick status # what it chose
config /etc/yggdrasil.toml (Ng)
peers tls://192.0.2.41:443?sni=fra1.example.net
active tls://192.0.2.41:443?sni=fra1.example.net [up]
backup tcp://ams.example.org:9002
root 0000000a3f6c0b2d9e1c7f4a85b6d2e09c3f1a7b4e8d5c2f6a9b3e7d1c4f8a2b
Install and update
The install script downloads the latest release for your architecture, checks its sha256 and installs /usr/local/bin/yggpick and the systemd unit. On first install it enables the service. Run it again to update: it replaces the binary and restarts the service when a new version is out, and changes nothing otherwise. To install a specific version, set YGGPICK_VERSION=v0.1.0 before sh.
How it picks
- Takes peers from the public list publicnodes.json: only those up now, with at least 90% uptime, using
tls,tcp,wsorwss. - Stage A. Opens 5 TCP connections to each candidate directly through your ISP and keeps the 8 fastest.
- Stage B. Adds those 8 to the running daemon over its admin socket, reads each one's depth to the root from
gettreeand takes latency as the median of the core's RTT over 15 seconds. Peers in another tree are dropped, and so are peers whose link was down in more than 1 of 5 seconds or dropped after coming up (a peer that connects and then keeps timing out). - Switches to a new peer only when it beats the current one by at least 15%. The next best peer becomes the standby, preferably from another /24 (IPv4) or /48 (IPv6).
- Leaves exactly one peer in the config, saves the standby to
/var/lib/yggpick/state.jsonand removes the probe links.
tcp and tls peers are written by the IP address that answered in stage A, with the name kept in sni= for TLS. The daemon then needs no DNS and cannot end up on a dead IPv6 address.
Every minute yggpick checks the active peer. If it stays down for 2 minutes, or looks up but reconnected within each of 2 checks in a row (the daemon reports the link's uptime), yggpick switches to the standby and looks for a new one 5 minutes later. A full pick also runs once a day and when the tree root changes, at most once an hour.
Commands
| Command | What it does |
|---|---|
yggpick run |
runs as a daemon, started by systemd |
sudo yggpick pick |
runs one pick and applies it |
sudo yggpick pick --dry-run |
runs a pick and prints the table without changing anything |
sudo yggpick status |
shows the config, active peer, standby and root |
--config PATH sets the daemon config. Without it yggpick uses the first that exists of /etc/yggdrasil.toml, /etc/yggdrasil.conf, /etc/yggdrasil/yggdrasil.toml and /etc/yggdrasil/yggdrasil.conf (the yggdrasil-go Debian package). The admin socket comes from the config's AdminListen; without it yggpick uses the daemon's default, /var/run/yggdrasil/yggdrasil.sock for a config in /etc/yggdrasil/ (Debian package) and /var/run/yggdrasil.sock otherwise. RUST_LOG=debug turns on verbose logging.
Service settings
The installer overwrites /etc/systemd/system/yggpick.service, so put your changes in a drop-in. For example, if your Yggdrasil service has another name or the config lives elsewhere:
sudo mkdir -p /etc/systemd/system/yggpick.service.d
sudo tee /etc/systemd/system/yggpick.service.d/local.conf <<'EOF'
[Unit]
After=yggdrasil-ng.service
[Service]
ExecStart=
ExecStart=/usr/local/bin/yggpick run --config /opt/ygg/yggdrasil.toml
EOF
sudo systemctl daemon-reload && sudo systemctl restart yggpick
Files
| Path | Contents |
|---|---|
the daemon config (see --config) |
yggpick edits only the peer list; comments and other keys stay as they are |
<config>.yggpick.bak |
the config as it was before yggpick's first write; delete it to take a fresh copy on the next write |
/var/lib/yggpick/state.json |
active peer, standby, root |
/var/lib/yggpick/pick.lock |
lock that keeps two picks from running at once |
/var/cache/yggpick/publicnodes.json |
the peer list; used for up to a week when the download fails |
Limitations
- yggpick runs as root: it writes to
/etcand talks to the admin socket. quic://peers are skipped, since stage A only tests TCP.wsandwsspeers keep their host name, because a proxy in front of them may route by Host. On a host with broken IPv6 they may not come up.- If a pick is already running,
yggpick pickexits with an error instead of waiting. - If the daemon config is a symlink, writing it replaces the link with a regular file.
Uninstall
sudo systemctl disable --now yggpick
sudo rm /usr/local/bin/yggpick /etc/systemd/system/yggpick.service
sudo rm -rf /etc/systemd/system/yggpick.service.d /var/lib/yggpick /var/cache/yggpick
sudo systemctl daemon-reload
The daemon config keeps the last chosen peer. To get your old peer list back, copy <config>.yggpick.bak over the config.
Build from source
cargo build --release
sudo install -m 755 target/release/yggpick /usr/local/bin/
License
GPL-3.0-only, see LICENSE. The peer selection logic comes from Huginn.