Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to skip host name scanning #6

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion EvilLimiter.Windows/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
</startup>
<appSettings>
<add key="StartRoutingServiceOnStartup" value="True"/>
<add key="StartRoutingServiceOnStartup" value="true"/>
<add key="ColorStyle" value="Default" />
<add key="ScanSendInterval" value="10" />
<add key="ScanReplyTimeout" value="2000" />
<add key="ScanResolveHostnames" value="True"/>
<add key="SpoofSendInterval" value="4000" />
<add key="SpoofRestoreSendCount" value="3" />
<add key="SpoofRestoreSendInterval" value="50" />
Expand Down
14 changes: 14 additions & 0 deletions EvilLimiter.Windows/Common/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ public static int ScanReplyTimeout
set { lock (_scanReplyTimeoutLock) _scanReplyTimeout = value; }
}

public static bool ScanResolveHostnames
{
get { lock (_scanResolveHostnamesLock) return _scanResolveHostnames; }
set { lock (_scanResolveHostnamesLock) _scanResolveHostnames = value; }
}


public static int SpoofSendInterval
{
Expand Down Expand Up @@ -69,6 +75,8 @@ public static int BandwidthMonitorUpdateInterval
private static readonly object _scanSendIntervalLock;
private static int _scanReplyTimeout;
private static readonly object _scanReplyTimeoutLock;
private static bool _scanResolveHostnames;
private static readonly object _scanResolveHostnamesLock;

private static int _spoofSendInterval;
private static readonly object _spoofSendIntervalLock;
Expand All @@ -88,6 +96,7 @@ static Config()
_colorStyle = MetroColorStyle.Default;
_scanSendInterval = 10;
_scanReplyTimeout = 2000;
_scanResolveHostnames = true;
_spoofSendInterval = 4000;
_spoofRestoreSendCount = 3;
_spoofRestoreSendInterval = 50;
Expand All @@ -97,10 +106,13 @@ static Config()
_colorStyleLock = new object();
_scanSendIntervalLock = new object();
_scanReplyTimeoutLock = new object();
_scanResolveHostnamesLock = new object();
_spoofSendIntervalLock = new object();
_spoofRestoreSendCountLock = new object();
_spoofRestoreSendIntervalLock = new object();
_bandwidthMonitorUpdateIntervalLock = new object();

System.Console.WriteLine(true.ToString());
}


Expand All @@ -117,6 +129,7 @@ public static bool Read()

ScanSendInterval = int.Parse(config.AppSettings.Settings["ScanSendInterval"].Value);
ScanReplyTimeout = int.Parse(config.AppSettings.Settings["ScanReplyTimeout"].Value);
ScanResolveHostnames = bool.Parse(config.AppSettings.Settings["ScanResolveHostnames"].Value);

SpoofSendInterval = int.Parse(config.AppSettings.Settings["SpoofSendInterval"].Value);
SpoofRestoreSendCount = int.Parse(config.AppSettings.Settings["SpoofRestoreSendCount"].Value);
Expand Down Expand Up @@ -145,6 +158,7 @@ public static bool Write()

config.AppSettings.Settings["ScanSendInterval"].Value = ScanSendInterval.ToString();
config.AppSettings.Settings["ScanReplyTimeout"].Value = ScanReplyTimeout.ToString();
config.AppSettings.Settings["ScanResolveHostnames"].Value = ScanResolveHostnames.ToString();

config.AppSettings.Settings["SpoofSendInterval"].Value = SpoofSendInterval.ToString();
config.AppSettings.Settings["SpoofRestoreSendCount"].Value = SpoofRestoreSendCount.ToString();
Expand Down
19 changes: 17 additions & 2 deletions EvilLimiter.Windows/Forms/FrmMain.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions EvilLimiter.Windows/Forms/FrmMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ private void UpdateConfigDisplay()

tbScanSendInterval.Text = Config.ScanSendInterval.ToString();
tbScanReplyTimeout.Text = Config.ScanReplyTimeout.ToString();
cbScanResolveHostnames.Checked = Config.ScanResolveHostnames;
tbSpoofSendInterval.Text = Config.SpoofSendInterval.ToString();
tbSpoofRestoreSendCount.Text = Config.SpoofRestoreSendCount.ToString();
tbSpoofRestoreSendInterval.Text = Config.SpoofRestoreSendInterval.ToString();
Expand Down Expand Up @@ -362,6 +363,7 @@ private void BtnApplySettings_Click(object sender, EventArgs e)
Config.ColorStyle = colorStyle;
Config.ScanSendInterval = scanSendInterval;
Config.ScanReplyTimeout = scanReplyTimeout;
Config.ScanResolveHostnames = cbScanResolveHostnames.Checked;
Config.SpoofSendInterval = spoofSendInterval;
Config.SpoofRestoreSendCount = spoofRestoreSendCount;
Config.SpoofRestoreSendInterval = spoofRestoreSendInterval;
Expand Down
7 changes: 4 additions & 3 deletions EvilLimiter.Windows/Forms/FrmScan.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using EvilLimiter.Windows.Data;
using EvilLimiter.Windows.Common;
using EvilLimiter.Windows.Data;
using EvilLimiter.Windows.Networking;
using EvilLimiter.Windows.Utilities;
using MetroFramework;
Expand Down Expand Up @@ -104,7 +105,7 @@ private void HostScanner_HostScanned(object sender, HostScannedEventArgs e)
pbScan.Maximum = e.Total;
pbScan.Value = e.Current;

if (e.Current == e.Total)
if (e.Current == e.Total && Config.ScanResolveHostnames)
{
btnScan.Enabled = false;
lblStatus.Text = "Resolving hostnames...";
Expand Down Expand Up @@ -144,7 +145,7 @@ private void BtnScan_Click(object sender, System.EventArgs e)
range = _networkInfo.SubnetRange;

ChangeScanState(ScanState.Scan);
_hostScanner.Scan(range);
_hostScanner.Scan(range, Config.ScanResolveHostnames);
}
}

Expand Down
9 changes: 6 additions & 3 deletions EvilLimiter.Windows/Networking/HostScanner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public HostScanner(NetworkInformation netInfo)



public void Scan(ICollection<IpV4Address> addresses)
public void Scan(ICollection<IpV4Address> addresses, bool resolveHostnames = true)
{
if (IsScanning)
return;
Expand Down Expand Up @@ -137,8 +137,11 @@ public void Scan(ICollection<IpV4Address> addresses)
Thread.Sleep(Config.ScanReplyTimeout);
_tokenSource.Cancel();

foreach (var host in discoveredHosts)
host.HostName = NetworkUtilities.GetHostNameByIp(host.IpAddress);
if(resolveHostnames)
{
foreach (var host in discoveredHosts)
host.HostName = NetworkUtilities.GetHostNameByIp(host.IpAddress);
}

OnScanFinished(new ScanFinishedEventArgs(discoveredHosts));
}
Expand Down