Skip to content

Commit

Permalink
Migrate remaining hard-coded IPv4 loopback to 'localhost'
Browse files Browse the repository at this point in the history
For IPv6 compatibility, use of IPv4 loopback addresses should instead
use 'localhost', which should resolve to both IPv4 and IPv6 addresses.

provider/dummy/environs.go adds both IPv4 and IPv6 loopback addresses to
the machine, rather than 'localhost', to still add scoped IP addresses
and to reflect what we expect to see in other providers.

Tests using loopback addresses have not be changed, as they should still
be correct as tests.
  • Loading branch information
Mick Gregg committed Nov 30, 2016
1 parent eab9310 commit 57a4bd1
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions container/kvm/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ var kvmTemplate = `
</console>
<input type='mouse' bus='ps2'/>
<input type='keyboard' bus='ps2'/>
<graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1'>
<listen type='address' address='127.0.0.1'/>
<graphics type='vnc' port='-1' autoport='yes' listen='localhost'>
<listen type='address' address='localhost'/>
</graphics>
<video>
<model type='cirrus' vram='9216' heads='1'/>
Expand Down
2 changes: 1 addition & 1 deletion juju/testing/instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ func fillinStartInstanceParams(env environs.Environ, machineId string, isControl
Config: testing.FakeControllerConfig(),
MongoInfo: &mongo.MongoInfo{
Info: mongo.Info{
Addrs: []string{"127.0.0.1:1234"},
Addrs: []string{"localhost:1234"},
CACert: "CA CERT\n" + testing.CACert,
},
Password: "mongosecret",
Expand Down
2 changes: 1 addition & 1 deletion network/address.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ func NewAddressOnSpace(spaceName string, value string) Address {
return addr
}

// NewAddresses is a convenience function to create addresses from a a variable
// NewAddresses is a convenience function to create addresses from a variable
// number of string arguments.
func NewAddresses(inAddresses ...string) (outAddresses []Address) {
outAddresses = make([]Address, len(inAddresses))
Expand Down
4 changes: 3 additions & 1 deletion provider/dummy/environs.go
Original file line number Diff line number Diff line change
Expand Up @@ -981,7 +981,9 @@ func (e *environ) StartInstance(args environs.StartInstanceParams) (*environs.St
series := args.Tools.OneSeries()

idString := fmt.Sprintf("%s-%d", e.name, estate.maxId)
addrs := network.NewAddresses(idString+".dns", "127.0.0.1")
// Add the addresses we want to see in the machine doc. This means both
// IPv4 and IPv6 loopback, as well as the DNS name.
addrs := network.NewAddresses(idString+".dns", "127.0.0.1", "::1")
logger.Debugf("StartInstance addresses: %v", addrs)
i := &dummyInstance{
id: instance.Id(idString),
Expand Down

0 comments on commit 57a4bd1

Please sign in to comment.