mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-11-15 06:49:56 +00:00
bug6038: interims commit, starting to work on reverse hostname lookup
This commit is contained in:
1 parent
cab52516ac
commit
396cddb4e0
2 files changed
+27
No files matched your search
@@ -757,6 +757,17 @@ public interface AwsLandscape<ShardingKey> extends Landscape<ShardingKey> {
|
||||
|
||||
CompletableFuture<Iterable<ResourceRecordSet>> getResourceRecordSetsAsync(String hostname);
|
||||
|
||||
/**
|
||||
* For an IP address looks for Route53 resource records that hold an A- or AAAA-record pointing
|
||||
* to that {@code ipAddress} and returns the record set name as the hostname. This searches
|
||||
* the whole of all resource record sets in the AWS account.<p>
|
||||
*
|
||||
* Example: asking for "172.31.13.233" may return something like "mongo0.internal.sapsailing.com"
|
||||
*
|
||||
* @return the fully-qualified resource record set name if found, otherwise {@code null}
|
||||
*/
|
||||
String findHostnamesForIP(String ipAddress);
|
||||
|
||||
Iterable<ResourceRecordSet> getResourceRecordSets(String hostname);
|
||||
|
||||
DNSCache getNewDNSCache();
|
||||
|
||||
+16
@@ -181,6 +181,7 @@ import software.amazon.awssdk.services.route53.model.ChangeInfo;
|
||||
import software.amazon.awssdk.services.route53.model.ChangeResourceRecordSetsRequest;
|
||||
import software.amazon.awssdk.services.route53.model.ChangeResourceRecordSetsResponse;
|
||||
import software.amazon.awssdk.services.route53.model.GetChangeRequest;
|
||||
import software.amazon.awssdk.services.route53.model.HostedZone;
|
||||
import software.amazon.awssdk.services.route53.model.ListResourceRecordSetsResponse;
|
||||
import software.amazon.awssdk.services.route53.model.RRType;
|
||||
import software.amazon.awssdk.services.route53.model.ResourceRecord;
|
||||
@@ -1753,6 +1754,21 @@ public class AwsLandscapeImpl<ShardingKey> implements AwsLandscape<ShardingKey>
|
||||
Util.filter(response.resourceRecordSets(), resourceRecordSet->AwsLandscape.removeTrailingDotFromHostname(resourceRecordSet.name()).equals(hostname)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String findHostnamesForIP(String ipAddress) {
|
||||
final Route53Client route53Client = getRoute53Client();
|
||||
for (final HostedZone hostedZone : route53Client.listHostedZones().hostedZones()) {
|
||||
for (final ResourceRecordSet resourceRecordSet : route53Client.listResourceRecordSets(b->b.hostedZoneId(hostedZone.id())).resourceRecordSets()) {
|
||||
for (final ResourceRecord resourceRecord : resourceRecordSet.resourceRecords()) {
|
||||
if (Util.equalsWithNull(resourceRecord.value(), ipAddress)) {
|
||||
return resourceRecordSet.name();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<ResourceRecordSet> getResourceRecordSets(String hostname) {
|
||||
final Route53Client route53Client = getRoute53Client();
|
||||
|
||||
Reference in new issue
Block a user