Last active
January 30, 2021 21:21
-
-
Save mahdyar/fbbb8c925263dd22999994bfa69c2c89 to your computer and use it in GitHub Desktop.
Whois lookup script written in Golang for .ir domains
This file contains hidden or 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" | |
"net" | |
) | |
/************************************************************************* | |
Author: Mahdyar | |
Github: https://github.com/mahdyar | |
*************************************************************************/ | |
func whois(domainName string) string { | |
server := "whois.nic.ir" | |
conn, err := net.Dial("tcp", server+":43") | |
if err != nil { | |
fmt.Println("Err!") | |
} | |
defer conn.Close() | |
conn.Write([]byte(domainName + "\r\n")) | |
buf := make([]byte, 1024) | |
result := []byte{} | |
for { | |
numBytes, err := conn.Read(buf) | |
sbuf := buf[0:numBytes] | |
result = append(result, sbuf...) | |
if err != nil { | |
break | |
} | |
} | |
return string(result) | |
} | |
func main() { | |
result := whois("mahdyar.ir") | |
fmt.Println(result) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment