connect/proxy: don't start public listener if 0 port

This commit is contained in:
Mitchell Hashimoto 2018-05-19 00:46:06 -07:00
parent 3e8ea58585
commit b88023c607
No known key found for this signature in database
GPG Key ID: 744E147AA52F5B0A
1 changed files with 9 additions and 5 deletions

View File

@ -60,11 +60,15 @@ func (p *Proxy) Serve() error {
p.logger.Printf("[DEBUG] leaf: %s roots: %s", leaf.URIs[0], bytes.Join(tcfg.RootCAs.Subjects(), []byte(",")))
}()
newCfg.PublicListener.applyDefaults()
l := NewPublicListener(p.service, newCfg.PublicListener, p.logger)
err = p.startListener("public listener", l)
if err != nil {
return err
// Only start a listener if we have a port set. This allows
// the configuration to disable our public listener.
if newCfg.PublicListener.BindPort != 0 {
newCfg.PublicListener.applyDefaults()
l := NewPublicListener(p.service, newCfg.PublicListener, p.logger)
err = p.startListener("public listener", l)
if err != nil {
return err
}
}
}