hotfix(publicip): return an error if trying to use cloudflare as ip provider for updating servers data
This commit is contained in:
@@ -12,6 +12,8 @@ import (
|
||||
)
|
||||
|
||||
type API interface {
|
||||
String() string
|
||||
CanFetchAnyIP() bool
|
||||
FetchInfo(ctx context.Context, ip netip.Addr) (
|
||||
result models.PublicIP, err error)
|
||||
}
|
||||
|
||||
@@ -22,6 +22,14 @@ func newCloudflare(client *http.Client) *cloudflare {
|
||||
}
|
||||
}
|
||||
|
||||
func (c *cloudflare) String() string {
|
||||
return string(Cloudflare)
|
||||
}
|
||||
|
||||
func (c *cloudflare) CanFetchAnyIP() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// FetchInfo obtains information on the public IP address of the machine,
|
||||
// and returns an error if the `ip` argument is set since the Cloudflare API
|
||||
// can only be used to provide details about the current machine public IP.
|
||||
|
||||
@@ -20,6 +20,14 @@ func newIfConfigCo(client *http.Client) *ifConfigCo {
|
||||
}
|
||||
}
|
||||
|
||||
func (i *ifConfigCo) String() string {
|
||||
return string(IfConfigCo)
|
||||
}
|
||||
|
||||
func (i *ifConfigCo) CanFetchAnyIP() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// FetchInfo obtains information on the ip address provided
|
||||
// using the ifconfig.co/json API. If the ip is the zero value,
|
||||
// the public IP address of the machine is used as the IP.
|
||||
|
||||
@@ -23,6 +23,14 @@ func newIP2Location(client *http.Client, token string) *ip2Location {
|
||||
}
|
||||
}
|
||||
|
||||
func (i *ip2Location) String() string {
|
||||
return string(IP2Location)
|
||||
}
|
||||
|
||||
func (i *ip2Location) CanFetchAnyIP() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// FetchInfo obtains information on the ip address provided
|
||||
// using the api.ip2location.io API. If the ip is the zero value,
|
||||
// the public IP address of the machine is used as the IP.
|
||||
|
||||
@@ -24,6 +24,14 @@ func newIPInfo(client *http.Client, token string) *ipInfo {
|
||||
}
|
||||
}
|
||||
|
||||
func (i *ipInfo) String() string {
|
||||
return string(IPInfo)
|
||||
}
|
||||
|
||||
func (i *ipInfo) CanFetchAnyIP() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// FetchInfo obtains information on the ip address provided
|
||||
// using the ipinfo.io API. If the ip is the zero value, the public IP address
|
||||
// of the machine is used as the IP.
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
)
|
||||
|
||||
type Fetcher interface {
|
||||
String() string
|
||||
FetchInfo(ctx context.Context, ip netip.Addr) (
|
||||
result models.PublicIP, err error)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user