handle the scheme correctly in config.Bind

This commit is contained in:
Travis Turner 2018-02-23 10:48:55 -06:00
parent 359fc190bd
commit 3d1538d53c
No known key found for this signature in database
GPG key ID: 7F08008DFD9314C9
2 changed files with 9 additions and 6 deletions

View file

@ -19,7 +19,6 @@ import (
"io"
"io/ioutil"
"log"
"net"
"os"
"strconv"
"strings"
@ -154,10 +153,12 @@ func NewGossipMemberSetWithTransport(name string, cfg *pilosa.Config, transport
}
port := transport.Net.GetAutoBindPort()
host, _, err := net.SplitHostPort(cfg.Bind)
bindURI, err := pilosa.NewURIFromAddress(cfg.Bind)
if err != nil {
return nil, fmt.Errorf("split host port: %s", err)
return nil, fmt.Errorf("getting uri from bind address (with transport): %s", err)
}
host := bindURI.Host()
var gossipKey []byte
if cfg.Gossip.Key != "" {
@ -210,10 +211,12 @@ func NewGossipMemberSet(name string, cfg *pilosa.Config, server *pilosa.Server)
if err != nil {
return nil, fmt.Errorf("convert port: %s", err)
}
host, _, err := net.SplitHostPort(cfg.Bind)
bindURI, err := pilosa.NewURIFromAddress(cfg.Bind)
if err != nil {
return nil, fmt.Errorf("split host port: %s", err)
return nil, fmt.Errorf("getting uri from bind address: %s", err)
}
host := bindURI.Host()
// Set up the transport.
transport, err := NewTransport(host, port)

View file

@ -50,7 +50,7 @@ func NewMain() *Main {
m := &Main{Command: server.NewCommand(os.Stdin, os.Stdout, os.Stderr)}
m.Server.Network = *Network
m.Config.DataDir = path
m.Config.Bind = "localhost:0"
m.Config.Bind = "http://localhost:0"
m.Config.Cluster.Disabled = true
m.Command.Stdin = &m.Stdin
m.Command.Stdout = &m.Stdout