Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
62351a2
Add and improve tests (#13)
xBaank Jan 14, 2026
6e6fcab
wip
xBaank Jan 14, 2026
e40a830
wip
xBaank Jan 14, 2026
b7cffbf
wip
xBaank Jan 14, 2026
a5f2d0f
wip
xBaank Jan 14, 2026
f8345f5
wip
xBaank Jan 14, 2026
375e2cd
wip
xBaank Jan 14, 2026
5dff639
wip
xBaank Jan 14, 2026
93a9080
Revert "wip"
xBaank Jan 14, 2026
e062a1c
Create dependabot.yml
xBaank Jan 14, 2026
d7c2f7d
wip
xBaank Jan 14, 2026
ab5665f
wip
xBaank Jan 14, 2026
fe4fb20
wip
xBaank Jan 14, 2026
3a6a730
wip
xBaank Jan 14, 2026
da8029e
wip
xBaank Jan 14, 2026
7bbd15b
wip
xBaank Jan 14, 2026
c921e42
wip
xBaank Jan 14, 2026
c45fd99
Merge branch 'master' into develop
xBaank Jan 14, 2026
b9648a7
wip
xBaank Jan 14, 2026
a488227
wip
xBaank Jan 14, 2026
ee36661
Bump CSharpier.MsBuild from 1.2.1 to 1.2.5 (#33)
dependabot[bot] Jan 14, 2026
41a8ebe
Bump Microsoft.Extensions.Logging.Abstractions from 10.0.1 to 10.0.2 …
dependabot[bot] Jan 14, 2026
3f8e6ca
Bump Microsoft.Extensions.Logging and Microsoft.Extensions.Logging.Co…
dependabot[bot] Jan 14, 2026
8d59c9c
Bump Testcontainers from 4.9.0 to 4.10.0 (#37)
dependabot[bot] Jan 14, 2026
d03f03f
Bump TUnit from 1.11.18 to 1.11.28 (#38)
dependabot[bot] Jan 14, 2026
8dbdcf1
Merge branch 'master' into develop
xBaank Jan 14, 2026
c9b5ff6
wip
xBaank Jan 14, 2026
f7ceea6
Bump actions/checkout from 4 to 6 (#40)
dependabot[bot] Jan 14, 2026
3e52df0
Bump actions/github-script from 7 to 8 (#41)
dependabot[bot] Jan 14, 2026
467725d
Bump actions/upload-artifact from 4 to 6 (#44)
dependabot[bot] Jan 14, 2026
3956226
Bump actions/setup-dotnet from 4 to 5 (#42)
dependabot[bot] Jan 14, 2026
4c6302e
Bump actions/download-artifact from 4 to 7 (#43)
dependabot[bot] Jan 14, 2026
3081979
wip
xBaank Jan 15, 2026
42013d6
Bump actions/cache from 4 to 5 (#45)
dependabot[bot] Jan 15, 2026
0ad161e
wip
xBaank Jan 15, 2026
d9d562d
wip
xBaank Jan 15, 2026
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
5 changes: 5 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,8 @@ updates:
target-branch: "develop"
schedule:
interval: "daily"
- package-ecosystem: "github-actions"
directory: "/"
target-branch: "develop"
schedule:
interval: "daily"
6 changes: 3 additions & 3 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6

- name: Setup .NET
uses: actions/setup-dotnet@v4
uses: actions/setup-dotnet@v5
with:
dotnet-version: 10.0.x

- name: Cache NuGet packages
uses: actions/cache@v4
uses: actions/cache@v5
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
Expand Down
45 changes: 8 additions & 37 deletions .github/workflows/nuget-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,8 @@ name: NuGet Publish

on:
push:
branches: [ master, develop ]
branches: [ develop ]
tags: [ '*' ]
workflow_dispatch:
inputs:
version:
description: 'Override version (optional)'
required: false
type: string
environment:
description: 'Publish environment'
required: false
default: 'auto'
type: choice
options:
- auto
- staging
- production
create_release:
description: 'Create GitHub release (production only)'
required: false
type: boolean
default: false
release_notes:
description: 'Release notes'
required: false
type: string

env:
DOTNET_VERSION: 10.0.x
Expand All @@ -45,17 +21,17 @@ jobs:
create-release: ${{ steps.setup.outputs.create-release }}

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
with:
fetch-depth: 0

- name: Setup .NET
uses: actions/setup-dotnet@v4
uses: actions/setup-dotnet@v5
with:
dotnet-version: ${{ env.DOTNET_VERSION }}

- name: Cache NuGet packages
uses: actions/cache@v4
uses: actions/cache@v5
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
Expand Down Expand Up @@ -134,11 +110,6 @@ jobs:
environment = 'production';
// Create GitHub release for all tags
createRelease = true;
} else if (ref === 'refs/heads/master') {
// master branch builds (preview versions)
version = `${baseVersion}-preview-${context.runNumber}`;
environment = 'staging';
shouldPublish = false; // Don't auto-publish from master
}
}

Expand Down Expand Up @@ -185,7 +156,7 @@ jobs:
ls -la ./artifacts/ || echo "No artifacts found"

- name: Upload artifacts
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@v6
if: steps.setup.outputs.should-publish == 'true'
with:
name: nuget-packages-${{ steps.setup.outputs.version }}
Expand All @@ -202,13 +173,13 @@ jobs:

steps:
- name: Download artifacts
uses: actions/download-artifact@v4
uses: actions/download-artifact@v7
with:
name: nuget-packages-${{ needs.build.outputs.version }}
path: ./artifacts

- name: Setup .NET
uses: actions/setup-dotnet@v4
uses: actions/setup-dotnet@v5
with:
dotnet-version: ${{ env.DOTNET_VERSION }}

Expand Down Expand Up @@ -243,7 +214,7 @@ jobs:

- name: Upload release assets
if: needs.build.outputs.create-release == 'true'
uses: actions/github-script@v7
uses: actions/github-script@v8
with:
script: |
const fs = require('fs');
Expand Down
4 changes: 2 additions & 2 deletions Netorrent.Example/Netorrent.Example.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="10.0.1" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="10.0.1" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="10.0.2" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="10.0.2" />
<PackageReference Include="Spectre.Console" Version="0.54.0" />
</ItemGroup>
<ItemGroup>
Expand Down
3 changes: 1 addition & 2 deletions Netorrent.Tests.Integration/Fixtures/OpenTrackerFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ public class OpenTrackerFixture : IAsyncInitializer, IAsyncDisposable

public async Task InitializeAsync()
{
_container = new ContainerBuilder()
.WithImage("xbank/opentracker-docker")
_container = new ContainerBuilder("xbank/opentracker-docker")
.WithName("opentracker-test")
.WithPortBinding("6969/tcp", true)
.WithPortBinding("6969/udp", true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<IsTestProject>true</IsTestProject>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Testcontainers" Version="4.9.0" />
<PackageReference Include="Testcontainers" Version="4.10.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Netorrent.Tests\Netorrent.Tests.csproj" />
Expand Down
4 changes: 2 additions & 2 deletions Netorrent.Tests/Netorrent.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="CSharpier.MsBuild" Version="1.2.1">
<PackageReference Include="CSharpier.MsBuild" Version="1.2.5">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Shouldly" Version="4.3.0" />
<PackageReference Include="TUnit" Version="1.11.18" />
<PackageReference Include="TUnit" Version="1.11.28" />
<PackageReference Include="PublicApiGenerator" Version="11.5.4" />
</ItemGroup>
<ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions Netorrent/IO/MessageStream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ namespace Netorrent.IO;
internal class MessageStream(Stream stream, Handshake handshake, TimeSpan timeout) : IMessageStream
{
private readonly Channel<Message> _incomingMessages = Channel.CreateBounded<Message>(
new BoundedChannelOptions(512) { SingleWriter = true, SingleReader = true }
new BoundedChannelOptions(128) { SingleWriter = true, SingleReader = true }
);
private readonly Channel<Message> _outgoingMessages = Channel.CreateBounded<Message>(
new BoundedChannelOptions(512) { SingleWriter = false, SingleReader = true }
new BoundedChannelOptions(128) { SingleWriter = false, SingleReader = true }
);

public Handshake Handshake => handshake;
Expand Down
4 changes: 2 additions & 2 deletions Netorrent/Netorrent.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@
<WarningsAsErrors>CS8600;CS8602;CS8603;CS8604;CS8618;CS8625</WarningsAsErrors>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="CSharpier.MsBuild" Version="1.2.1">
<PackageReference Include="CSharpier.MsBuild" Version="1.2.5">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="10.0.1" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="10.0.2" />
<PackageReference Include="R3" Version="1.3.0" />
<PackageReference Include="ZLinq" Version="1.5.4" />
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion Netorrent/P2P/Download/RequestScheduler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ ILogger logger

private readonly Channel<DownloadMessage> _downloadMessageChannel =
Channel.CreateBounded<DownloadMessage>(
new BoundedChannelOptions(512) { SingleWriter = false, SingleReader = true }
new BoundedChannelOptions(128) { SingleWriter = false, SingleReader = true }
);

private static readonly DownloadMessage.CheckTimeoutMessage _timeoutMessage = new();
Expand Down
6 changes: 3 additions & 3 deletions Netorrent/P2P/PeerConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -167,13 +167,13 @@ private async Task RunAsync(CancellationTokenSource cancellationTokenSource)
await SendBitfieldAsync(MyBitField, cancellationTokenSource.Token).ConfigureAwait(false);

await using var downloadTimer = DownloadTracker
.StartSampling(500.Milliseconds)
.StartSampling(100.Milliseconds)
.ConfigureAwait(false);
await using var uploadTimer = UploadTracker
.StartSampling(500.Milliseconds)
.StartSampling(100.Milliseconds)
.ConfigureAwait(false);
await using var requestWindowTimer = PeerRequestWindow
.StartSampling(500.Milliseconds, DownloadTracker)
.StartSampling(100.Milliseconds, DownloadTracker)
.ConfigureAwait(false);

try
Expand Down
2 changes: 1 addition & 1 deletion Netorrent/P2P/PeersClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ ILogger logger
private readonly Subject<PeerEndpoint> _peerConnected = new();
private readonly Channel<PeerConnection> _peerConnections =
Channel.CreateBounded<PeerConnection>(
new BoundedChannelOptions(100) { SingleReader = true, SingleWriter = false }
new BoundedChannelOptions(128) { SingleReader = true, SingleWriter = false }
);

public PeerId PeerId => peerId;
Expand Down
2 changes: 1 addition & 1 deletion Netorrent/P2P/Upload/UploadScheduler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ ILogger logger

private readonly Channel<UploadMessage> _uploadMessagesChannel =
Channel.CreateBounded<UploadMessage>(
new BoundedChannelOptions(256) { SingleWriter = false, SingleReader = true }
new BoundedChannelOptions(128) { SingleWriter = false, SingleReader = true }
);

private static readonly UploadMessage.CheckRoundMessage _checkRoundMessage = new();
Expand Down
2 changes: 1 addition & 1 deletion Netorrent/TorrentFile/Torrent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ IReadOnlySet<int> downloadedPieces
var files = metaInfo.Info.NormalizedFiles;
var totalSize = files.Sum(i => i.Length);
var trackersChannel = Channel.CreateBounded<IPEndPoint>(
new BoundedChannelOptions(100) { SingleWriter = false, SingleReader = true }
new BoundedChannelOptions(128) { SingleWriter = false, SingleReader = true }
);

MetaInfo = metaInfo;
Expand Down
41 changes: 5 additions & 36 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Netorrent

A high-performance, async-first .NET 10.0 BitTorrent client library for downloading and seeding torrents.
A async-first .NET 10.0 BitTorrent client library for downloading and seeding torrents.

## Installation

Expand Down Expand Up @@ -56,9 +56,10 @@ await using var client = new TorrentClient();
await using var torrent = await client.LoadTorrentAsync("file.torrent", "output");

await torrent.StartAsync();
var completionTask = torrent.Completion.AsTask();

// Monitor detailed statistics
while (!torrent.Completion.IsCompleted)
while (!completionTask.IsCompleted)
{
var data = torrent.Statistics.Data;
var peers = torrent.Statistics.Peers;
Expand All @@ -72,6 +73,8 @@ while (!torrent.Completion.IsCompleted)

await Task.Delay(1000);
}

await completionTask;
```

### Advanced Configuration
Expand Down Expand Up @@ -160,40 +163,6 @@ The library is designed with async-first architecture for optimal performance:
- **Installation**: `dotnet add package Netorrent --version 1.0.0-nightly-*`
- **Warning**: May contain breaking changes or bugs

### 🚀 Preview Releases
- **Purpose**: Pre-release testing of upcoming features
- **Versioning**: Pre-release suffix (e.g., `1.0.0-preview-123`)
- **Updates**: Periodic builds from master branch
- **Installation**: `dotnet add package Netorrent --prerelease`

### Version Selection Strategies

**For Production Applications:**
```xml
<PackageReference Include="Netorrent" Version="[1.0.0,2.0.0)" />
```

**For Testing Latest Features:**
```xml
<PackageReference Include="Netorrent" Version="1.0.0-nightly-*" />
```

**For Early Adopters:**
```xml
<PackageReference Include="Netorrent" Version="1.0.0-*" />
```

## CI/CD Integration

The project uses GitHub Actions for automated publishing:

- **Per-commit nightly builds** from `develop` branch
- **Release builds** from git tags
- **Manual publishing** for custom versions
- **Comprehensive testing** before all publications

See [`.github/workflows/`](.github/workflows/) for complete workflow configurations.

## Features

- [x] **Torrent files** - Complete .torrent file support
Expand Down
Loading