mirror of
https://github.com/qdm12/ddns-updater.git
synced 2026-04-05 08:54:09 -04:00
fix(publicip/dns): use address of Cloudflare for ipv4 or ipv6
This commit is contained in:
@@ -24,7 +24,7 @@ func fetch(ctx context.Context, client Client, network string,
|
|||||||
var serverHost string
|
var serverHost string
|
||||||
switch network {
|
switch network {
|
||||||
case "tcp":
|
case "tcp":
|
||||||
serverHost = providerData.TLSName
|
serverHost = providerData.Address
|
||||||
case "tcp4":
|
case "tcp4":
|
||||||
serverHost = providerData.IPv4.String()
|
serverHost = providerData.IPv4.String()
|
||||||
case "tcp6":
|
case "tcp6":
|
||||||
|
|||||||
@@ -102,12 +102,12 @@ func Test_fetch(t *testing.T) {
|
|||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
|
|
||||||
client := mock_dns.NewMockClient(ctrl)
|
client := mock_dns.NewMockClient(ctrl)
|
||||||
expectedAddress := net.JoinHostPort(providerData.TLSName, "853")
|
expectedAddress := net.JoinHostPort(providerData.Address, "853")
|
||||||
client.EXPECT().
|
client.EXPECT().
|
||||||
ExchangeContext(ctx, expectedMessage, expectedAddress).
|
ExchangeContext(ctx, expectedMessage, expectedAddress).
|
||||||
Return(testCase.response, time.Millisecond, testCase.exchangeErr)
|
Return(testCase.response, time.Millisecond, testCase.exchangeErr)
|
||||||
|
|
||||||
const network = "tcp" // so it picks the TLSName field as the address
|
const network = "tcp" // so it picks the Address field as the address
|
||||||
publicIPs, err := fetch(ctx, client, network, providerData)
|
publicIPs, err := fetch(ctx, client, network, providerData)
|
||||||
|
|
||||||
if testCase.err != nil {
|
if testCase.err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user