Skip to content

Commit 094cd6a

Browse files
authored
Merge pull request #6 from codingfreak/bugfix
Migrated to .NET 10 and fixed reolution exception
2 parents d949930 + 01aa3a0 commit 094cd6a

13 files changed

Lines changed: 91 additions & 133 deletions
-150 KB
Binary file not shown.

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,3 +137,13 @@ The following table lists all available options:
137137
| d | detailed | -d | If provided, pping will try to write reason details at closed ports to te console. |
138138
| 4 | ipv4 | -4 | If provided, pping will use IPv4 for resolutions. |
139139
| 6 | ipv6 | -6 | If provided, pping will use IPv6 for resolutions. |
140+
141+
## Exit codes
142+
143+
Any positive number is returned if `-elsucc` or `-elfail` are defined. Those numbers will represent the successful or failed requests.
144+
145+
| Code | Description
146+
|--- | ---
147+
| 0 | All provided ports where open.
148+
| -2 | `-res` flag was given but the hostname could not be resolved.
149+

installer/Installer.Msi/Installer.Msi.wixproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
55
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
66
<ProductVersion>3.14</ProductVersion>
7-
<ProjectGuid>b1d698bb-dbc5-4fc2-8144-e29c1c2904b0</ProjectGuid>
7+
<ProjectGuid>{4923e0b5-8795-5d5b-050f-805cdd54d47d}</ProjectGuid>
88
<SchemaVersion>2.0</SchemaVersion>
99
<OutputName>pping</OutputName>
1010
<OutputType>Package</OutputType>

pping.sln

Lines changed: 0 additions & 55 deletions
This file was deleted.

pping.slnx

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<Solution>
2+
<Configurations>
3+
<Platform Name="ARM" />
4+
<Platform Name="x64" />
5+
<Platform Name="x86" />
6+
</Configurations>
7+
<Folder Name="/.sln/">
8+
<File Path=".gitignore" />
9+
<File Path="README.md" />
10+
</Folder>
11+
<Folder Name="/Installer/">
12+
<Project Path="installer/Installer.Msi/Installer.Msi.wixproj">
13+
<Platform Solution="*|ARM" Project="x86" />
14+
<Platform Solution="Debug|x64" Project="x86" />
15+
<Build Solution="*|x64" />
16+
<Build Solution="Debug|ARM" />
17+
<Build Solution="Debug|x86" />
18+
</Project>
19+
</Folder>
20+
<Folder Name="/Ui/">
21+
<Project Path="src/Ui/Ui.ConsoleApp/Ui.ConsoleApp.csproj">
22+
<Platform Solution="*|ARM" Project="ARM32" />
23+
<Platform Solution="*|x64" Project="x64" />
24+
<Platform Solution="*|x86" Project="x86" />
25+
<Build Solution="Release|x64" Project="false" />
26+
</Project>
27+
</Folder>
28+
</Solution>

src/Ui/Ui.ConsoleApp/PingLogic.cs

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace codingfreaks.pping.Ui.ConsoleApp
1+
namespace codingfreaks.pping.Ui.ConsoleApp
22
{
33
using System;
44
using System.Collections.Generic;
@@ -32,13 +32,18 @@ public class PingLogic
3232
/// <returns>The SemVer-styled version of the assembly.</returns>
3333
private string GetVersion()
3434
{
35-
return typeof(Program).Assembly?.GetCustomAttribute<AssemblyInformationalVersionAttribute>()
36-
?.InformationalVersion;
35+
var attribute = typeof(Program).Assembly?.GetCustomAttribute<AssemblyInformationalVersionAttribute>();
36+
var version = attribute?.InformationalVersion;
37+
version = version?.Split('+')[0];
38+
return version;
3739
}
3840

3941
/// <summary>
4042
/// Gets called by the logic of the <see cref="CommandAttribute" />.
4143
/// </summary>
44+
/// <returns>
45+
/// The return code to be used as the process result.
46+
/// </returns>
4247
private async Task<int> OnExecuteAsync()
4348
{
4449
if (UseIpV6)
@@ -57,7 +62,20 @@ private async Task<int> OnExecuteAsync()
5762
if (ResvoleAddress)
5863
{
5964
// we have to perform address resolution
60-
var entry = await Dns.GetHostEntryAsync(Host);
65+
var entry = await Dns.GetHostEntryAsync(Host).ContinueWith(t =>
66+
{
67+
if (t.IsFaulted)
68+
{
69+
Console.WriteLine($"Could not resolve IP of host '{Host}'.");
70+
return null;
71+
}
72+
return t.Result;
73+
});
74+
if (entry == null)
75+
{
76+
// Return the error code to define a failed DNS resolution.
77+
return -2;
78+
}
6179
if (entry.AddressList.Any())
6280
{
6381
var target = UseIpV4 ? AddressFamily.InterNetwork : AddressFamily.InterNetworkV6;
@@ -303,4 +321,4 @@ private IEnumerable<int> Ports
303321

304322
#endregion
305323
}
306-
}
324+
}
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"profiles": {
33
"Ui.ConsoleApp": {
4-
"commandName": "Project",
5-
"commandLineArgs": "google.de 440-443 -t -a"
4+
"commandName": "Project",
5+
"commandLineArgs": "--version"
66
}
77
}
8-
}
8+
}

src/Ui/Ui.ConsoleApp/Ui.ConsoleApp.csproj

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
33
<OutputType>Exe</OutputType>
4-
<TargetFramework>net9.0</TargetFramework>
4+
<TargetFramework>net10.0</TargetFramework>
55
<RootNamespace>codingfreaks.pping.Ui.ConsoleApp</RootNamespace>
66
<AssemblyName>pping</AssemblyName>
77
<Authors>codingfreaks</Authors>
8-
<Version>4.0.1</Version>
9-
<Copyright>2025 codingfreaks</Copyright>
8+
<Version>5.0.0</Version>
9+
<Copyright>2026 codingfreaks</Copyright>
1010
<LangVersion>latest</LangVersion>
1111
<SelfContained>True</SelfContained>
1212
<Platforms>AnyCPU;x64;x86;ARM32</Platforms>
1313
</PropertyGroup>
1414
<ItemGroup>
15-
<PackageReference Include="devdeer.Libraries.Utilities" Version="3.0.0" />
16-
<PackageReference Include="McMaster.Extensions.CommandLineUtils" Version="4.1.1" />
17-
<PackageReference Include="Microsoft.Extensions.Hosting" Version="9.0.2" />
15+
<PackageReference Include="devdeer.Libraries.Utilities" Version="5.0.0" />
16+
<PackageReference Include="McMaster.Extensions.CommandLineUtils" Version="5.1.0" />
17+
<PackageReference Include="Microsoft.Extensions.Hosting" Version="10.0.9" />
1818
</ItemGroup>
1919
<ItemGroup>
2020
<None Update="verification.txt">

src/Ui/Ui.ConsoleApp/choco.md

Lines changed: 3 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
You can perform all the steps in this file by simply `executing publish-choco-win64.ps1` in the project folder. Be
1+
You can perform all the steps in this file by simply `executing publish-choco-win64.ps1` in the project folder. Be
22
aware that before doing so you must:
33

44
1. Increase the version number in the csproj.
@@ -8,51 +8,5 @@ aware that before doing so you must:
88
# Generate self-contained EXE for Windows x64
99

1010
1. Open the Ui.Console folder in a PowerShell command prompt on Windows.
11-
2. Execute the dotnet publish command for self-contained EXE and Windows:
12-
13-
```
14-
dotnet publish -c Release
15-
```
16-
17-
3. Calculate the new Hash:
18-
19-
```
20-
$hashExe = Get-FileHash .\bin\Release\net9.0\publish\pping.exe | Select -ExpandProperty Hash
21-
$hashDll = Get-FileHash .\bin\Release\net9.0\publish\pping.dll | Select -ExpandProperty Hash
22-
```
23-
24-
4. Replace property in verification.txt:
25-
26-
```
27-
(Get-Content verification.txt) -replace '- pping.exe \(SHA256: (.*)', "- pping.exe (SHA256: $hashExe)" | Out-File verification.txt
28-
(Get-Content verification.txt) -replace '- pping.dll \(SHA256: (.*)', "- pping.exe (SHA256: $hashDll)" | Out-File verification.txt
29-
```
30-
31-
5. Copy additional files to publish-folder:
32-
33-
```
34-
cp pping.nuspec .\bin\Release\net9.0\win-x64\publish\pping.nuspec
35-
cp verification.txt .\bin\Release\net9.0\win-x64\publish\verification.txt
36-
cp license.txt .\bin\Release\net9.0\win-x64\publish\license.txt
37-
cp pping.runtimeconfig.json .\bin\Release\net9.0\win-x64\publish\pping.runtimeconfig.json
38-
```
39-
40-
6. Generate choco package:
41-
42-
```
43-
choco pack .\bin\Release\net9.0\win-x64\publish\pping.nuspec --output-directory .\bin\Release\net9.0\win-x64\publish\
44-
```
45-
46-
7. Get version out of nuspec:
47-
48-
```
49-
$xmlFile = ".\bin\Release\net9.0\win-x64\publish\pping.nuspec"
50-
[XML]$xml = Get-Content $xmlFile
51-
$version = $xml.package.metadata.version
52-
```
53-
54-
8. Push choco:
55-
56-
```
57-
choco push .\bin\Release\net9.0\win-x64\publish\pping.$version.nupkg
58-
```
11+
2. Define the ENV variable `CHOCO_API_KEY` with `$env:CHOCO_API_KEY="THEKEY"`.
12+
2. Execute the script `.\publish-choco.ps1`

src/Ui/Ui.ConsoleApp/license.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2013-2020 Alexander Schmidt (codingfreaks)
1+
Copyright (c) 2013-2026 Alexander Schmidt (codingfreaks)
22

33
Permission is hereby granted, free of charge, to any person obtaining a copy
44
of this software and associated documentation files (the "Software"), to deal
@@ -16,4 +16,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1616
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1717
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
1818
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19-
THE SOFTWARE.
19+
THE SOFTWARE.

0 commit comments

Comments
 (0)