mirror of
https://github.com/Stone-Red-Code/HyperbolicDownloader.git
synced 2026-09-08 15:56:23 +02:00
Update/Replace NuGet libraries
This commit is contained in:
@@ -12,8 +12,7 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Console.Commander.NET" Version="1.0.1.1" />
|
<PackageReference Include="Console.Commander.NET" Version="1.0.2" />
|
||||||
<PackageReference Include="Stone_Red-C-Sharp-Utilities" Version="1.0.3.1" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@@ -1,16 +1,16 @@
|
|||||||
using Commander_Net;
|
using Commander;
|
||||||
|
|
||||||
|
using CuteUtils.Misc;
|
||||||
|
|
||||||
using HyperbolicDownloaderApi.Commands;
|
using HyperbolicDownloaderApi.Commands;
|
||||||
using HyperbolicDownloaderApi.FileProcessing;
|
using HyperbolicDownloaderApi.FileProcessing;
|
||||||
using HyperbolicDownloaderApi.Networking;
|
using HyperbolicDownloaderApi.Networking;
|
||||||
|
|
||||||
using Stone_Red_Utilities.ConsoleExtentions;
|
|
||||||
|
|
||||||
namespace HyperbolicDownloader;
|
namespace HyperbolicDownloader;
|
||||||
|
|
||||||
internal class InputHandler
|
internal class InputHandler
|
||||||
{
|
{
|
||||||
private readonly Commander commander = new Commander();
|
private readonly Commander.Commander commander = new Commander.Commander();
|
||||||
private bool exit = false;
|
private bool exit = false;
|
||||||
|
|
||||||
public InputHandler(HostsManager hostsManager, FilesManager filesManager, DirectoryWatcher directoryWatcher)
|
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");
|
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");
|
_ = 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");
|
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)"Attempts to stream a .wav file from another host using a .hyper file.", "from");
|
_ = 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");
|
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");
|
_ = 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");
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
using HyperbolicDownloaderApi.Managment;
|
using CuteUtils.Misc;
|
||||||
|
|
||||||
using Stone_Red_Utilities.ConsoleExtentions;
|
using HyperbolicDownloaderApi.Managment;
|
||||||
|
|
||||||
using System.Net;
|
using System.Net;
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
using HyperbolicDownloaderApi.FileProcessing;
|
using CuteUtils.Misc;
|
||||||
|
|
||||||
|
using HyperbolicDownloaderApi.FileProcessing;
|
||||||
using HyperbolicDownloaderApi.Managment;
|
using HyperbolicDownloaderApi.Managment;
|
||||||
using HyperbolicDownloaderApi.Networking;
|
using HyperbolicDownloaderApi.Networking;
|
||||||
|
|
||||||
using Stone_Red_Utilities.ConsoleExtentions;
|
|
||||||
|
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
using HyperbolicDownloaderApi.FileProcessing;
|
using CuteUtils;
|
||||||
|
|
||||||
|
using HyperbolicDownloaderApi.FileProcessing;
|
||||||
using HyperbolicDownloaderApi.Managment;
|
using HyperbolicDownloaderApi.Managment;
|
||||||
using HyperbolicDownloaderApi.Networking;
|
using HyperbolicDownloaderApi.Networking;
|
||||||
using HyperbolicDownloaderApi.Utilities;
|
using HyperbolicDownloaderApi.Utilities;
|
||||||
|
|
||||||
using Stone_Red_Utilities.StringExtentions;
|
|
||||||
|
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Net.Sockets;
|
using System.Net.Sockets;
|
||||||
@@ -141,7 +141,6 @@ public class DownloadCommands(HostsManager hostsManager, FilesManager filesManag
|
|||||||
ApiManager.SendNotificationMessageNewLine($"File name: {fileName}");
|
ApiManager.SendNotificationMessageNewLine($"File name: {fileName}");
|
||||||
ApiManager.SendNotificationMessageNewLine($"Starting download...");
|
ApiManager.SendNotificationMessageNewLine($"Starting download...");
|
||||||
|
|
||||||
|
|
||||||
if (!Directory.Exists(directoryPath))
|
if (!Directory.Exists(directoryPath))
|
||||||
{
|
{
|
||||||
_ = Directory.CreateDirectory(directoryPath);
|
_ = Directory.CreateDirectory(directoryPath);
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
using HyperbolicDownloaderApi.FileProcessing;
|
using CuteUtils;
|
||||||
|
|
||||||
|
using HyperbolicDownloaderApi.FileProcessing;
|
||||||
using HyperbolicDownloaderApi.Managment;
|
using HyperbolicDownloaderApi.Managment;
|
||||||
using HyperbolicDownloaderApi.Networking;
|
using HyperbolicDownloaderApi.Networking;
|
||||||
|
|
||||||
using NAudio.Utils;
|
using NAudio.Utils;
|
||||||
using NAudio.Wave;
|
using NAudio.Wave;
|
||||||
|
|
||||||
using Stone_Red_Utilities.StringExtentions;
|
|
||||||
|
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Net.Sockets;
|
using System.Net.Sockets;
|
||||||
@@ -238,9 +238,9 @@ public class StreamingCommands(HostsManager hostsManager)
|
|||||||
hostsManager.SaveHosts();
|
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.BufferLength - bufferedWaveProvider.BufferedBytes
|
||||||
< bufferedWaveProvider.WaveFormat.AverageBytesPerSecond / 4;
|
< bufferedWaveProvider.WaveFormat.AverageBytesPerSecond / 4;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,9 +7,9 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<PackageReference Include="CuteUtils" Version="1.0.0" />
|
||||||
<PackageReference Include="NAudio" Version="2.2.1" />
|
<PackageReference Include="NAudio" Version="2.2.1" />
|
||||||
<PackageReference Include="Open.Nat" Version="2.1.0" />
|
<PackageReference Include="SharpOpenNat" Version="4.0.17" />
|
||||||
<PackageReference Include="Stone_Red-C-Sharp-Utilities" Version="1.0.3.1" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
using HyperbolicDownloaderApi.FileProcessing;
|
using HyperbolicDownloaderApi.FileProcessing;
|
||||||
using HyperbolicDownloaderApi.Networking;
|
using HyperbolicDownloaderApi.Networking;
|
||||||
|
|
||||||
using Open.Nat;
|
using SharpOpenNat;
|
||||||
|
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
@@ -14,7 +14,7 @@ public class ApiManager
|
|||||||
public static event EventHandler<NotificationMessageEventArgs>? OnNotificationMessageRecived;
|
public static event EventHandler<NotificationMessageEventArgs>? OnNotificationMessageRecived;
|
||||||
|
|
||||||
private static readonly Random random = new();
|
private static readonly Random random = new();
|
||||||
private static NatDevice? device;
|
private static INatDevice? device;
|
||||||
private static Mapping? portMapping;
|
private static Mapping? portMapping;
|
||||||
private readonly BroadcastClient broadcastClient = new BroadcastClient();
|
private readonly BroadcastClient broadcastClient = new BroadcastClient();
|
||||||
private readonly NetworkClient networkClient;
|
private readonly NetworkClient networkClient;
|
||||||
@@ -59,8 +59,7 @@ public class ApiManager
|
|||||||
{
|
{
|
||||||
ApiConfiguration.PublicPort = random.Next(1000, 6000);
|
ApiConfiguration.PublicPort = random.Next(1000, 6000);
|
||||||
|
|
||||||
NatDiscoverer? discoverer = new NatDiscoverer();
|
device = await OpenNat.Discoverer.DiscoverDeviceAsync();
|
||||||
device = await discoverer.DiscoverDeviceAsync();
|
|
||||||
|
|
||||||
IPAddress? ip = await device.GetExternalIPAsync();
|
IPAddress? ip = await device.GetExternalIPAsync();
|
||||||
SendNotificationMessageNewLine($"The public IP address is: {ip} ", NotificationMessageType.Success);
|
SendNotificationMessageNewLine($"The public IP address is: {ip} ", NotificationMessageType.Success);
|
||||||
@@ -92,7 +91,7 @@ public class ApiManager
|
|||||||
public static void ClosePorts()
|
public static void ClosePorts()
|
||||||
{
|
{
|
||||||
SendNotificationMessageNewLine("Closing ports...", NotificationMessageType.Info);
|
SendNotificationMessageNewLine("Closing ports...", NotificationMessageType.Info);
|
||||||
if (device is not null)
|
if (device is not null && portMapping is not null)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -153,6 +152,11 @@ public class ApiManager
|
|||||||
OnNotificationMessageRecived?.Invoke(null, new NotificationMessageEventArgs(messageType, message + Environment.NewLine));
|
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)
|
private async void BroadcastClient_OnBroadcastRecived(object? sender, BroadcastRecivedEventArgs recivedEventArgs)
|
||||||
{
|
{
|
||||||
IPAddress remoteIpAddress = recivedEventArgs.IPEndPoint.Address;
|
IPAddress remoteIpAddress = recivedEventArgs.IPEndPoint.Address;
|
||||||
@@ -229,17 +233,11 @@ public class ApiManager
|
|||||||
{
|
{
|
||||||
SendNotificationMessageNewLine($"{recivedEventArgs.IpAddress} > Requesting file list", NotificationMessageType.Log);
|
SendNotificationMessageNewLine($"{recivedEventArgs.IpAddress} > Requesting file list", NotificationMessageType.Log);
|
||||||
|
|
||||||
List<HyperFileDto> files = FilesManager
|
List<HyperFileDto> files = [.. FilesManager
|
||||||
.ToList()
|
.ToList()
|
||||||
.Select(f => new HyperFileDto(f))
|
.Select(f => new HyperFileDto(f))
|
||||||
.Where(f => f.Name.Contains(recivedEventArgs.Data))
|
.Where(f => f.Name.Contains(recivedEventArgs.Data))];
|
||||||
.ToList();
|
|
||||||
|
|
||||||
await recivedEventArgs.SendResponseAsync(files);
|
await recivedEventArgs.SendResponseAsync(files);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ReciveMessage(object? sender, MessageRecivedEventArgs<string> recivedEventArgs)
|
|
||||||
{
|
|
||||||
SendNotificationMessageNewLine($"Received \"{recivedEventArgs.Data}\" from {recivedEventArgs.IpAddress}.", NotificationMessageType.Info);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user