Skip to content

Commit

Permalink
chore(namecheap): make code only IPv4 compatible
Browse files Browse the repository at this point in the history
- Namecheap does not support IPv6 dynamic updates still
  • Loading branch information
qdm12 committed Jan 29, 2024
1 parent 67b83d4 commit b771b5c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 12 deletions.
1 change: 0 additions & 1 deletion internal/provider/errors/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ var (
ErrHostWildcard = errors.New(`host cannot be a "*"`)
ErrIPv4KeyNotSet = errors.New("IPv4 key is not set")
ErrIPv6KeyNotSet = errors.New("IPv6 key is not set")
ErrIPv6NotSupported = errors.New("IPv6 is not supported by this provider")
ErrKeyNotSet = errors.New("key is not set")
ErrKeyNotValid = errors.New("key is not valid")
ErrNameNotSet = errors.New("name is not set")
Expand Down
2 changes: 1 addition & 1 deletion internal/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ func New(providerName models.Provider, data json.RawMessage, domain, host string
case constants.LuaDNS:
return luadns.New(data, domain, host, ipVersion)
case constants.Namecheap:
return namecheap.New(data, domain, host, ipVersion)
return namecheap.New(data, domain, host)
case constants.NameCom:
return namecom.New(data, domain, host, ipVersion)
case constants.Netcup:
Expand Down
19 changes: 9 additions & 10 deletions internal/provider/providers/namecheap/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,12 @@ import (
type Provider struct {
domain string
host string
ipVersion ipversion.IPVersion
password string
useProviderIP bool
}

func New(data json.RawMessage, domain, host string,
ipVersion ipversion.IPVersion) (p *Provider, err error) {
if ipVersion == ipversion.IP6 {
return nil, fmt.Errorf("%w", errors.ErrIPv6NotSupported)
}
func New(data json.RawMessage, domain, host string) (
p *Provider, err error) {
extraSettings := struct {
Password string `json:"password"`
UseProviderIP bool `json:"provider_ip"`
Expand All @@ -43,7 +39,6 @@ func New(data json.RawMessage, domain, host string,
p = &Provider{
domain: domain,
host: host,
ipVersion: ipVersion,
password: extraSettings.Password,
useProviderIP: extraSettings.UseProviderIP,
}
Expand All @@ -65,7 +60,7 @@ func (p *Provider) isValid() error {
}

func (p *Provider) String() string {
return utils.ToString(p.domain, p.host, constants.Namecheap, p.ipVersion)
return utils.ToString(p.domain, p.host, constants.Namecheap, ipversion.IP4)
}

func (p *Provider) Domain() string {
Expand All @@ -77,7 +72,11 @@ func (p *Provider) Host() string {
}

func (p *Provider) IPVersion() ipversion.IPVersion {
return p.ipVersion
return ipversion.IP4
}

func (p *Provider) IPv6Suffix() netip.Prefix {
return netip.Prefix{}
}

func (p *Provider) Proxied() bool {
Expand All @@ -93,7 +92,7 @@ func (p *Provider) HTML() models.HTMLRow {
Domain: fmt.Sprintf("<a href=\"http://%s\">%s</a>", p.BuildDomainName(), p.BuildDomainName()),
Host: p.Host(),
Provider: "<a href=\"https://namecheap.com\">Namecheap</a>",
IPVersion: p.ipVersion.String(),
IPVersion: ipversion.IP4.String(),
}
}

Expand Down

0 comments on commit b771b5c

Please sign in to comment.