Implemented Equals and GetHashCode for VirtualNetworkIdentifier
All checks were successful
🚀 Pack skyscraper8 / make-zip (push) Successful in 58s
All checks were successful
🚀 Pack skyscraper8 / make-zip (push) Successful in 58s
This commit is contained in:
parent
56b6b84ffd
commit
e86a89846d
@ -6,26 +6,29 @@ using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using skyscraper5.Ietf.Rfc971;
|
||||
using skyscraper5.src.Skyscraper.Scraper;
|
||||
using skyscraper8.Skyscraper.Net.VirtualNetworks;
|
||||
|
||||
namespace skyscraper5.Skyscraper.Net
|
||||
{
|
||||
public class IpTrafficInfo
|
||||
{
|
||||
internal static IpTrafficInfo FromInternetHeader(InternetHeader ih)
|
||||
internal static IpTrafficInfo FromInternetHeader(InternetHeader ih, VirtualNetworkIdentifier networkIdentifier)
|
||||
{
|
||||
IpTrafficInfo child = new IpTrafficInfo();
|
||||
child.Source = ih.SourceAddress;
|
||||
child.Target = ih.DestinationAddress;
|
||||
child.Protocol = ih.Protocol;
|
||||
child.NetworkIdentifier = networkIdentifier;
|
||||
return child;
|
||||
}
|
||||
|
||||
internal static IpTrafficInfo FromIPAddresses(IPAddress source, IPAddress destination, byte protocol)
|
||||
internal static IpTrafficInfo FromIPAddresses(IPAddress source, IPAddress destination, byte protocol, VirtualNetworkIdentifier networkIdentifier)
|
||||
{
|
||||
IpTrafficInfo child = new IpTrafficInfo();
|
||||
child.Source = source;
|
||||
child.Target = destination;
|
||||
child.Protocol = protocol;
|
||||
child.NetworkIdentifier = networkIdentifier;
|
||||
return child;
|
||||
}
|
||||
|
||||
@ -33,12 +36,13 @@ namespace skyscraper5.Skyscraper.Net
|
||||
public IPAddress Target { get; set; }
|
||||
|
||||
public byte Protocol { get; set; }
|
||||
public VirtualNetworkIdentifier NetworkIdentifier { get; private set; }
|
||||
public string SourceName { get; set; }
|
||||
public string TargetName { get; set; }
|
||||
|
||||
public bool Equals(IpTrafficInfo other)
|
||||
{
|
||||
return Equals(Source, other.Source) && Equals(Target, other.Target) && Protocol == other.Protocol;
|
||||
return Equals(Source, other.Source) && Equals(Target, other.Target) && Protocol == other.Protocol && Equals(NetworkIdentifier, other.NetworkIdentifier); ;
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
@ -48,7 +52,7 @@ namespace skyscraper5.Skyscraper.Net
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return HashCode.Combine(Source, Target, Protocol);
|
||||
return HashCode.Combine(Source, Target, Protocol, NetworkIdentifier.GetHashCode());
|
||||
}
|
||||
|
||||
public static string GetProtocolName(byte Protocol)
|
||||
|
||||
@ -42,5 +42,28 @@ namespace skyscraper8.Skyscraper.Net.VirtualNetworks
|
||||
{
|
||||
return GetHumanReadableName();
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return HashCode.Combine(GetNetworkTypeId(), GetIdentifier());
|
||||
}
|
||||
|
||||
public override bool Equals(object? obj)
|
||||
{
|
||||
if (obj == null)
|
||||
return false;
|
||||
|
||||
VirtualNetworkIdentifier that = obj as VirtualNetworkIdentifier;
|
||||
if (that == null)
|
||||
return false;
|
||||
|
||||
if (this.GetNetworkTypeId() != that.GetNetworkTypeId())
|
||||
return false;
|
||||
|
||||
if (this.GetIdentifier() != that.GetIdentifier())
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1897,7 +1897,7 @@ namespace skyscraper5.Skyscraper.Scraper
|
||||
if (trafficInfos == null)
|
||||
trafficInfos = new HashSet<IpTrafficInfo>();
|
||||
|
||||
IpTrafficInfo iti = IpTrafficInfo.FromInternetHeader(internetHeader);
|
||||
IpTrafficInfo iti = IpTrafficInfo.FromInternetHeader(internetHeader, networkId);
|
||||
if (ProcessDns(iti, ipv4Packet))
|
||||
{
|
||||
LogEvent(SkyscraperContextEvent.LearnDns, String.Format("{0} = {1}", DnsCache.LastLearned.Value, DnsCache.LastLearned.Key));
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user