Skip to content

Commit a5ce342

Browse files
committed
Fix crash when using https
1 parent b5fcace commit a5ce342

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

pkg/mux/multiplexer.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,7 @@ func (m *Multiplexer) determineProtocol(conn net.Conn) (net.Conn, protocols.Type
444444
header := make([]byte, 14)
445445
n, err := conn.Read(header)
446446
if err != nil {
447+
conn.Close()
447448
return nil, "", fmt.Errorf("failed to read header: %s", err)
448449
}
449450

@@ -470,6 +471,7 @@ func (m *Multiplexer) determineProtocol(conn net.Conn) (net.Conn, protocols.Type
470471
return c, protocols.Download, nil
471472
}
472473

474+
conn.Close()
473475
return nil, "", errors.New("unknown protocol: " + string(header[:n]))
474476
}
475477

@@ -536,7 +538,6 @@ func (m *Multiplexer) unwrapTransports(conn net.Conn) (net.Conn, protocols.Type,
536538
// If we did unwrap tls, we now peek into the inner protocol to see whats there
537539
conn, proto, err = m.determineProtocol(c)
538540
if err != nil {
539-
conn.Close()
540541
return nil, protocols.Invalid, fmt.Errorf("error determining functional protocol: %s", err)
541542
}
542543

0 commit comments

Comments
 (0)