Exemple #1
0
        public ActionResult GetNodesRaw(string nodeid)
        {
            var nodes = GetNodes(nodeid);

            if (nodes != null)
            {
                var key = _node.NodeConfiguration.LocaleNodePrivateKey;
                var m   = new KademliaQueryResultMessage
                {
                    Nodes   = nodes,
                    SignKey = key
                };

                return(File(m.ToByteArray(), "application/octet-stream", "result.data"));
            }
            return(BadRequestJson());
        }
Exemple #2
0
        Task OnQueryResult(KademliaQueryResultMessage message, Connection connection, NodeInfo nodeInfo)
        {
            if (Log.LogTrace)
            {
                Log.Trace($"Kademlia QueryResult received from: {nodeInfo.PublicEndPoint}", this);
            }

            lock (_lock)
            {
                _queryNodes.Add(nodeInfo);
                foreach (var node in message.Nodes)
                {
                    _queryNodes.Add(node);
                }
            }

            return(Task.CompletedTask);
        }
Exemple #3
0
        async Task OnQuery(KademliaQueryMessage message, Connection connection, NodeInfo nodeInfo)
        {
            if (Log.LogTrace)
            {
                Log.Trace($"Kademlia Query received from: {nodeInfo.PublicEndPoint}", this);
            }

            lock (_lock)
                _queryNodes.Add(nodeInfo);

            var nodes         = _bucket.GetNearNodes(nodeInfo.NodeId);
            var resultMessage = new KademliaQueryResultMessage {
                SignKey = LocalKey
            };

            foreach (var node in nodes)
            {
                resultMessage.Nodes.Add(node);
            }

            await connection.Send(resultMessage);
        }