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:
Marten Seemann
2017-10-29 18:19:24 +07:00
parent 515babb4bd
commit b0f34e776e
6 changed files with 108 additions and 36 deletions

View File

@@ -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
}