feat: Add support for legacy markers in ParseManagedBlock to ensure backward compatibility

This commit is contained in:
2026-03-04 18:05:54 -05:00
parent 6b07c9e2e1
commit 25aa16be14
3 changed files with 141 additions and 2 deletions
+6 -2
View File
@@ -17,13 +17,17 @@ func ParseManagedBlock(lines []string) (prefix, managed, postfix []string, hasMa
endCount := 0
for i, line := range lines {
if strings.Contains(line, "ekDNSHelper <<-> START CONFIG") {
// Recognise both current and legacy markers so that hosts files
// written by the old "DNSHelper" binary are parsed correctly.
if strings.Contains(line, "ekDNSHelper <<-> START CONFIG") ||
strings.Contains(line, "DNSHelper <<-> START CONFIG") {
startCount++
if startIdx == -1 {
startIdx = i
}
}
if strings.Contains(line, "ekDNSHelper <->> END CONFIG") {
if strings.Contains(line, "ekDNSHelper <->> END CONFIG") ||
strings.Contains(line, "DNSHelper <->> END CONFIG") {
endCount++
if endIdx == -1 {
endIdx = i