Commit 846b975
fix(mdns): defer setup-state mutation until validated; drop dead setters
Two cursorbot findings on 57968fd:
1. handleSetup assigned config.LocalAuthMode before validating the
password (length, bcrypt). On validation failure it returned
without SaveConfig, but the in-memory LocalAuthMode was already
dirty — so a subsequent restartMdns (e.g. from
networkStateChanged) would publish `setup=true` over Bonjour
even though the device hadn't actually been set up, and the
"Device is already set up" guard at the top of handleSetup
would refuse the user's retry. Move the assignment after all
validation succeeds, and roll back the in-memory state if
SaveConfig itself fails.
2. SetService / SetLocalNames / SetListenOptions (and their inner
set* helpers) are unused — only SetOptions is called from
restartMdns. Since they could even mislead future maintainers
into bypassing the atomic SetOptions path, drop them along with
the now-unused `reflect` import.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>1 parent 57968fd commit 846b975
2 files changed
Lines changed: 27 additions & 69 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
24 | 23 | | |
25 | 24 | | |
26 | 25 | | |
| |||
327 | 326 | | |
328 | 327 | | |
329 | 328 | | |
330 | | - | |
331 | | - | |
332 | | - | |
333 | | - | |
334 | | - | |
335 | | - | |
336 | | - | |
337 | | - | |
338 | | - | |
339 | | - | |
340 | | - | |
341 | | - | |
342 | | - | |
343 | | - | |
344 | | - | |
345 | | - | |
346 | | - | |
347 | | - | |
348 | | - | |
349 | | - | |
350 | | - | |
351 | | - | |
352 | | - | |
353 | | - | |
354 | | - | |
355 | | - | |
356 | | - | |
357 | | - | |
358 | | - | |
359 | | - | |
360 | | - | |
361 | | - | |
362 | | - | |
363 | | - | |
364 | | - | |
365 | | - | |
366 | | - | |
367 | | - | |
368 | | - | |
369 | | - | |
370 | | - | |
371 | | - | |
372 | | - | |
373 | | - | |
374 | | - | |
375 | | - | |
376 | | - | |
377 | | - | |
378 | | - | |
379 | | - | |
380 | | - | |
381 | | - | |
382 | | - | |
383 | | - | |
384 | 329 | | |
385 | 330 | | |
386 | 331 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
870 | 870 | | |
871 | 871 | | |
872 | 872 | | |
873 | | - | |
874 | | - | |
| 873 | + | |
| 874 | + | |
| 875 | + | |
| 876 | + | |
| 877 | + | |
| 878 | + | |
| 879 | + | |
875 | 880 | | |
876 | 881 | | |
877 | 882 | | |
| |||
890 | 895 | | |
891 | 896 | | |
892 | 897 | | |
893 | | - | |
894 | 898 | | |
895 | 899 | | |
896 | 900 | | |
897 | 901 | | |
898 | 902 | | |
899 | 903 | | |
900 | | - | |
901 | | - | |
902 | | - | |
903 | | - | |
904 | | - | |
905 | | - | |
906 | | - | |
907 | | - | |
908 | | - | |
| 904 | + | |
| 905 | + | |
909 | 906 | | |
910 | 907 | | |
911 | | - | |
912 | | - | |
| 908 | + | |
| 909 | + | |
| 910 | + | |
| 911 | + | |
| 912 | + | |
| 913 | + | |
| 914 | + | |
| 915 | + | |
| 916 | + | |
| 917 | + | |
| 918 | + | |
| 919 | + | |
| 920 | + | |
| 921 | + | |
913 | 922 | | |
914 | 923 | | |
915 | 924 | | |
916 | 925 | | |
| 926 | + | |
| 927 | + | |
| 928 | + | |
| 929 | + | |
917 | 930 | | |
918 | 931 | | |
919 | 932 | | |
| |||
0 commit comments