Skip to content

Commit

Permalink
Allow providing alternative WHOIS client implementations
Browse files Browse the repository at this point in the history
  • Loading branch information
Bradley Kemp committed Apr 2, 2021
1 parent d8558b7 commit 22ac178
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
7 changes: 7 additions & 0 deletions matchers/whois_client.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package matchers

import "os/exec"

var WHOISClient = func(query string) (rawResult []byte, err error) {
return exec.Command("whois", query).CombinedOutput()
}
3 changes: 1 addition & 2 deletions matchers/whois_matchers.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package matchers

import (
"fmt"
"os/exec"
"strings"
)

Expand All @@ -29,7 +28,7 @@ func whoisContains(contents string) func(string) bool {
}

func getContactsFromWHOIS(query string) ([]ProviderContact, error) {
rawWhois, err := exec.Command("whois", query).CombinedOutput()
rawWhois, err := WHOISClient(query)
if err != nil {
return nil, fmt.Errorf("failed to query whois: %s, %w", string(rawWhois), err)
}
Expand Down

0 comments on commit 22ac178

Please sign in to comment.