diff options
author | Jonathan DeMasi <jon.demasi@colorado.edu> | 2019-06-05 13:41:29 -0600 |
---|---|---|
committer | Jonathan DeMasi <jon.demasi@colorado.edu> | 2019-06-05 13:41:29 -0600 |
commit | 329e1848da07383ed695077ea5007a884882b30c (patch) | |
tree | 2e726c45d9cce8bb653f5b13ecd5e6e7c852dfa0 | |
parent | 77c6c6ed028e45e79ab9f9446b97c9449f021fa5 (diff) | |
download | gh_authkey_checker-329e1848da07383ed695077ea5007a884882b30c.tar gh_authkey_checker-329e1848da07383ed695077ea5007a884882b30c.tar.gz gh_authkey_checker-329e1848da07383ed695077ea5007a884882b30c.tar.bz2 gh_authkey_checker-329e1848da07383ed695077ea5007a884882b30c.tar.lz gh_authkey_checker-329e1848da07383ed695077ea5007a884882b30c.tar.xz gh_authkey_checker-329e1848da07383ed695077ea5007a884882b30c.tar.zst gh_authkey_checker-329e1848da07383ed695077ea5007a884882b30c.zip |
Logging adds, added check for user
-rw-r--r-- | main.go | 22 |
1 files changed, 21 insertions, 1 deletions
@@ -39,7 +39,7 @@ func fetchKeys(username string) string { if resp.StatusCode == http.StatusOK { bodyBytes, err := ioutil.ReadAll(resp.Body) if err != nil { - log.Fatal(err) + log.Fatalln(err) } bodyString := string(bodyBytes) return bodyString @@ -47,10 +47,29 @@ func fetchKeys(username string) string { return "" } +func checkUsername(username string) { + log.Printf("Checking for GitHub user %s", username) + + url := fmt.Sprintf("https://github.com/%s.keys", username) + response, err := http.Get(url) + if err != nil { + log.Fatalln(err) + } + + if response.StatusCode != http.StatusOK { + log.Fatalf("%s is an invalid user", username) + } + + log.Printf("Found valid user %s", username) + + return +} + // Need to fix this to not be an infinite loop func checkResolvers() { i := 1 for i < 3 { + log.Println("Checking if DNS is working") _, err := net.LookupIP("github.com") if err != nil { log.Println("No DNS yet, trying again in 5s") @@ -69,6 +88,7 @@ func checkResolvers() { func main() { username := parseArgs() checkResolvers() + checkUsername(username) keys := fetchKeys(username) fmt.Print(keys) return |