diff --git a/.github/renovate.json b/.github/renovate.json index 1471bba96..62f6e88ea 100644 --- a/.github/renovate.json +++ b/.github/renovate.json @@ -12,6 +12,20 @@ ":automergeMinor", ":disableRateLimiting" ], + "packageRules": [ + { + "matchPackagePrefixes": [ + "Volo.Abp" + ], + "groupName": "ABP" + }, + { + "matchPackagePrefixes": [ + "ReactiveUI" + ], + "groupName": "ReactiveUI" + } + ], "labels": [ "Automatic" ] diff --git a/.github/workflows/CI.yaml b/.github/workflows/CI.yaml index 94c4a5526..d87db9c73 100644 --- a/.github/workflows/CI.yaml +++ b/.github/workflows/CI.yaml @@ -1,21 +1,12 @@ name: CI -on: - push: - branches: - - master - - 'renovate/**' - tags: - - "*" - pull_request: - workflow_dispatch: +on: [push, pull_request, workflow_dispatch] env: - ProjectName: NatTypeTester - NET_TFM: net6.0-windows10.0.22000.0 + ProjectName: ${{ github.event.repository.name }} + NET_TFM: net6.0-windows Configuration: Release jobs: check_format: - name: Check format runs-on: windows-latest steps: - name: Setup .NET @@ -30,11 +21,13 @@ jobs: run: dotnet format -v diag --verify-no-changes test: - name: Test runs-on: ${{ matrix.os }} strategy: matrix: - os: [ubuntu-latest, windows-latest, macos-latest] + os: + - windows-latest + - ubuntu-latest + - macos-latest steps: - name: Checkout code @@ -45,48 +38,40 @@ jobs: with: dotnet-version: 6.0.x - - name: Test - shell: pwsh - run: dotnet test -c Release UnitTest + - name: Run tests + working-directory: UnitTest + run: dotnet test -c Release build: - name: Build needs: [test, check_format] - if: ${{ !startsWith(github.ref, 'refs/tags/') }} runs-on: windows-latest - strategy: - matrix: - Rid: [generic, win-x64, win-x86, win-arm64] steps: - name: Checkout code uses: actions/checkout@v3 - with: - submodules: true - name: Setup .NET uses: actions/setup-dotnet@v2 with: dotnet-version: 6.0.x - - name: Build ${{ matrix.Rid }} + - name: Build shell: pwsh - run: .\build.ps1 ${{ matrix.Rid }} + run: .\build.ps1 - - name: Upload ${{ matrix.Rid }} - continue-on-error: true + - name: Upload uses: actions/upload-artifact@v3 with: - name: ${{ env.ProjectName }}-${{ matrix.Rid }} - path: ${{ env.ProjectName }}\bin\${{ env.Configuration }}\${{ env.NET_TFM }}\${{ matrix.Rid }}\publish\ + name: ${{ env.ProjectName }} + path: ${{ env.ProjectName }}\bin\${{ env.Configuration }}\${{ env.NET_TFM }}\generic\publish\ nuget: - name: Nuget needs: [test, check_format] if: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') }} runs-on: ubuntu-latest strategy: matrix: - PackageName: [STUN] + PackageName: + - STUN steps: - name: Checkout code @@ -98,62 +83,46 @@ jobs: dotnet-version: 6.0.x - name: Build - shell: pwsh - run: dotnet build -c Release ${{ matrix.PackageName }}\${{ matrix.PackageName }}.csproj + working-directory: ${{ matrix.PackageName }} + run: dotnet build -c Release - name: Push nuget packages - shell: pwsh + working-directory: ${{ matrix.PackageName }}/bin/Release run: | - dotnet nuget push ${{ matrix.PackageName }}\bin\Release\*.nupkg -s https://nuget.pkg.github.com/HMBSbige -k ${{ secrets.GITHUB_TOKEN }} --skip-duplicate - dotnet nuget push ${{ matrix.PackageName }}\bin\Release\*.nupkg -s https://api.nuget.org/v3/index.json -k ${{ secrets.NuGetAPIKey }} --skip-duplicate + dotnet nuget push *.nupkg -s https://nuget.pkg.github.com/HMBSbige -k ${{ secrets.GITHUB_TOKEN }} --skip-duplicate + dotnet nuget push *.nupkg -s https://api.nuget.org/v3/index.json -k ${{ secrets.NuGetAPIKey }} --skip-duplicate release: - name: Release - needs: nuget - runs-on: windows-latest + needs: [build, nuget] + runs-on: ubuntu-latest steps: - - name: Checkout code - uses: actions/checkout@v3 - with: - submodules: true - - - name: Setup .NET - uses: actions/setup-dotnet@v2 + - uses: actions/download-artifact@v3 with: - dotnet-version: 6.0.x - - - name: Build - shell: pwsh - run: .\build.ps1 + name: ${{ env.ProjectName }} + path: ${{ env.ProjectName }} - name: Get tag id: tag uses: dawidd6/action-get-tag@v1 - - name: Package generic + - name: Package shell: pwsh run: | - New-Item -ItemType Directory -Path C:\builtfiles -Force > $null - $zip_path = "C:\builtfiles\$env:ProjectName-generic-${{ steps.tag.outputs.tag }}.7z" - 7z a -mx9 "$zip_path" ".\$env:ProjectName\bin\$env:Configuration\$env:NET_TFM\generic\publish\" - 7z rn "$zip_path" publish $env:ProjectName + New-Item -ItemType Directory -Path builtfiles -Force > $null + $zip_path = "builtfiles/$env:ProjectName-${{ steps.tag.outputs.tag }}.7z" + 7z a -mx9 "$zip_path" ${{ env.ProjectName }} echo "GENERIC_SHA256=$((Get-FileHash $zip_path -Algorithm SHA256).Hash)" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append - - name: Changelog - uses: glennawatson/ChangeLog@v1 - id: changelog - - name: Create a new GitHub release uses: ncipollo/release-action@v1 with: token: ${{ secrets.GITHUB_TOKEN }} prerelease: true draft: false - artifacts: C:\builtfiles\* + artifacts: builtfiles/* body: | - ${{ steps.changelog.outputs.commitLog }} ## Hash | Filename | SHA-256 | | :- | :- | - | ${{ env.ProjectName }}-generic-${{ steps.tag.outputs.tag }}.7z | ${{ env.GENERIC_SHA256 }} | + | ${{ env.ProjectName }}-${{ steps.tag.outputs.tag }}.7z | ${{ env.GENERIC_SHA256 }} | diff --git a/NatTypeTester-Console/NatTypeTester_Console.csproj b/NatTypeTester-Console/NatTypeTester_Console.csproj deleted file mode 100644 index dfd2cfff2..000000000 --- a/NatTypeTester-Console/NatTypeTester_Console.csproj +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - Exe - NatTypeTester - NatTypeTester.Console - - - - - - - - - - - diff --git a/NatTypeTester-Console/Program.cs b/NatTypeTester-Console/Program.cs deleted file mode 100644 index 7d83ca9c9..000000000 --- a/NatTypeTester-Console/Program.cs +++ /dev/null @@ -1,41 +0,0 @@ -using Dns.Net.Clients; -using STUN; -using STUN.Client; -using STUN.StunResult; -using System.Net; - -//stun.qq.com:3478 0.0.0.0:0 -string server = @"stun.syncthing.net"; -ushort port = 3478; -IPEndPoint local = new(IPAddress.Any, 0); - -if (args.Length > 0 && StunServer.TryParse(args[0], out StunServer? stun)) -{ - server = stun.Hostname; - port = stun.Port; -} - -if (args.Length > 1) -{ - if (IPEndPoint.TryParse(args[2], out IPEndPoint? ipEndPoint)) - { - local = ipEndPoint; - } -} - -DefaultDnsClient dnsClient = new(); -IPAddress ip = await dnsClient.QueryAsync(server); -using StunClient5389UDP client = new(new IPEndPoint(ip, port), local); - -using CancellationTokenSource cts = new(); -cts.CancelAfter(TimeSpan.FromSeconds(5)); -await client.QueryAsync(cts.Token); - -StunResult5389 res = client.State; - -Console.WriteLine($@"Other address is {res.OtherEndPoint}"); -Console.WriteLine($@"Binding test: {res.BindingTestResult}"); -Console.WriteLine($@"Local address: {res.LocalEndPoint}"); -Console.WriteLine($@"Mapped address: {res.PublicEndPoint}"); -Console.WriteLine($@"Nat mapping behavior: {res.MappingBehavior}"); -Console.WriteLine($@"Nat filtering behavior: {res.FilteringBehavior}"); diff --git a/NatTypeTester.Models/NatTypeTester.Models.csproj b/NatTypeTester.Models/NatTypeTester.Models.csproj index c049a38d8..7467dd41d 100644 --- a/NatTypeTester.Models/NatTypeTester.Models.csproj +++ b/NatTypeTester.Models/NatTypeTester.Models.csproj @@ -4,7 +4,7 @@ - + diff --git a/NatTypeTester.ViewModels/NatTypeTester.ViewModels.csproj b/NatTypeTester.ViewModels/NatTypeTester.ViewModels.csproj index 43311ca8d..3ffe48ea7 100644 --- a/NatTypeTester.ViewModels/NatTypeTester.ViewModels.csproj +++ b/NatTypeTester.ViewModels/NatTypeTester.ViewModels.csproj @@ -5,7 +5,7 @@ - + diff --git a/NatTypeTester.sln b/NatTypeTester.sln index c73584286..bec3f9ba8 100644 --- a/NatTypeTester.sln +++ b/NatTypeTester.sln @@ -1,19 +1,17 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.29102.190 +# Visual Studio Version 17 +VisualStudioVersion = 17.2.32505.173 MinimumVisualStudioVersion = 10.0.40219.1 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NatTypeTester", "NatTypeTester\NatTypeTester.csproj", "{B5104123-EB01-4079-8865-2A99DD91DC24}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NatTypeTester_Console", "NatTypeTester-Console\NatTypeTester_Console.csproj", "{CC6BE2E2-81CB-4C0B-BA17-4BB48DD403AC}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "STUN", "STUN\STUN.csproj", "{BF8F4960-AA76-4A0F-BA6D-EDF26DEFB9CA}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UnitTest", "UnitTest\UnitTest.csproj", "{AA8AF9BF-5CFB-4725-B42A-7B3B3890A279}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NatTypeTester.ViewModels", "NatTypeTester.ViewModels\NatTypeTester.ViewModels.csproj", "{D7626B0E-17B0-4743-888F-A32797442750}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NatTypeTester.Models", "NatTypeTester.Models\NatTypeTester.Models.csproj", "{FC61BC61-E24B-4E78-ABA4-C6CB6C05EFC2}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NatTypeTester.Models", "NatTypeTester.Models\NatTypeTester.Models.csproj", "{FC61BC61-E24B-4E78-ABA4-C6CB6C05EFC2}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -25,10 +23,6 @@ Global {B5104123-EB01-4079-8865-2A99DD91DC24}.Debug|Any CPU.Build.0 = Debug|Any CPU {B5104123-EB01-4079-8865-2A99DD91DC24}.Release|Any CPU.ActiveCfg = Release|Any CPU {B5104123-EB01-4079-8865-2A99DD91DC24}.Release|Any CPU.Build.0 = Release|Any CPU - {CC6BE2E2-81CB-4C0B-BA17-4BB48DD403AC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {CC6BE2E2-81CB-4C0B-BA17-4BB48DD403AC}.Debug|Any CPU.Build.0 = Debug|Any CPU - {CC6BE2E2-81CB-4C0B-BA17-4BB48DD403AC}.Release|Any CPU.ActiveCfg = Release|Any CPU - {CC6BE2E2-81CB-4C0B-BA17-4BB48DD403AC}.Release|Any CPU.Build.0 = Release|Any CPU {BF8F4960-AA76-4A0F-BA6D-EDF26DEFB9CA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {BF8F4960-AA76-4A0F-BA6D-EDF26DEFB9CA}.Debug|Any CPU.Build.0 = Debug|Any CPU {BF8F4960-AA76-4A0F-BA6D-EDF26DEFB9CA}.Release|Any CPU.ActiveCfg = Release|Any CPU diff --git a/NatTypeTester/NatTypeTester.csproj b/NatTypeTester/NatTypeTester.csproj index 95b06210d..2c7494389 100644 --- a/NatTypeTester/NatTypeTester.csproj +++ b/NatTypeTester/NatTypeTester.csproj @@ -3,10 +3,10 @@ - net6.0-windows10.0.22000.0 + net6.0-windows WinExe true - 6.1.0 + 6.2.0 icon.ico @@ -16,11 +16,11 @@ - + - + diff --git a/STUN/STUN.csproj b/STUN/STUN.csproj index 6ca50b930..567cd9eaa 100644 --- a/STUN/STUN.csproj +++ b/STUN/STUN.csproj @@ -11,7 +11,7 @@ https://github.com/HMBSbige/NatTypeTester https://github.com/HMBSbige/NatTypeTester stun;nat;rfc3489;rfc5389 - 6.1.0 + 6.2.0 Stun.Net diff --git a/UnitTest/UnitTest.csproj b/UnitTest/UnitTest.csproj index 9515d3025..041de7626 100644 --- a/UnitTest/UnitTest.csproj +++ b/UnitTest/UnitTest.csproj @@ -9,7 +9,7 @@ - + diff --git a/build.ps1 b/build.ps1 index 11c16902d..467369193 100644 --- a/build.ps1 +++ b/build.ps1 @@ -1,21 +1,19 @@ -param([string]$rid = 'all') $ErrorActionPreference = 'Stop' -Write-Host 'dotnet SDK info' dotnet --info $proj = 'NatTypeTester' $exe = "$proj.exe" -$net_tfm = 'net6.0-windows10.0.22000.0' +$net_tfm = 'net6.0-windows' $configuration = 'Release' $output_dir = "$PSScriptRoot\$proj\bin\$configuration" $proj_path = "$PSScriptRoot\$proj\$proj.csproj" +$generic_outdir = "$output_dir\$net_tfm\generic" -function Build-Generic -{ +function Build-Generic { Write-Host 'Building generic' - $outdir = "$output_dir\$net_tfm\generic" + $outdir = $generic_outdir $publishDir = "$outdir\publish" Remove-Item $publishDir -Recurse -Force -Confirm:$false -ErrorAction Ignore @@ -25,12 +23,14 @@ function Build-Generic & "$PSScriptRoot\Build\DotNetDllPathPatcher.ps1" "$publishDir\$exe" bin if ($LASTEXITCODE) { exit $LASTEXITCODE } + + Remove-Item "$publishDir\$exe" } -function Build-SelfContained -{ - param([string]$rid) +function Build { + param([string]$arch) + $rid = "win-$arch" Write-Host "Building $rid" $outdir = "$output_dir\$net_tfm\$rid" @@ -38,25 +38,17 @@ function Build-SelfContained Remove-Item $publishDir -Recurse -Force -Confirm:$false -ErrorAction Ignore - dotnet publish -c $configuration -f $net_tfm -r $rid --self-contained true $proj_path + dotnet publish -c $configuration -f $net_tfm -r $rid --no-self-contained true $proj_path if ($LASTEXITCODE) { exit $LASTEXITCODE } & "$PSScriptRoot\Build\DotNetDllPathPatcher.ps1" "$publishDir\$exe" bin if ($LASTEXITCODE) { exit $LASTEXITCODE } -} -if($rid -eq 'all' -or $rid -eq 'generic') -{ - Build-Generic + Move-Item "$publishDir\$exe" "$generic_outdir\publish\$proj-$arch.exe" } -if($rid -eq 'all') -{ - Build-SelfContained win-x86 - Build-SelfContained win-x64 - Build-SelfContained win-arm64 -} -elseif($rid -ne 'generic') -{ - Build-SelfContained $rid -} +Build-Generic +Build x64 +Build x86 +Build arm64 +Build arm