Ejemplo n.º 1
0
        public IActionResult Index(string node, string location = "NY")
        {
            ViewData["sidebar"]  = "serverlist";
            ViewData["WhereAmI"] = node;
            ViewData["location"] = location;
            NodeInfoViewModel nodeObj = new NodeInfoViewModel();

            nodeObj.Name = node;
            nodeObj.SelectFromDb();
            return(View(nodeObj));
        }
Ejemplo n.º 2
0
        public IActionResult Nodes()
        {
            List <NodeInfoViewModel> lists = new List <NodeInfoViewModel>();
            var nodes = TinctTaskService.GetCurrentNodes();

            foreach (var node in nodes)
            {
                NodeInfoViewModel m = new NodeInfoViewModel();
                m.NodeName       = node.NodeName;
                m.LastUpdateTime = DateTimeExtension.GetTimeFromTimeSpan(node.LastUpdateTime);
                m.Status         = node.Status;
                lists.Add(m);
            }

            ViewBag.Nodes    = lists;
            ViewBag.PageSize = 10;
            return(View());
        }
        public IActionResult GetNodeInfo(string nodePubKey)
        {
            var connectReply = this._blocknetService.xrConnectedNodes().Reply;
            var configReply  = this._blocknetService.xrShowConfigs();
            var serviceNode  = connectReply.Find(s => s.NodePubKey == nodePubKey);

            if (string.IsNullOrWhiteSpace(serviceNode.NodePubKey))
            {
                return(BadRequest());
            }

            string config            = string.Empty;
            var    serviceNodeConfig = configReply.Find(c => c.NodePubKey == serviceNode.NodePubKey);

            if (serviceNodeConfig != null)
            {
                config = serviceNodeConfig.Config;
            }

            var viewModel = new NodeInfoViewModel
            {
                Banned         = serviceNode.Banned,
                FeeDefault     = serviceNode.FeeDefault,
                Fees           = serviceNode.Fees,
                NodePubKey     = serviceNode.NodePubKey,
                PaymentAddress = serviceNode.PaymentAddress,
                Score          = serviceNode.Score,
                Config         = config,
                Services       = serviceNode.Services.Select(s => s.Key).ToList(),
                SpvWallets     = serviceNode.SpvWallets,
                SpvConfigs     = serviceNode.SpvConfigs.Select(s => new SpvConfigViewModel {
                    SpvWallet = s.SpvWallet,
                    Commands  = s.Commands.Select(c => new SpvCommandViewModel {
                        Command        = c.Command,
                        Disabled       = c.Disabled,
                        Fee            = c.Fee,
                        PaymentAddress = c.PaymentAddress,
                        RequestLimit   = c.RequestLimit
                    }).ToList()
                }).ToList()
            };

            return(Ok(viewModel));
        }
Ejemplo n.º 4
0
        public IActionResult GetNodeInfo(string nodePubKey, string service = null, int node_count = 1)
        {
            if (string.IsNullOrWhiteSpace(nodePubKey))
            {
                return(BadRequest("NodePubKey was not supplied"));
            }

            var getConnectedResponse = xrouterService.xrConnectedNodes();
            var connectReply         = getConnectedResponse.Reply;

            var serviceNode = connectReply.Find(s => s.NodePubKey == nodePubKey);

            if (serviceNode == null)
            {
                if (service == null)
                {
                    service = "xr::BLOCK";
                }

                var connectResponse = xrouterService.xrConnect(service, node_count);

                serviceNode = connectResponse.Reply.Find(s => s.NodePubKey == nodePubKey);

                if (serviceNode == null)
                {
                    return(StatusCode(StatusCodes.Status500InternalServerError, new JsonRpcXrError
                    {
                        Error = "Servicenode info cannot be retrieved." + Environment.NewLine + "Node Public Key: " + nodePubKey,
                    }));
                }
            }
            string config = string.Empty;

            var configReply = xrouterService.xrShowConfigs();

            var serviceNodeConfig = configReply.Find(c => c.NodePubKey == serviceNode.NodePubKey);

            if (serviceNodeConfig != null)
            {
                config = serviceNodeConfig.Config;
            }

            var serviceNodeConfigElements = config.Split(new string[] { "\n", "\r\n" }, StringSplitOptions.RemoveEmptyEntries)
                                            .Select(value => value.Split('='));

            string serviceNodeHost = null;

            if (serviceNodeConfigElements.Any(lc => lc[0] == "host"))
            {
                serviceNodeHost = serviceNodeConfigElements.FirstOrDefault(e => e[0] == "host")[1];
            }

            string serviceNodePort = null;

            if (serviceNodeConfigElements.Any(lc => lc[0] == "port"))
            {
                serviceNodePort = serviceNodeConfigElements.FirstOrDefault(e => e[0] == "port")[1];
            }

            var viewModel = new NodeInfoViewModel
            {
                Type           = (serviceNodePort == "41412" || string.IsNullOrEmpty(serviceNodePort))? "Regular" : "Enterprise",
                Host           = serviceNodeHost,
                Port           = serviceNodePort,
                Banned         = serviceNode.Banned,
                FeeDefault     = serviceNode.FeeDefault,
                Fees           = serviceNode.Fees,
                NodePubKey     = serviceNode.NodePubKey,
                PaymentAddress = serviceNode.PaymentAddress,
                Score          = serviceNode.Score,
                Config         = config,
                Services       = serviceNode.Services.Select(s => s.Key).ToList(),
                SpvWallets     = serviceNode.SpvWallets,
                SpvConfigs     = serviceNode.SpvConfigs.Select(s => new SpvConfigViewModel {
                    SpvWallet = s.SpvWallet,
                    Commands  = s.Commands.Select(c => new SpvCommandViewModel {
                        Command        = c.Command,
                        Disabled       = c.Disabled,
                        Fee            = c.Fee,
                        PaymentAddress = c.PaymentAddress,
                        RequestLimit   = c.RequestLimit
                    }).ToList()
                }).ToList()
            };

            return(Ok(viewModel));
        }