Last active
October 30, 2015 13:44
-
-
Save tbg/8c3ec9fa46534825bbe3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/gossip/resolver/resolver.go b/gossip/resolver/resolver.go | |
index 6afa291..38e7a8e 100644 | |
--- a/gossip/resolver/resolver.go | |
+++ b/gossip/resolver/resolver.go | |
@@ -20,7 +20,6 @@ package resolver | |
import ( | |
"net" | |
"strings" | |
- "unicode" | |
"github.com/cockroachdb/cockroach/base" | |
"github.com/cockroachdb/cockroach/util" | |
@@ -80,8 +79,8 @@ func NewResolver(context *base.Context, spec string) (Resolver, error) { | |
// For non-unix resolvers, make sure we fill in the host when not specified (eg: ":26257") | |
if typ != "unix" { | |
// Non-unix resolvers address first character must be letter or digit if only one character. | |
- if len(addr) == 1 && !unicode.IsLetter(rune(addr[0])) && !unicode.IsDigit(rune(addr[0])) { | |
- return nil, util.Errorf("invalid address value in gossip resolver spec: %q", spec) | |
+ if len(addr) == 0 { | |
+ return nil, util.Errorf("empty address value in gossip resolver spec") | |
} | |
// Ensure addr has port and host set. | |
diff --git a/gossip/resolver/resolver_test.go b/gossip/resolver/resolver_test.go | |
index 637cd60..25259bc 100644 | |
--- a/gossip/resolver/resolver_test.go | |
+++ b/gossip/resolver/resolver_test.go | |
@@ -27,6 +27,7 @@ import ( | |
var nodeTestBaseContext = testutils.NewNodeTestBaseContext() | |
func TestParseResolverSpec(t *testing.T) { | |
+ def := util.EnsureHostPort(":") | |
testCases := []struct { | |
input string | |
success bool | |
@@ -35,21 +36,23 @@ func TestParseResolverSpec(t *testing.T) { | |
}{ | |
// Ports are not checked at parsing time. They are at GetAddress time though. | |
{"127.0.0.1:26222", true, "tcp", "127.0.0.1:26222"}, | |
- {":26257", true, "tcp", util.EnsureHostPort(":26257")}, | |
+ {":26257", true, "tcp", def}, | |
{"127.0.0.1", true, "tcp", "127.0.0.1:26257"}, | |
{"tcp=127.0.0.1", true, "tcp", "127.0.0.1:26257"}, | |
{"tcp=127.0.0.1:23456", true, "tcp", "127.0.0.1:23456"}, | |
{"lb=127.0.0.1", true, "lb", "127.0.0.1:26257"}, | |
{"unix=/tmp/unix-socket12345", true, "unix", "/tmp/unix-socket12345"}, | |
{"http-lb=localhost:26257", true, "http-lb", "localhost:26257"}, | |
- {"http-lb=:26257", true, "http-lb", util.EnsureHostPort(":26257")}, | |
+ {"http-lb=newhost:1234", true, "http-lb", "newhost:1234"}, | |
+ {"http-lb=:26257", true, "http-lb", def}, | |
+ {"http-lb=:", true, "http-lb", def}, | |
{"", false, "", ""}, | |
{"foo=127.0.0.1", false, "", ""}, | |
{"lb=", false, "", ""}, | |
{"", false, "tcp", ""}, | |
- {":", false, "tcp", ""}, | |
+ {":", true, "tcp", def}, | |
{"tcp=", false, "tcp", ""}, | |
- {"tcp=:", false, "tcp", ""}, | |
+ {"tcp=:", true, "tcp", def}, | |
} | |
for tcNum, tc := range testCases { |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment