本文整理汇总了Golang中github.com/project-iris/iris/proto.Message.KnownSecure方法的典型用法代码示例。如果您正苦于以下问题:Golang Message.KnownSecure方法的具体用法?Golang Message.KnownSecure怎么用?Golang Message.KnownSecure使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/project-iris/iris/proto.Message
的用法示例。
在下文中一共展示了Message.KnownSecure方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: RecvDirect
// The actual message receiving logic. Reads a message from the stream, verifies
// its mac, decodes the headers and send it upwards. Direct receive is public for
// handshake simplifications, after which the link should switch to channel mode.
func (l *Link) RecvDirect() (*proto.Message, error) {
var msg proto.Message
var err error
// Retrieve a new package
if err = l.socket.Recv(&l.inHeadBuf); err != nil {
return nil, err
}
if err = l.socket.Recv(&msg.Data); err != nil {
return nil, err
}
if err = l.socket.Recv(&l.inMacBuf); err != nil {
return nil, err
}
// Verify the message contents (payload + header)
l.inMacer.Write(l.inHeadBuf)
l.inMacer.Write(msg.Data)
if !bytes.Equal(l.inMacBuf, l.inMacer.Sum(nil)) {
err = errors.New(fmt.Sprintf("mac mismatch: have %v, want %v.", l.inMacer.Sum(nil), l.inMacBuf))
return nil, err
}
// Extract the package contents
l.inCipher.XORKeyStream(l.inHeadBuf, l.inHeadBuf)
l.inBuffer.Write(l.inHeadBuf)
if err = l.inCoder.Decode(&msg.Head); err != nil {
return nil, err
}
// Set the message security knowingly to true
msg.KnownSecure()
return &msg, nil
}