From 4c002cc1263b4c68da1b42c9c280684187045630 Mon Sep 17 00:00:00 2001 From: r0p0s3c Date: Mon, 8 Feb 2016 10:22:06 -0500 Subject: [PATCH] PR #49: If the supplied addr has a host-ip part, use that, otherwise fallback to local ip detection --- CHANGELOG.md | 1 + registry/consul/register.go | 13 ++++++------- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5414bab3c..5cb03b864 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ * [Issue #43](https://github.com/eBay/fabio/issues/43): Allow configuration via env vars * [Issue #47](https://github.com/eBay/fabio/issues/47): Move dependencies to vendor path * [Issue #48](https://github.com/eBay/fabio/issues/48): Allow configuration of serviceip used during consul registration + * [PR #49](https://github.com/eBay/fabio/pull/49): Fix up use of addr in service registration ### [v1.0.8](https://github.com/eBay/fabio/releases/tag/v1.0.8) - 14 Jan 2015 diff --git a/registry/consul/register.go b/registry/consul/register.go index 620882b74..6f7019f15 100644 --- a/registry/consul/register.go +++ b/registry/consul/register.go @@ -26,16 +26,15 @@ func serviceRegistration(addr, name string, interval, timeout time.Duration) (*a return nil, err } - ip, err := config.LocalIP() - if err != nil { - return nil, err - } + ip := net.ParseIP(ipstr) if ip == nil { - givenip := net.ParseIP(ipstr) - if givenip == nil { + ip, err := config.LocalIP() + if err != nil { + return nil, err + } + if ip == nil { return nil, errors.New("no local ip") } - ip = givenip } serviceID := fmt.Sprintf("%s-%s-%d", name, hostname, port)