Skip to content
This repository has been archived by the owner on Oct 23, 2024. It is now read-only.

Support IPv6 #508

Merged
merged 13 commits into from
Oct 10, 2017
8 changes: 8 additions & 0 deletions dnstest/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,14 @@ func A(hdr dns.RR_Header, ip net.IP) *dns.A {
}
}

// AAAA returns an AAAA record set with the given arguments.
func AAAA(hdr dns.RR_Header, ip net.IP) *dns.AAAA {
return &dns.AAAA{
Hdr: hdr,
AAAA: ip.To16(),
}
}

// SRV returns a SRV record set with the given arguments.
func SRV(hdr dns.RR_Header, target string, port, priority, weight uint16) *dns.SRV {
return &dns.SRV{
Expand Down
81 changes: 80 additions & 1 deletion factories/fake.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"activated_slaves": 3,
"activated_slaves": 4,
"build_date": "2014-07-18 18:52:23",
"build_time": 1405709543,
"build_user": "root",
Expand Down Expand Up @@ -38,6 +38,69 @@
"zk_session_timeout": "10secs"
},
"frameworks": [
{
"active": true,
"checkpoint": false,
"completed_tasks": [],
"failover_timeout": 1200,
"hostname": "localhost",
"pid": "scheduler(1)@[2001:db8::1]:25501",
"id": "20140703-014514-3041283216-5050-5349-0001",
"name": "ipv6-framework",
"offers": [],
"registered_time": 1414913537.10742,
"reregistered_time": 1414913537.10744,
"resources": {
"cpus": 0,
"disk": 0,
"mem": 0
},
"role": "*",
"tasks": [
{
"executor_id": "",
"framework_id": "20140703-014514-3041283216-5050-5349-0001",
"id": "toy-store.b8db9f73-562f-11e4-a088-c20493233aa5",
"name": "toy-store",
"resources": {
"cpus": 1,
"disk": 0,
"mem": 1024,
"ports": "[31354-31354, 31355-31355]"
},
"slave_id": "20140803-194712-3041283216-5050-2116-3",
"state": "TASK_RUNNING",
"statuses": [
{
"state": "TASK_RUNNING",
"timestamp": 1507139816.34576,
"container_status": {
"container_id": {
"value": "da87d8aa-98f1-4fc3-a260-f92c116fc926"
},
"network_infos": [
{
"ip_addresses": [
{
"protocol": "IPv4",
"ip_address": "12.0.1.2"
},
{
"protocol": "IPv6",
"ip_address": "fd01:b::1:8000:2"
}
],
"name": "dcos6"
}
]
}
}
]
}
],
"unregistered_time": 0,
"user": "root"
},
{
"active": true,
"checkpoint": false,
Expand Down Expand Up @@ -619,6 +682,22 @@
"mem": 31016,
"ports": "[31000-32000]"
}
},
{
"attributes": {
"host": "dev-123-1g.c.mesos.internal"
},
"hostname": "2001:db8::1",
"id": "20140803-194712-3041283216-5050-2116-3",
"pid": "slave(1)@[2001:db8::1]:5051",
"registered_time": 1414913537.56731,
"reregistered_time": 1414913537.56735,
"resources": {
"cpus": 8,
"disk": 1855784,
"mem": 31016,
"ports": "[31000-32000]"
}
}
],
"staged_tasks": 310,
Expand Down
7 changes: 4 additions & 3 deletions models/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ type AXFRResourceRecordSet map[string][]string
// This is the internal structure of how mesos-dns works today and the transformation of string -> DNS Struct
// happens on actual query time. Why this logic happens at query time? Who knows.

// AXFRRecords are the As, and SRVs that actually make up the Mesos-DNS zone
// AXFRRecords are the As, AAAAs, and SRVs that actually make up the Mesos-DNS zone
type AXFRRecords struct {
As AXFRResourceRecordSet
SRVs AXFRResourceRecordSet
As AXFRResourceRecordSet
AAAAs AXFRResourceRecordSet
SRVs AXFRResourceRecordSet
}

// AXFR is a rough representation of a "transfer" of the Mesos-DNS data
Expand Down
8 changes: 6 additions & 2 deletions records/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -412,9 +412,13 @@ func localAddies() []string {
if err != nil {
logging.Error.Println(err)
}
t4 := ip.To4()
if t4 != nil {
// The servers in cservers above could include
// ipv6, so we should include local ipv6 for
// that filtering
if t4 := ip.To4(); t4 != nil {
bad = append(bad, t4.String())
} else if t6 := ip.To16(); t6 != nil {
bad = append(bad, t6.String())
}
}

Expand Down
9 changes: 3 additions & 6 deletions records/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,10 @@ import (
)

func TestNonLocalAddies(t *testing.T) {
nlocal := []string{"127.0.0.1"}
nlocal := localAddies()
addies := nonLocalAddies(nlocal)

for i := 0; i < len(addies); i++ {
if "127.0.0.1" == addies[i] {
t.Error("finding a local address")
}
if len(addies) > 0 {
t.Error("finding a local address")
}
}

Expand Down
Loading