plugin: add DNS names
This adds DNS names to the output for host queries. Hosts are discovered in private, then public order, first at the top-level, and then through attached network interfaces. This mirrors the discovery order of IP addresses.
This commit is contained in:
2 files changed
+61
-15
No files matched your search
+35
-5
@@ -1380,15 +1380,19 @@ func TestAwsInstanceToHost(t *testing.T) {
|
||||
instance: &ec2.Instance{
|
||||
InstanceId: aws.String("foobar"),
|
||||
PrivateIpAddress: aws.String("10.0.0.1"),
|
||||
PrivateDnsName: aws.String("test.example.internal"),
|
||||
PublicIpAddress: aws.String("1.1.1.1"),
|
||||
PublicDnsName: aws.String("test.example.com"),
|
||||
NetworkInterfaces: []*ec2.InstanceNetworkInterface{
|
||||
&ec2.InstanceNetworkInterface{
|
||||
PrivateIpAddresses: []*ec2.InstancePrivateIpAddress{
|
||||
&ec2.InstancePrivateIpAddress{
|
||||
Association: &ec2.InstanceNetworkInterfaceAssociation{
|
||||
PublicIp: aws.String("1.1.1.1"),
|
||||
PublicIp: aws.String("1.1.1.1"),
|
||||
PublicDnsName: aws.String("test.example.com"),
|
||||
},
|
||||
PrivateIpAddress: aws.String("10.0.0.1"),
|
||||
PrivateDnsName: aws.String("test.example.internal"),
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -1397,6 +1401,7 @@ func TestAwsInstanceToHost(t *testing.T) {
|
||||
expected: &pb.ListHostsResponseHost{
|
||||
ExternalId: "foobar",
|
||||
IpAddresses: []string{"10.0.0.1", "1.1.1.1"},
|
||||
DnsNames: []string{"test.example.internal", "test.example.com"},
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -1404,11 +1409,13 @@ func TestAwsInstanceToHost(t *testing.T) {
|
||||
instance: &ec2.Instance{
|
||||
InstanceId: aws.String("foobar"),
|
||||
PrivateIpAddress: aws.String("10.0.0.1"),
|
||||
PrivateDnsName: aws.String("test.example.internal"),
|
||||
NetworkInterfaces: []*ec2.InstanceNetworkInterface{
|
||||
&ec2.InstanceNetworkInterface{
|
||||
PrivateIpAddresses: []*ec2.InstancePrivateIpAddress{
|
||||
&ec2.InstancePrivateIpAddress{
|
||||
PrivateIpAddress: aws.String("10.0.0.1"),
|
||||
PrivateDnsName: aws.String("test.example.internal"),
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -1417,6 +1424,7 @@ func TestAwsInstanceToHost(t *testing.T) {
|
||||
expected: &pb.ListHostsResponseHost{
|
||||
ExternalId: "foobar",
|
||||
IpAddresses: []string{"10.0.0.1"},
|
||||
DnsNames: []string{"test.example.internal"},
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -1424,12 +1432,15 @@ func TestAwsInstanceToHost(t *testing.T) {
|
||||
instance: &ec2.Instance{
|
||||
InstanceId: aws.String("foobar"),
|
||||
PrivateIpAddress: aws.String("10.0.0.1"),
|
||||
PrivateDnsName: aws.String("test.example.internal"),
|
||||
PublicIpAddress: aws.String("1.1.1.1"),
|
||||
PublicDnsName: aws.String("test.example.com"),
|
||||
NetworkInterfaces: []*ec2.InstanceNetworkInterface{
|
||||
&ec2.InstanceNetworkInterface{
|
||||
PrivateIpAddresses: []*ec2.InstancePrivateIpAddress{
|
||||
&ec2.InstancePrivateIpAddress{
|
||||
PrivateIpAddress: aws.String("10.0.0.2"),
|
||||
PrivateDnsName: aws.String("test2.example.internal"),
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -1437,9 +1448,11 @@ func TestAwsInstanceToHost(t *testing.T) {
|
||||
PrivateIpAddresses: []*ec2.InstancePrivateIpAddress{
|
||||
&ec2.InstancePrivateIpAddress{
|
||||
Association: &ec2.InstanceNetworkInterfaceAssociation{
|
||||
PublicIp: aws.String("1.1.1.1"),
|
||||
PublicIp: aws.String("1.1.1.1"),
|
||||
PublicDnsName: aws.String("test.example.com"),
|
||||
},
|
||||
PrivateIpAddress: aws.String("10.0.0.1"),
|
||||
PrivateDnsName: aws.String("test.example.internal"),
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -1448,6 +1461,7 @@ func TestAwsInstanceToHost(t *testing.T) {
|
||||
expected: &pb.ListHostsResponseHost{
|
||||
ExternalId: "foobar",
|
||||
IpAddresses: []string{"10.0.0.1", "1.1.1.1", "10.0.0.2"},
|
||||
DnsNames: []string{"test.example.internal", "test.example.com", "test2.example.internal"},
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -1455,15 +1469,19 @@ func TestAwsInstanceToHost(t *testing.T) {
|
||||
instance: &ec2.Instance{
|
||||
InstanceId: aws.String("foobar"),
|
||||
PrivateIpAddress: aws.String("10.0.0.1"),
|
||||
PrivateDnsName: aws.String("test.example.internal"),
|
||||
PublicIpAddress: aws.String("1.1.1.1"),
|
||||
PublicDnsName: aws.String("test.example.com"),
|
||||
NetworkInterfaces: []*ec2.InstanceNetworkInterface{
|
||||
&ec2.InstanceNetworkInterface{
|
||||
PrivateIpAddresses: []*ec2.InstancePrivateIpAddress{
|
||||
&ec2.InstancePrivateIpAddress{
|
||||
Association: &ec2.InstanceNetworkInterfaceAssociation{
|
||||
PublicIp: aws.String("1.1.1.2"),
|
||||
PublicIp: aws.String("1.1.1.2"),
|
||||
PublicDnsName: aws.String("test2.example.com"),
|
||||
},
|
||||
PrivateIpAddress: aws.String("10.0.0.2"),
|
||||
PrivateDnsName: aws.String("test2.example.internal"),
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -1471,9 +1489,11 @@ func TestAwsInstanceToHost(t *testing.T) {
|
||||
PrivateIpAddresses: []*ec2.InstancePrivateIpAddress{
|
||||
&ec2.InstancePrivateIpAddress{
|
||||
Association: &ec2.InstanceNetworkInterfaceAssociation{
|
||||
PublicIp: aws.String("1.1.1.1"),
|
||||
PublicIp: aws.String("1.1.1.1"),
|
||||
PublicDnsName: aws.String("test.example.com"),
|
||||
},
|
||||
PrivateIpAddress: aws.String("10.0.0.1"),
|
||||
PrivateDnsName: aws.String("test.example.internal"),
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -1482,6 +1502,7 @@ func TestAwsInstanceToHost(t *testing.T) {
|
||||
expected: &pb.ListHostsResponseHost{
|
||||
ExternalId: "foobar",
|
||||
IpAddresses: []string{"10.0.0.1", "1.1.1.1", "10.0.0.2", "1.1.1.2"},
|
||||
DnsNames: []string{"test.example.internal", "test.example.com", "test2.example.internal", "test2.example.com"},
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -1489,18 +1510,23 @@ func TestAwsInstanceToHost(t *testing.T) {
|
||||
instance: &ec2.Instance{
|
||||
InstanceId: aws.String("foobar"),
|
||||
PrivateIpAddress: aws.String("10.0.0.1"),
|
||||
PrivateDnsName: aws.String("test.example.internal"),
|
||||
PublicIpAddress: aws.String("1.1.1.1"),
|
||||
PublicDnsName: aws.String("test.example.com"),
|
||||
NetworkInterfaces: []*ec2.InstanceNetworkInterface{
|
||||
&ec2.InstanceNetworkInterface{
|
||||
PrivateIpAddresses: []*ec2.InstancePrivateIpAddress{
|
||||
&ec2.InstancePrivateIpAddress{
|
||||
Association: &ec2.InstanceNetworkInterfaceAssociation{
|
||||
PublicIp: aws.String("1.1.1.1"),
|
||||
PublicIp: aws.String("1.1.1.1"),
|
||||
PublicDnsName: aws.String("test.example.com"),
|
||||
},
|
||||
PrivateIpAddress: aws.String("10.0.0.1"),
|
||||
PrivateDnsName: aws.String("test.example.internal"),
|
||||
},
|
||||
&ec2.InstancePrivateIpAddress{
|
||||
PrivateIpAddress: aws.String("10.0.0.2"),
|
||||
PrivateDnsName: aws.String("test2.example.internal"),
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -1509,6 +1535,7 @@ func TestAwsInstanceToHost(t *testing.T) {
|
||||
expected: &pb.ListHostsResponseHost{
|
||||
ExternalId: "foobar",
|
||||
IpAddresses: []string{"10.0.0.1", "1.1.1.1", "10.0.0.2"},
|
||||
DnsNames: []string{"test.example.internal", "test.example.com", "test2.example.internal"},
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -1516,7 +1543,9 @@ func TestAwsInstanceToHost(t *testing.T) {
|
||||
instance: &ec2.Instance{
|
||||
InstanceId: aws.String("foobar"),
|
||||
PrivateIpAddress: aws.String("10.0.0.1"),
|
||||
PrivateDnsName: aws.String("test.example.internal"),
|
||||
PublicIpAddress: aws.String("1.1.1.1"),
|
||||
PublicDnsName: aws.String("test.example.com"),
|
||||
NetworkInterfaces: []*ec2.InstanceNetworkInterface{
|
||||
&ec2.InstanceNetworkInterface{
|
||||
PrivateIpAddresses: []*ec2.InstancePrivateIpAddress{
|
||||
@@ -1537,6 +1566,7 @@ func TestAwsInstanceToHost(t *testing.T) {
|
||||
expected: &pb.ListHostsResponseHost{
|
||||
ExternalId: "foobar",
|
||||
IpAddresses: []string{"10.0.0.1", "1.1.1.1", "some::fake::address"},
|
||||
DnsNames: []string{"test.example.internal", "test.example.com"},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user