(content, host string)
| 63 | } |
| 64 | |
| 65 | func hasHostBlock(content, host string) bool { |
| 66 | s := bufio.NewScanner(strings.NewReader(content)) |
| 67 | for s.Scan() { |
| 68 | line := strings.TrimSpace(s.Text()) |
| 69 | if strings.HasPrefix(strings.ToLower(line), "host ") { |
| 70 | parts := strings.Fields(line[5:]) |
| 71 | for _, h := range parts { if h == host { return true } } |
| 72 | } |
| 73 | } |
| 74 | return false |
| 75 | } |
| 76 | |
| 77 | func replaceHostBlock(content, host, block string) string { |
| 78 | lines := strings.Split(content, "\n") |