Skip to content

Commit

Permalink
Renamed configuration setting for allowing AAAA use.
Browse files Browse the repository at this point in the history
Deprecated the allow_ipv6_use field, replacing it with a more descriptive
allow_aaaa_use field. The field is actually allowing AAAA records to be
used from DNS lookups, and by implication, directly using external IPv6
addresses, instead of synthesizing an IPv6 address from the A record and
doing NAT64 always.
  • Loading branch information
Paul Michali committed Jun 11, 2018
1 parent 910f760 commit 83b0612
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 9 deletions.
4 changes: 2 additions & 2 deletions README.md
Expand Up @@ -135,7 +135,7 @@ dns64:
remote_server: "64.102.6.247"
cidr: "fd00:10:64:ff9b::/96"
ip: "fd00:10::100"
allow_ipv6_use: true
allow_aaaa_use: true
```

### Token (token) and Token CA Certificate Hash (token-cert-hash)
Expand Down Expand Up @@ -266,7 +266,7 @@ them to IPv4 addresses using NAT64. To do this, requires telling DNS64 to use
the AAAA records for lookups. The default is false, meaning IPv4 addresses will
be used in all lookups.
```
allow_ipv6_use: true
allow_aaaa_use: true
```

## Usage
Expand Down
2 changes: 1 addition & 1 deletion cmd/lazyjack.go
Expand Up @@ -13,7 +13,7 @@ import (
)

const (
Version = "1.1.0"
Version = "1.1.1"
)

func init() {
Expand Down
3 changes: 2 additions & 1 deletion config.go
Expand Up @@ -42,7 +42,8 @@ type DNS64Config struct {
CIDR string `yaml:"cidr"`
CIDRPrefix string
ServerIP string `yaml:"ip"`
AllowIPv6Use bool `yaml:"allow_ipv6_use"`
AllowIPv6Use bool `yaml:"allow_ipv6_use"` // Deprecated
AllowAAAAUse bool `yaml:"allow_aaaa_use"`
}

// NAT64Config defines information for the NAT64 server configuration.
Expand Down
2 changes: 1 addition & 1 deletion prepare.go
Expand Up @@ -355,7 +355,7 @@ func CreateNamedConfContents(c *Config) *bytes.Buffer {
fmt.Fprintf(contents, " %s%s;\n", c.DNS64.CIDRPrefix, c.DNS64.RemoteV4Server)
fmt.Fprintf(contents, middle)
fmt.Fprintf(contents, " dns64 %s {\n", c.DNS64.CIDR)
if !c.DNS64.AllowIPv6Use {
if !c.DNS64.AllowAAAAUse {
fmt.Fprintf(contents, " exclude { any; };\n")
}
fmt.Fprintf(contents, trailer)
Expand Down
4 changes: 2 additions & 2 deletions prepare_test.go
Expand Up @@ -126,13 +126,13 @@ func TestNamedConfContents(t *testing.T) {
}
}

func TestNamedConfContentsAllowingIPv6(t *testing.T) {
func TestNamedConfContentsAllowingAAAA(t *testing.T) {
c := &lazyjack.Config{
DNS64: lazyjack.DNS64Config{
CIDR: "fd00:10:64:ff9b::/96",
CIDRPrefix: "fd00:10:64:ff9b::",
RemoteV4Server: "8.8.8.8",
AllowIPv6Use: true,
AllowAAAAUse: true,
},
}

Expand Down
4 changes: 4 additions & 0 deletions validate.go
Expand Up @@ -290,6 +290,10 @@ func CalculateDerivedFields(c *Config) error {
if err != nil {
return fmt.Errorf("invalid DNS64 CIDR: %v", err)
}

if c.DNS64.AllowIPv6Use {
c.DNS64.AllowAAAAUse = true
}
return nil
}

Expand Down
30 changes: 28 additions & 2 deletions validate_test.go
Expand Up @@ -155,7 +155,7 @@ dns64:
remote_server: "8.8.8.8" # Could be a internal/company DNS server
cidr: "fd00:10:64:ff9b::/96"
ip: "fd00:10::100"
allow_ipv6_use: true`
allow_aaaa_use: true`

stream := &ClosingBuffer{bytes.NewBufferString(goodYAML)}
config, err := lazyjack.LoadConfig(stream)
Expand Down Expand Up @@ -207,7 +207,7 @@ dns64:
if config.DNS64.RemoteV4Server != "8.8.8.8" ||
config.DNS64.CIDR != "fd00:10:64:ff9b::/96" ||
config.DNS64.ServerIP != "fd00:10::100" ||
!config.DNS64.AllowIPv6Use {
!config.DNS64.AllowAAAAUse {
t.Errorf("DNS64 config parse failure (%+v)", config.DNS64)
}
}
Expand Down Expand Up @@ -741,6 +741,32 @@ func TestCalculateDerivedFieldsSuccess(t *testing.T) {
}
}

func TestCalculateDerivedFieldsDeprecatedAAAASupport(t *testing.T) {
c := &lazyjack.Config{
Mgmt: lazyjack.ManagementNetwork{
CIDR: "fd00:20::/64",
},
Support: lazyjack.SupportNetwork{
CIDR: "fd00:10::/64",
},
DNS64: lazyjack.DNS64Config{
CIDR: "fd00:10:64:ff9b::/96",
AllowIPv6Use: true, // Deprecated field
},
Pod: lazyjack.PodNetwork{
CIDR: "fd00:40::/72",
},
}

err := lazyjack.CalculateDerivedFields(c)
if err != nil {
t.Fatalf("Expected derived fields parsed OK, but see error: %s", err.Error())
}
if !c.DNS64.AllowAAAAUse {
t.Fatalf("Expected allow AAAA use field to be set by deprecated value")
}
}

func TestCalculateDerivedFieldsSuccessMigrateLegacyPodInfo(t *testing.T) {
c := &lazyjack.Config{
Mgmt: lazyjack.ManagementNetwork{
Expand Down

0 comments on commit 83b0612

Please sign in to comment.