Created
September 16, 2013 16:31
-
-
Save darraghenright/6583029 to your computer and use it in GitHub Desktop.
wip
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 ( | |
"bufio" | |
"fmt" | |
"log" | |
"net" | |
"strings" | |
) | |
func main() { | |
url := "cainteach" | |
conn, err := net.Dial("tcp", "ie.whois-servers.net:43") | |
if err != nil { | |
fmt.Println(err) | |
} | |
fmt.Fprintf(conn, "%s.ie / HTTP/1.0\r\n\r\n", url) | |
scanner := bufio.NewScanner(conn) | |
for scanner.Scan() { | |
// no to empty strings | |
// no to string starting with % | |
// all other strings split on : and key/value paired | |
line := scanner.Text() | |
if len(line) > 0 && line[0] != 37 { | |
fields := strings.Fields(line) // k,v split | |
fmt.Println(fields) | |
} | |
} | |
if err := scanner.Err(); err != nil { | |
log.Fatal(err) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment