Esempio n. 1
0
        public void RemovePeerFromBlacklist_Test()
        {
            var ipAddress = "127.0.0.1";

            _blackListProvider.AddHostToBlackList(ipAddress, int.MaxValue);
            _blackListProvider.IsIpBlackListed(ipAddress).ShouldBeTrue();

            _blackListProvider.RemoveHostFromBlackList(ipAddress).ShouldBeTrue();

            _blackListProvider.IsIpBlackListed(ipAddress).ShouldBeFalse();

            _blackListProvider.RemoveHostFromBlackList(ipAddress).ShouldBeFalse();
        }
        private async Task <bool> TryAddPeerAsync(string endpoint, bool isTrusted)
        {
            if (!AElfPeerEndpointHelper.TryParse(endpoint, out var aelfPeerEndpoint))
            {
                Logger.LogDebug($"Could not parse endpoint {endpoint}.");
                return(false);
            }

            if (isTrusted)
            {
                _blackListedPeerProvider.RemoveHostFromBlackList(aelfPeerEndpoint.Host);
            }

            return(await _networkServer.ConnectAsync(aelfPeerEndpoint));
        }