Skip to content

Commit

Permalink
More robust VN packet parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
mpiraux committed Mar 25, 2019
1 parent 9e917a7 commit 14981a0
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions agents/parse_agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,17 @@ func (a *ParsingAgent) Run(conn *Connection) {
var off int
for off < len(udpPayload) {
ciphertext := udpPayload[off:]
header := ReadHeader(bytes.NewReader(ciphertext), a.conn)
cryptoState := a.conn.CryptoStates[header.EncryptionLevel()]

if lh, ok := header.(*LongHeader); ok && lh.Version == 0x00000000 {
if bytes.Equal(ciphertext[1:5], []byte{0, 0, 0, 0}) {
packet := ReadVersionNegotationPacket(bytes.NewReader(ciphertext))

a.SaveCleartextPacket(ciphertext, packet.Pointer())
a.conn.IncomingPackets.Submit(packet)

break packetSelect
}

header := ReadHeader(bytes.NewReader(ciphertext), a.conn)
cryptoState := a.conn.CryptoStates[header.EncryptionLevel()]

switch header.PacketType() {
case Initial, Handshake, ZeroRTTProtected, ShortHeaderPacket: // Decrypt PN
if cryptoState != nil && cryptoState.HeaderRead != nil && cryptoState.Read != nil {
Expand Down

0 comments on commit 14981a0

Please sign in to comment.