diff --git a/example/main.go b/example/main.go index 9a8a05254..fb195b706 100644 --- a/example/main.go +++ b/example/main.go @@ -68,7 +68,7 @@ func main() { panic(err) } utils.WriteUint32BigEndian(fullReply, QuicVersion32) - _, err := conn.WriteToUDP(fullReply.Bytes(), remoteAddr) + _, err = conn.WriteToUDP(fullReply.Bytes(), remoteAddr) if err != nil { panic(err) } @@ -80,6 +80,9 @@ func main() { session = quic.NewSession(conn, publicHeader.ConnectionID, serverConfig) 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()) + } } } diff --git a/session.go b/session.go index 64ea97d18..ac6ee4bd9 100644 --- a/session.go +++ b/session.go @@ -2,6 +2,7 @@ package quic import ( "bytes" + "errors" "fmt" "net" @@ -68,11 +69,11 @@ func (s *Session) HandlePacket(addr *net.UDPAddr, publicHeaderBinary []byte, pub // TODO: Switch client messages here if messageTag != handshake.TagCHLO { - panic("expected CHLO") + return errors.New("Session: expected CHLO") } - if _, ok := cryptoData[handshake.TagPUBS]; ok { - panic("received CHLO with PUBS") + if _, ok := cryptoData[handshake.TagSCFG]; ok { + return errors.New("Session: received CHLO with PUBS") } proof, err := s.ServerConfig.Sign(frame.Data)