forked from quic-go/quic-go
only start new session if the client sends a version in the PublicHeader
fixes #349
This commit is contained in:
14
server.go
14
server.go
@@ -3,6 +3,7 @@ package quic
|
||||
import (
|
||||
"bytes"
|
||||
"crypto/tls"
|
||||
"errors"
|
||||
"net"
|
||||
"strings"
|
||||
"sync"
|
||||
@@ -153,10 +154,19 @@ func (s *Server) handlePacket(conn *net.UDPConn, remoteAddr *net.UDPAddr, packet
|
||||
s.sessionsMutex.RUnlock()
|
||||
|
||||
if !ok {
|
||||
utils.Infof("Serving new connection: %x, version %d from %v", hdr.ConnectionID, hdr.VersionNumber, remoteAddr)
|
||||
if !hdr.VersionFlag {
|
||||
_, err = conn.WriteToUDP(writePublicReset(hdr.ConnectionID, hdr.PacketNumber, 0), remoteAddr)
|
||||
return err
|
||||
}
|
||||
version := hdr.VersionNumber
|
||||
if !protocol.IsSupportedVersion(version) {
|
||||
return errors.New("Server BUG: negotiated version not supported")
|
||||
}
|
||||
|
||||
utils.Infof("Serving new connection: %x, version %d from %v", hdr.ConnectionID, version, remoteAddr)
|
||||
session, err = s.newSession(
|
||||
&udpConn{conn: conn, currentAddr: remoteAddr},
|
||||
hdr.VersionNumber,
|
||||
version,
|
||||
hdr.ConnectionID,
|
||||
s.scfg,
|
||||
s.streamCallback,
|
||||
|
||||
Reference in New Issue
Block a user