Skip to content

Commit

Permalink
fix use case DNSResolver for Consul
Browse files Browse the repository at this point in the history
  • Loading branch information
belaban committed Feb 7, 2022
1 parent c79ee74 commit 5a1ac36
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
9 changes: 7 additions & 2 deletions src/org/jgroups/protocols/dns/AddressedDNSResolver.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public AddressedDNSResolver(String dnsContextFactory, String dnsAddress) throws
}

@Override
protected List<Address> resolveAEntries(String dnsQuery) {
protected List<Address> resolveAEntries(String dnsQuery, String srcPort) {
List<Address> addresses = new ArrayList<>();
try {
// We are parsing this kind of structure:
Expand All @@ -37,7 +37,12 @@ protected List<Address> resolveAEntries(String dnsQuery) {
NamingEnumeration<?> namingEnumeration = attributes.get(DNSRecordType.A.toString()).getAll();
while (namingEnumeration.hasMoreElements()) {
try {
addresses.add(new IpAddress(namingEnumeration.nextElement().toString()));
int p = Integer.parseInt(srcPort);
if (p == 0) {
addresses.add(new IpAddress(namingEnumeration.nextElement().toString()));
} else {
addresses.add(new IpAddress(namingEnumeration.nextElement().toString(), p));
}
} catch (Exception e) {
log.trace("non critical DNS resolution error", e);
}
Expand Down
2 changes: 1 addition & 1 deletion src/org/jgroups/protocols/dns/DefaultDNSResolver.java
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ protected List<Address> resolveAEntries(String dnsQuery) {
return resolveAEntries(dnsQuery, "0");
}

protected static List<Address> resolveAEntries(String dnsQuery, String srcPort) {
protected List<Address> resolveAEntries(String dnsQuery, String srcPort) {
List<Address> addresses = new ArrayList<>();
try {
InetAddress[] inetAddresses = InetAddress.getAllByName(dnsQuery);
Expand Down

0 comments on commit 5a1ac36

Please sign in to comment.