Skip to content
Open
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
Binary file added CANAPE.Cli.Lib/.DS_Store
Binary file not shown.
2 changes: 1 addition & 1 deletion CANAPE.Cli.Lib/CANAPE.Cli.Lib.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
<Authors>James Forshaw</Authors>
<Description>Command Line Interface library for the CANAPE.Core network library.</Description>
Expand Down
2 changes: 1 addition & 1 deletion CANAPE.Cli/CANAPE.Cli.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>netcoreapp3.0; netcoreapp2.0; net471</TargetFrameworks>
<TargetFramework>net9.0</TargetFramework>
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
<Authors>James Forshaw</Authors>
<Description>Command Line Interface CANAPE.Core network library.</Description>
Expand Down
Binary file added CANAPE.Net.Protocols/.DS_Store
Binary file not shown.
2 changes: 1 addition & 1 deletion CANAPE.Net.Protocols/CANAPE.Net.Protocols.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
<Authors>James Forshaw</Authors>
<Description>Network protocol parsing library for the CANAPE.Core network library.</Description>
Expand Down
Binary file added CANAPE.Net.Templates/.DS_Store
Binary file not shown.
2 changes: 1 addition & 1 deletion CANAPE.Net.Templates/CANAPE.Net.Templates.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
<Authors>James Forshaw</Authors>
<Description>Network service template library for the CANAPE.Core network library.</Description>
Expand Down
Binary file added CANAPE.Net/.DS_Store
Binary file not shown.
2 changes: 1 addition & 1 deletion CANAPE.Net/CANAPE.Net.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
<Authors>James Forshaw</Authors>
<Description>Core networking library for the CANAPE.Core network library.</Description>
Expand Down
5 changes: 5 additions & 0 deletions CANAPE.Net/Listeners/TcpNetworkListener.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion CANAPE.Security/CANAPE.Security.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
<Authors>James Forshaw</Authors>
<Description>Network security and certificate generator library for the CANAPE.Core network library.</Description>
Expand Down
Binary file added CANAPE/.DS_Store
Binary file not shown.
2 changes: 1 addition & 1 deletion CANAPE/CANAPE.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
<Authors>James Forshaw</Authors>
<Description>Base library for the CANAPE.Core network library.</Description>
Expand Down
69 changes: 69 additions & 0 deletions NET9_MIGRATION.md
Original file line number Diff line number Diff line change
@@ -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
13 changes: 6 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -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
```