Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var blShortReply = make([]string, 0, 10)
- if !strings.HasPrefix(event.Message, "!lookup") {
- return // We weren't given a !lookup command
- }
- StringMessageSplit := strings.Split(event.Message, " ")
- if len(StringMessageSplit) < 1 {
- return // We weren't given anything after the !lookup command
- }
- IPToCheck := net.ParseIP(StringMessageSplit[1]).To4() // Only handles IPv4, currently.
- if IPToCheck == nil {
- ircbot.writesocket <- fmt.Sprintf("PRIVMSG %s :Wasn't given a valid IP, %s\r\n", event.Arguments[0], StringMessageSplit[1])
- return // We weren't given a valid IP
- }
- /* If we have made it to this point we have a valid IP and should begin doing blacklist lookups. */
- StringIP := IPToCheck.String() // Turn the IP into a String for processing
- StringIPSplit := strings.Split(StringIP, ".") // Split the IP by .
- DroneBL := fmt.Sprintf("%s.%s.%s.%s.dnsbl.dronebl.org", StringIPSplit[3], StringIPSplit[2], StringIPSplit[1], StringIPSplit[0])
- DroneBLReply, _ := net.LookupHost(DroneBL)
- ircbot.writesocket <- fmt.Sprintf("PRIVMSG %s :Looking up: %s\r\n", event.Arguments[0], StringIP)
- if len(DroneBLReply) == 0 {
- ircbot.writesocket <- fmt.Sprintf("PRIVMSG %s :No listings for %s\r\n", event.Arguments[0], StringIP)
- return // Not listed in DroneBL!
- }
- /* Loop over all of the replies and append the last octet to blShortReply */
- for key := range DroneBLReply {
- blFullReply := strings.Split(DroneBLReply[key], ".")
- blShortReply = append(blShortReply, blFullReply[3])
- }
- /* IP was listed in DroneBL, print the listings to the channel. */
- ircbot.writesocket <- fmt.Sprintf("PRIVMSG %s :dnsbl return: %s\r\n", event.Arguments[0], blShortReply)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement