Skip to content
Merged
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
1 change: 1 addition & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ REPOSITORY_ROOT/
│ ├── Create-FlagFromSVG.ps1 # Create flag images
│ ├── Create-OUIListFromWeb.ps1 # Update OUI (MAC vendor) list
│ ├── Create-PortListFromWeb.ps1 # Update port list database
│ ├── Create-PublicSuffixListFromWeb.ps1 # Update public suffix list (RDAP: registered domain of a hostname)
│ ├── Create-ReleaseTable.ps1 # Create the SHA256 sums / file table for release notes
│ ├── Create-WhoisServerListFromWebAndWhois.ps1 # Update WHOIS servers
│ ├── Create-WorldMapFromWeb.ps1 # Create the world map (Traceroute map)
Expand Down
44 changes: 44 additions & 0 deletions Scripts/Create-PublicSuffixListFromWeb.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Filepath in the resources
[string]$OutFilePath = Join-Path -Path (Split-Path $PSScriptRoot -Parent) -ChildPath "Source\NETworkManager.Models\Resources\PublicSuffixList.dat"

# Download the public suffix list (MPL 2.0) from publicsuffix.org
$List = (Invoke-WebRequest -Uri "https://publicsuffix.org/list/public_suffix_list.dat").Content -split "[`r`n]+"

# Keep the license notice, version and commit of the list
$Header = $List | Where-Object { $_ -match "^// (This Source Code Form|License, v\. 2\.0|file, You can obtain|VERSION:|COMMIT:)" }

# Only the ICANN section is used, since the private section (e.g. github.io) doesn't contain registered domains
$IsICANN = $false
$IdnMapping = New-Object System.Globalization.IdnMapping

$Rules = foreach ($Line in $List) {
if ($Line -eq "// ===BEGIN ICANN DOMAINS===") {
$IsICANN = $true
continue
}

if ($Line -eq "// ===END ICANN DOMAINS===") {
break
}

$Rule = $Line.Trim()

if (-not $IsICANN -or [string]::IsNullOrEmpty($Rule) -or $Rule.StartsWith("//")) {
continue
}

# Rules are converted to A-labels (punycode), like the queries. Wildcard (*.) and exception (!) prefixes are kept.
$Prefix = if ($Rule.StartsWith("*.")) { "*." } elseif ($Rule.StartsWith("!")) { "!" } else { "" }

$Prefix + $IdnMapping.GetAscii($Rule.Substring($Prefix.Length)).ToLowerInvariant()
}

$Description = @"
$($Header -join "`n")
//
// ICANN section of the public suffix list from https://publicsuffix.org/list/public_suffix_list.dat, with the
// rules converted to A-labels (punycode).
// Generated $(Get-Date) by Scripts/Create-PublicSuffixListFromWeb.ps1
"@

Set-Content -Path $OutFilePath -Value (@($Description) + $Rules) -Encoding utf8NoBOM
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
using System;
using System.Globalization;
using System.Windows.Data;

namespace NETworkManager.Converters;

/// <summary>
/// Convert a hostname to <see cref="bool" />: true if it has a domain (e.g. "server01.borntoberoot.net"), false for
/// a single label like a NetBIOS name ("SERVER01").
/// </summary>
public sealed class HostnameHasDomainToBooleanConverter : IValueConverter
{
/// <summary>
/// Convert a hostname to <see cref="bool" />.
/// </summary>
/// <param name="value">Hostname as <see cref="string" />.</param>
/// <param name="targetType"></param>
/// <param name="parameter"></param>
/// <param name="culture"></param>
/// <returns>True if the hostname has a domain, otherwise false.</returns>
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return value is string hostname && hostname.Trim('.').Contains('.');
}

/// <summary>
/// !!! Method not implemented !!!
/// </summary>
/// <param name="value"></param>
/// <param name="targetType"></param>
/// <param name="parameter"></param>
/// <param name="culture"></param>
/// <returns></returns>
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
using System;
using System.Globalization;
using System.Windows.Data;
using NETworkManager.Localization.Resources;
using NETworkManager.Models.RDAP;

namespace NETworkManager.Converters;

/// <summary>
/// Convert <see cref="RDAPQueryType" /> to an example input (watermark).
/// </summary>
public sealed class RDAPQueryTypeToWatermarkConverter : IValueConverter
{
/// <summary>
/// Convert <see cref="RDAPQueryType" /> to an example input (watermark).
/// </summary>
/// <param name="value">Object from type <see cref="RDAPQueryType" />.</param>
/// <param name="targetType"></param>
/// <param name="parameter"></param>
/// <param name="culture"></param>
/// <returns>Example input for the <see cref="RDAPQueryType" />.</returns>
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return value switch
{
RDAPQueryType.Nameserver => StaticStrings.ExampleRDAPNameserver,
RDAPQueryType.TLD => StaticStrings.ExampleTLD,
RDAPQueryType.IPAddress => StaticStrings.ExampleIPAddressOrCIDR,
RDAPQueryType.ASN => StaticStrings.ExampleASN,
RDAPQueryType.Entity => StaticStrings.ExampleRDAPEntityHandle,
_ => StaticStrings.ExampleDomain
};
}

/// <summary>
/// !!! Method not implemented !!!
/// </summary>
/// <param name="value"></param>
/// <param name="targetType"></param>
/// <param name="parameter"></param>
/// <param name="culture"></param>
/// <returns></returns>
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
5 changes: 4 additions & 1 deletion Source/NETworkManager.Documentation/ResourceManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ public static class ResourceManager
Strings.Resource_ListTLD_Description),

new("natural-earth-geojson", "https://github.com/martynafford/natural-earth-geojson",
Strings.Resource_NaturalEarth_Description)
Strings.Resource_NaturalEarth_Description),

new("Public Suffix List", "https://publicsuffix.org/",
Strings.Resource_PublicSuffixList_Description)
];
}

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

Original file line number Diff line number Diff line change
Expand Up @@ -372,4 +372,7 @@
<data name="ExampleRDAPEntityHandle" xml:space="preserve">
<value>ORG-RIEN1-RIPE</value>
</data>
<data name="ExampleRDAPNameserver" xml:space="preserve">
<value>a.iana-servers.net</value>
</data>
</root>
81 changes: 81 additions & 0 deletions Source/NETworkManager.Localization/Resources/Strings.Designer.cs

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

27 changes: 27 additions & 0 deletions Source/NETworkManager.Localization/Resources/Strings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -4809,4 +4809,31 @@ Cloudflare may log your IP address and network information. See Cloudflare's pri
<data name="DeleteRulesX" xml:space="preserve">
<value>Delete rules ({0})</value>
</data>
<data name="RDAPQueryType_Auto" xml:space="preserve">
<value>Auto</value>
</data>
<data name="EnterValidRDAPQuery" xml:space="preserve">
<value>Enter a valid domain, IP address, AS number or entity handle!</value>
</data>
<data name="RDAPTimeoutAfterXSeconds" xml:space="preserve">
<value>The RDAP server did not respond within {0} seconds.</value>
</data>
<data name="RDAPQueryType_Nameserver" xml:space="preserve">
<value>Nameserver</value>
</data>
<data name="EnterValidNameserver" xml:space="preserve">
<value>Enter a valid nameserver (e.g., "ns1.example.com")!</value>
</data>
<data name="ASNumbers" xml:space="preserve">
<value>AS numbers</value>
</data>
<data name="RDAPDots" xml:space="preserve">
<value>RDAP...</value>
</data>
<data name="RDAPXIsNotARegisteredDomainShowingY" xml:space="preserve">
<value>"{0}" is not a registered domain, showing the registration data of "{1}".</value>
</data>
<data name="Resource_PublicSuffixList_Description" xml:space="preserve">
<value>List of public suffixes (e.g. "co.uk") from publicsuffix.org (MPL-2.0), which is used to get the registered domain of a hostname for RDAP queries.</value>
</data>
</root>
2 changes: 2 additions & 0 deletions Source/NETworkManager.Models/NETworkManager.Models.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<None Remove="Resources\OUI.xml" />
<None Remove="Resources\Ports.xml" />
<None Remove="Resources\PSDiscoveryProtocol.psm1" />
<None Remove="Resources\PublicSuffixList.dat" />
<None Remove="Resources\RDAPStealthEndpoints.json" />
<None Remove="Resources\WhoisServers.xml" />
</ItemGroup>
Expand All @@ -23,6 +24,7 @@
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Resources\PSDiscoveryProtocol.psm1" />
<EmbeddedResource Include="Resources\PublicSuffixList.dat" />
<EmbeddedResource Include="Resources\RDAPStealthEndpoints.json" />
</ItemGroup>
<ItemGroup>
Expand Down
Loading
Loading