mirror of
https://github.com/qdm12/ddns-updater.git
synced 2026-04-05 08:54:09 -04:00
chore(all): format code using gofumpt
This commit is contained in:
@@ -79,7 +79,8 @@ func Test_IPv6(t *testing.T) {
|
||||
|
||||
func Fuzz_IPv6(f *testing.F) {
|
||||
f.Fuzz(func(_ *testing.T, ipv6A, ipv6B, ipv6C []byte,
|
||||
garbageA, garbageB, garbageC string) {
|
||||
garbageA, garbageB, garbageC string,
|
||||
) {
|
||||
var arrayA [16]byte
|
||||
if len(ipv6A) > 0 {
|
||||
copy(arrayA[:], ipv6A)
|
||||
|
||||
@@ -20,7 +20,8 @@ var (
|
||||
)
|
||||
|
||||
func fetch(ctx context.Context, client Client, network string,
|
||||
providerData providerData) (publicIPs []netip.Addr, err error) {
|
||||
providerData providerData,
|
||||
) (publicIPs []netip.Addr, err error) {
|
||||
var serverHost string
|
||||
switch network {
|
||||
case "tcp":
|
||||
@@ -80,9 +81,7 @@ func fetch(ctx context.Context, client Client, network string,
|
||||
return publicIPs, nil
|
||||
}
|
||||
|
||||
var (
|
||||
ErrTooManyTXTRecords = errors.New("too many TXT records")
|
||||
)
|
||||
var ErrTooManyTXTRecords = errors.New("too many TXT records")
|
||||
|
||||
func handleAnswerTXT(answer dns.RR) (publicIP netip.Addr, err error) {
|
||||
answerTXT, ok := answer.(*dns.TXT)
|
||||
|
||||
@@ -11,9 +11,7 @@ import (
|
||||
"github.com/miekg/dns"
|
||||
)
|
||||
|
||||
var (
|
||||
ErrIPNotFoundForVersion = errors.New("IP addresses found but not for IP version")
|
||||
)
|
||||
var ErrIPNotFoundForVersion = errors.New("IP addresses found but not for IP version")
|
||||
|
||||
func (f *Fetcher) IP(ctx context.Context) (publicIP netip.Addr, err error) {
|
||||
publicIPs, err := f.ip(ctx, "tcp")
|
||||
@@ -52,7 +50,8 @@ func (f *Fetcher) IP6(ctx context.Context) (publicIP netip.Addr, err error) {
|
||||
}
|
||||
|
||||
func (f *Fetcher) ip(ctx context.Context, network string) (
|
||||
publicIPs []netip.Addr, err error) {
|
||||
publicIPs []netip.Addr, err error,
|
||||
) {
|
||||
index := int(atomic.AddUint32(f.ring.counter, 1)) % len(f.ring.providers)
|
||||
providerData := f.ring.providers[index].data()
|
||||
|
||||
|
||||
@@ -20,7 +20,8 @@ var (
|
||||
)
|
||||
|
||||
func fetch(ctx context.Context, client *http.Client, url string,
|
||||
version ipversion.IPVersion) (publicIP netip.Addr, err error) {
|
||||
version ipversion.IPVersion,
|
||||
) (publicIP netip.Addr, err error) {
|
||||
request, err := http.NewRequestWithContext(ctx, http.MethodGet, url, nil)
|
||||
if err != nil {
|
||||
return netip.Addr{}, err
|
||||
|
||||
@@ -23,7 +23,8 @@ func (f *Fetcher) IP6(ctx context.Context) (publicIP netip.Addr, err error) {
|
||||
}
|
||||
|
||||
func (f *Fetcher) ip(ctx context.Context, ring *urlsRing, version ipversion.IPVersion) (
|
||||
publicIP netip.Addr, err error) {
|
||||
publicIP netip.Addr, err error,
|
||||
) {
|
||||
ring.mutex.Lock()
|
||||
|
||||
var index int
|
||||
|
||||
@@ -109,7 +109,8 @@ func Test_fetcher_IP6(t *testing.T) {
|
||||
httpBytes := []byte(`::1`)
|
||||
expectedPublicIP := netip.AddrFrom16([16]byte{
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 1})
|
||||
0, 0, 0, 0, 0, 0, 0, 1,
|
||||
})
|
||||
|
||||
client := &http.Client{
|
||||
Transport: roundTripFunc(func(r *http.Request) (*http.Response, error) {
|
||||
|
||||
@@ -19,8 +19,10 @@ func Test_ListProvidersForVersion(t *testing.T) {
|
||||
}{
|
||||
"ip4or6": {
|
||||
version: ipversion.IP4or6,
|
||||
providers: []Provider{Ifconfig, Ipify, Ipinfo, Spdyn, Ipleak,
|
||||
Icanhazip, Ident, Nnev, Wtfismyip, Seeip, Changeip},
|
||||
providers: []Provider{
|
||||
Ifconfig, Ipify, Ipinfo, Spdyn, Ipleak,
|
||||
Icanhazip, Ident, Nnev, Wtfismyip, Seeip, Changeip,
|
||||
},
|
||||
},
|
||||
"ip4": {
|
||||
version: ipversion.IP4,
|
||||
|
||||
@@ -19,7 +19,8 @@ type ip2Location struct {
|
||||
}
|
||||
|
||||
func (p *ip2Location) get(ctx context.Context, ip netip.Addr) (
|
||||
result Result, err error) {
|
||||
result Result, err error,
|
||||
) {
|
||||
result.Source = string(Ipinfo)
|
||||
|
||||
url := "https://api.ip2location.io/"
|
||||
|
||||
@@ -19,7 +19,8 @@ type ipinfo struct {
|
||||
}
|
||||
|
||||
func (p *ipinfo) get(ctx context.Context, ip netip.Addr) (
|
||||
result Result, err error) {
|
||||
result Result, err error,
|
||||
) {
|
||||
result.Source = string(Ipinfo)
|
||||
|
||||
url := "https://ipinfo.io/"
|
||||
|
||||
Reference in New Issue
Block a user