changed address variable to bindAddress. Used net.JoinHostPort() instead of fmt.Sprintf()

pull/6/head
Brian Ketelsen 2014-09-07 23:50:36 -07:00
parent 34922226fd
commit 83d3da1436
2 changed files with 4 additions and 4 deletions

View File

@ -33,7 +33,7 @@ var (
configFile = flag.String("configfile", "/tmp/proxy_config", "Configuration file for the proxy")
master = flag.String("master", "", "The address of the Kubernetes API server (optional)")
etcdServerList util.StringList
address = flag.String("address", "0.0.0.0", "The address for the proxy server to serve on (set to 0.0.0.0 or \"\" for all interfaces)")
bindAddress = flag.String("bindaddress", "0.0.0.0", "The address for the proxy server to serve on (set to 0.0.0.0 or \"\" for all interfaces)")
)
func init() {
@ -85,7 +85,7 @@ func main() {
glog.Infof("Using configuration file %s", *configFile)
loadBalancer := proxy.NewLoadBalancerRR()
proxier := proxy.NewProxier(loadBalancer, *address)
proxier := proxy.NewProxier(loadBalancer, *bindAddress)
// Wire proxier to handle changes to services
serviceConfig.RegisterHandler(proxier)
// And wire loadBalancer to handle changes to endpoints to services

View File

@ -155,7 +155,7 @@ var unusedPortLock sync.Mutex
func (proxier *Proxier) addServiceOnUnusedPort(service string) (string, error) {
unusedPortLock.Lock()
defer unusedPortLock.Unlock()
l, err := net.Listen("tcp", fmt.Sprintf("%s:0", proxier.address))
l, err := net.Listen("tcp", net.JoinHostPort(proxier.address, "0"))
if err != nil {
return "", err
}
@ -197,7 +197,7 @@ func (proxier *Proxier) OnUpdate(services []api.Service) {
proxier.StopProxy(service.ID)
}
glog.Infof("Adding a new service %s on port %d", service.ID, service.Port)
listener, err := net.Listen("tcp", fmt.Sprintf("%s:%d", proxier.address, service.Port))
listener, err := net.Listen("tcp", net.JoinHostPort(proxier.address, strconv.Itoa(service.Port)))
if err != nil {
glog.Infof("Failed to start listening for %s on %d", service.ID, service.Port)
continue