feat: confirm + reversible DNS and hosts changes#810
Merged
Conversation
Round 2b of the audit — network mutations now confirm and are reversible. - HostsFileService.SaveHosts no longer overwrites the backup on every save. Previously File.Copy(..., overwrite: true) ran each save, so after the first write hosts.bak already held SysManager's own output and the pristine original was gone. Now the backup is created only when none exists, preserving the true pre-SysManager file. Added HasBackup + RestoreBackup, and a path-injection constructor so backup/restore is unit-testable without admin or System32. - DnsHostsViewModel: ApplyDns and SaveHosts now require DialogService.Confirm, stating what changes and how to revert; declining makes no change. Added a RestoreHosts command + 'Restore original' button (with AutomationProperties.Name). Tests: HostsFileServiceTests covers pristine-backup preservation across saves, restore-to-original, and no-backup handling.
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.
Round 2b of the audit — network mutations now confirm and are properly reversible.
Hosts file backup (P1 fix — data loss of the original)
SaveHostscopied the live hosts file overhosts.bakon every save (overwrite: true). After the first save the backup already contained SysManager's own output, so the pristine pre-SysManager original was gone and restore was impossible. Now the backup is written only when none exists, preserving the true original. AddedHasBackup+RestoreBackup.Confirmation gates
ApplyDnsandSaveHostsnow prompt withDialogService.Confirmfirst, stating what changes and how to revert. Declining makes no system change.Reversibility (new capability)
New
RestoreHostscommand + "Restore original" button (withAutomationProperties.Name) reverts the hosts file to the pristine backup.Testability
HostsFileServicegained a path-injection constructor (testing only — DI still uses the parameterless path). NewHostsFileServiceTests:RestoreBackupreturns falseVerification
dotnet buildmain + tests: 0 warnings, 0 errors. CHANGELOG + ARCHITECTURE updated; version 1.20.0 (feat → minor).