forked from quic-go/quic-go
send IETF draft style version negotiation packets
Send a gQUIC Version Negotiation Packet, if the client packet has a Public Header. If the client has an IETF draft style header, send an IETF draft style Version Negotiation Packet.
This commit is contained in:
12
server.go
12
server.go
@@ -266,15 +266,21 @@ func (s *server) handlePacket(pconn net.PacketConn, remoteAddr net.Addr, packet
|
||||
return nil
|
||||
}
|
||||
|
||||
// Send Version Negotiation Packet if the client is speaking a different protocol version
|
||||
// send a Version Negotiation Packet if the client is speaking a different protocol version
|
||||
// since the client send a Public Header (only gQUIC has a Version Flag), we need to send a gQUIC Version Negotiation Packet
|
||||
if hdr.VersionFlag && !protocol.IsSupportedVersion(s.config.Versions, hdr.Version) {
|
||||
// drop packets that are too small to be valid first packets
|
||||
if len(packet) < protocol.ClientHelloMinimumSize+len(hdr.Raw) {
|
||||
return errors.New("dropping small packet with unknown version")
|
||||
}
|
||||
// TODO(894): send a IETF draft style Version Negotiation Packets
|
||||
utils.Infof("Client offered version %s, sending VersionNegotiationPacket", hdr.Version)
|
||||
_, err = pconn.WriteTo(wire.ComposeVersionNegotiation(hdr.ConnectionID, s.config.Versions), remoteAddr)
|
||||
if _, err := pconn.WriteTo(wire.ComposeGQUICVersionNegotiation(hdr.ConnectionID, s.config.Versions), remoteAddr); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
// send an IETF draft style Version Negotiation Packet, if the client sent an unsupported version with an IETF draft style header
|
||||
if hdr.Type == protocol.PacketTypeClientInitial && !protocol.IsSupportedVersion(s.config.Versions, hdr.Version) {
|
||||
_, err := pconn.WriteTo(wire.ComposeVersionNegotiation(hdr.ConnectionID, hdr.PacketNumber, s.config.Versions), remoteAddr)
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user