fix(publicip/dns): use address of Cloudflare for ipv4 or ipv6

This commit is contained in:
Quentin McGaw
2024-01-31 14:25:05 +00:00
parent dc2b7aaa0b
commit 875cd027d7
2 changed files with 3 additions and 3 deletions

View File

@@ -24,7 +24,7 @@ func fetch(ctx context.Context, client Client, network string,
var serverHost string
switch network {
case "tcp":
serverHost = providerData.TLSName
serverHost = providerData.Address
case "tcp4":
serverHost = providerData.IPv4.String()
case "tcp6":

View File

@@ -102,12 +102,12 @@ func Test_fetch(t *testing.T) {
ctx := context.Background()
client := mock_dns.NewMockClient(ctrl)
expectedAddress := net.JoinHostPort(providerData.TLSName, "853")
expectedAddress := net.JoinHostPort(providerData.Address, "853")
client.EXPECT().
ExchangeContext(ctx, expectedMessage, expectedAddress).
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)
if testCase.err != nil {