potknocker/common/read.go

28 lines
416 B
Go
Raw Permalink Normal View History

2024-08-30 23:51:26 +00:00
package common
import (
"bufio"
"fmt"
"os"
"strings"
)
func readlist(list string, out chan string) {
fd, err := os.Open(list)
if err != nil {
fatal(err.Error())
}
defer fd.Close()
fs := bufio.NewScanner(fd)
for fs.Scan() {
line := strings.TrimSpace(fs.Text())
if len(line) > 0 {
if !validcidr(line) {
fatal(fmt.Sprintf("invalid target range: %s", line))
}
lcgcidr(line, out)
}
}
}