Skip to content

Commit bc9a06d

Browse files
authored
Merge pull request #64 from BornToBeRoot/HttpHeaders
Get "HTTP Headers" added
2 parents a3a0e1a + 7123fe7 commit bc9a06d

14 files changed

Lines changed: 548 additions & 12 deletions

File tree

Source/NETworkManager/Helpers/RegexHelper.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,8 @@ public static class RegexHelper
3232

3333
// Match a IPv4-Address like 192.168.[50-100].1
3434
public const string IPv4AddressSpecialRangeRegex = @"^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|" + SpecialRangeRegex + @")\.){3}((?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)|" + SpecialRangeRegex + @")$";
35+
36+
// Test for http|https uris
37+
public const string httpAndHttpsUriRegex = @"^http(s)?:\/\/([\w-]+.)+[\w-]+(\/[\w- ./?%&=])?$";
3538
}
3639
}

Source/NETworkManager/MainWindow.xaml.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,7 @@ private async void MetroWindowMain_Closing(object sender, CancelEventArgs e)
341341
RemoteDesktopView remoteDesktopView;
342342
WakeOnLANView wakeOnLANView;
343343
SubnetCalculatorView subnetCalculatorView;
344+
HTTPHeadersView httpHeadersView;
344345
ARPTableView arpTableView;
345346
LookupView lookupView;
346347

@@ -407,6 +408,12 @@ private void ChangeApplicationView(ApplicationViewManager.Name name)
407408

408409
contentControlApplication.Content = subnetCalculatorView;
409410
break;
411+
case ApplicationViewManager.Name.HTTPHeaders:
412+
if (httpHeadersView == null)
413+
httpHeadersView = new HTTPHeadersView();
414+
415+
contentControlApplication.Content = httpHeadersView;
416+
break;
410417
case ApplicationViewManager.Name.ARPTable:
411418
if (arpTableView == null)
412419
arpTableView = new ARPTableView();
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
using System;
2+
using System.Net;
3+
using System.Threading.Tasks;
4+
5+
namespace NETworkManager.Models.Network
6+
{
7+
public class HTTPHeaders
8+
{
9+
public static async Task<WebHeaderCollection> GetHeadersAsync(Uri uri)
10+
{
11+
WebHeaderCollection headers;
12+
13+
HttpWebRequest request = WebRequest.CreateHttp(uri);
14+
15+
using (HttpWebResponse response = (HttpWebResponse)(await request.GetResponseAsync().ConfigureAwait(false)))
16+
{
17+
headers = response.Headers;
18+
}
19+
20+
return headers;
21+
}
22+
}
23+
}

Source/NETworkManager/Models/Settings/SettingsInfo.cs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1249,6 +1249,36 @@ public bool RemoteDesktop_ExpandSessionView
12491249
}
12501250
}
12511251
#endregion
1252+
1253+
#region HTTP Headers
1254+
private List<string> _httpHeader_WebsiteUriHistory = new List<string>();
1255+
public List<string> HTTPHeader_WebsiteUriHistory
1256+
{
1257+
get { return _httpHeader_WebsiteUriHistory; }
1258+
set
1259+
{
1260+
if (value == _httpHeader_WebsiteUriHistory)
1261+
return;
1262+
1263+
_httpHeader_WebsiteUriHistory = value;
1264+
SettingsChanged = true;
1265+
}
1266+
}
1267+
1268+
private bool _httpHeader_ExpandStatistics = true;
1269+
public bool HTTPHeader_ExpandStatistics
1270+
{
1271+
get { return _httpHeader_ExpandStatistics; }
1272+
set
1273+
{
1274+
if (value == _httpHeader_ExpandStatistics)
1275+
return;
1276+
1277+
_httpHeader_ExpandStatistics = value;
1278+
SettingsChanged = true;
1279+
}
1280+
}
1281+
#endregion
12521282
#endregion
12531283

12541284
#region Constructor

Source/NETworkManager/NETworkManager.csproj

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,10 +186,13 @@
186186
<Compile Include="Converters\ValidateNetworkInterfaceProfileConverter.cs" />
187187
<Compile Include="Converters\ValidateSubnetCalculatorIPv4SplitterConverter.cs" />
188188
<Compile Include="Helpers\SingleInstanceHelper.cs" />
189+
<Compile Include="Models\Network\HTTPHeaders.cs" />
189190
<Compile Include="Models\Network\ARPTableInfo.cs" />
190191
<Compile Include="Models\RemoteDesktop\RemoteDesktopSessionInfo.cs" />
191192
<Compile Include="Models\Settings\RemoteDesktopSessionManager.cs" />
192193
<Compile Include="Models\Settings\RemoteDesktopSessionInfo.cs" />
194+
<Compile Include="Validators\HttpAndHttpsUriValidator.cs" />
195+
<Compile Include="ViewModels\Applications\HTTPHeadersViewModel.cs" />
193196
<Compile Include="ViewModels\Applications\ARPTableViewModel.cs" />
194197
<Compile Include="ViewModels\Dialogs\NetworkInterfaceProfileViewModel.cs" />
195198
<Compile Include="ViewModels\Dialogs\PortScannerProfileViewModel.cs" />
@@ -224,6 +227,9 @@
224227
<Compile Include="Controls\RemoteDesktopControl.xaml.cs">
225228
<DependentUpon>RemoteDesktopControl.xaml</DependentUpon>
226229
</Compile>
230+
<Compile Include="Views\Applications\HTTPHeadersView.xaml.cs">
231+
<DependentUpon>HTTPHeadersView.xaml</DependentUpon>
232+
</Compile>
227233
<Compile Include="Views\Applications\ARPTableView.xaml.cs">
228234
<DependentUpon>ARPTableView.xaml</DependentUpon>
229235
</Compile>
@@ -354,6 +360,10 @@
354360
<Generator>MSBuild:Compile</Generator>
355361
<SubType>Designer</SubType>
356362
</Page>
363+
<Page Include="Views\Applications\HTTPHeadersView.xaml">
364+
<Generator>MSBuild:Compile</Generator>
365+
<SubType>Designer</SubType>
366+
</Page>
357367
<Page Include="Views\Applications\ARPTableView.xaml">
358368
<Generator>MSBuild:Compile</Generator>
359369
<SubType>Designer</SubType>

Source/NETworkManager/Properties/AssemblyInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,4 @@
4949
// Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern
5050
// übernehmen, indem Sie "*" eingeben:
5151
// [assembly: AssemblyVersion("1.0.*")]
52-
[assembly: AssemblyVersion("1.4.0.0")]
52+
[assembly: AssemblyVersion("1.5.0.0")]

Source/NETworkManager/Resources/Localization/Resources.de-DE.xaml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,9 @@
8282
<system:String x:Key="String_Header_Display">Anzeige</system:String>
8383
<system:String x:Key="String_Header_Filter">Filter</system:String>
8484
<system:String x:Key="String_Header_ARPTable">ARP-Tabelle</system:String>
85-
85+
<system:String x:Key="String_Header_Website">Webseite</system:String>
86+
<system:String x:Key="String_Header_Headers">Headers</system:String>
87+
8688
<!-- Normal strings -->
8789
<system:String x:Key="String_ProductName">NETworkManager</system:String>
8890
<system:String x:Key="String_Slogan">Ein leistungsstarkes Tool zum Verwalten von Netzwerken und zur Behebung von Netzwerkproblemen!</system:String>
@@ -325,6 +327,7 @@
325327
<system:String x:Key="String_Button_Refresh">Aktualisieren</system:String>
326328
<system:String x:Key="String_Button_Reconnect">Wiederverbinden</system:String>
327329
<system:String x:Key="String_Button_ClearCache">Cache leeren</system:String>
330+
<system:String x:Key="String_Button_Check">Prüfen</system:String>
328331

329332
<!-- ContextMenuItem.Header -->
330333
<system:String x:Key="String_ContextMenu_Cut">Ausschneiden</system:String>
@@ -360,7 +363,8 @@
360363
<system:String x:Key="String_Watermark_EamplePortPortRangeOrService">22; 80; https; ldaps; 777 - 999; 8080</system:String>
361364
<system:String x:Key="String_Watermark_ExampleSubnet">192.168.178.133/22 oder 192.168.178.133/255.255.252.0</system:String>
362365
<system:String x:Key="String_Watermark_Filter">Filter...</system:String>
363-
366+
<system:String x:Key="String_Watermark_ExampleWebsiteUri">http(s)://example.com/index.html</system:String>
367+
364368
<!-- ShowProgress -->
365369
<system:String x:Key="String_ProgessHeader_ConfigureNetworkInterface">Konfiguriere Netzwerkinterface</system:String>
366370
<system:String x:Key="String_Progress_SetStaticIPAddress">Setze statische IP-Adresse und Gateway...</system:String>
@@ -385,6 +389,7 @@
385389
<system:String x:Key="String_ValidateError_EnterValidValueBetween10and100">Geben Sie einen gültigen Wert ein zwischen 10 und 100!</system:String>
386390
<system:String x:Key="String_ValidateError_EnterValidIPAddress">Geben Sie eine gültige IP-Adresse ein!</system:String>
387391
<system:String x:Key="String_ValidateError_EnterValidSubnet">Geben Sie ein gültiges Subnetz ein (z.B. 192.168.178.133/26)</system:String>
392+
<system:String x:Key="String_ValidateError_EnterValidWebsiteUri">Geben Sie eine gültige Webseite ein (z.B. https://example.com/index.html)</system:String>
388393

389394
<!-- ApplicationInfo.Name -->
390395
<system:String x:Key="String_ApplicationName_IPScanner">IP-Scanner</system:String>
@@ -396,6 +401,7 @@
396401
<system:String x:Key="String_ApplicationName_Traceroute">Traceroute</system:String>
397402
<system:String x:Key="String_ApplicationName_DNSLookup">DNS-Lookup</system:String>
398403
<system:String x:Key="String_ApplicationName_RemoteDesktop">Remote Desktop</system:String>
404+
<system:String x:Key="String_ApplicationName_HTTPHeaders">HTTP-Headers</system:String>
399405
<system:String x:Key="String_ApplicationName_ARPTable">ARP-Tabelle</system:String>
400406
<system:String x:Key="String_ApplicationName_Lookup">Lookup</system:String>
401407

Source/NETworkManager/Resources/Localization/Resources.en-US.xaml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,9 @@
8282
<system:String x:Key="String_Header_Display">Display</system:String>
8383
<system:String x:Key="String_Header_Filter">Filter</system:String>
8484
<system:String x:Key="String_Header_ARPTable">ARP Table</system:String>
85-
85+
<system:String x:Key="String_Header_Website">Website</system:String>
86+
<system:String x:Key="String_Header_Headers">Headers</system:String>
87+
8688
<!-- Normal strings -->
8789
<system:String x:Key="String_ProductName">NETworkManager</system:String>
8890
<system:String x:Key="String_Slogan">A powerful tool for managing networks and troubleshoot network problems!</system:String>
@@ -325,6 +327,7 @@
325327
<system:String x:Key="String_Button_Refresh">Refresh</system:String>
326328
<system:String x:Key="String_Button_Reconnect">Reconnect</system:String>
327329
<system:String x:Key="String_Button_ClearCache">Clear cache</system:String>
330+
<system:String x:Key="String_Button_Check">Check</system:String>
328331

329332
<!-- ContextMenuItem.Header -->
330333
<system:String x:Key="String_ContextMenu_Cut">Cut</system:String>
@@ -360,7 +363,8 @@
360363
<system:String x:Key="String_Watermark_EamplePortPortRangeOrService">22; 80; https; ldaps; 777 - 999; 8080</system:String>
361364
<system:String x:Key="String_Watermark_ExampleSubnet">192.168.178.133/22 or 192.168.178.133/255.255.252.0</system:String>
362365
<system:String x:Key="String_Watermark_Filter">Filter...</system:String>
363-
366+
<system:String x:Key="String_Watermark_ExampleWebsiteUri">http(s)://example.com/index.html</system:String>
367+
364368
<!-- ShowProgress -->
365369
<system:String x:Key="String_ProgessHeader_ConfigureNetworkInterface">Configure Network Interface</system:String>
366370
<system:String x:Key="String_Progress_SetStaticIPAddress">Set static IP address and gateway...</system:String>
@@ -385,6 +389,7 @@
385389
<system:String x:Key="String_ValidateError_EnterValidValueBetween10and100">Enter a valid value between 10 and 100!</system:String>
386390
<system:String x:Key="String_ValidateError_EnterValidIPAddress">Enter a valid IP address!</system:String>
387391
<system:String x:Key="String_ValidateError_EnterValidSubnet">Enter a valid subnet (like 192.168.178.133/26)</system:String>
392+
<system:String x:Key="String_ValidateError_EnterValidWebsiteUri">Enter a valid website (like https://example.com/index.html)</system:String>
388393

389394
<!-- ApplicationView.Name -->
390395
<system:String x:Key="String_ApplicationName_IPScanner">IP Scanner</system:String>
@@ -396,6 +401,7 @@
396401
<system:String x:Key="String_ApplicationName_Traceroute">Traceroute</system:String>
397402
<system:String x:Key="String_ApplicationName_DNSLookup">DNS Lookup</system:String>
398403
<system:String x:Key="String_ApplicationName_RemoteDesktop">Remote Desktop</system:String>
404+
<system:String x:Key="String_ApplicationName_HTTPHeaders">HTTP Headers</system:String>
399405
<system:String x:Key="String_ApplicationName_ARPTable">ARP Table</system:String>
400406
<system:String x:Key="String_ApplicationName_Lookup">Lookup</system:String>
401407

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using NETworkManager.Helpers;
2+
using System.Globalization;
3+
using System.Text.RegularExpressions;
4+
using System.Windows;
5+
using System.Windows.Controls;
6+
7+
namespace NETworkManager.Validators
8+
{
9+
public class MACAddressValidator : ValidationRule
10+
{
11+
public override ValidationResult Validate(object value, CultureInfo cultureInfo)
12+
{
13+
if (Regex.IsMatch(value as string, RegexHelper.MACAddressRegex))
14+
return ValidationResult.ValidResult;
15+
16+
return new ValidationResult(false, Application.Current.Resources["String_ValidateError_EnterValidMACAddress"] as string);
17+
}
18+
}
19+
}

Source/NETworkManager/Validators/MACAddressValidator.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66

77
namespace NETworkManager.Validators
88
{
9-
public class MACAddressValidator : ValidationRule
9+
public class HttpAndHttpsUriValidator : ValidationRule
1010
{
1111
public override ValidationResult Validate(object value, CultureInfo cultureInfo)
1212
{
13-
if (Regex.IsMatch(value as string, RegexHelper.MACAddressRegex))
13+
if (Regex.IsMatch(value as string, RegexHelper.httpAndHttpsUriRegex))
1414
return ValidationResult.ValidResult;
1515

16-
return new ValidationResult(false, Application.Current.Resources["String_ValidateError_EnterValidMACAddress"] as string);
16+
return new ValidationResult(false, Application.Current.Resources["String_ValidateError_EnterValidWebsiteUri"] as string);
1717
}
1818
}
1919
}

0 commit comments

Comments
 (0)