Update/Replace NuGet libraries

This commit is contained in:
Stone_Red
2025-03-03 21:21:29 +01:00
parent 4bd949ef79
commit e41a9eff45
8 changed files with 33 additions and 37 deletions
@@ -12,8 +12,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Console.Commander.NET" Version="1.0.1.1" />
<PackageReference Include="Stone_Red-C-Sharp-Utilities" Version="1.0.3.1" />
<PackageReference Include="Console.Commander.NET" Version="1.0.2" />
</ItemGroup>
<ItemGroup>
+6 -6
View File
@@ -1,16 +1,16 @@
using Commander_Net;
using Commander;
using CuteUtils.Misc;
using HyperbolicDownloaderApi.Commands;
using HyperbolicDownloaderApi.FileProcessing;
using HyperbolicDownloaderApi.Networking;
using Stone_Red_Utilities.ConsoleExtentions;
namespace HyperbolicDownloader;
internal class InputHandler
{
private readonly Commander commander = new Commander();
private readonly Commander.Commander commander = new Commander.Commander();
private bool exit = false;
public InputHandler(HostsManager hostsManager, FilesManager filesManager, DirectoryWatcher directoryWatcher)
@@ -37,8 +37,8 @@ internal class InputHandler
Command getCommand = commander.Register(downloadCommands.GetFile, (HelpText)"Attempts to retrieve a file from another host using a hash.", "get");
_ = getCommand.Register(downloadCommands.GetFileFrom, (HelpText)"Attempts to retrieve a file from another host using a .hyper file.", "from");
Command streamCommand = commander.Register(streamingCommands.StreamWav, (HelpText)"Attempts to stream a .wav file from another host using a hash.", "stream");
_ = streamCommand.Register(streamingCommands.GetWavStreamFrom, (HelpText)"Attempts to stream a .wav file from another host using a .hyper file.", "from");
Command streamCommand = commander.Register(streamingCommands.StreamWav, (HelpText)"(EXPERIMENTAL) Attempts to stream a .wav file from another host using a hash.", "stream");
_ = streamCommand.Register(streamingCommands.GetWavStreamFrom, (HelpText)"(EXPERIMENTAL) Attempts to stream a .wav file from another host using a .hyper file.", "from");
Command generateCommad = commander.Register(fileCommands.GenerateFileFull, (HelpText)"Generates a .hyper file from a file hash.", "generate", "gen");
_ = generateCommad.Register(fileCommands.GenerateFileSingle, (HelpText)"Generates a .hyper file from a file hash without checking the known hosts. This adds only the local host to the file.", "noscan");
+2 -2
View File
@@ -1,6 +1,6 @@
using HyperbolicDownloaderApi.Managment;
using CuteUtils.Misc;
using Stone_Red_Utilities.ConsoleExtentions;
using HyperbolicDownloaderApi.Managment;
using System.Net;
+3 -3
View File
@@ -1,9 +1,9 @@
using HyperbolicDownloaderApi.FileProcessing;
using CuteUtils.Misc;
using HyperbolicDownloaderApi.FileProcessing;
using HyperbolicDownloaderApi.Managment;
using HyperbolicDownloaderApi.Networking;
using Stone_Red_Utilities.ConsoleExtentions;
using System.Reflection;
using System.Text.Json;
@@ -1,10 +1,10 @@
using HyperbolicDownloaderApi.FileProcessing;
using CuteUtils;
using HyperbolicDownloaderApi.FileProcessing;
using HyperbolicDownloaderApi.Managment;
using HyperbolicDownloaderApi.Networking;
using HyperbolicDownloaderApi.Utilities;
using Stone_Red_Utilities.StringExtentions;
using System.Diagnostics;
using System.Net;
using System.Net.Sockets;
@@ -141,7 +141,6 @@ public class DownloadCommands(HostsManager hostsManager, FilesManager filesManag
ApiManager.SendNotificationMessageNewLine($"File name: {fileName}");
ApiManager.SendNotificationMessageNewLine($"Starting download...");
if (!Directory.Exists(directoryPath))
{
_ = Directory.CreateDirectory(directoryPath);
@@ -1,12 +1,12 @@
using HyperbolicDownloaderApi.FileProcessing;
using CuteUtils;
using HyperbolicDownloaderApi.FileProcessing;
using HyperbolicDownloaderApi.Managment;
using HyperbolicDownloaderApi.Networking;
using NAudio.Utils;
using NAudio.Wave;
using Stone_Red_Utilities.StringExtentions;
using System.Diagnostics;
using System.Net;
using System.Net.Sockets;
@@ -238,9 +238,9 @@ public class StreamingCommands(HostsManager hostsManager)
hostsManager.SaveHosts();
}
private bool IsBufferNearlyFull(BufferedWaveProvider bufferedWaveProvider)
private static bool IsBufferNearlyFull(BufferedWaveProvider bufferedWaveProvider)
{
return bufferedWaveProvider != null &&
return bufferedWaveProvider is not null &&
bufferedWaveProvider.BufferLength - bufferedWaveProvider.BufferedBytes
< bufferedWaveProvider.WaveFormat.AverageBytesPerSecond / 4;
}
@@ -7,9 +7,9 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="CuteUtils" Version="1.0.0" />
<PackageReference Include="NAudio" Version="2.2.1" />
<PackageReference Include="Open.Nat" Version="2.1.0" />
<PackageReference Include="Stone_Red-C-Sharp-Utilities" Version="1.0.3.1" />
<PackageReference Include="SharpOpenNat" Version="4.0.17" />
</ItemGroup>
</Project>
+11 -13
View File
@@ -1,7 +1,7 @@
using HyperbolicDownloaderApi.FileProcessing;
using HyperbolicDownloaderApi.Networking;
using Open.Nat;
using SharpOpenNat;
using System.Diagnostics;
using System.Net;
@@ -14,7 +14,7 @@ public class ApiManager
public static event EventHandler<NotificationMessageEventArgs>? OnNotificationMessageRecived;
private static readonly Random random = new();
private static NatDevice? device;
private static INatDevice? device;
private static Mapping? portMapping;
private readonly BroadcastClient broadcastClient = new BroadcastClient();
private readonly NetworkClient networkClient;
@@ -59,8 +59,7 @@ public class ApiManager
{
ApiConfiguration.PublicPort = random.Next(1000, 6000);
NatDiscoverer? discoverer = new NatDiscoverer();
device = await discoverer.DiscoverDeviceAsync();
device = await OpenNat.Discoverer.DiscoverDeviceAsync();
IPAddress? ip = await device.GetExternalIPAsync();
SendNotificationMessageNewLine($"The public IP address is: {ip} ", NotificationMessageType.Success);
@@ -92,7 +91,7 @@ public class ApiManager
public static void ClosePorts()
{
SendNotificationMessageNewLine("Closing ports...", NotificationMessageType.Info);
if (device is not null)
if (device is not null && portMapping is not null)
{
try
{
@@ -153,6 +152,11 @@ public class ApiManager
OnNotificationMessageRecived?.Invoke(null, new NotificationMessageEventArgs(messageType, message + Environment.NewLine));
}
private static void ReciveMessage(object? sender, MessageRecivedEventArgs<string> recivedEventArgs)
{
SendNotificationMessageNewLine($"Received \"{recivedEventArgs.Data}\" from {recivedEventArgs.IpAddress}.", NotificationMessageType.Info);
}
private async void BroadcastClient_OnBroadcastRecived(object? sender, BroadcastRecivedEventArgs recivedEventArgs)
{
IPAddress remoteIpAddress = recivedEventArgs.IPEndPoint.Address;
@@ -229,17 +233,11 @@ public class ApiManager
{
SendNotificationMessageNewLine($"{recivedEventArgs.IpAddress} > Requesting file list", NotificationMessageType.Log);
List<HyperFileDto> files = FilesManager
List<HyperFileDto> files = [.. FilesManager
.ToList()
.Select(f => new HyperFileDto(f))
.Where(f => f.Name.Contains(recivedEventArgs.Data))
.ToList();
.Where(f => f.Name.Contains(recivedEventArgs.Data))];
await recivedEventArgs.SendResponseAsync(files);
}
private void ReciveMessage(object? sender, MessageRecivedEventArgs<string> recivedEventArgs)
{
SendNotificationMessageNewLine($"Received \"{recivedEventArgs.Data}\" from {recivedEventArgs.IpAddress}.", NotificationMessageType.Info);
}
}