mirror of
https://github.com/t94j0/AIRMASTER
synced 2026-06-08 17:42:17 +00:00
Fixed
This commit is contained in:
@@ -46,7 +46,10 @@ The options are:
|
||||
* email - Email for contact
|
||||
* phone - Phone number (format: TODO)
|
||||
* fax - Fax number
|
||||
* mailing - Mailing number
|
||||
* address
|
||||
* city
|
||||
* postal
|
||||
* country_code - ISO ["Alpha 2 Code"](http://www.nationsonline.org/oneworld/country_code_list.htm)
|
||||
* godaddy - Godaddy configuration
|
||||
* key
|
||||
* secret
|
||||
|
||||
+27
@@ -19,6 +19,7 @@ var listCmd = &cobra.Command{
|
||||
Short: "List domains to purchase",
|
||||
Long: `List domains and have the option to purchase the domains as well`,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
checkConfig()
|
||||
// Configure domain finding mechanism
|
||||
if viper.GetString("file") != "" {
|
||||
if err := domain.ParseFile(viper.GetString("file")); err != nil {
|
||||
@@ -36,6 +37,32 @@ var listCmd = &cobra.Command{
|
||||
},
|
||||
}
|
||||
|
||||
func checkConfig() {
|
||||
godaddyConfig := []string{
|
||||
"godaddyKey",
|
||||
"godaddySecret",
|
||||
"first",
|
||||
"middle",
|
||||
"last",
|
||||
"organization",
|
||||
"title",
|
||||
"email",
|
||||
"phone",
|
||||
"address",
|
||||
"city",
|
||||
"state",
|
||||
"postal",
|
||||
"country_code",
|
||||
}
|
||||
|
||||
for _, c := range godaddyConfig {
|
||||
if viper.GetString(c) == "" {
|
||||
fmt.Printf("Not using GoDaddy (Provide %s)\n", c)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func init() {
|
||||
RootCmd.AddCommand(listCmd)
|
||||
|
||||
|
||||
+4
-1
@@ -48,7 +48,7 @@ func initConfig() {
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
// Search config in home directory with name ".AIRMASTER" (without extension).
|
||||
// Search config in home directory with name ".AIRMASTER"
|
||||
viper.AddConfigPath(home)
|
||||
viper.SetConfigName(".AIRMASTER")
|
||||
}
|
||||
@@ -58,5 +58,8 @@ func initConfig() {
|
||||
// If a config file is found, read it in.
|
||||
if err := viper.ReadInConfig(); err == nil {
|
||||
fmt.Println("Using config file:", viper.ConfigFileUsed())
|
||||
} else {
|
||||
fmt.Println(err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,7 +63,11 @@ func CheckDomain(domain string, client *http.Client, cooldown int64) error {
|
||||
categorization := getCategorization(cat.Categorization)
|
||||
// Purchase domain if that option is specified
|
||||
if viper.GetBool("purchase") {
|
||||
newDomain := NewDomain(cat.URL, categorization)
|
||||
domainURL, err := url.Parse(cat.URL)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
newDomain := NewDomain(domainURL.Host, categorization)
|
||||
newDomain.PromptPurchase()
|
||||
return nil
|
||||
} else {
|
||||
|
||||
@@ -48,6 +48,9 @@ func ParseKeywords(keywords []string) error {
|
||||
}
|
||||
|
||||
fmt.Println("Done getting domains")
|
||||
if len(rawDomains) == 0 {
|
||||
fmt.Println("No domains found")
|
||||
}
|
||||
|
||||
jar, err := cookiejar.New(&cookiejar.Options{})
|
||||
if err != nil {
|
||||
@@ -65,7 +68,7 @@ func ParseKeywords(keywords []string) error {
|
||||
!strings.Contains(domain.Status, "Auction") {
|
||||
|
||||
if err := CheckDomain(domain.Site, client, 0); err != nil {
|
||||
fmt.Println("Error checking domain:", err)
|
||||
fmt.Println("Error checking domain ("+domain.Site+"):", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+35
-20
@@ -30,29 +30,39 @@ type Domain struct {
|
||||
var ErrUnavailable = errors.New("Domain unavailable")
|
||||
|
||||
func NewDomain(url, categorization string) *Domain {
|
||||
return &Domain{url, categorization, 0, 0}
|
||||
return &Domain{url, categorization}
|
||||
}
|
||||
|
||||
func (d *Domain) PromptPurchase() {
|
||||
fmt.Println("This feature has not been implemented!")
|
||||
return
|
||||
var clientList []Registrars
|
||||
|
||||
clientList := []Registrars{
|
||||
godaddy.NewClient(
|
||||
viper.GetString("godaddy.key"),
|
||||
viper.GetString("godaddy.secret"),
|
||||
godaddy.Contact{
|
||||
viper.GetString("user.first"),
|
||||
viper.GetString("user.middle"),
|
||||
viper.GetString("user.last"),
|
||||
viper.GetString("user.organization"),
|
||||
viper.GetString("user.title"),
|
||||
viper.GetString("user.email"),
|
||||
viper.GetString("user.phone"),
|
||||
viper.GetString("user.fax"),
|
||||
viper.GetString("user.mailing"),
|
||||
godaddyClient, err := godaddy.NewClient(
|
||||
viper.GetString("godaddyKey"),
|
||||
viper.GetString("godaddySecret"),
|
||||
godaddy.Contact{
|
||||
viper.GetString("first"),
|
||||
viper.GetString("middle"),
|
||||
viper.GetString("last"),
|
||||
viper.GetString("organization"),
|
||||
viper.GetString("title"),
|
||||
viper.GetString("email"),
|
||||
viper.GetString("phone"),
|
||||
viper.GetString("fax"),
|
||||
godaddy.Address{
|
||||
viper.GetString("address"),
|
||||
viper.GetString("city"),
|
||||
viper.GetString("state"),
|
||||
viper.GetString("postal"),
|
||||
viper.GetString("country_code"),
|
||||
},
|
||||
),
|
||||
},
|
||||
)
|
||||
|
||||
// TODO: Have a more elegant way to handle this
|
||||
if err == nil {
|
||||
clientList = append(clientList, godaddyClient)
|
||||
} else {
|
||||
fmt.Println(err)
|
||||
}
|
||||
|
||||
for _, client := range clientList {
|
||||
@@ -61,16 +71,21 @@ func (d *Domain) PromptPurchase() {
|
||||
fmt.Fprintln(os.Stderr, "Error getting availability:", err)
|
||||
continue
|
||||
}
|
||||
|
||||
if isAvailable {
|
||||
fmt.Printf(
|
||||
"Would you like to purchase \"%s\" (%s) for %d from %s (y/N): ",
|
||||
d.URL, d.Categorization, price, client.GetName,
|
||||
d.URL, d.Categorization, price, client.GetName(),
|
||||
)
|
||||
reader := bufio.NewReader(os.Stdin)
|
||||
input, _ := reader.ReadString('\n')
|
||||
if strings.Contains(input, "Y") || strings.Contains(input, "y") {
|
||||
client.Purchase(d.URL)
|
||||
if err := client.Purchase(d.URL); err != nil {
|
||||
fmt.Fprintln(os.Stderr, "Error purchasing domain:", err)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
fmt.Printf("Found %s, but not available\n", d.URL)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user