diff --git a/CANAPE.Cli.Lib/.DS_Store b/CANAPE.Cli.Lib/.DS_Store new file mode 100644 index 0000000..917c075 Binary files /dev/null and b/CANAPE.Cli.Lib/.DS_Store differ diff --git a/CANAPE.Cli.Lib/CANAPE.Cli.Lib.csproj b/CANAPE.Cli.Lib/CANAPE.Cli.Lib.csproj index 465e880..929bc0e 100644 --- a/CANAPE.Cli.Lib/CANAPE.Cli.Lib.csproj +++ b/CANAPE.Cli.Lib/CANAPE.Cli.Lib.csproj @@ -1,7 +1,7 @@  - netstandard2.0 + net9.0 true James Forshaw Command Line Interface library for the CANAPE.Core network library. diff --git a/CANAPE.Cli/CANAPE.Cli.csproj b/CANAPE.Cli/CANAPE.Cli.csproj index e86d4f4..778eb7b 100644 --- a/CANAPE.Cli/CANAPE.Cli.csproj +++ b/CANAPE.Cli/CANAPE.Cli.csproj @@ -2,7 +2,7 @@ Exe - netcoreapp3.0; netcoreapp2.0; net471 + net9.0 true James Forshaw Command Line Interface CANAPE.Core network library. diff --git a/CANAPE.Net.Protocols/.DS_Store b/CANAPE.Net.Protocols/.DS_Store new file mode 100644 index 0000000..a35ccd3 Binary files /dev/null and b/CANAPE.Net.Protocols/.DS_Store differ diff --git a/CANAPE.Net.Protocols/CANAPE.Net.Protocols.csproj b/CANAPE.Net.Protocols/CANAPE.Net.Protocols.csproj index 8870832..25c2ebb 100644 --- a/CANAPE.Net.Protocols/CANAPE.Net.Protocols.csproj +++ b/CANAPE.Net.Protocols/CANAPE.Net.Protocols.csproj @@ -1,7 +1,7 @@  - netstandard2.0 + net9.0 true James Forshaw Network protocol parsing library for the CANAPE.Core network library. diff --git a/CANAPE.Net.Templates/.DS_Store b/CANAPE.Net.Templates/.DS_Store new file mode 100644 index 0000000..fcbf4a7 Binary files /dev/null and b/CANAPE.Net.Templates/.DS_Store differ diff --git a/CANAPE.Net.Templates/CANAPE.Net.Templates.csproj b/CANAPE.Net.Templates/CANAPE.Net.Templates.csproj index efb73c6..daa6d4e 100644 --- a/CANAPE.Net.Templates/CANAPE.Net.Templates.csproj +++ b/CANAPE.Net.Templates/CANAPE.Net.Templates.csproj @@ -1,7 +1,7 @@  - netstandard2.0 + net9.0 true James Forshaw Network service template library for the CANAPE.Core network library. diff --git a/CANAPE.Net/.DS_Store b/CANAPE.Net/.DS_Store new file mode 100644 index 0000000..e029fba Binary files /dev/null and b/CANAPE.Net/.DS_Store differ diff --git a/CANAPE.Net/CANAPE.Net.csproj b/CANAPE.Net/CANAPE.Net.csproj index 1c7ef5f..d3d13a4 100644 --- a/CANAPE.Net/CANAPE.Net.csproj +++ b/CANAPE.Net/CANAPE.Net.csproj @@ -1,7 +1,7 @@  - netstandard2.0 + net9.0 true James Forshaw Core networking library for the CANAPE.Core network library. diff --git a/CANAPE.Net/Listeners/TcpNetworkListener.cs b/CANAPE.Net/Listeners/TcpNetworkListener.cs index 49e7d81..01f8fde 100644 --- a/CANAPE.Net/Listeners/TcpNetworkListener.cs +++ b/CANAPE.Net/Listeners/TcpNetworkListener.cs @@ -162,6 +162,11 @@ private async Task AcceptCallback(TcpListener listener) // If client socket closed then exit loop. break; } + catch (InvalidOperationException) + { + // In .NET 9.0+, TcpListener throws InvalidOperationException when stopped + break; + } catch (Exception ex) { _logger.LogException(ex); diff --git a/CANAPE.Security/CANAPE.Security.csproj b/CANAPE.Security/CANAPE.Security.csproj index 1b14414..e09fc21 100644 --- a/CANAPE.Security/CANAPE.Security.csproj +++ b/CANAPE.Security/CANAPE.Security.csproj @@ -1,7 +1,7 @@  - netstandard2.0 + net9.0 true James Forshaw Network security and certificate generator library for the CANAPE.Core network library. diff --git a/CANAPE/.DS_Store b/CANAPE/.DS_Store new file mode 100644 index 0000000..dbee206 Binary files /dev/null and b/CANAPE/.DS_Store differ diff --git a/CANAPE/CANAPE.csproj b/CANAPE/CANAPE.csproj index 8bbbcc4..a6f09f2 100644 --- a/CANAPE/CANAPE.csproj +++ b/CANAPE/CANAPE.csproj @@ -1,7 +1,7 @@  - netstandard2.0 + net9.0 true James Forshaw Base library for the CANAPE.Core network library. diff --git a/NET9_MIGRATION.md b/NET9_MIGRATION.md new file mode 100644 index 0000000..d8d5f7a --- /dev/null +++ b/NET9_MIGRATION.md @@ -0,0 +1,69 @@ +# .NET 9.0 Migration Notes + +This document describes the changes made to migrate CANAPE.Core from .NET Standard 2.0/.NET Core 2.0/3.0 to .NET 9.0. + +## Project Files Updated + +All project files were updated to target .NET 9.0: + +1. **CANAPE.csproj** - Changed from `netstandard2.0` to `net9.0` +2. **CANAPE.Net.csproj** - Changed from `netstandard2.0` to `net9.0` +3. **CANAPE.Security.csproj** - Changed from `netstandard2.0` to `net9.0` +4. **CANAPE.Net.Protocols.csproj** - Changed from `netstandard2.0` to `net9.0` +5. **CANAPE.Net.Templates.csproj** - Changed from `netstandard2.0` to `net9.0` +6. **CANAPE.Cli.csproj** - Changed from `netcoreapp3.0; netcoreapp2.0; net471` to `net9.0` +7. **CANAPE.Cli.Lib.csproj** - Changed from `netstandard2.0` to `net9.0` + +## Code Changes Required + +### TcpNetworkListener.cs + +**Issue**: In .NET 9.0, `TcpListener.Stop()` behavior changed. When stopped, subsequent calls to `AcceptTcpClientAsync()` now throw `InvalidOperationException` instead of `ObjectDisposedException`. + +**Fix**: Added exception handling for `InvalidOperationException` in the `AcceptCallback` method: + +```csharp +catch (InvalidOperationException) +{ + // In .NET 9.0+, TcpListener throws InvalidOperationException when stopped + break; +} +``` + +**File**: `/CANAPE.Net/Listeners/TcpNetworkListener.cs` +**Line**: ~165 (in the `AcceptCallback` method) + +## Build and Run + +To build the solution: +```bash +dotnet build CANAPE.Core.sln -c Release +``` + +To run the CLI with the SOCKS proxy example: +```bash +cd CANAPE.Cli/bin/Release/net9.0 +dotnet exec CANAPE.Cli.dll /path/to/CANAPE.Cli.Lib/Examples/SocksProxy.csx --color +``` + +## Known Warnings + +The build produces several deprecation warnings that should be addressed in future updates: + +1. **SYSLIB0057**: X509Certificate2 constructor is obsolete - should use X509CertificateLoader +2. **SYSLIB0039**: TLS 1.0/1.1 protocols are obsolete - should use newer TLS versions +3. **SYSLIB0001**: UTF7Encoding is obsolete - should use UTF-8 +4. **NU5048**: PackageIconUrl is deprecated - should use PackageIcon + +These warnings don't prevent the code from working but should be addressed for better security and future compatibility. + +## Testing + +The migration was tested by: +1. Building the entire solution successfully +2. Running the SOCKS proxy example without errors +3. Verifying the TCP listener starts and accepts connections properly + +## Date + +Migration completed: October 12, 2025 diff --git a/README.md b/README.md index 669fcbc..993ea92 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,13 @@ # CANAPE.Core - (c) James Forshaw 2017 A network proxy library written in C# for .NET Core based on CANAPE. Licensed under GPLv3. -It should work on any platform with .NET Standard support 2.0, so .NET Core 2.0.5 and .NET Framework 4.7.1 on Windows, Linux and -macOS should be suitable as well as recompiling for .NET framework and Mono. +This version has been updated to target .NET 9.0. -To use either compile with Visual Studio 2017 with .NET Core support or from the command line do the -following (replace netcoreapp3.0 with netcoreapp2.0 if using 2.X framework): +To use either compile with Visual Studio with .NET 9.0 SDK support or from the command line do the +following: -```cd CANAPE.Core -dotnet build CANAPE.Cli/CANAPE.Cli.csproj -c Release -f netcoreapp3.0 -cd CANAPE.Cli/bin/Release/netcoreapp3.0 +``` +dotnet build CANAPE.Cli/CANAPE.Cli.csproj -c Release +cd CANAPE.Cli/bin/Release/net9.0 dotnet exec CANAPE.Cli.dll Examples/SocksProxy.csx --color ``` \ No newline at end of file