Add lightweight shell-based macOS client (no Xcode required)#1
Open
sai99claw wants to merge 3 commits into
Open
Add lightweight shell-based macOS client (no Xcode required)#1sai99claw wants to merge 3 commits into
sai99claw wants to merge 3 commits into
Conversation
The original Swift Mac client (CsieDnsUpdater/) was written for Swift 1.x/2.x in 2015 and no longer compiles on modern Xcode toolchains. This adds a zero-dependency alternative using only bash, curl, and launchd — all of which ship with macOS. Layout: CsieDnsUpdater-Mac-Shell/ - csie-ddns.sh core updater - config.example.sh config template - io.csie.ddns-updater.plist.template LaunchAgent template - install.sh / uninstall.sh one-shot setup - README.md usage Behavioural notes: - Recognises current server response codes (OK, KO2, KO4, KO6) with distinct log messages. - Caches last-seen IP locally to avoid unnecessary API hits, but forces a re-send hourly as a safety net. - Falls back across multiple public-IP echo endpoints. - Token is read from ~/.csie-ddns.conf (chmod 600), never committed. The existing Swift and Java clients are untouched.
When the csie.io server rejects updates (e.g. KO5/KO6/KO7), the LaunchAgent was still firing every 5 min — which over a day adds up to ~290 useless requests and is an unfriendly client. Now: after 3 consecutive KO* responses the script writes a "next attempt" timestamp into ~/.csie-ddns.fail. Subsequent runs no-op until that timestamp elapses (default 6h). A single OK clears the state and the normal 5-min cadence resumes. Tunable via CSIE_BACKOFF_AFTER_FAILS (default 3) and CSIE_BACKOFF_SECONDS (default 21600 = 6h). Network errors (e.g. transient curl failures) do not count toward the backoff counter — only server-side rejections. Also added: explicit log messages for KO5 (token does not authorize this hostname — newer counterpart of KO6) and KO7 (server refused the IP change). These weren't recognised before.
Adds DDNS_PROVIDER=duckdns (default remains csie) so a single install and LaunchAgent can target either csie.io or DuckDNS by editing one config line. Motivation: when csie.io's update endpoint is unavailable or restricted for a hostname, users can repoint to DuckDNS without touching the LaunchAgent. Implementation: provider-specific block selects the update URL, host parameter name, and the human-readable record label used in logs. Rest of the script (IP fetch, state caching, backoff, response decoding) is shared. csie.io's KO2/KO4/KO5/KO6/KO7 and DuckDNS's plain KO are all recognised with distinct log messages. Response is trimmed for providers that append a trailing newline. Config keys for csie.io users are unchanged (CSIE_HOSTNAME, CSIE_TOKEN); DuckDNS users set DUCKDNS_DOMAIN and DUCKDNS_TOKEN. All operational knobs (log path, cache files, force-update interval, backoff) keep the CSIE_ prefix to preserve compatibility with any existing config files.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The existing Swift Mac client (
CsieDnsUpdater/) was written for Swift 1.x/2.x in 2015 and no longer compiles on modern Xcode toolchains. This PR adds a small, zero-dependency alternative atCsieDnsUpdater-Mac-Shell/that does exactly the same job using onlybash,curl, andlaunchd— all of which ship with macOS.Nothing existing is removed or modified — purely additive.
What it does
hostnameandtokenfrom~/.csie-ddns.conf(chmod 600, never committed)https://csie.io/update?hn=...&token=...&ip=...request~/Library/Logs/csie-ddns.logOK,KO2,KO4,KO6) with friendly log messages — the original client only knewOK/KOlaunchdLaunchAgent that runs every 5 minutes and survives rebootsLayout
Why
launchdapproach has fewer moving parts than a GUI app and doesn't need to stay running in the menu bar.Test plan
franksai.csie.io: script run → server returnsOK→ DNS resolves to the host's new public IPKO2/KO4/KO6produce distinct log lines🤖 Generated with Claude Code