aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan DeMasi <jon.demasi@colorado.edu>2019-06-05 11:57:56 -0600
committerJonathan DeMasi <jon.demasi@colorado.edu>2019-06-05 11:57:56 -0600
commit372e8ee5619f872c5d9e641fb354ebea6ceacb58 (patch)
tree7246f8b9c22b47b63d85318b39df8467da07679c
parent8d544748f39190294cfcce1e58a9d414c94609f9 (diff)
downloadgh_authkey_checker-372e8ee5619f872c5d9e641fb354ebea6ceacb58.tar
gh_authkey_checker-372e8ee5619f872c5d9e641fb354ebea6ceacb58.tar.gz
gh_authkey_checker-372e8ee5619f872c5d9e641fb354ebea6ceacb58.tar.bz2
gh_authkey_checker-372e8ee5619f872c5d9e641fb354ebea6ceacb58.tar.lz
gh_authkey_checker-372e8ee5619f872c5d9e641fb354ebea6ceacb58.tar.xz
gh_authkey_checker-372e8ee5619f872c5d9e641fb354ebea6ceacb58.tar.zst
gh_authkey_checker-372e8ee5619f872c5d9e641fb354ebea6ceacb58.zip
Added some error checking so DNS is not infinite
-rw-r--r--main.go9
1 files changed, 6 insertions, 3 deletions
diff --git a/main.go b/main.go
index 3ebcb97..fd775d8 100644
--- a/main.go
+++ b/main.go
@@ -7,6 +7,7 @@ import (
"os"
"net/http"
"io/ioutil"
+ "time"
)
func parseArgs() string {
@@ -48,10 +49,13 @@ func fetchKeys(username string) string {
// Need to fix this to not be an infinite loop
func checkResolvers() {
- for {
+ i := 0
+ for i < 3 {
_, err := net.LookupIP("github.com")
if err != nil {
- log.Println("No DNS yet...")
+ log.Println("No DNS yet, trying again in 5s")
+ time.Sleep(5 * time.Second)
+ i += 1
} else {
break
}
@@ -62,7 +66,6 @@ func checkResolvers() {
func main() {
username := parseArgs()
checkResolvers()
- //fmt.Println(username)
keys := fetchKeys(username)
fmt.Print(keys)
return