Documentation ¶
Index ¶
- func AddMessageCache(hash *[]byte, msgBytes *go_protobuf.MessageMulticast, ...) error
- func AddMessageCacheByBytes(hash, head, body *[]byte, levelDB *utilsleveldb.LevelDB) error
- func FindMessageCacheByHash(hash []byte, levelDB *utilsleveldb.LevelDB) (*[]byte, error)
- func FindMessageCacheByHashExist(hash []byte, levelDB *utilsleveldb.LevelDB) (bool, error)
- func GetSortSession(ss []engine.Session, self nodeStore.AddressNet) ([]engine.Session, int)
- func GetSortSessionForTarget(ss []engine.Session, self nodeStore.AddressNet, target nodeStore.AddressNet) ([]nodeStore.AddressNet, int)
- type KeyMutext
- type Message
- func (this *Message) BuildHash()
- func (this *Message) BuildReplyHash(createtime uint64, sendhash []byte, sendrand uint64) error
- func (this *Message) Forward(version uint64, nodeManager *nodeStore.NodeManager, ...) (bool, error)
- func (this *Message) GetSortSession(allAddr []nodeStore.AddressNet, sessionEngine *engine.Engine) ([]nodeStore.AddressNet, int)
- func (this *Message) ParserContentProto() error
- func (this *Message) Proto() ([]byte, error)
- func (this *Message) Reply(version uint64, nodeManager *nodeStore.NodeManager, ...) (bool, error)
- func (this *Message) Send(version uint64, nodeManager *nodeStore.NodeManager, ...) (bool, error)
- type MessageBody
- type MessageCenter
- func (this *MessageCenter) BroadcastsAll(msgid, p2pMsgid uint64, ...) error
- func (this *MessageCenter) CheckOnline() bool
- func (this *MessageCenter) CheckRepeatHash(sendhash []byte) bool
- func (this *MessageCenter) CleanHEInfo(id nodeStore.AddressNet, machineId string)
- func (this *MessageCenter) CreatePipe(c engine.Controller, msg engine.Packet, message *Message)
- func (this *MessageCenter) CreatePipe_recv(c engine.Controller, msg engine.Packet, message *Message)
- func (this *MessageCenter) Destroy()
- func (this *MessageCenter) GetSearchNetAddr(nodeId, recvProxyId, senderProxyId *nodeStore.AddressNet, oneByOne bool, ...) ([]nodeStore.AddressNet, error)
- func (this *MessageCenter) GetSearchNetAddrProxy(nodeId, recvProxyId, senderProxyId *nodeStore.AddressNet) (*nodeStore.AddressNet, error)
- func (this *MessageCenter) Init()
- func (this *MessageCenter) NeighborHandler(c engine.Controller, msg engine.Packet)
- func (this *MessageCenter) Pipe_error(c engine.Controller, msg engine.Packet, message *Message)
- func (this *MessageCenter) RegisterMsgVersion()
- func (this *MessageCenter) Register_multicast(msgid uint64, handler MsgHandler, isSysMsg bool)
- func (this *MessageCenter) Register_neighbor(msgid uint64, handler MsgHandler, isSysMsg bool)
- func (this *MessageCenter) Register_p2p(msgid uint64, handler MsgHandler, isSysMsg bool)
- func (this *MessageCenter) Register_p2pHE(msgid uint64, handler MsgHandler, isSysMsg bool)
- func (this *MessageCenter) Register_search_all(msgid uint64, handler MsgHandler, isSysMsg bool)
- func (this *MessageCenter) Register_search_super(msgid uint64, handler MsgHandler, isSysMsg bool)
- func (this *MessageCenter) Register_vnode_p2pHE(msgid uint64, handler MsgHandler, isSysMsg bool)
- func (this *MessageCenter) Register_vnode_search(msgid uint64, handler MsgHandler, isSysMsg bool)
- func (this *MessageCenter) SearchAddress(c engine.Controller, msg engine.Packet, message *Message)
- func (this *MessageCenter) SearchAddress_recv(c engine.Controller, msg engine.Packet, message *Message)
- func (this *MessageCenter) SendMulticastMsg(msgid uint64, content *[]byte) error
- func (this *MessageCenter) SendNeighborMsg(msgid uint64, recvid *nodeStore.AddressNet, content *[]byte) (*Message, error)
- func (this *MessageCenter) SendNeighborMsgBySession(msgid uint64, session engine.Session, recvid *nodeStore.AddressNet, ...) (*Message, error)
- func (this *MessageCenter) SendNeighborMsgWaitRequest(msgid uint64, recvid *nodeStore.AddressNet, content *[]byte, ...) (*[]byte, error)
- func (this *MessageCenter) SendNeighborReplyMsg(message *Message, msgid uint64, content *[]byte, session engine.Session) error
- func (this *MessageCenter) SendP2pMsg(msgid uint64, recvid *nodeStore.AddressNet, content *[]byte) (*Message, bool, bool, error)
- func (this *MessageCenter) SendP2pMsgEX(msgid uint64, recvid, recvSuperId *nodeStore.AddressNet, content *[]byte, ...) (*Message, error)
- func (this *MessageCenter) SendP2pMsgEXWaitRequest(msgid uint64, ...) (*[]byte, error)
- func (this *MessageCenter) SendP2pMsgHE(msgid uint64, recvid *nodeStore.AddressNet, content *[]byte) (*Message, bool, bool, error)
- func (this *MessageCenter) SendP2pMsgHEProxy(msgid uint64, recvid, recvProxyId, senderProxyId *nodeStore.AddressNet, ...) (*Message, bool, bool, error)
- func (this *MessageCenter) SendP2pMsgHEProxyWaitRequest(msgid uint64, recvid, recvProxyId, senderProxyId *nodeStore.AddressNet, ...) (*[]byte, bool, bool, error)
- func (this *MessageCenter) SendP2pMsgHEWaitRequest(msgid uint64, recvid *nodeStore.AddressNet, content *[]byte, ...) (*[]byte, bool, bool, error)
- func (this *MessageCenter) SendP2pMsgProxy(msgid uint64, recvid, recvProxyId, senderProxyId *nodeStore.AddressNet, ...) (*Message, bool, bool, error)
- func (this *MessageCenter) SendP2pMsgProxyWaitRequest(msgid uint64, recvid, recvProxyId, senderProxyId *nodeStore.AddressNet, ...) (*[]byte, bool, bool, error)
- func (this *MessageCenter) SendP2pMsgWaitRequest(msgid uint64, recvid *nodeStore.AddressNet, content *[]byte, ...) (*[]byte, bool, bool, error)
- func (this *MessageCenter) SendP2pReplyMsg(message *Message, msgid uint64, content *[]byte) error
- func (this *MessageCenter) SendP2pReplyMsgHE(message *Message, msgid uint64, content *[]byte) error
- func (this *MessageCenter) SendP2pReplyMsgHEProxy(message *Message, msgid uint64, content *[]byte, ...) error
- func (this *MessageCenter) SendP2pReplyMsgProxy(message *Message, msgid uint64, content *[]byte, ...) error
- func (this *MessageCenter) SendSearchAllMsg(msgid uint64, recvid *nodeStore.AddressNet, content *[]byte) (*Message, error)
- func (this *MessageCenter) SendSearchAllReplyMsg(message *Message, msgid uint64, content *[]byte) error
- func (this *MessageCenter) SendSearchSuperMsg(msgid uint64, recvid *nodeStore.AddressNet, content *[]byte) (*Message, error)
- func (this *MessageCenter) SendSearchSuperMsgProxy(msgid uint64, recvid, recvProxyId, senderProxyId *nodeStore.AddressNet, ...) (*Message, error)
- func (this *MessageCenter) SendSearchSuperMsgProxyWaitRequest(msgid uint64, recvid, recvProxyId, senderProxyId *nodeStore.AddressNet, ...) (*[]byte, error)
- func (this *MessageCenter) SendSearchSuperMsgWaitRequest(msgid uint64, recvid *nodeStore.AddressNet, content *[]byte, ...) (*[]byte, error)
- func (this *MessageCenter) SendSearchSuperReplyMsg(message *Message, msgid uint64, content *[]byte) error
- func (this *MessageCenter) SendSearchSuperReplyMsgProxy(message *Message, msgid uint64, content *[]byte, ...) error
- func (this *MessageCenter) SendVnodeP2pMsgHE(msgid uint64, sendVnodeid, recvVnodeid *virtual_node.AddressNetExtend, ...) (*Message, error)
- func (this *MessageCenter) SendVnodeP2pMsgHEWaitRequest(msgid uint64, sendVnodeid, recvVnodeid *virtual_node.AddressNetExtend, ...) (*[]byte, error)
- func (this *MessageCenter) SendVnodeP2pReplyMsgHE(message *Message, msgid uint64, content *[]byte, onebyone bool) error
- func (this *MessageCenter) SendVnodeSearchMsg(msgid uint64, sendVnodeid, recvVnodeid *virtual_node.AddressNetExtend, ...) (*Message, error)
- func (this *MessageCenter) SendVnodeSearchMsgWaitRequest(msgid uint64, sendVnodeid, recvVnodeid *virtual_node.AddressNetExtend, ...) (*[]byte, error)
- func (this *MessageCenter) SendVnodeSearchReplyMsg(message *Message, msgid uint64, content *[]byte, onebyone bool) error
- func (this *MessageCenter) SetLevelDB(leveldb *utilsleveldb.LevelDB)
- func (this *MessageCenter) SyncMulticastMsg(id nodeStore.AddressNet, hash []byte, machineId string) (*go_protobuf.MessageMulticast, error)
- type MessageHead
- func NewMessageHead(nodeSelf *nodeStore.Node, superId, recvid, recvSuperid *nodeStore.AddressNet, ...) *MessageHead
- func NewMessageHeadOneByOne(nodeSelf *nodeStore.Node, superId, recvid, recvSuperid *nodeStore.AddressNet, ...) *MessageHead
- func NewMessageHeadProxy(nodeSelf *nodeStore.Node, ...) *MessageHead
- func NewMessageHeadVnode(senderId *nodeStore.AddressNet, ...) *MessageHead
- type MessageHeadVO
- type MsgHandler
- type MsgHolder
- type MsgHolderOne
- type Router
- type SearchNodeInfo
- type Session
- type SessionKey
- type SessionManager
- func (this *SessionManager) AddRecvPipe(id nodeStore.AddressNet, machineId string, ...) error
- func (this *SessionManager) AddSendPipe(id nodeStore.AddressNet, machineId string, sk, sharedHka, sharedNhkb [32]byte, ...) error
- func (this *SessionManager) GetRecvRatchet(id nodeStore.AddressNet, machineId string) doubleratchet.SessionHE
- func (this *SessionManager) GetSendRatchet(id nodeStore.AddressNet, machineId string) doubleratchet.SessionHE
- func (this *SessionManager) RemoveSendPipe(id nodeStore.AddressNet, machineId string)
- type ShareKey
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddMessageCache ¶
func AddMessageCache(hash *[]byte, msgBytes *go_protobuf.MessageMulticast, levelDB *utilsleveldb.LevelDB) error
添加消息到缓存
func AddMessageCacheByBytes ¶
func AddMessageCacheByBytes(hash, head, body *[]byte, levelDB *utilsleveldb.LevelDB) error
添加消息到缓存
func FindMessageCacheByHash ¶
func FindMessageCacheByHash(hash []byte, levelDB *utilsleveldb.LevelDB) (*[]byte, error)
通过hash查询一条消息
func FindMessageCacheByHashExist ¶
func FindMessageCacheByHashExist(hash []byte, levelDB *utilsleveldb.LevelDB) (bool, error)
通过hash查询一条消息是否存在
func GetSortSession ¶
+给连接的节点排序,结果相对self 由正到负 大到小,确认消息发送顺序 +@return []engine.Session 由远及近排列的节点session数组; +@return 数组中有多少地址大于传入self地址; +
func GetSortSessionForTarget ¶
func GetSortSessionForTarget(ss []engine.Session, self nodeStore.AddressNet, target nodeStore.AddressNet) ([]nodeStore.AddressNet, int)
给连接的节点排序(包括本节点),结果相对target 由正到负 大到小,确认消息发送顺序 +@return []nodeStore.AddressNet 由远及近排列的节点地址; +@return 数组中有多少地址大于传入self地址; +
Types ¶
type Message ¶
type Message struct { Head *MessageHead `json:"head"` // Body *MessageBody `json:"body"` // DataPlus *[]byte `json:"dp"` //body部分加密数据,消息路由时候不需要解密,临时保存 // contains filtered or unexported fields }
发送消息序列化对象
func NewMessage ¶
func NewMessage(head *MessageHead, body *MessageBody) *Message
func ParserMessageProto ¶
func (*Message) BuildReplyHash ¶
func (*Message) Forward ¶
func (this *Message) Forward(version uint64, nodeManager *nodeStore.NodeManager, sessionEngine *engine.Engine, vnc *virtual_node.VnodeManager, from *nodeStore.AddressNet, timeout time.Duration) (bool, error)
检查该消息是否是自己的 不是自己的则自动转发出去 @return bool 是否发送给其他人,true=成功发送给其他人;false=发送给自己; @return error 发送错误信息
func (*Message) GetSortSession ¶
func (this *Message) GetSortSession(allAddr []nodeStore.AddressNet, sessionEngine *engine.Engine) ([]nodeStore.AddressNet, int)
func (*Message) Reply ¶
func (this *Message) Reply(version uint64, nodeManager *nodeStore.NodeManager, sessionEngine *engine.Engine, vnc *virtual_node.VnodeManager) (bool, error)
检查该消息是否是自己的 不是自己的则自动转发出去 @return sendOk bool 是否发送给其他人。true=发送给其他人了;false=自己的消息;
func (*Message) Send ¶
func (this *Message) Send(version uint64, nodeManager *nodeStore.NodeManager, sessionEngine *engine.Engine, vnc *virtual_node.VnodeManager, timeout time.Duration) (bool, error)
检查该消息是否是自己的 不是自己的则自动转发出去 @return bool 是否发送给其他人,true=成功发送给其他人;false=发送给自己; @return error 发送错误信息
type MessageBody ¶
type MessageBody struct { MessageId uint64 `json:"m_id"` //消息协议编号 CreateTime uint64 `json:"c_time"` //消息创建时间unix ReplyTime uint64 `json:"r_time"` //消息回复时间unix Hash []byte `json:"hash"` //消息的hash值 ReplyHash []byte `json:"r_hash"` //回复消息的hash SendRand uint64 `json:"s_rand"` //发送随机数 RecvRand uint64 `json:"r_rand"` //接收随机数 Content *[]byte `json:"content"` //发送的内容 }
func NewMessageBody ¶
func (*MessageBody) Proto ¶
func (this *MessageBody) Proto() ([]byte, error)
type MessageCenter ¶
type MessageCenter struct { RatchetSession *SessionManager // // contains filtered or unexported fields }
func NewMessageCenter ¶
func NewMessageCenter(nodeManager *nodeStore.NodeManager, sessionEngine *engine.Engine, vm *virtual_node.VnodeManager, key keystore.KeystoreInterface, c context.Context, areaName []byte) *MessageCenter
func (*MessageCenter) BroadcastsAll ¶
func (this *MessageCenter) BroadcastsAll(msgid, p2pMsgid uint64, whiltlistNodes, superNodes, proxyNodes []nodeStore.AddressNet, hash *[]byte) error
func (*MessageCenter) CheckRepeatHash ¶
func (this *MessageCenter) CheckRepeatHash(sendhash []byte) bool
检查重复消息,检查这个消息是否发送过 @return bool 是否重复。true=重复;false=不重复;
func (*MessageCenter) CleanHEInfo ¶
func (this *MessageCenter) CleanHEInfo(id nodeStore.AddressNet, machineId string)
* 清理加密通道信息
func (*MessageCenter) CreatePipe ¶
func (this *MessageCenter) CreatePipe(c engine.Controller, msg engine.Packet, message *Message)
获取节点地址和身份公钥
func (*MessageCenter) CreatePipe_recv ¶
func (this *MessageCenter) CreatePipe_recv(c engine.Controller, msg engine.Packet, message *Message)
获取节点地址和身份公钥_返回
func (*MessageCenter) GetSearchNetAddr ¶
func (this *MessageCenter) GetSearchNetAddr(nodeId, recvProxyId, senderProxyId *nodeStore.AddressNet, oneByOne bool, num uint16) ([]nodeStore.AddressNet, error)
获取磁力节点地址
func (*MessageCenter) GetSearchNetAddrProxy ¶
func (this *MessageCenter) GetSearchNetAddrProxy(nodeId, recvProxyId, senderProxyId *nodeStore.AddressNet) (*nodeStore.AddressNet, error)
* 获取磁力节点地址,可以指定发送端的代理节点
func (*MessageCenter) Init ¶
func (this *MessageCenter) Init()
func (*MessageCenter) NeighborHandler ¶
func (this *MessageCenter) NeighborHandler(c engine.Controller, msg engine.Packet)
邻居节点消息控制器,不转发消息
func (*MessageCenter) Pipe_error ¶
func (this *MessageCenter) Pipe_error(c engine.Controller, msg engine.Packet, message *Message)
解密错误
func (*MessageCenter) RegisterMsgVersion ¶
func (this *MessageCenter) RegisterMsgVersion()
func (*MessageCenter) Register_multicast ¶
func (this *MessageCenter) Register_multicast(msgid uint64, handler MsgHandler, isSysMsg bool)
注册广播消息
func (*MessageCenter) Register_neighbor ¶
func (this *MessageCenter) Register_neighbor(msgid uint64, handler MsgHandler, isSysMsg bool)
注册邻居节点消息,不转发
func (*MessageCenter) Register_p2p ¶
func (this *MessageCenter) Register_p2p(msgid uint64, handler MsgHandler, isSysMsg bool)
注册点对点通信消息
func (*MessageCenter) Register_p2pHE ¶
func (this *MessageCenter) Register_p2pHE(msgid uint64, handler MsgHandler, isSysMsg bool)
注册点对点通信消息
func (*MessageCenter) Register_search_all ¶
func (this *MessageCenter) Register_search_all(msgid uint64, handler MsgHandler, isSysMsg bool)
注册消息 从所有节点中搜索节点,包括普通节点
func (*MessageCenter) Register_search_super ¶
func (this *MessageCenter) Register_search_super(msgid uint64, handler MsgHandler, isSysMsg bool)
注册消息 从超级节点中搜索目标节点
func (*MessageCenter) Register_vnode_p2pHE ¶
func (this *MessageCenter) Register_vnode_p2pHE(msgid uint64, handler MsgHandler, isSysMsg bool)
注册虚拟节点之间点对点加密消息
func (*MessageCenter) Register_vnode_search ¶
func (this *MessageCenter) Register_vnode_search(msgid uint64, handler MsgHandler, isSysMsg bool)
注册虚拟节点搜索节点消息
func (*MessageCenter) SearchAddress ¶
func (this *MessageCenter) SearchAddress(c engine.Controller, msg engine.Packet, message *Message)
获取节点地址和身份公钥
func (*MessageCenter) SearchAddress_recv ¶
func (this *MessageCenter) SearchAddress_recv(c engine.Controller, msg engine.Packet, message *Message)
获取节点地址和身份公钥_返回
func (*MessageCenter) SendMulticastMsg ¶
func (this *MessageCenter) SendMulticastMsg(msgid uint64, content *[]byte) error
发送一个新的广播消息
func (*MessageCenter) SendNeighborMsg ¶
func (this *MessageCenter) SendNeighborMsg(msgid uint64, recvid *nodeStore.AddressNet, content *[]byte) (*Message, error)
发送一个新邻居节点消息 发出去不管 @return bool 消息是否发送成功
func (*MessageCenter) SendNeighborMsgBySession ¶
func (this *MessageCenter) SendNeighborMsgBySession(msgid uint64, session engine.Session, recvid *nodeStore.AddressNet, content *[]byte) (*Message, error)
发送一个新邻居节点消息 发出去不管 @return bool 消息是否发送成功
func (*MessageCenter) SendNeighborMsgWaitRequest ¶
func (this *MessageCenter) SendNeighborMsgWaitRequest(msgid uint64, recvid *nodeStore.AddressNet, content *[]byte, timeout time.Duration) (*[]byte, error)
发送一个新邻居节点消息 发送出去,等返回
func (*MessageCenter) SendNeighborReplyMsg ¶
func (this *MessageCenter) SendNeighborReplyMsg(message *Message, msgid uint64, content *[]byte, session engine.Session) error
对某个消息回复
func (*MessageCenter) SendP2pMsg ¶
func (this *MessageCenter) SendP2pMsg(msgid uint64, recvid *nodeStore.AddressNet, content *[]byte) (*Message, bool, bool, error)
给指定节点发送一个消息 @return *Message 返回的消息 @return bool 是否发送成功 @return bool 消息是发给自己 @return error 发送失败
func (*MessageCenter) SendP2pMsgEX ¶
func (this *MessageCenter) SendP2pMsgEX(msgid uint64, recvid, recvSuperId *nodeStore.AddressNet, content *[]byte, hash *[]byte) (*Message, error)
给指定节点发送一个消息 是SendP2pMsg方法的定制版本,多了recvSuperId参数。
func (*MessageCenter) SendP2pMsgEXWaitRequest ¶
func (this *MessageCenter) SendP2pMsgEXWaitRequest(msgid uint64, recvid, recvSuperId, recvProxyId, senderProxyId *nodeStore.AddressNet, recvMachineId string, content *[]byte, timeout time.Duration) (*[]byte, error)
给指定节点发送一个消息 是SendP2pMsg方法的定制版本,多了recvSuperId、recvProxId和senderProxyId参数。
func (*MessageCenter) SendP2pMsgHE ¶
func (this *MessageCenter) SendP2pMsgHE(msgid uint64, recvid *nodeStore.AddressNet, content *[]byte) (*Message, bool, bool, error)
发送一个加密消息,包括消息头也加密 @return *Message 返回的消息 @return bool 是否发送成功 @return bool 消息是发给自己
func (*MessageCenter) SendP2pMsgHEProxy ¶
func (this *MessageCenter) SendP2pMsgHEProxy(msgid uint64, recvid, recvProxyId, senderProxyId *nodeStore.AddressNet, recvMachineId string, content *[]byte) (*Message, bool, bool, error)
* 发送一个加密消息,包括消息头也加密,可以指定接收端和发送端的代理节点 * @return *Message 返回的消息 * @return bool 是否发送成功 * @return bool 消息是发给自己
func (*MessageCenter) SendP2pMsgHEProxyWaitRequest ¶
func (this *MessageCenter) SendP2pMsgHEProxyWaitRequest(msgid uint64, recvid, recvProxyId, senderProxyId *nodeStore.AddressNet, recvMachineId string, content *[]byte, timeout time.Duration) (*[]byte, bool, bool, error)
* 发送一个加密消息,包括消息头也加密,可以指定接收端和发送端的代理节点 * @return *Message 返回的消息 * @return bool 是否发送成功 * @return bool 消息是发给自己
func (*MessageCenter) SendP2pMsgHEWaitRequest ¶
func (this *MessageCenter) SendP2pMsgHEWaitRequest(msgid uint64, recvid *nodeStore.AddressNet, content *[]byte, timeout time.Duration) (*[]byte, bool, bool, error)
发送一个加密消息,包括消息头也加密 @return *Message 返回的消息 @return bool 是否发送成功 @return bool 消息是发给自己
func (*MessageCenter) SendP2pMsgProxy ¶
func (this *MessageCenter) SendP2pMsgProxy(msgid uint64, recvid, recvProxyId, senderProxyId *nodeStore.AddressNet, recvMachineId string, content *[]byte) (*Message, bool, bool, error)
* 给指定节点发送一个消息,可以指定发送端的代理节点 * * @param msgid uint64 消息号 * @param recvid addressnet 接收者节点id * @param recvProxyId addressnet 接收者代理节点id * @param senderProxyId addressnet 发送者代理节点id * @param recvMachineId string 接收方机器Id * @param content []byte 发送内容 * @return msg *Message 返回的消息 * @return sendSuccess bool 是否发送成功 * @return toSelf bool 消息是发给自己 * @return err error 错误信息
func (*MessageCenter) SendP2pMsgProxyWaitRequest ¶
func (this *MessageCenter) SendP2pMsgProxyWaitRequest(msgid uint64, recvid, recvProxyId, senderProxyId *nodeStore.AddressNet, recvMachineId string, content *[]byte, timeout time.Duration) (*[]byte, bool, bool, error)
* 给指定节点发送一个消息,可以指定接收端和发送端的代理节点 * @return *[]byte 返回的内容 * @return bool 是否发送成功 * @return bool 消息是发给自己
func (*MessageCenter) SendP2pMsgWaitRequest ¶
func (this *MessageCenter) SendP2pMsgWaitRequest(msgid uint64, recvid *nodeStore.AddressNet, content *[]byte, timeout time.Duration) (*[]byte, bool, bool, error)
给指定节点发送一个消息 @return *[]byte 返回的内容 @return bool 是否发送成功 @return bool 消息是发给自己
func (*MessageCenter) SendP2pReplyMsg ¶
func (this *MessageCenter) SendP2pReplyMsg(message *Message, msgid uint64, content *[]byte) error
对某个消息回复
func (*MessageCenter) SendP2pReplyMsgHE ¶
func (this *MessageCenter) SendP2pReplyMsgHE(message *Message, msgid uint64, content *[]byte) error
对某个消息回复
func (*MessageCenter) SendP2pReplyMsgHEProxy ¶
func (this *MessageCenter) SendP2pReplyMsgHEProxy(message *Message, msgid uint64, content *[]byte, senderProxyId *nodeStore.AddressNet) error
* 对某个消息回复,可以指定发送端的代理节点
func (*MessageCenter) SendP2pReplyMsgProxy ¶
func (this *MessageCenter) SendP2pReplyMsgProxy(message *Message, msgid uint64, content *[]byte, senderProxyId *nodeStore.AddressNet) error
* 对某个消息回复,可以指定发送端的代理节点
func (*MessageCenter) SendSearchAllMsg ¶
func (this *MessageCenter) SendSearchAllMsg(msgid uint64, recvid *nodeStore.AddressNet, content *[]byte) (*Message, error)
发送一个新的查找超级节点消息
func (*MessageCenter) SendSearchAllReplyMsg ¶
func (this *MessageCenter) SendSearchAllReplyMsg(message *Message, msgid uint64, content *[]byte) error
对某个消息回复
func (*MessageCenter) SendSearchSuperMsg ¶
func (this *MessageCenter) SendSearchSuperMsg(msgid uint64, recvid *nodeStore.AddressNet, content *[]byte) (*Message, error)
发送一个新的查找超级节点消息 @return bool 是否发送给其他节点:true=发送成功;false=发送失败;
func (*MessageCenter) SendSearchSuperMsgProxy ¶
func (this *MessageCenter) SendSearchSuperMsgProxy(msgid uint64, recvid, recvProxyId, senderProxyId *nodeStore.AddressNet, content *[]byte) (*Message, error)
* 发送一个新的查找超级节点消息,可以指定发送端的代理节点 * @msgid uint64 消息号 * @recvid addressnet 接收者节点id * @recvProxyId addressnet 接收者代理节点id * @senderProxyId addressnet 发送者代理节点id * @content []byte 发送内容 * @return bool 是否发送给其他节点:true=发送成功;false=发送失败;
func (*MessageCenter) SendSearchSuperMsgProxyWaitRequest ¶
func (this *MessageCenter) SendSearchSuperMsgProxyWaitRequest(msgid uint64, recvid, recvProxyId, senderProxyId *nodeStore.AddressNet, content *[]byte, timeout time.Duration, oneByOne bool) (*[]byte, error)
* 发送一个新的查找超级节点消息,可以指定发送端的代理节点 * @msgid uint64 消息号 * @recvid addressnet 接收者节点id * @recvProxyId addressnet 接收者代理节点id * @senderProxyId addressnet 发送者代理节点id * @content []byte 发送内容 * @return bool 是否发送给其他节点:true=发送成功;false=发送失败;
func (*MessageCenter) SendSearchSuperMsgWaitRequest ¶
func (this *MessageCenter) SendSearchSuperMsgWaitRequest(msgid uint64, recvid *nodeStore.AddressNet, content *[]byte, timeout time.Duration, oneByOne bool) (*[]byte, error)
发送一个新的查找超级节点消息
func (*MessageCenter) SendSearchSuperReplyMsg ¶
func (this *MessageCenter) SendSearchSuperReplyMsg(message *Message, msgid uint64, content *[]byte) error
对某个消息回复
func (*MessageCenter) SendSearchSuperReplyMsgProxy ¶
func (this *MessageCenter) SendSearchSuperReplyMsgProxy(message *Message, msgid uint64, content *[]byte, senderProxyId *nodeStore.AddressNet) error
* 对某个消息回复,可以指定发送端的代理节点
func (*MessageCenter) SendVnodeP2pMsgHE ¶
func (this *MessageCenter) SendVnodeP2pMsgHE(msgid uint64, sendVnodeid, recvVnodeid *virtual_node.AddressNetExtend, recvNodeId, recvProxyId, senderProxyId *nodeStore.AddressNet, recvMachineId string, content *[]byte) (*Message, error)
发送虚拟节点之间点对点消息
func (*MessageCenter) SendVnodeP2pMsgHEWaitRequest ¶
func (this *MessageCenter) SendVnodeP2pMsgHEWaitRequest(msgid uint64, sendVnodeid, recvVnodeid *virtual_node.AddressNetExtend, recvNodeId, recvProxyId, senderProxyId *nodeStore.AddressNet, recvMachineId string, content *[]byte, timeout time.Duration) (*[]byte, error)
发送虚拟节点搜索节点消息
func (*MessageCenter) SendVnodeP2pReplyMsgHE ¶
func (this *MessageCenter) SendVnodeP2pReplyMsgHE(message *Message, msgid uint64, content *[]byte, onebyone bool) error
对发送虚拟节点之间点对点消息回复
func (*MessageCenter) SendVnodeSearchMsg ¶
func (this *MessageCenter) SendVnodeSearchMsg(msgid uint64, sendVnodeid, recvVnodeid *virtual_node.AddressNetExtend, recvProxyId, senderProxyId *nodeStore.AddressNet, content *[]byte) (*Message, error)
发送虚拟节点搜索节点消息
func (*MessageCenter) SendVnodeSearchMsgWaitRequest ¶
func (this *MessageCenter) SendVnodeSearchMsgWaitRequest(msgid uint64, sendVnodeid, recvVnodeid *virtual_node.AddressNetExtend, recvProxyId, senderProxyId *nodeStore.AddressNet, content *[]byte, timeout time.Duration, onebyone bool) (*[]byte, error)
发送到目标节点时用 虚拟节点onebyone规则搜索节点 目标节点发回时使用p2p消息 发送 虚拟节点 搜索节点消息
func (*MessageCenter) SendVnodeSearchReplyMsg ¶
func (this *MessageCenter) SendVnodeSearchReplyMsg(message *Message, msgid uint64, content *[]byte, onebyone bool) error
对发送虚拟节点搜索节点消息回复
func (*MessageCenter) SetLevelDB ¶
func (this *MessageCenter) SetLevelDB(leveldb *utilsleveldb.LevelDB)
设置数据库
func (*MessageCenter) SyncMulticastMsg ¶
func (this *MessageCenter) SyncMulticastMsg(id nodeStore.AddressNet, hash []byte, machineId string) (*go_protobuf.MessageMulticast, error)
* 去邻居节点同步广播消息 * * @param id AddressNet 同步对象的地址 * @param hash []byte 需要同步的消息hash值 * @param machineId string 同步对象的设备机器Id,可以穿空串,如果传值,则会根据设备id,获取对应的session进行处理 * @return res MessageMulticast 同步到的消息信息 * @return err error 错误信息
type MessageHead ¶
type MessageHead struct { RecvId *nodeStore.AddressNet `json:"r_id"` //接收者id RecvSuperId *nodeStore.AddressNet `json:"r_s_id"` //接收者的超级节点id RecvVnode *virtual_node.AddressNetExtend `json:"r_v_id"` //接收者虚拟节点id Sender *nodeStore.AddressNet `json:"s_id"` //发送者id SenderSuperId *nodeStore.AddressNet `json:"s_s_id"` //发送者超级节点id SenderVnode *virtual_node.AddressNetExtend `json:"s_v_id"` //发送者虚拟节点id Accurate bool `json:"a"` //是否准确发送给一个节点,如果 OneByOne bool `json:"onebyone"` //是否使用onebyone规则去路由 RecvProxyId *nodeStore.AddressNet `json:"r_p_id"` //接收者代理节点id SenderProxyId *nodeStore.AddressNet `json:"s_p_id"` //发送者代理节点id SearchVnodeEndId *virtual_node.AddressNetExtend `json:"s_v_e_id"` //最终接收者虚拟节点id SelfVnodeId *virtual_node.AddressNetExtend //查询磁力节点的时候,落到自己的哪个虚拟节点上。此字段不作序列化。 SenderMachineID string `json:"s_m_id"` // 发送者设备机器id RecvMachineID string `json:"r_m_id"` // 接收者者设备机器id }
func NewMessageHead ¶
func NewMessageHead(nodeSelf *nodeStore.Node, superId, recvid, recvSuperid *nodeStore.AddressNet, accurate bool, senderMachineId, recvMachineID string) *MessageHead
func NewMessageHeadOneByOne ¶
func NewMessageHeadOneByOne(nodeSelf *nodeStore.Node, superId, recvid, recvSuperid *nodeStore.AddressNet, accurate, oneByOne bool, senderMachineId, recvMachineID string) *MessageHead
func NewMessageHeadProxy ¶
func NewMessageHeadProxy(nodeSelf *nodeStore.Node, superId, recvid, recvSuperid, recvProxyid, senderProxyid *nodeStore.AddressNet, accurate bool, senderMachineId, recvMachineID string) *MessageHead
创建含有接收者代理节点和发送者代理节点的消息头
func NewMessageHeadVnode ¶
func NewMessageHeadVnode(senderId *nodeStore.AddressNet, sendVid, recvVid *virtual_node.AddressNetExtend, recvProxyid, senderProxyid *nodeStore.AddressNet, accurate bool, senderMachineId, recvMachineID string) *MessageHead
创建一个虚拟节点消息
func (*MessageHead) JSON ¶
func (this *MessageHead) JSON() ([]byte, error)
func (*MessageHead) Proto ¶
func (this *MessageHead) Proto() []byte
type MessageHeadVO ¶
type MsgHandler ¶
type MsgHandler func(c engine.Controller, msg engine.Packet, message *Message)
type MsgHolder ¶
type MsgHolder struct { MsgHash []byte //消息hash Lock *sync.RWMutex // Holder []*MsgHolderOne //消息持有者 HolderTag []bool //消息持有者同步标志,超时或者同步失败,设置为true IsRun bool //是否正在同步 IsFinish bool //是否已经同步到了消息 RunSignal chan bool //继续运行信号 }
func CreateMsgHolder ¶
func CreateMsgHolder(holder *MsgHolderOne, mc *MessageCenter) *MsgHolder
func (*MsgHolder) AddHolder ¶
func (this *MsgHolder) AddHolder(holder *MsgHolderOne)
func (*MsgHolder) GetHolder ¶
func (this *MsgHolder) GetHolder() (holder *MsgHolderOne)
func (*MsgHolder) GetMulticastMsg ¶
func (this *MsgHolder) GetMulticastMsg(messageCenter *MessageCenter)
同步新消息并广播给其他节点
func (*MsgHolder) SetHolder ¶
func (this *MsgHolder) SetHolder(holder *MsgHolderOne)
type MsgHolderOne ¶
type Router ¶
type Router struct {
// contains filtered or unexported fields
}
func (*Router) GetHandler ¶
func (this *Router) GetHandler(msgid uint64) MsgHandler
type SearchNodeInfo ¶
type SearchNodeInfo struct { Id *nodeStore.AddressNet // SuperId *nodeStore.AddressNet // CPuk dh.Key // }
func ParserSearchNodeInfo ¶
func ParserSearchNodeInfo(bs []byte) (*SearchNodeInfo, error)
func (*SearchNodeInfo) Proto ¶
func (this *SearchNodeInfo) Proto() ([]byte, error)
type Session ¶
type Session struct { Id nodeStore.AddressNet //节点地址 // contains filtered or unexported fields }
func NewSession ¶
func NewSession(id nodeStore.AddressNet) Session
type SessionKey ¶
type SessionKey struct {
// contains filtered or unexported fields
}
加密通道
func NewSessionKey ¶
func NewSessionKey(sk, sharedHka, sharedNhkb [32]byte) SessionKey
type SessionManager ¶
type SessionManager struct {
// contains filtered or unexported fields
}
func (*SessionManager) AddRecvPipe ¶
func (this *SessionManager) AddRecvPipe(id nodeStore.AddressNet, machineId string, sk, sharedHka, sharedNhkb, puk [32]byte) error
添加一个接收管道
func (*SessionManager) AddSendPipe ¶
func (this *SessionManager) AddSendPipe(id nodeStore.AddressNet, machineId string, sk, sharedHka, sharedNhkb [32]byte, key keystore.KeystoreInterface) error
添加一个发送管道
func (*SessionManager) GetRecvRatchet ¶
func (this *SessionManager) GetRecvRatchet(id nodeStore.AddressNet, machineId string) doubleratchet.SessionHE
获取一个接收棘轮
func (*SessionManager) GetSendRatchet ¶
func (this *SessionManager) GetSendRatchet(id nodeStore.AddressNet, machineId string) doubleratchet.SessionHE
获取一个发送棘轮
func (*SessionManager) RemoveSendPipe ¶
func (this *SessionManager) RemoveSendPipe(id nodeStore.AddressNet, machineId string)
删除发送管道