Commit a28fd7d
nssh: ntfy read deadlines + one-shot remote prep (#3)
## Summary
- Fix ntfy subscriber hanging on dead TCP sockets (overnight/sleep/NAT
rebind). Wrap the dialed `net.Conn` so every `Read` resets a 90s
deadline; ntfy's ~55s keepalives keep a healthy stream inside the
window, silence trips `i/o timeout` → reconnect.
- Collapse `checkRemoteVersion` + `writeRemoteSession` into a single
`bash -l -s` invocation (`prepareRemote`). Startup goes from 2 SSH
round-trips to 1 before the interactive session.
- Drop the now-unused `probeRemoteVersion`/`checkRemoteVersion` from
`infect.go`.
## Test plan
- [ ] `go build ./...` and `go test ./...` pass locally
- [ ] `nssh <host>` opens a session and the ntfy subscriber logs a
reconnect line if the network is bounced
- [ ] Leave a session idle > 2 minutes with no activity; clipboard still
works after
- [ ] Version-mismatch prompt still fires when the remote `nssh` is
outdated
- [ ] Missing-remote prompt still fires when `nssh` isn't installed on
the remote
🤖 Generated with [Claude Code](https://claude.com/claude-code)
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> **Medium Risk**
> Medium risk because it changes the ntfy streaming transport behavior
and refactors remote session initialization/version probing into a new
single SSH invocation, which could affect connection reliability and
upgrade prompts.
>
> **Overview**
> Improves reliability of the ntfy subscriber by dialing with TCP
keepalive, enforcing per-read deadlines (to detect zombie sockets), and
logging scanner errors before reconnecting.
>
> Refactors remote startup so version probing, session file write, and
remote JSONL log seeding happen in one `bash -l` SSH call
(`prepareRemote`), and removes the now-redundant remote version-check
helpers from `infect.go`. Also updates README wording to better describe
`nssh`’s purpose.
>
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
9af7c7e. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent cc0d7bc commit a28fd7d
3 files changed
Lines changed: 84 additions & 61 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
5 | 8 | | |
6 | 9 | | |
7 | 10 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
217 | 217 | | |
218 | 218 | | |
219 | 219 | | |
220 | | - | |
221 | | - | |
222 | | - | |
223 | | - | |
224 | | - | |
225 | | - | |
226 | | - | |
227 | | - | |
228 | | - | |
229 | | - | |
230 | | - | |
231 | | - | |
232 | | - | |
233 | | - | |
234 | | - | |
235 | | - | |
236 | | - | |
237 | | - | |
238 | | - | |
239 | | - | |
240 | 220 | | |
241 | 221 | | |
242 | 222 | | |
| |||
250 | 230 | | |
251 | 231 | | |
252 | 232 | | |
253 | | - | |
254 | | - | |
255 | | - | |
256 | | - | |
257 | | - | |
258 | | - | |
259 | | - | |
260 | | - | |
261 | | - | |
262 | | - | |
263 | | - | |
264 | | - | |
265 | | - | |
266 | | - | |
267 | | - | |
268 | | - | |
269 | | - | |
270 | | - | |
271 | | - | |
272 | | - | |
273 | | - | |
274 | | - | |
275 | | - | |
276 | 233 | | |
277 | 234 | | |
278 | 235 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
43 | | - | |
44 | | - | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
45 | 46 | | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
46 | 52 | | |
47 | 53 | | |
48 | 54 | | |
| |||
54 | 60 | | |
55 | 61 | | |
56 | 62 | | |
57 | | - | |
| 63 | + | |
58 | 64 | | |
59 | | - | |
60 | | - | |
61 | | - | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
62 | 70 | | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
63 | 83 | | |
64 | 84 | | |
65 | 85 | | |
| |||
177 | 197 | | |
178 | 198 | | |
179 | 199 | | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
180 | 215 | | |
181 | 216 | | |
182 | 217 | | |
183 | | - | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
184 | 232 | | |
185 | 233 | | |
186 | 234 | | |
| |||
214 | 262 | | |
215 | 263 | | |
216 | 264 | | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
217 | 268 | | |
218 | 269 | | |
219 | 270 | | |
| |||
385 | 436 | | |
386 | 437 | | |
387 | 438 | | |
388 | | - | |
389 | | - | |
390 | | - | |
391 | | - | |
392 | 439 | | |
393 | 440 | | |
394 | 441 | | |
| |||
401 | 448 | | |
402 | 449 | | |
403 | 450 | | |
404 | | - | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
405 | 468 | | |
406 | 469 | | |
407 | 470 | | |
| |||
0 commit comments