Created
June 25, 2013 00:51
-
-
Save sosedoff/5855047 to your computer and use it in GitHub Desktop.
Capture IPs from heroku log drain
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"os" | |
"bufio" | |
"regexp" | |
) | |
var IP_REGEX = regexp.MustCompile(`([\d]{1,3}\.[\d]{1,3}\.[\d]{1,3}\.[\d]{1,3})`) | |
func print_ip(str string) { | |
match := IP_REGEX.FindString(str) | |
if len(match) > 0 { | |
fmt.Println(match) | |
} | |
} | |
func main() { | |
reader := bufio.NewReader(os.Stdin) | |
for { | |
str, err := reader.ReadString('\n') | |
if err != nil { | |
fmt.Println("ERROR:", err) | |
break | |
} | |
print_ip(str) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment