Skip to content

Commit

Permalink
Use go-sockaddr to parse proxy listeners, consul service address and …
Browse files Browse the repository at this point in the history
…the proxy local ip - fixes #652 (#653)
  • Loading branch information
Aaron Hurt committed May 6, 2019
1 parent 6862237 commit 2982f38
Show file tree
Hide file tree
Showing 29 changed files with 5,720 additions and 2 deletions.
17 changes: 16 additions & 1 deletion config/load.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"strings"
"time"

gs "github.com/hashicorp/go-sockaddr/template"
"github.com/magiconair/properties"
)

Expand Down Expand Up @@ -265,6 +266,18 @@ func load(cmdline, environ, envprefix []string, props *properties.Properties) (c
return nil, err
}

if cfg.Proxy.LocalIP != "" {
if cfg.Proxy.LocalIP, err = gs.Parse(cfg.Proxy.LocalIP); err != nil {
return nil, fmt.Errorf("failed to parse local ip: %s", err)
}
}

if cfg.Registry.Consul.ServiceAddr != "" {
if cfg.Registry.Consul.ServiceAddr, err = gs.Parse(cfg.Registry.Consul.ServiceAddr); err != nil {
return nil, fmt.Errorf("failed to consul service address: %s", err)
}
}

cfg.Registry.Consul.CheckScheme = defaultConfig.Registry.Consul.CheckScheme
if cfg.UI.Listen.CertSource.Name != "" {
cfg.Registry.Consul.CheckScheme = "https"
Expand Down Expand Up @@ -355,7 +368,9 @@ func parseListen(cfg map[string]string, cs map[string]CertSource, readTimeout, w
for k, v := range cfg {
switch k {
case "", "addr":
l.Addr = v
if l.Addr, err = gs.Parse(v); err != nil {
return Listen{}, err
}
case "proto":
l.Proto = v
switch l.Proto {
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ require (
github.com/hashicorp/go-multierror v0.0.0-20150916205742-d30f09973e19 // indirect
github.com/hashicorp/go-retryablehttp v0.5.0 // indirect
github.com/hashicorp/go-rootcerts v0.0.0-20160503143440-6bb64b370b90 // indirect
github.com/hashicorp/go-sockaddr v0.0.0-20180320115054-6d291a969b86 // indirect
github.com/hashicorp/go-sockaddr v0.0.0-20180320115054-6d291a969b86
github.com/hashicorp/hcl v0.0.0-20160607001940-d7400db7143f // indirect
github.com/hashicorp/memberlist v0.1.0 // indirect
github.com/hashicorp/serf v0.7.0 // indirect
Expand Down
26 changes: 26 additions & 0 deletions vendor/github.com/hashicorp/go-sockaddr/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

65 changes: 65 additions & 0 deletions vendor/github.com/hashicorp/go-sockaddr/GNUmakefile

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 2982f38

Please sign in to comment.