Create CNAME

This commit is contained in:
2025-11-28 12:31:45 +00:00
parent 22552aec99
commit 9c1c1eb9c6
17 changed files with 939 additions and 156 deletions
+17
View File
@@ -292,6 +292,23 @@ type BackupInfo struct {
Size int64
}
// GetBackupContent returns the content of a backup file.
func (m *HostsManager) GetBackupContent(name string) (string, error) {
backupPath := filepath.Join(m.backupDir, name)
// Validate backup name to prevent path traversal
if filepath.Base(name) != name || !strings.HasPrefix(name, "hosts.") || !strings.HasSuffix(name, ".bak") {
return "", fmt.Errorf("invalid backup name")
}
content, err := os.ReadFile(backupPath)
if err != nil {
return "", fmt.Errorf("failed to read backup: %w", err)
}
return string(content), nil
}
// RestoreBackup restores a backup by name.
func (m *HostsManager) RestoreBackup(name string) error {
backupPath := filepath.Join(m.backupDir, name)