ErrorNoInternet / openheimer

An open-source remake of the Copenheimer project. Scan the entire internet for exposed Minecraft servers!
MIT License
32 stars 1 forks source link

The IP address on line 1 is invalid! #5

Open EmilWilder opened 1 year ago

EmilWilder commented 1 year ago

I have a file that consist ips from masscan that looks like this: 111.111.111.111 222.222.222.222 (has 3.5 million ip addresses) but when I try to use -ipFile ips.txt, it returns this error: The IP address on line 1 is invalid! Which format should I use? I even tried masscan default format which is: open tcp 25565 xx.xx.xx.xx 1680825136 still, no luck

EmilWilder commented 1 year ago

Okay fixed it I changed the readFromFile function on ips.go to continue even if there is an invalid ip

func readFromFile(filePath string, outputChannel chan string) int {
    log.Printf("Reading IPs from %v...\n", filePath)
    fileData, err := ioutil.ReadFile(filePath)
    if err != nil {
        log.Fatalf("Unable to read file: %v\n", err.Error())
        return 1
    }
    ips := strings.Split(strings.TrimSpace(string(fileData)), "\n")
    ok, _ := validateIps(ips)
    if !ok {
        log.Println("Some IP addresses are invalid")
    }
    log.Printf("Successfully read %v IP addresses from file\n", len(ips))
    for _, ip := range ips {
        if strings.TrimSpace(ip) != "" {
            outputChannel <- ip
        }
    }

    time.Sleep(100 * time.Millisecond)
    outputChannel <- "end"
    return 0
}
ErrorNoInternet commented 1 year ago

Are there trailing spaces on the lines? Or maybe your file uses CRLF line endings?