core: Handle address lookup and bind errors more gracefully (fixes #136 and #164)

Addresses which fail to resolve are handled more gracefully in the two most common cases: the hostname doesn't resolve or the port is unknown (like "http" on a system that doesn't support that port name). If the hostname doesn't resolve, the host is served on the listener at host 0.0.0.0. If the port is unknown, we attempt to rewrite it as a number manually and try again.
This commit is contained in:
Matthew Holt
2015-06-23 22:00:55 -06:00
parent 640cd059ce
commit d8391d6fbd
3 changed files with 123 additions and 9 deletions

View File

@ -47,9 +47,6 @@ type Config struct {
// Address returns the host:port of c as a string.
func (c Config) Address() string {
if c.BindHost != "" {
return net.JoinHostPort(c.BindHost, c.Port)
}
return net.JoinHostPort(c.Host, c.Port)
}