Upgrade MonoTorrent and harden networking defaults to avoid firewall prompts#2
Conversation
Co-authored-by: mrbbbaixue <17956756+mrbbbaixue@users.noreply.github.com>
Co-authored-by: mrbbbaixue <17956756+mrbbbaixue@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR upgrades MonoTorrent from version 2.0.7 to 3.0.2 and hardens the networking configuration to prevent Windows firewall prompts during torrent downloads.
- Updates MonoTorrent dependency to version 3.0.2 for latest security fixes and API improvements
- Explicitly disables all inbound networking features (local peer discovery, port forwarding, DHT, and listener endpoints) to avoid firewall warnings
- Migrates to MonoTorrent 3.x API by switching from deprecated properties (
DataBytesDownloaded,DownloadSpeed) to current equivalents (DataBytesReceived,DownloadRate)
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| Ra3.BattleNet.Downloader/Ra3.BattleNet.Downloader.csproj | Upgrades MonoTorrent package reference from 2.0.7 to 3.0.2 |
| Ra3.BattleNet.Downloader/Download.cs | Updates networking configuration to disable all inbound sockets (preventing firewall prompts) and migrates to MonoTorrent 3.x API with updated property names and local variable optimization |
Comments suppressed due to low confidence (8)
Ra3.BattleNet.Downloader/Download.cs:35
- This foreach loop implicitly filters its target sequence - consider filtering the sequence explicitly using '.Where(...)'.
foreach (var path in new List<string> { tempFolder, cacheFolder, DownloadFolder})
{
if (!Directory.Exists(path))
{
Directory.CreateDirectory(path);
}
}
Ra3.BattleNet.Downloader/Download.cs:173
- Replace this call with a call to managed code if possible.
IntPtr pidlList = ILCreateFromPathW(filePath);
Ra3.BattleNet.Downloader/Download.cs:178
- Replace this call with a call to managed code if possible.
Marshal.ThrowExceptionForHR(SHOpenFolderAndSelectItems(pidlList, 0, IntPtr.Zero, 0));
Ra3.BattleNet.Downloader/Download.cs:182
- Replace this call with a call to managed code if possible.
ILFree(pidlList);
Ra3.BattleNet.Downloader/Download.cs:152
- Minimise the use of unmanaged code.
private static extern void ILFree(IntPtr pidlList);
Ra3.BattleNet.Downloader/Download.cs:155
- Minimise the use of unmanaged code.
private static extern IntPtr ILCreateFromPathW(string pszPath);
Ra3.BattleNet.Downloader/Download.cs:158
- Minimise the use of unmanaged code.
private static extern int SHOpenFolderAndSelectItems(IntPtr pidlList, uint cild, IntPtr children, uint dwFlags);
Ra3.BattleNet.Downloader/Download.cs:79
- This assignment to downloadedFile is useless, since its value is never read.
var downloadedFile = await taskSource.Task;
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| DhtEndPoint = null, | ||
| }; | ||
| settingsBuilder.ListenEndPoints.Clear(); | ||
| var engine = new ClientEngine(settingsBuilder.ToSettings()); |
There was a problem hiding this comment.
Disposable 'ClientEngine' is created but not disposed.
The downloader must use the latest MonoTorrent while avoiding OS firewall warnings by preventing listener/DHT sockets.
DataBytesReceived,DownloadRate) and reduced duplicate reads via a local variable.Example:
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.