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 fabiolb#652
  • Loading branch information
Aaron Hurt committed Apr 30, 2019
1 parent b11536b commit 74d7103
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 74d7103

Please sign in to comment.