mirror of
https://github.com/t94j0/AIRMASTER
synced 2026-06-08 17:42:17 +00:00
Updated with non-broken CUI
This commit is contained in:
@@ -16,9 +16,9 @@ import (
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
|
||||
// DomainCategorization is a struct that is returned by bluecoat when asked
|
||||
// Categorization is a struct that is returned by bluecoat when asked
|
||||
// to classify a domain
|
||||
type DomainCategorization struct {
|
||||
type Categorization struct {
|
||||
// URL of domain
|
||||
URL string `json:"url"`
|
||||
// Error is returned if there is an error checking the domain
|
||||
@@ -73,10 +73,9 @@ func CheckDomain(domain string, client *http.Client) error {
|
||||
newDomain := NewDomain(domainURL.Host, categorization)
|
||||
newDomain.PromptPurchase()
|
||||
return nil
|
||||
} else {
|
||||
fmt.Println("Found:", cat.URL, "-", categorization)
|
||||
return nil
|
||||
}
|
||||
fmt.Println("Found:", cat.URL, "-", categorization)
|
||||
return nil
|
||||
}
|
||||
default:
|
||||
return errors.New(cat.Error)
|
||||
@@ -85,8 +84,8 @@ func CheckDomain(domain string, client *http.Client) error {
|
||||
}
|
||||
|
||||
// makeRequest makes a bluecoat domain categorization request and returns a
|
||||
// DomainCategorization object
|
||||
func makeRequest(domain, captcha string, client *http.Client) (*DomainCategorization, error) {
|
||||
// Categorization object
|
||||
func makeRequest(domain, captcha string, client *http.Client) (*Categorization, error) {
|
||||
// Set captcha if a captcha is specified
|
||||
v := url.Values{}
|
||||
if captcha != "" {
|
||||
@@ -114,7 +113,7 @@ func makeRequest(domain, captcha string, client *http.Client) (*DomainCategoriza
|
||||
return nil, err
|
||||
}
|
||||
|
||||
cat := &DomainCategorization{}
|
||||
cat := &Categorization{}
|
||||
if err := json.NewDecoder(response.Body).Decode(cat); err != nil {
|
||||
fmt.Println(err)
|
||||
return nil, err
|
||||
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
// ParseFile takes a path and runs every domain through the CheckDomain function
|
||||
func ParseFile(filePath string) error {
|
||||
file, err := ioutil.ReadFile(filePath)
|
||||
if err != nil {
|
||||
|
||||
@@ -11,6 +11,7 @@ import (
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
|
||||
// ExpiredDomain is returned from scraping expireddomains.com
|
||||
type ExpiredDomain struct {
|
||||
Site string
|
||||
Registrars string
|
||||
@@ -30,6 +31,8 @@ type ExpiredDomain struct {
|
||||
Status string
|
||||
}
|
||||
|
||||
// ParseKeywords takes a list of keywords and scrapes expireddomains.com for
|
||||
// keywords and passes them into CheckDomain
|
||||
func ParseKeywords(keywords []string) error {
|
||||
pages := viper.GetInt("pages")
|
||||
keyword := strings.Join(keywords, " ")
|
||||
|
||||
+8
-1
@@ -65,7 +65,11 @@ func (d *Domain) PromptPurchase() {
|
||||
for {
|
||||
fmt.Printf("Choose an option: ")
|
||||
reader := bufio.NewReader(os.Stdin)
|
||||
input, _ := reader.ReadString('\n')
|
||||
input, err := reader.ReadString('\n')
|
||||
if err != nil {
|
||||
fmt.Fprintln(os.Stderr, err)
|
||||
break
|
||||
}
|
||||
input = strings.Trim(input, "\n")
|
||||
choice, err := strconv.Atoi(input)
|
||||
if err != nil {
|
||||
@@ -85,6 +89,9 @@ func (d *Domain) PromptPurchase() {
|
||||
fmt.Fprintln(os.Stderr, "Error purchasing domain:", err)
|
||||
break
|
||||
}
|
||||
|
||||
fmt.Println("Success!")
|
||||
break
|
||||
}
|
||||
fmt.Printf("\n\n")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user