fix crash

This commit is contained in:
aler9
2020-12-06 17:56:43 +01:00
parent 6d201429f1
commit b4c183ad2a
6 changed files with 47 additions and 34 deletions

View File

@@ -37,6 +37,19 @@ type ServerConf struct {
// Serve starts a server on the given address.
func (c ServerConf) Serve(address string, handler ServerHandler) (*Server, error) {
if c.ReadTimeout == 0 {
c.ReadTimeout = 10 * time.Second
}
if c.WriteTimeout == 0 {
c.WriteTimeout = 10 * time.Second
}
if c.ReadBufferCount == 0 {
c.ReadBufferCount = 1
}
if c.ListenTCP == nil {
c.ListenTCP = net.ListenTCP
}
addr, err := net.ResolveTCPAddr("tcp", address)
if err != nil {
return nil, err