Exemplo n.º 1
0
 public bool Reject(PeerAddress peerAddress, ICollection <PeerAddress> all, Number160 target)
 {
     if (peerAddress.InetAddress.IsIPv4())
     {
         var ipv4 = IPv4.FromInetAddress(peerAddress.InetAddress);
         // ReSharper disable once LoopCanBeConvertedToQuery
         foreach (var paddr in all)
         {
             if (paddr.InetAddress.IsIPv4())
             {
                 var ipv4Test = IPv4.FromInetAddress(paddr.InetAddress);
                 if (ipv4.MaskWithNetworkMask(_mask4).Equals(ipv4Test.MaskWithNetworkMask(_mask4)))
                 {
                     return(true);
                 }
             }
         }
     }
     else
     {
         var ipv6 = IPv6.FromInetAddress(peerAddress.InetAddress);
         // ReSharper disable once LoopCanBeConvertedToQuery
         foreach (var paddr in all)
         {
             if (paddr.InetAddress.IsIPv6())
             {
                 var ipv6Test = IPv6.FromInetAddress(paddr.InetAddress);
                 if (ipv6.MaskWithNetworkMask(_mask6).Equals(ipv6Test.MaskWithNetworkMask(_mask6)))
                 {
                     return(true);
                 }
             }
         }
     }
     return(false);
 }