don't panic! 🎉

This commit is contained in:
Lucas Clemente
2016-04-14 20:02:24 +02:00
parent 0febba87ba
commit 70531832af
2 changed files with 9 additions and 5 deletions

View File

@@ -68,7 +68,7 @@ func main() {
panic(err) panic(err)
} }
utils.WriteUint32BigEndian(fullReply, QuicVersion32) utils.WriteUint32BigEndian(fullReply, QuicVersion32)
_, err := conn.WriteToUDP(fullReply.Bytes(), remoteAddr) _, err = conn.WriteToUDP(fullReply.Bytes(), remoteAddr)
if err != nil { if err != nil {
panic(err) panic(err)
} }
@@ -80,6 +80,9 @@ func main() {
session = quic.NewSession(conn, publicHeader.ConnectionID, serverConfig) session = quic.NewSession(conn, publicHeader.ConnectionID, serverConfig)
sessions[publicHeader.ConnectionID] = session sessions[publicHeader.ConnectionID] = session
} }
session.HandlePacket(remoteAddr, data[0:n-r.Len()], publicHeader, r) err = session.HandlePacket(remoteAddr, data[0:n-r.Len()], publicHeader, r)
if err != nil {
fmt.Printf("Error handling packet: %s\n", err.Error())
}
} }
} }

View File

@@ -2,6 +2,7 @@ package quic
import ( import (
"bytes" "bytes"
"errors"
"fmt" "fmt"
"net" "net"
@@ -68,11 +69,11 @@ func (s *Session) HandlePacket(addr *net.UDPAddr, publicHeaderBinary []byte, pub
// TODO: Switch client messages here // TODO: Switch client messages here
if messageTag != handshake.TagCHLO { if messageTag != handshake.TagCHLO {
panic("expected CHLO") return errors.New("Session: expected CHLO")
} }
if _, ok := cryptoData[handshake.TagPUBS]; ok { if _, ok := cryptoData[handshake.TagSCFG]; ok {
panic("received CHLO with PUBS") return errors.New("Session: received CHLO with PUBS")
} }
proof, err := s.ServerConfig.Sign(frame.Data) proof, err := s.ServerConfig.Sign(frame.Data)