Prevent panic on wrong interface conversion (#4803)

* Prevent panic on wrong interface conversion
* remove import
This commit is contained in:
Preston Van Loon 2020-02-09 00:41:50 -08:00 committed by GitHub
parent f14ff34797
commit 7e0d0502aa

View File

@ -27,7 +27,10 @@ func (r *Service) goodbyeRPCHandler(ctx context.Context, msg interface{}, stream
defer cancel() defer cancel()
setRPCStreamDeadlines(stream) setRPCStreamDeadlines(stream)
m := msg.(uint64) m, ok:= msg.(uint64)
if !ok {
return fmt.Errorf("wrong message type for goodbye, got %T, wanted uint64", msg)
}
log := log.WithField("Reason", goodbyeMessage(m)) log := log.WithField("Reason", goodbyeMessage(m))
log.WithField("peer", stream.Conn().RemotePeer()).Info("Peer has sent a goodbye message") log.WithField("peer", stream.Conn().RemotePeer()).Info("Peer has sent a goodbye message")
// closes all streams with the peer // closes all streams with the peer