Repository navigation
Cleanup review, and recover from a local address change (eg after sleep) - #86
Conversation
…n, fix -interval and -sync-watch help
…hat only starts like home
…lper, change() without the unused version
…peersCleanup), mcastListen
…percentOf, paths.go, fmt.Appendf
… Esc) show a notice and only log in verbose
…stance) and concurrently
…nstance, syncStep, incomingFileFrame)
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #86 +/- ##
==========================================
+ Coverage 72.19% 72.77% +0.58%
==========================================
Files 31 32 +1
Lines 5779 5892 +113
==========================================
+ Hits 4172 4288 +116
+ Misses 1327 1321 -6
- Partials 280 283 +3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
🟡 Changes recommended
Regression coverage is missing for receiver-triggered shutdown and concurrent or subsequent Stop() calls, leaving potential shutdown hangs untested.
1 open issue
What changed in this PR
This PR cleans up tsync’s networking, crypto, and terminal UI code without changing the wire protocol. It also fixes malformed-key handling, home-path shortening, and duplicate-instance shutdown.
Changes:
- Consolidates shared helpers, configuration setup, and connection handling into smaller functions.
- Rejects invalid private-key lengths, corrects
ShortPath, and serializes shutdown while moving receiver-triggered shutdown off the receiver. - Expands API and directory-sync documentation, clarifies flag help, and adds notices for unknown keys.
| File | Description |
|---|---|
| tsnet/tsnet.go | Documents APIs, simplifies discovery, and revises shutdown handling. |
| tsnet/syncwatch.go | Reuses the shared parent-path helper. |
| tsnet/syncpull.go | Updates change notifications. |
| tsnet/sync.go | Extracts sync steps and reuses link and path helpers. |
| tsnet/link.go | Unifies link setup and execution for both connection directions. |
| tsnet/link_internal_test.go | Updates tests for renamed discovery internals. |
| tsnet/handshake.go | Simplifies status-change notifications. |
| tsnet/files.go | Extracts frame handling and reuses shared helpers. |
| tsnet/dirs.go | Reuses syncdir’s permission helper. |
| tcrypto/identity.go | Validates private-key length and documents identity APIs. |
| tcrypto/identity_test.go | Adds malformed-private-key regression cases. |
| tcrypto/file.go | Uses platform-aware paths and consolidates storage initialization. |
| tcrypto/errors.go | Documents crypto error types and constructors. |
| tcrypto/encoding.go | Documents encoding helpers. |
| tcrypto/ecdh.go | Removes the unused curve field and documents key exchange. |
| syncui.go | Reuses percentage calculations and relocates path helpers. |
| syncdir/index.go | Exposes shared parent-path and Windows-name helpers. |
| SYNC_DETAILS.md | Separates scanning and watching documentation. |
| README.md | Expands directory-sync guidance and revises usage examples. |
| paths.go | Centralizes path helpers and fixes home-prefix matching. |
| notice.go | Adds notices without logging. |
| main.go | Shares configuration setup and improves key and flag feedback. |
| main_test.go | Tests key names and unknown-key notices. |
| logarea.go | Documents the log-area constructor. |
| headless.go | Accepts the shared, fully configured sync settings. |
| fileui.go | Consolidates progress calculations and relocates path helpers. |
| fileui_test.go | Tests home-path matching boundaries. |
| clipui.go | Documents the clipboard-panel constructor. |
| clip.go | Documents bracketed-paste markers. |
Review effort: Balanced
…listen on all addresses, check the route every tick, close links from the old address
…rver, concurrent and later Stop calls return
There was a problem hiding this comment.
🟡 Changes recommended
The connection-closing logic disconnects healthy links on unrelated interfaces when the default-route address changes, disrupting active transfers; it should close only connections whose local IP matches old.IP.
1 open issue
1 resolved since last review
Review effort: Balanced
…not the ones from others (eg a VPN for -peers)


Code review cleanups and a fix for local address changes, no protocol change.
Fixes:
ShortPathof a directory that only starts like home (eg/Users/dlx).Stopis safe from a receiver goroutine (newer duplicate instance) and concurrently.sendto: can't assign requested address). Sockets now always listen on all addresses (like with-peers), the route to-targetis checked every discovery tick (nothing sent), and on change: new address used as ours (UI row too), multicast interface set and group rejoined, links from the old address closed so they reconnect. Our own discovery (same key and run id) is ignored from any address.Cleanups:
-intervaland-sync-watchhelp fixed.KeptMode,ParentKey,WindowsReservedNameinstead of copies.linkedLockedhelper,change()without the unused version.mcastSend,decodeDiscovery,peersCleanup),mcastListenrename.handleDiscovery,runSync,handleFileFrame.Ephemeral.Curve,percentOf,paths.go,fmt.Appendf.Tested: lint (darwin/linux/windows),
make test,make e2e.