28 lines
416 B
Go
28 lines
416 B
Go
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)
|
|
}
|
|
}
|
|
}
|