Skip to content

Commit

Permalink
Finish adressing build warning code
Browse files Browse the repository at this point in the history
  • Loading branch information
H4NM committed Jan 14, 2025
1 parent 3ab2ed1 commit da8aa7c
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 14 deletions.
2 changes: 1 addition & 1 deletion WhoYouCalling.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Platforms>AnyCPU;x64;x86</Platforms>
<FileVersion>1.4</FileVersion>
<FileVersion>1.4.1</FileVersion>
<ApplicationManifest>WhoYouCalling\app.manifest</ApplicationManifest>
<AssemblyName>wyc</AssemblyName>
</PropertyGroup>
Expand Down
16 changes: 13 additions & 3 deletions WhoYouCalling/ETW/Listener.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,26 @@ namespace WhoYouCalling.ETW
{
internal class Listener
{
protected TraceEventSession _session;
protected TraceEventSession? _session;
public string SourceName = "";

public void StopSession()
{
_session.Dispose();
if (_session != null)
{
_session.Dispose();
}
}
public bool GetSessionStatus()
{
return _session.IsActive;
if (_session != null)
{
return _session.IsActive;
}
else
{
return false;
}
}
}
}
6 changes: 3 additions & 3 deletions WhoYouCalling/Network/DNS/DNSResponseResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ namespace WhoYouCalling.Network.DNS
{
public class DNSResponseResult
{
public int BundledRecordTypeCode { get; set; }
public int BundledRecordTypeCode { get; set; } = 0;
public string BundledRecordTypeText { get; set; } = string.Empty;
public string BundledDomain { get; set; } = string.Empty;
public List<string> IPs { get; set; }
public List<string> IPs { get; set; } = new List<string>();

public override bool Equals(object? obj)
{
Expand All @@ -18,7 +18,7 @@ public override bool Equals(object? obj)
BundledRecordTypeText == other.BundledRecordTypeText &&
BundledDomain == other.BundledDomain &&
IPs.SequenceEqual(other.IPs);
}
}

public override int GetHashCode()
{
Expand Down
18 changes: 13 additions & 5 deletions WhoYouCalling/Network/FPC/BasePacketCapture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ namespace WhoYouCalling.Network.FPC
internal class BasePacketCapture
{
protected static int s_packetCounter;
protected CaptureFileWriterDevice _captureFileWriterDevice;
protected LibPcapLiveDevice _captureDevice;
protected CaptureFileWriterDevice? _captureFileWriterDevice;
protected LibPcapLiveDevice? _captureDevice;

public int GetPacketCount()
{
Expand All @@ -21,15 +21,23 @@ public void SetCaptureDevice(LibPcapLiveDevice device)

public void StopCapture()
{
_captureDevice.StopCapture();
_captureFileWriterDevice.Close();
if (_captureDevice != null) {
_captureDevice.StopCapture();
}
if (_captureFileWriterDevice != null)
{
_captureFileWriterDevice.Close();
}
}

protected void device_OnPacketArrival(object sender, PacketCapture e)
{
s_packetCounter++;
var rawPacket = e.GetPacket();
_captureFileWriterDevice.Write(rawPacket);
if (_captureFileWriterDevice != null)
{
_captureFileWriterDevice.Write(rawPacket);
}
}
}
}
5 changes: 4 additions & 1 deletion WhoYouCalling/Network/FPC/LivePacketCapture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ internal class LivePacketCapture : BasePacketCapture
public void StartCaptureToFile(string pcapFile)
{
s_packetCounter = 0;

if (_captureDevice == null)
{
return;
}
// Register our handler function to the 'packet arrival' event
_captureDevice.OnPacketArrival += new PacketArrivalEventHandler(device_OnPacketArrival);

Expand Down
2 changes: 1 addition & 1 deletion imgs/version.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit da8aa7c

Please sign in to comment.