Skip to content

Commit

Permalink
Support adding an additional IP to a user account and domain
Browse files Browse the repository at this point in the history
  • Loading branch information
wolveix committed Aug 1, 2024
1 parent 213b8df commit 633a4df
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
27 changes: 27 additions & 0 deletions domain.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,33 @@ type Domain struct {
Username string `json:"username" yaml:"username"`
}

// AddDomainIP (user) adds an additional IP to a domain.
func (c *UserContext) AddDomainIP(domain string, ip string, createDNSRecords bool) error {
var response apiGenericResponse

body := url.Values{}
body.Set("action", "multi_ip")
body.Set("add", "yes")
body.Set("domain", domain)
body.Set("ip", ip)

if createDNSRecords {
body.Set("dns", "yes")
} else {
body.Set("dns", "no")
}

if _, err := c.makeRequestOld(http.MethodPost, "DOMAIN", body, &response); err != nil {
return fmt.Errorf("failed to add IP to domain: %v", err)
}

if response.Success != "IP Added" {
return fmt.Errorf("failed to add IP to domain: %v", response.Result)
}

return nil
}

// CheckDomainExists (user) checks if the given domain exists on the server
func (c *UserContext) CheckDomainExists(domain string) error {
return c.checkObjectExists(url.Values{
Expand Down
20 changes: 20 additions & 0 deletions reseller.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,26 @@ func (c *ResellerContext) CheckUserExists(username string) error {
})
}

// AddUserIP (reseller) adds an additional IP to a user's account.
func (c *ResellerContext) AddUserIP(username string, ip string) error {
var response apiGenericResponse

body := url.Values{}
body.Set("action", "multi_ip")
body.Set("extra_ip", ip)
body.Set("user", username)

if _, err := c.makeRequestOld(http.MethodPost, "MODIFY_USER", body, &response); err != nil {
return fmt.Errorf("failed to add IP to user account: %v", err)
}

if response.Success != "IP Added" {
return fmt.Errorf("failed to add IP to user account: %v", response.Result)
}

return nil
}

// CreateUser (reseller) create a user.
//
// The following fields must be populated: Domain, Email, IpAddresses, Package, Username
Expand Down

0 comments on commit 633a4df

Please sign in to comment.