Skip to content

Commit

Permalink
Fix resolv.conf repairer logic (#1931)
Browse files Browse the repository at this point in the history
Stop the file repairer before doing the restore
  • Loading branch information
pappz authored May 6, 2024
1 parent 961d919 commit 735ed7a
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions client/internal/dns/file_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,24 +47,20 @@ func (f *fileConfigurator) supportCustomPort() bool {
}

func (f *fileConfigurator) applyDNSConfig(config HostDNSConfig) error {
backupFileExist := false
_, err := os.Stat(fileDefaultResolvConfBackupLocation)
if err == nil {
backupFileExist = true
}

backupFileExist := f.isBackupFileExist()
if !config.RouteAll {
if backupFileExist {
err = f.restore()
f.repair.stopWatchFileChanges()
err := f.restore()
if err != nil {
return fmt.Errorf("unable to configure DNS for this peer using file manager without a Primary nameserver group. Restoring the original file return err: %w", err)
return fmt.Errorf("restoring the original resolv.conf file return err: %w", err)
}
}
return fmt.Errorf("unable to configure DNS for this peer using file manager without a nameserver group with all domains configured")
}

if !backupFileExist {
err = f.backup()
err := f.backup()
if err != nil {
return fmt.Errorf("unable to backup the resolv.conf file: %w", err)
}
Expand Down Expand Up @@ -184,6 +180,11 @@ func (f *fileConfigurator) restoreUncleanShutdownDNS(storedDNSAddress *netip.Add
return nil
}

func (f *fileConfigurator) isBackupFileExist() bool {
_, err := os.Stat(fileDefaultResolvConfBackupLocation)
return err == nil
}

func restoreResolvConfFile() error {
log.Debugf("restoring unclean shutdown: restoring %s from %s", defaultResolvConfPath, fileUncleanShutdownResolvConfLocation)

Expand Down

0 comments on commit 735ed7a

Please sign in to comment.