From 81f785a6805f349540dc299056d9588397bfaa90 Mon Sep 17 00:00:00 2001 From: xeL Date: Tue, 10 Sep 2024 14:33:23 +0300 Subject: [PATCH 01/34] fix message display --- Commands/TerminalCommands/ConsoleSystem/Firewall.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Commands/TerminalCommands/ConsoleSystem/Firewall.cs b/Commands/TerminalCommands/ConsoleSystem/Firewall.cs index 255ef992..ddeb6016 100644 --- a/Commands/TerminalCommands/ConsoleSystem/Firewall.cs +++ b/Commands/TerminalCommands/ConsoleSystem/Firewall.cs @@ -233,7 +233,7 @@ public void Execute(string arg) } catch (Exception ex) { - FileSystem.ErrorWriteLine($"{ex.ToString()}. Use -h for more information!"); + FileSystem.ErrorWriteLine($"{ex.Message}. Use -h for more information!"); } } } From 7834d210e857d27c7c07b6eebe9da8b928e2b8c2 Mon Sep 17 00:00:00 2001 From: xeL Date: Tue, 10 Sep 2024 14:33:54 +0300 Subject: [PATCH 02/34] set to work with hostname as wel --- .../TerminalCommands/Network/WakeOverLan.cs | 4 ++-- Core/NetWork.cs | 22 +++++++++++++++++++ Core/WakeOverLAN.cs | 4 ++++ README.md | 4 ++-- 4 files changed, 30 insertions(+), 4 deletions(-) diff --git a/Commands/TerminalCommands/Network/WakeOverLan.cs b/Commands/TerminalCommands/Network/WakeOverLan.cs index 6313cc28..a1031c20 100644 --- a/Commands/TerminalCommands/Network/WakeOverLan.cs +++ b/Commands/TerminalCommands/Network/WakeOverLan.cs @@ -10,8 +10,8 @@ public class WakeOverLan : ITerminalCommand { private const int _port = 9; private static string s_helpMessage = @"Usage of wol (Wake Over LAN) command: - wol -ip IP_Address -mac MAC_Address : sends wake packet for ip/mac. - wol -ip IP_Address -mac MAC_Address -port number_port : sends wake packet for ip/mac and custom WOL port. + wol -ip IPAddress/HostName -mac MAC_Address : sends wake packet for ip/mac. + wol -ip IPAddress/HostName -mac MAC_Address -port number_port : sends wake packet for ip/mac and custom WOL port. "; public string Name => "wol"; public void Execute(string args) diff --git a/Core/NetWork.cs b/Core/NetWork.cs index e6e54d4b..46810d2c 100644 --- a/Core/NetWork.cs +++ b/Core/NetWork.cs @@ -312,6 +312,28 @@ public static string GetMacAddress(string ipAddress) return macAddress; } + /// + /// Return IP address from hostname. + /// + /// + /// + public static string GetIPV4FromHostName(string host) + { + var ip = ""; + try + { + IPHostEntry hostEntry = Dns.GetHostEntry(host); + var firstIp = hostEntry.AddressList[0]; + if(!firstIp.ToString().Contains(":")) + ip = firstIp.ToString(); + } + catch + { + //Ignore + } + return ip; + } + /// /// Inititialize the Get IP and MAC from IP diff --git a/Core/WakeOverLAN.cs b/Core/WakeOverLAN.cs index cfe1d29f..cd3d498d 100644 --- a/Core/WakeOverLAN.cs +++ b/Core/WakeOverLAN.cs @@ -39,6 +39,10 @@ public void Wake() Log.ErrorWriteLine("Parameters should not be empty!"); return; } + + var host = NetWork.GetIPV4FromHostName(IP); + if(!string.IsNullOrEmpty(host)) + IP = host; int countSymbolIP = Regex.Matches(IP, "\\.").Count; if (countSymbolIP != 3) diff --git a/README.md b/README.md index 485becfb..857841c5 100644 --- a/README.md +++ b/README.md @@ -331,8 +331,8 @@ This is the full list of commands that can be used in xTerminal: Cport check command can be used with --noping parameter to disable ping check on hostname/ip. Example: cport IPAddress/HostName -p 80 --noping wol -- Sends Wake over LAN packet to a machine. - Example 1: wol -ip IP_Address -mac MAC_Address : sends wake packet for ip/mac. - Example 2: wol -ip IP_Address -mac MAC_Address -port number_port : sends wake packet for ip/mac and custom WOL port. + Example 1: wol -ip IPAddress/HostName -mac MAC_Address : sends wake packet for ip/mac. + Example 2: wol -ip IPAddress/HostName -mac MAC_Address -port number_port : sends wake packet for ip/mac and custom WOL port. dspoof -- The command detects MITM(man in the middle) attacks using ARP spoof method. Use -h for additional parameters. ---------------- C# Code Runner and Add-ons ------------- From a445edc541f138948fd96593bbfacd0fa69edaf2 Mon Sep 17 00:00:00 2001 From: xeL Date: Tue, 10 Sep 2024 17:14:18 +0300 Subject: [PATCH 03/34] trim --- Core/WakeOverLAN.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Core/WakeOverLAN.cs b/Core/WakeOverLAN.cs index cd3d498d..d3b08820 100644 --- a/Core/WakeOverLAN.cs +++ b/Core/WakeOverLAN.cs @@ -42,7 +42,7 @@ public void Wake() var host = NetWork.GetIPV4FromHostName(IP); if(!string.IsNullOrEmpty(host)) - IP = host; + IP = host.Trim(); int countSymbolIP = Regex.Matches(IP, "\\.").Count; if (countSymbolIP != 3) From 023dc3a3c0a6244fdc303d11361195b7b997a7c8 Mon Sep 17 00:00:00 2001 From: xeL Date: Tue, 10 Sep 2024 17:15:00 +0300 Subject: [PATCH 04/34] version change --- Commands/Properties/AssemblyInfo.cs | 4 ++-- Core/Properties/AssemblyInfo.cs | 4 ++-- Shell/Properties/AssemblyInfo.cs | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Commands/Properties/AssemblyInfo.cs b/Commands/Properties/AssemblyInfo.cs index 23f1f531..6a85076f 100644 --- a/Commands/Properties/AssemblyInfo.cs +++ b/Commands/Properties/AssemblyInfo.cs @@ -31,5 +31,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.8.2.0")] -[assembly: AssemblyFileVersion("1.8.2.0")] +[assembly: AssemblyVersion("1.8.3.0")] +[assembly: AssemblyFileVersion("1.8.3.0")] diff --git a/Core/Properties/AssemblyInfo.cs b/Core/Properties/AssemblyInfo.cs index 1866efa3..f7e197a7 100644 --- a/Core/Properties/AssemblyInfo.cs +++ b/Core/Properties/AssemblyInfo.cs @@ -31,5 +31,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.7.1.0")] -[assembly: AssemblyFileVersion("1.7.1.0")] +[assembly: AssemblyVersion("1.7.2.0")] +[assembly: AssemblyFileVersion("1.7.2.0")] diff --git a/Shell/Properties/AssemblyInfo.cs b/Shell/Properties/AssemblyInfo.cs index 26c5471b..6d865e5e 100644 --- a/Shell/Properties/AssemblyInfo.cs +++ b/Shell/Properties/AssemblyInfo.cs @@ -31,5 +31,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.8.9")] -[assembly: AssemblyFileVersion("1.8.9")] +[assembly: AssemblyVersion("1.8.9.1")] +[assembly: AssemblyFileVersion("1.8.9.1")] From bd68be9e5ab7d234bc3080785a5f93a27671b22e Mon Sep 17 00:00:00 2001 From: x_coding Date: Wed, 11 Sep 2024 14:41:39 +0300 Subject: [PATCH 05/34] changed version --- Shell/Properties/AssemblyInfo.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Shell/Properties/AssemblyInfo.cs b/Shell/Properties/AssemblyInfo.cs index 26c5471b..6d865e5e 100644 --- a/Shell/Properties/AssemblyInfo.cs +++ b/Shell/Properties/AssemblyInfo.cs @@ -31,5 +31,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.8.9")] -[assembly: AssemblyFileVersion("1.8.9")] +[assembly: AssemblyVersion("1.8.9.1")] +[assembly: AssemblyFileVersion("1.8.9.1")] From aba2507c643c537a28f689b1658437defb0d00ce Mon Sep 17 00:00:00 2001 From: x_coding Date: Wed, 11 Sep 2024 14:42:05 +0300 Subject: [PATCH 06/34] replaced getparamfirewallvalue to getparamvalue --- Commands/ExtensionMethods.cs | 2 +- .../TerminalCommands/ConsoleSystem/Firewall.cs | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Commands/ExtensionMethods.cs b/Commands/ExtensionMethods.cs index a7082d40..ddc903a3 100644 --- a/Commands/ExtensionMethods.cs +++ b/Commands/ExtensionMethods.cs @@ -82,6 +82,6 @@ internal static string MiddleString(this string input, string firstParam, string /// /// /// - internal static string GetParamValueFirewall(this string arg, string param) => arg.SplitByText(param, 1).Trim().Split(' ')[0]; + internal static string GetParamValue(this string arg, string param) => arg.SplitByText(param, 1).Trim().Split(' ')[0]; } } \ No newline at end of file diff --git a/Commands/TerminalCommands/ConsoleSystem/Firewall.cs b/Commands/TerminalCommands/ConsoleSystem/Firewall.cs index ddeb6016..da82027a 100644 --- a/Commands/TerminalCommands/ConsoleSystem/Firewall.cs +++ b/Commands/TerminalCommands/ConsoleSystem/Firewall.cs @@ -141,30 +141,30 @@ public void Execute(string arg) } if (arg.Contains("-pf ")) - profile = Int32.Parse(arg.GetParamValueFirewall("-pf ")); + profile = Int32.Parse(arg.GetParamValue("-pf ")); if (arg.Contains("-di ")) - direction = arg.GetParamValueFirewall("-di "); + direction = arg.GetParamValue("-di "); if (arg.Contains("-a ")) - action = arg.GetParamValueFirewall("-a "); + action = arg.GetParamValue("-a "); if (arg.Contains("-lP ")) - localPort = arg.GetParamValueFirewall("-lP "); + localPort = arg.GetParamValue("-lP "); if (arg.Contains("-rP ")) - remotePort = arg.GetParamValueFirewall("-rP "); + remotePort = arg.GetParamValue("-rP "); if (arg.Contains("-lA ")) - localAddress = arg.GetParamValueFirewall("-lA "); + localAddress = arg.GetParamValue("-lA "); if (arg.Contains("-rA ")) - remoteAddress = arg.GetParamValueFirewall("-rA "); + remoteAddress = arg.GetParamValue("-rA "); if (arg.Contains("-pr ")) - protocol = Int32.Parse(arg.GetParamValueFirewall("-pr ")); + protocol = Int32.Parse(arg.GetParamValue("-pr ")); if (arg.Contains("-e ")) - enable = arg.GetParamValueFirewall("-e "); + enable = arg.GetParamValue("-e "); if (arg.Contains("-de ")) { From 61eb2feacad7d3156678ac09f14da5748af053e8 Mon Sep 17 00:00:00 2001 From: x_coding Date: Wed, 11 Sep 2024 14:42:40 +0300 Subject: [PATCH 07/34] creted waifu command for uploade files based on https://waifuvault.moe/ API --- Commands/TerminalCommands/DirFiles/Waifu.cs | 144 ++++++++++++++++++++ 1 file changed, 144 insertions(+) create mode 100644 Commands/TerminalCommands/DirFiles/Waifu.cs diff --git a/Commands/TerminalCommands/DirFiles/Waifu.cs b/Commands/TerminalCommands/DirFiles/Waifu.cs new file mode 100644 index 00000000..186b09df --- /dev/null +++ b/Commands/TerminalCommands/DirFiles/Waifu.cs @@ -0,0 +1,144 @@ +using Core; +using Microsoft.VisualBasic.ApplicationServices; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.Versioning; +using System.Text; +using System.Threading.Tasks; +using System.Xml.Linq; +using WaifuManager = Core.DirFiles.WaifuManage; + +namespace Commands.TerminalCommands.DirFiles +{ + [SupportedOSPlatform("windows")] + public class Waifu : ITerminalCommand + { + public string Name => "waifu"; + private string _currentLocation; + private List _params = ["-cb", "-u", "-b", "-p", "-o", "-e", "-h", "-db", "-df","-gf","-lb"]; + private static string s_helpMessage = $@"Usage of waifu command: + + -cb : Create bucket. + -u : Upload file (From path or URL). + -b : specify bucket token (optional). Specify bucket token. + -p : specify file password (optional). Specify password. + -o : one time download (optional) + -e : expire download link. A string containing a number and a unit (1d = 1day). Valid units are m, h and d + -h : hide file name. + -db : Delete bucket. Example : waifu -db + -lb : List all files from bucket with detailed information: waifu -lb + -df : Delete file. Example : waifu -df + -gf : Get updated file information. waifu -gf +"; + public void Execute(string arg) + { + try + { + + + arg = arg.Substring(5); + + // Display help message. + if (arg.Trim() == "-h" && !GlobalVariables.isPipeCommand) + { + Console.WriteLine(s_helpMessage); + return; + } + + var waifu = new WaifuManager(); + + // Create bucket + if (arg.Trim().StartsWith("-cb")) + { + waifu.CreateBucket(); + return; + } + + // Delete bucket + if (arg.Trim().StartsWith("-db")) + { + var token = arg.SplitByText("-db", 1); + waifu.DeleteBucket(token.Trim()); + return; + } + + // Delete file + if (arg.Trim().StartsWith("-df")) + { + var token = arg.SplitByText("-df", 1); + waifu.DeleteFile(token.Trim()); + return; + } + + // List files from bucket. + if (arg.Trim().StartsWith("-lb")) + { + var token = arg.SplitByText("-lb", 1); + waifu.ListBucketFiles(token.Trim()); + return; + } + + + // Get uploaded file info. + if (arg.Trim().StartsWith("-gf")) + { + var token = arg.SplitByText("-gf", 1); + waifu.GetFileInfo(token.Trim()); + return; + } + + + // Upload file + if (arg.Trim().StartsWith("-u")) + { + var fileUrl = ""; + var bucket = ""; + var password = ""; + var expire = ""; + bool oneTimeDownload = false; + bool hideFileName = false; + + + var desData = arg.SplitByText("-u ", 1); + var isParamPresent = _params.Any(param => desData.Contains(param)); + if (isParamPresent) + { + var paramPresent = _params.Where(param => desData.Contains(param)).Select(x => x).FirstOrDefault(); + fileUrl = desData.SplitByText(paramPresent, 0).Trim(); + } + else + fileUrl = desData.Trim(); + + if(arg.Contains("-o")) + oneTimeDownload = true; + + if (arg.Contains("-h")) + hideFileName = true; + + if (arg.Contains("-p ")) + password = arg.GetParamValue("-p "); + + if (arg.Contains("-e ")) + expire = arg.GetParamValue("-e "); + + if (arg.Contains("-b ")) + bucket = arg.GetParamValue("-b "); + + waifu.URLorFile = fileUrl; + waifu.Upload(bucket,oneTimeDownload,expire,hideFileName,password); + } + } + catch (Exception ex) + { + if(ex.Message.Contains("Unknown token")) + { + FileSystem.ErrorWriteLine("Bucket/File token was already removed! Use -h for more information!"); + return; + } + FileSystem.ErrorWriteLine($"{ex.Message}. Use -h for more information!"); + } + + } + } +} From 86c705c77335db8701da5cf430828cf35f08f21e Mon Sep 17 00:00:00 2001 From: x_coding Date: Wed, 11 Sep 2024 14:42:56 +0300 Subject: [PATCH 08/34] windows only platform --- Core/InterceptKeys.cs | 2 ++ Core/OpenAI/OpenAIManage.cs | 2 ++ 2 files changed, 4 insertions(+) diff --git a/Core/InterceptKeys.cs b/Core/InterceptKeys.cs index 0d506898..0aeb527b 100644 --- a/Core/InterceptKeys.cs +++ b/Core/InterceptKeys.cs @@ -1,10 +1,12 @@ using System; using System.Diagnostics; using System.Runtime.InteropServices; +using System.Runtime.Versioning; using System.Windows.Forms; namespace Core { + [SupportedOSPlatform("windows")] public class InterceptKeys { // https://blogs.msdn.microsoft.com/toub/2006/05/03/low-level-keyboard-hook-in-c/ diff --git a/Core/OpenAI/OpenAIManage.cs b/Core/OpenAI/OpenAIManage.cs index 205e0c4c..11b7d0a5 100644 --- a/Core/OpenAI/OpenAIManage.cs +++ b/Core/OpenAI/OpenAIManage.cs @@ -2,9 +2,11 @@ using System.Net.Http; using System.Threading.Tasks; using System.Linq; +using System.Runtime.Versioning; namespace Core.OpenAI { + [SupportedOSPlatform("windows")] public class OpenAIManage { private string _apiKey = string.Empty; From 6409fac05c05b0d70c4d4915f31ed6fde1fcfacb Mon Sep 17 00:00:00 2001 From: x_coding Date: Wed, 11 Sep 2024 14:43:17 +0300 Subject: [PATCH 09/34] created class for waifu command for manage upload files based https://waifuvault.moe/ API --- Core/DirFiles/WaifuManage.cs | 150 +++++++++++++++++++++++++++++++++++ 1 file changed, 150 insertions(+) create mode 100644 Core/DirFiles/WaifuManage.cs diff --git a/Core/DirFiles/WaifuManage.cs b/Core/DirFiles/WaifuManage.cs new file mode 100644 index 00000000..27d5370e --- /dev/null +++ b/Core/DirFiles/WaifuManage.cs @@ -0,0 +1,150 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.Versioning; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +using System.IO; +using Waifuvault; +using System.Management.Automation.Language; +using System.Management.Automation; + +namespace Core.DirFiles +{ + /* + + Based on https://www.nuget.org/packages/Waifuvault documentaiton. + + */ + [SupportedOSPlatform("windows")] + public class WaifuManage + { + public string URLorFile { get; set; } + + private string CurrentDirectory { get; set; } + /// + /// Waifuvault manager + /// + public WaifuManage() { } + + + /// + /// Create waifu bucket. + /// + public void CreateBucket() + { + var bucket = Task.Run(()=>Api.createBucket()).Result; + FileSystem.SuccessWriteLine($"Your waifu bucket token: {bucket.token}"); + } + + /// + /// Upload from file or URL. + /// + /// + /// + /// + /// + /// + public void Upload(string bucket = "", bool onetimeDownload = false, string expires = "", bool hidefileName = false, string password = "") + { + var fileUrl = URLorFile; + if (string.IsNullOrEmpty(fileUrl)) + { + FileSystem.ErrorWriteLine("You need to specify the path to file or URL!"); + return; + } + + if (!fileUrl.StartsWith("http")) + { + CurrentDirectory = File.ReadAllText(GlobalVariables.currentDirectory); + fileUrl = FileSystem.SanitizePath(fileUrl, CurrentDirectory); + if (!File.Exists(fileUrl)) + { + FileSystem.ErrorWriteLine($"File does not exist: {fileUrl}!"); + return; + } + } + var uploadFile = new FileUpload(fileUrl, bucket, expires,password,hidefileName,onetimeDownload); + var uploadResp = Task.Run(()=>Api.uploadFile(uploadFile)).Result; + var tokenInfo = Task.Run(() => Api.fileInfo(uploadResp.token, true)).Result; + FileSystem.SuccessWriteLine($"File {fileUrl} was uploaded!"); + FileSystem.SuccessWriteLine($"URL: {uploadResp.url}"); + FileSystem.SuccessWriteLine($"Token: {uploadResp.token}"); + FileSystem.SuccessWriteLine($"Expire date: {tokenInfo.retentionPeriod}"); + } + + /// + /// Delete file by token. + /// + /// + public void DeleteFile(string token) + { + if (string.IsNullOrEmpty(token)) + { + FileSystem.ErrorWriteLine("You need to specify the uploaded file token!"); + return; + } + var deleted = Task.Run(()=>Api.deleteFile(token)).Result; + if (deleted) + FileSystem.SuccessWriteLine($"File with token {token} was deleted!"); + else + FileSystem.SuccessWriteLine($"File with {token} was NOT deleted!"); + } + + /// + /// Delete bucket token. + /// + /// + public void DeleteBucket(string bucketToken) + { + if (string.IsNullOrEmpty(bucketToken)) + { + FileSystem.ErrorWriteLine("You need to specify the bucket token!"); + return; + } + var resp = Task.Run(()=> Api.deleteBucket(bucketToken)).Result; + if(resp) + FileSystem.SuccessWriteLine($"Bucket {bucketToken} was deleted!"); + else + FileSystem.SuccessWriteLine($"Bucket {bucketToken} was NOT deleted!"); + } + + /// + /// Get uploaded file info + /// + /// + public void GetFileInfo(string fileToken) + { + if (string.IsNullOrEmpty(fileToken)) + { + FileSystem.ErrorWriteLine("You need to specify the uploaded file token!"); + return; + } + var tokenInfo = Task.Run(()=>Api.fileInfo(fileToken, true)).Result; + FileSystem.SuccessWriteLine($"URL: {tokenInfo.url}"); + FileSystem.SuccessWriteLine($"Expire date: {tokenInfo.retentionPeriod}"); + FileSystem.SuccessWriteLine($"Bucket: {tokenInfo.bucket}"); + FileSystem.SuccessWriteLine($"Hidden Name: {tokenInfo.options.hideFilename}"); + FileSystem.SuccessWriteLine($"Password protected: {tokenInfo.options.fileprotected}"); + } + + /// + /// List file from bucket + /// + /// + public void ListBucketFiles(string bucketToken) + { + var bucket =Task.Run(()=>Api.getBucket(bucketToken)).Result; + foreach (var file in bucket.files) + { + FileSystem.SuccessWriteLine($"-----------------------------------------------"); + FileSystem.SuccessWriteLine($"URL: {file.url}"); + FileSystem.SuccessWriteLine($"File Token: {file.token}"); + FileSystem.SuccessWriteLine($"Expire date: {file.retentionPeriod}"); + FileSystem.SuccessWriteLine($"Hidden Name: {file.options.hideFilename}"); + FileSystem.SuccessWriteLine($"Password protected: {file.options.fileprotected}"); + } + } + } +} From c1d3733d8174f484ed4ef60497fb72a54206925b Mon Sep 17 00:00:00 2001 From: x_coding Date: Wed, 11 Sep 2024 14:43:34 +0300 Subject: [PATCH 10/34] added Waifuvault nuget package --- Core/Core.csproj | 1 + 1 file changed, 1 insertion(+) diff --git a/Core/Core.csproj b/Core/Core.csproj index f19a8a7a..45f3041b 100644 --- a/Core/Core.csproj +++ b/Core/Core.csproj @@ -58,6 +58,7 @@ + From 1003b43e61c075059722aa90e63499f8aa409279 Mon Sep 17 00:00:00 2001 From: x_coding Date: Wed, 11 Sep 2024 14:52:45 +0300 Subject: [PATCH 11/34] reworkd help message --- Commands/TerminalCommands/DirFiles/Waifu.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Commands/TerminalCommands/DirFiles/Waifu.cs b/Commands/TerminalCommands/DirFiles/Waifu.cs index 186b09df..e8225a62 100644 --- a/Commands/TerminalCommands/DirFiles/Waifu.cs +++ b/Commands/TerminalCommands/DirFiles/Waifu.cs @@ -21,11 +21,11 @@ public class Waifu : ITerminalCommand -cb : Create bucket. -u : Upload file (From path or URL). - -b : specify bucket token (optional). Specify bucket token. - -p : specify file password (optional). Specify password. - -o : one time download (optional) - -e : expire download link. A string containing a number and a unit (1d = 1day). Valid units are m, h and d - -h : hide file name. + -b : Specify bucket token. (optional) + -p : Specify file password. (optional) + -o : Pne time download. (optional) + -e : Expire download link. A string containing a number and a unit (1d = 1day). Valid units are m, h and d. (optional) + -h : Hide file name.(optional) -db : Delete bucket. Example : waifu -db -lb : List all files from bucket with detailed information: waifu -lb -df : Delete file. Example : waifu -df From 45e415945067e340799cdb72325631d2b73b4788 Mon Sep 17 00:00:00 2001 From: x_coding Date: Wed, 11 Sep 2024 14:54:00 +0300 Subject: [PATCH 12/34] cleanup --- Commands/TerminalCommands/DirFiles/Waifu.cs | 6 ------ Core/DirFiles/WaifuManage.cs | 9 +-------- 2 files changed, 1 insertion(+), 14 deletions(-) diff --git a/Commands/TerminalCommands/DirFiles/Waifu.cs b/Commands/TerminalCommands/DirFiles/Waifu.cs index e8225a62..cb36407a 100644 --- a/Commands/TerminalCommands/DirFiles/Waifu.cs +++ b/Commands/TerminalCommands/DirFiles/Waifu.cs @@ -1,12 +1,8 @@ using Core; -using Microsoft.VisualBasic.ApplicationServices; using System; using System.Collections.Generic; using System.Linq; using System.Runtime.Versioning; -using System.Text; -using System.Threading.Tasks; -using System.Xml.Linq; using WaifuManager = Core.DirFiles.WaifuManage; namespace Commands.TerminalCommands.DirFiles @@ -35,8 +31,6 @@ public void Execute(string arg) { try { - - arg = arg.Substring(5); // Display help message. diff --git a/Core/DirFiles/WaifuManage.cs b/Core/DirFiles/WaifuManage.cs index 27d5370e..f807e294 100644 --- a/Core/DirFiles/WaifuManage.cs +++ b/Core/DirFiles/WaifuManage.cs @@ -1,14 +1,7 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Runtime.Versioning; -using System.Text; -using System.Threading; +using System.Runtime.Versioning; using System.Threading.Tasks; using System.IO; using Waifuvault; -using System.Management.Automation.Language; -using System.Management.Automation; namespace Core.DirFiles { From 642e61c8028f551f913f299ffe4bd18ae824642b Mon Sep 17 00:00:00 2001 From: x_coding Date: Wed, 11 Sep 2024 15:09:22 +0300 Subject: [PATCH 13/34] help message changed with critical information --- Commands/TerminalCommands/DirFiles/Waifu.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Commands/TerminalCommands/DirFiles/Waifu.cs b/Commands/TerminalCommands/DirFiles/Waifu.cs index cb36407a..48e7f18e 100644 --- a/Commands/TerminalCommands/DirFiles/Waifu.cs +++ b/Commands/TerminalCommands/DirFiles/Waifu.cs @@ -26,6 +26,10 @@ public class Waifu : ITerminalCommand -lb : List all files from bucket with detailed information: waifu -lb -df : Delete file. Example : waifu -df -gf : Get updated file information. waifu -gf + +ATTENTION what you upload. xTerminal developers takes no responsibility for what you upload. + +All restriction and private policy information can be found here https://waifuvault.moe/ "; public void Execute(string arg) { From 2dd0d6eccd0367f883daf114f1e6e78944696bd3 Mon Sep 17 00:00:00 2001 From: x_coding Date: Wed, 11 Sep 2024 15:10:32 +0300 Subject: [PATCH 14/34] version change --- Shell/Properties/AssemblyInfo.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Shell/Properties/AssemblyInfo.cs b/Shell/Properties/AssemblyInfo.cs index 6d865e5e..15eff0e4 100644 --- a/Shell/Properties/AssemblyInfo.cs +++ b/Shell/Properties/AssemblyInfo.cs @@ -31,5 +31,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.8.9.1")] -[assembly: AssemblyFileVersion("1.8.9.1")] +[assembly: AssemblyVersion("1.9.0")] +[assembly: AssemblyFileVersion("1.9.0")] From 63748655ecf1b9d5d5d2732d525bfed57960edc8 Mon Sep 17 00:00:00 2001 From: x_coding Date: Wed, 11 Sep 2024 15:11:57 +0300 Subject: [PATCH 15/34] set to display help commands info if no parameters --- Commands/TerminalCommands/DirFiles/Waifu.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Commands/TerminalCommands/DirFiles/Waifu.cs b/Commands/TerminalCommands/DirFiles/Waifu.cs index 48e7f18e..d0413df8 100644 --- a/Commands/TerminalCommands/DirFiles/Waifu.cs +++ b/Commands/TerminalCommands/DirFiles/Waifu.cs @@ -35,6 +35,12 @@ public void Execute(string arg) { try { + if (arg == Name && !GlobalVariables.isPipeCommand) + { + FileSystem.SuccessWriteLine("Use -h for more information!"); + return; + } + arg = arg.Substring(5); // Display help message. From 4e420de979d2a251ca0785e4ba178a9a8a2325f7 Mon Sep 17 00:00:00 2001 From: x_coding Date: Wed, 11 Sep 2024 15:12:43 +0300 Subject: [PATCH 16/34] typo --- Commands/TerminalCommands/DirFiles/Waifu.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Commands/TerminalCommands/DirFiles/Waifu.cs b/Commands/TerminalCommands/DirFiles/Waifu.cs index d0413df8..f31eb454 100644 --- a/Commands/TerminalCommands/DirFiles/Waifu.cs +++ b/Commands/TerminalCommands/DirFiles/Waifu.cs @@ -29,7 +29,7 @@ public class Waifu : ITerminalCommand ATTENTION what you upload. xTerminal developers takes no responsibility for what you upload. -All restriction and private policy information can be found here https://waifuvault.moe/ +All restriction and privacy policy information can be found here https://waifuvault.moe/ "; public void Execute(string arg) { From 5a1762f385e14e984b03a744d77f97a9eea1f1e7 Mon Sep 17 00:00:00 2001 From: x_coding Date: Wed, 11 Sep 2024 15:20:00 +0300 Subject: [PATCH 17/34] typo --- Commands/TerminalCommands/DirFiles/Waifu.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Commands/TerminalCommands/DirFiles/Waifu.cs b/Commands/TerminalCommands/DirFiles/Waifu.cs index f31eb454..e3a9a2f5 100644 --- a/Commands/TerminalCommands/DirFiles/Waifu.cs +++ b/Commands/TerminalCommands/DirFiles/Waifu.cs @@ -25,7 +25,7 @@ public class Waifu : ITerminalCommand -db : Delete bucket. Example : waifu -db -lb : List all files from bucket with detailed information: waifu -lb -df : Delete file. Example : waifu -df - -gf : Get updated file information. waifu -gf + -gf : Get uploaded file information. waifu -gf ATTENTION what you upload. xTerminal developers takes no responsibility for what you upload. From 5fcf856e62ecd0fc9100cbb3b4f09c710d4ebb82 Mon Sep 17 00:00:00 2001 From: x_coding Date: Wed, 11 Sep 2024 15:23:31 +0300 Subject: [PATCH 18/34] added more information to help --- Commands/TerminalCommands/DirFiles/Waifu.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Commands/TerminalCommands/DirFiles/Waifu.cs b/Commands/TerminalCommands/DirFiles/Waifu.cs index e3a9a2f5..0e1b9a1b 100644 --- a/Commands/TerminalCommands/DirFiles/Waifu.cs +++ b/Commands/TerminalCommands/DirFiles/Waifu.cs @@ -13,7 +13,11 @@ public class Waifu : ITerminalCommand public string Name => "waifu"; private string _currentLocation; private List _params = ["-cb", "-u", "-b", "-p", "-o", "-e", "-h", "-db", "-df","-gf","-lb"]; - private static string s_helpMessage = $@"Usage of waifu command: + private static string s_helpMessage = $@" +Host files with https://waifuvault.moe/. +WaifuVault is a temporary file hosting service that allows for file uploads that are hosted for a set amount of time. + +Usage of waifu command: -cb : Create bucket. -u : Upload file (From path or URL). From d6d1dba042937b51236a3317a40a516db1bd6ee8 Mon Sep 17 00:00:00 2001 From: x_coding Date: Wed, 11 Sep 2024 23:52:10 +0300 Subject: [PATCH 19/34] display bucket if uploaded ont it --- Core/DirFiles/WaifuManage.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Core/DirFiles/WaifuManage.cs b/Core/DirFiles/WaifuManage.cs index f807e294..d2d7387d 100644 --- a/Core/DirFiles/WaifuManage.cs +++ b/Core/DirFiles/WaifuManage.cs @@ -16,6 +16,7 @@ public class WaifuManage public string URLorFile { get; set; } private string CurrentDirectory { get; set; } + /// /// Waifuvault manager /// @@ -62,6 +63,8 @@ public void Upload(string bucket = "", bool onetimeDownload = false, string expi var uploadResp = Task.Run(()=>Api.uploadFile(uploadFile)).Result; var tokenInfo = Task.Run(() => Api.fileInfo(uploadResp.token, true)).Result; FileSystem.SuccessWriteLine($"File {fileUrl} was uploaded!"); + if(!string.IsNullOrEmpty(bucket)) + FileSystem.SuccessWriteLine($"Bucket {bucket}"); FileSystem.SuccessWriteLine($"URL: {uploadResp.url}"); FileSystem.SuccessWriteLine($"Token: {uploadResp.token}"); FileSystem.SuccessWriteLine($"Expire date: {tokenInfo.retentionPeriod}"); From 1fcde85fc60dc7213ba0606e944a8787cc18d67c Mon Sep 17 00:00:00 2001 From: x_coding Date: Thu, 12 Sep 2024 01:02:11 +0300 Subject: [PATCH 20/34] removed language version --- Core/Core.csproj | 1 - 1 file changed, 1 deletion(-) diff --git a/Core/Core.csproj b/Core/Core.csproj index 45f3041b..3bf2ade0 100644 --- a/Core/Core.csproj +++ b/Core/Core.csproj @@ -2,7 +2,6 @@ net8.0-windows7.0 Library - 8.0 false true true From 808a3c168b203b69f2c0c5bae2d41fad4d6714d2 Mon Sep 17 00:00:00 2001 From: x_coding Date: Thu, 12 Sep 2024 01:08:01 +0300 Subject: [PATCH 21/34] check expire format to match the creteria specified on waifuvault documentation --- Core/DirFiles/WaifuManage.cs | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/Core/DirFiles/WaifuManage.cs b/Core/DirFiles/WaifuManage.cs index d2d7387d..d19b101b 100644 --- a/Core/DirFiles/WaifuManage.cs +++ b/Core/DirFiles/WaifuManage.cs @@ -1,7 +1,9 @@ using System.Runtime.Versioning; using System.Threading.Tasks; using System.IO; +using System.Linq; using Waifuvault; +using System.Collections.Generic; namespace Core.DirFiles { @@ -16,6 +18,7 @@ public class WaifuManage public string URLorFile { get; set; } private string CurrentDirectory { get; set; } + private List ExpireFormatList = ["d","m","h"]; /// /// Waifuvault manager @@ -45,7 +48,13 @@ public void Upload(string bucket = "", bool onetimeDownload = false, string expi var fileUrl = URLorFile; if (string.IsNullOrEmpty(fileUrl)) { - FileSystem.ErrorWriteLine("You need to specify the path to file or URL!"); + FileSystem.ErrorWriteLine("You need to specify the path to file or URL. Use -h for more information!"); + return; + } + + var isParamPresent = ExpireFormatList.Any(param => expires.EndsWith(param)); + if (!isParamPresent) { + FileSystem.ErrorWriteLine("You need to use the expire data format. Use -h for more information!"); return; } @@ -55,7 +64,7 @@ public void Upload(string bucket = "", bool onetimeDownload = false, string expi fileUrl = FileSystem.SanitizePath(fileUrl, CurrentDirectory); if (!File.Exists(fileUrl)) { - FileSystem.ErrorWriteLine($"File does not exist: {fileUrl}!"); + FileSystem.ErrorWriteLine($"File does not exist: {fileUrl}. Use -h for more information!"); return; } } @@ -78,7 +87,7 @@ public void DeleteFile(string token) { if (string.IsNullOrEmpty(token)) { - FileSystem.ErrorWriteLine("You need to specify the uploaded file token!"); + FileSystem.ErrorWriteLine("You need to specify the uploaded file token. Use -h for more information!"); return; } var deleted = Task.Run(()=>Api.deleteFile(token)).Result; @@ -96,7 +105,7 @@ public void DeleteBucket(string bucketToken) { if (string.IsNullOrEmpty(bucketToken)) { - FileSystem.ErrorWriteLine("You need to specify the bucket token!"); + FileSystem.ErrorWriteLine("You need to specify the bucket token. Use -h for more information!"); return; } var resp = Task.Run(()=> Api.deleteBucket(bucketToken)).Result; @@ -114,7 +123,7 @@ public void GetFileInfo(string fileToken) { if (string.IsNullOrEmpty(fileToken)) { - FileSystem.ErrorWriteLine("You need to specify the uploaded file token!"); + FileSystem.ErrorWriteLine("You need to specify the uploaded file token. Use -h for more information!"); return; } var tokenInfo = Task.Run(()=>Api.fileInfo(fileToken, true)).Result; From ea88f3054637b36c3f3f9153c2967995dbce2e00 Mon Sep 17 00:00:00 2001 From: x_coding Date: Thu, 12 Sep 2024 07:44:01 +0300 Subject: [PATCH 22/34] NuGet packages update --- Commands/Commands.csproj | 2 +- Core/Core.csproj | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Commands/Commands.csproj b/Commands/Commands.csproj index c4a41360..7e3274b5 100644 --- a/Commands/Commands.csproj +++ b/Commands/Commands.csproj @@ -51,7 +51,7 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - + diff --git a/Core/Core.csproj b/Core/Core.csproj index 3bf2ade0..00d399cc 100644 --- a/Core/Core.csproj +++ b/Core/Core.csproj @@ -1,4 +1,4 @@ - + net8.0-windows7.0 Library @@ -47,17 +47,17 @@ - + - - + + - + From 975ac4180e916eea1c3d7aeb988398e0d183836d Mon Sep 17 00:00:00 2001 From: x_coding Date: Thu, 12 Sep 2024 08:42:27 +0300 Subject: [PATCH 23/34] created ms timestamp convertor --- Core/FileSystem.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Core/FileSystem.cs b/Core/FileSystem.cs index dc8d4639..36594a6d 100644 --- a/Core/FileSystem.cs +++ b/Core/FileSystem.cs @@ -529,5 +529,18 @@ public static string GetFileDirOwner(string path) } return outp; } + + /// + /// Convert time stamp to local time. + /// + /// + /// + public static string EpohConverter(long unixTimeStamp) + { + DateTime dateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc); + var epoh = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds() + unixTimeStamp; + dateTime = dateTime.AddMilliseconds(epoh).ToLocalTime(); + return dateTime.ToString("HH:mm:ss dd/MM/yyyy"); + } } } From e5e0b14869ac63aef1d5874be95e0a312dfdf7d3 Mon Sep 17 00:00:00 2001 From: x_coding Date: Thu, 12 Sep 2024 08:42:41 +0300 Subject: [PATCH 24/34] converted timestamp to human readable format --- Core/DirFiles/WaifuManage.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Core/DirFiles/WaifuManage.cs b/Core/DirFiles/WaifuManage.cs index d19b101b..5e7eb338 100644 --- a/Core/DirFiles/WaifuManage.cs +++ b/Core/DirFiles/WaifuManage.cs @@ -146,7 +146,7 @@ public void ListBucketFiles(string bucketToken) FileSystem.SuccessWriteLine($"-----------------------------------------------"); FileSystem.SuccessWriteLine($"URL: {file.url}"); FileSystem.SuccessWriteLine($"File Token: {file.token}"); - FileSystem.SuccessWriteLine($"Expire date: {file.retentionPeriod}"); + FileSystem.SuccessWriteLine($"Expire date: {FileSystem.EpohConverter(long.Parse(file.retentionPeriod))}"); FileSystem.SuccessWriteLine($"Hidden Name: {file.options.hideFilename}"); FileSystem.SuccessWriteLine($"Password protected: {file.options.fileprotected}"); } From 618fd5a38f7bcee4d8653525d1823b43b508e27b Mon Sep 17 00:00:00 2001 From: x_coding Date: Thu, 12 Sep 2024 08:51:44 +0300 Subject: [PATCH 25/34] added list waifuvault restritions --- Core/DirFiles/WaifuManage.cs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Core/DirFiles/WaifuManage.cs b/Core/DirFiles/WaifuManage.cs index 5e7eb338..8b08eb86 100644 --- a/Core/DirFiles/WaifuManage.cs +++ b/Core/DirFiles/WaifuManage.cs @@ -4,6 +4,7 @@ using System.Linq; using Waifuvault; using System.Collections.Generic; +using System; namespace Core.DirFiles { @@ -151,5 +152,22 @@ public void ListBucketFiles(string bucketToken) FileSystem.SuccessWriteLine($"Password protected: {file.options.fileprotected}"); } } + + /// + /// List vault restrictions. + /// + public void ListRestrictions() + { + Api.clearRestrictions(); + var restrictions =Task.Run(()=> Api.getRestrictions()).Result; + foreach (var restriction in restrictions.Restrictions) + { + var restrictionType = restriction.type; + if (restrictionType.Contains("MAX_")) + FileSystem.SuccessWriteLine($"{restriction.type} : {FileSystem.GetSize(restriction.value,false)}"); + else + FileSystem.SuccessWriteLine($"{restriction.type} : {restriction.value}"); + } + } } } From 44d814ffb12d3cd619f23a401bd1d8b9aa485ee7 Mon Sep 17 00:00:00 2001 From: x_coding Date: Thu, 12 Sep 2024 08:52:44 +0300 Subject: [PATCH 26/34] added param -lr to list wifuvault restrictions types. --- Commands/TerminalCommands/DirFiles/Waifu.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Commands/TerminalCommands/DirFiles/Waifu.cs b/Commands/TerminalCommands/DirFiles/Waifu.cs index 0e1b9a1b..2400dce5 100644 --- a/Commands/TerminalCommands/DirFiles/Waifu.cs +++ b/Commands/TerminalCommands/DirFiles/Waifu.cs @@ -30,6 +30,7 @@ public class Waifu : ITerminalCommand -lb : List all files from bucket with detailed information: waifu -lb -df : Delete file. Example : waifu -df -gf : Get uploaded file information. waifu -gf + -lr : List wifuvault restrictions types. ATTENTION what you upload. xTerminal developers takes no responsibility for what you upload. @@ -96,6 +97,13 @@ public void Execute(string arg) return; } + // List waifuvault restrictions. + if (arg.Trim().StartsWith("-lr")) + { + waifu.ListRestrictions(); + return; + } + // Upload file if (arg.Trim().StartsWith("-u")) From 9e5f48c5e5e9219d346380ad4402e221dce50f46 Mon Sep 17 00:00:00 2001 From: xeL Date: Thu, 12 Sep 2024 17:20:06 +0300 Subject: [PATCH 27/34] version change --- Shell/Properties/AssemblyInfo.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Shell/Properties/AssemblyInfo.cs b/Shell/Properties/AssemblyInfo.cs index 26c5471b..15eff0e4 100644 --- a/Shell/Properties/AssemblyInfo.cs +++ b/Shell/Properties/AssemblyInfo.cs @@ -31,5 +31,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.8.9")] -[assembly: AssemblyFileVersion("1.8.9")] +[assembly: AssemblyVersion("1.9.0")] +[assembly: AssemblyFileVersion("1.9.0")] From e745f3efe6a28c5ad3e240015e41d4001389f2de Mon Sep 17 00:00:00 2001 From: xeL Date: Thu, 12 Sep 2024 17:55:37 +0300 Subject: [PATCH 28/34] added help info for waifu --- Commands/TerminalCommands/ConsoleSystem/Help.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Commands/TerminalCommands/ConsoleSystem/Help.cs b/Commands/TerminalCommands/ConsoleSystem/Help.cs index 01fd5c38..ed6fad89 100644 --- a/Commands/TerminalCommands/ConsoleSystem/Help.cs +++ b/Commands/TerminalCommands/ConsoleSystem/Help.cs @@ -74,6 +74,7 @@ public void Execute(string arg) pjson -- Prettify the JSON data. Use -h for additional help. attr -- Displays/Sets/Removes the current attributes of a file or directory. Use -h for additional help. cmp -- Check if two files are identical by comparing MD5 hash. Use -h for additional help. + waifu -- Host temporary files on https://waifuvault.moe/. Use -h for additional help. ---------------------- Networking ---------------------- ifconfig -- Display onboard Network Interface Cards configuration (Ethernet and Wireless) From 6b28bb14c083ce878bb9d8afbc2abec701762ca1 Mon Sep 17 00:00:00 2001 From: xeL Date: Thu, 12 Sep 2024 17:55:49 +0300 Subject: [PATCH 29/34] added example in -h param --- Commands/TerminalCommands/DirFiles/Waifu.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Commands/TerminalCommands/DirFiles/Waifu.cs b/Commands/TerminalCommands/DirFiles/Waifu.cs index 2400dce5..da9f90db 100644 --- a/Commands/TerminalCommands/DirFiles/Waifu.cs +++ b/Commands/TerminalCommands/DirFiles/Waifu.cs @@ -23,7 +23,7 @@ public class Waifu : ITerminalCommand -u : Upload file (From path or URL). -b : Specify bucket token. (optional) -p : Specify file password. (optional) - -o : Pne time download. (optional) + -o : One time download. (optional) -e : Expire download link. A string containing a number and a unit (1d = 1day). Valid units are m, h and d. (optional) -h : Hide file name.(optional) -db : Delete bucket. Example : waifu -db @@ -32,6 +32,8 @@ public class Waifu : ITerminalCommand -gf : Get uploaded file information. waifu -gf -lr : List wifuvault restrictions types. +Example: waifu -u -p -b -o -e 1h -h + ATTENTION what you upload. xTerminal developers takes no responsibility for what you upload. All restriction and privacy policy information can be found here https://waifuvault.moe/ From 42d422d9d682712fca5ce02a1c296be7fbd071ad Mon Sep 17 00:00:00 2001 From: xeL Date: Thu, 12 Sep 2024 17:55:56 +0300 Subject: [PATCH 30/34] updated documentation for waifu command --- README.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/README.md b/README.md index 857841c5..109d3f34 100644 --- a/README.md +++ b/README.md @@ -304,6 +304,21 @@ This is the full list of commands that can be used in xTerminal: Example 2: attr -r : Remove the attribute/attributes to a file or directory. Attributes needs to be splited by ';' if more then 1 are added. cmp -- Check if two files are identical by comparing MD5 hash. Example: cmp ; + waifu -- Host temporary files on https://waifuvault.moe/. + -cb : Create bucket. + -u : Upload file (From path or URL). + -b : Specify bucket token. (optional) + -p : Specify file password. (optional) + -o : One time download. (optional) + -e : Expire download link. A string containing a number and a unit (1d = 1day). Valid units are m, h and d. (optional) + -h : Hide file name.(optional) + -db : Delete bucket. Example : waifu -db + -lb : List all files from bucket with detailed information: waifu -lb + -df : Delete file. Example : waifu -df + -gf : Get uploaded file information. waifu -gf + -lr : List wifuvault restrictions types. + + Example: waifu -u -p -b -o -e 1h -h ---------------------- Networking ---------------------- ifconfig -- Display onboard Network Interface Cards configuration (Ethernet and Wireless) From 751df03c836b0ee6cdbe6192f420a1d19a9c7124 Mon Sep 17 00:00:00 2001 From: xeL Date: Thu, 12 Sep 2024 23:29:53 +0300 Subject: [PATCH 31/34] added check for site and fix param split --- Commands/TerminalCommands/DirFiles/Waifu.cs | 29 +++++++++++---------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/Commands/TerminalCommands/DirFiles/Waifu.cs b/Commands/TerminalCommands/DirFiles/Waifu.cs index da9f90db..f115183c 100644 --- a/Commands/TerminalCommands/DirFiles/Waifu.cs +++ b/Commands/TerminalCommands/DirFiles/Waifu.cs @@ -12,7 +12,7 @@ public class Waifu : ITerminalCommand { public string Name => "waifu"; private string _currentLocation; - private List _params = ["-cb", "-u", "-b", "-p", "-o", "-e", "-h", "-db", "-df","-gf","-lb"]; + private List _params = ["-cb", "-u", "-b", "-p", "-o", "-e", "-h", "-db", "-df", "-gf", "-lb"]; private static string s_helpMessage = $@" Host files with https://waifuvault.moe/. WaifuVault is a temporary file hosting service that allows for file uploads that are hosted for a set amount of time. @@ -42,6 +42,13 @@ public void Execute(string arg) { try { + // Check if site is up. + if (!NetWork.PingHost("waifuvault.moe")) + { + FileSystem.SuccessWriteLine("https://waifuvault.moe/ seems down or no internet connection!"); + return; + } + if (arg == Name && !GlobalVariables.isPipeCommand) { FileSystem.SuccessWriteLine("Use -h for more information!"); @@ -119,37 +126,31 @@ public void Execute(string arg) var desData = arg.SplitByText("-u ", 1); - var isParamPresent = _params.Any(param => desData.Contains(param)); - if (isParamPresent) - { - var paramPresent = _params.Where(param => desData.Contains(param)).Select(x => x).FirstOrDefault(); - fileUrl = desData.SplitByText(paramPresent, 0).Trim(); - } - else - fileUrl = desData.Trim(); + fileUrl = arg.GetParamValue("-u "); - if(arg.Contains("-o")) + if (arg.Contains("-o")) oneTimeDownload = true; if (arg.Contains("-h")) hideFileName = true; if (arg.Contains("-p ")) + { password = arg.GetParamValue("-p "); - + } if (arg.Contains("-e ")) expire = arg.GetParamValue("-e "); if (arg.Contains("-b ")) bucket = arg.GetParamValue("-b "); - waifu.URLorFile = fileUrl; - waifu.Upload(bucket,oneTimeDownload,expire,hideFileName,password); + waifu.URLorFile = fileUrl; + waifu.Upload(bucket, oneTimeDownload, expire, hideFileName, password); } } catch (Exception ex) { - if(ex.Message.Contains("Unknown token")) + if (ex.Message.Contains("Unknown token")) { FileSystem.ErrorWriteLine("Bucket/File token was already removed! Use -h for more information!"); return; From da7ca3dd7c89571758e1609ed4b267e9ebce998c Mon Sep 17 00:00:00 2001 From: xeL Date: Thu, 12 Sep 2024 23:32:25 +0300 Subject: [PATCH 32/34] removed unsued ref --- Commands/TerminalCommands/DirFiles/Waifu.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/Commands/TerminalCommands/DirFiles/Waifu.cs b/Commands/TerminalCommands/DirFiles/Waifu.cs index f115183c..06c0722a 100644 --- a/Commands/TerminalCommands/DirFiles/Waifu.cs +++ b/Commands/TerminalCommands/DirFiles/Waifu.cs @@ -1,7 +1,6 @@ using Core; using System; using System.Collections.Generic; -using System.Linq; using System.Runtime.Versioning; using WaifuManager = Core.DirFiles.WaifuManage; From 16bda1e54ecbe2a94c66ef24c30840636440a045 Mon Sep 17 00:00:00 2001 From: xeL Date: Thu, 12 Sep 2024 23:32:29 +0300 Subject: [PATCH 33/34] arangement --- README.md | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 109d3f34..d0605d5d 100644 --- a/README.md +++ b/README.md @@ -305,19 +305,18 @@ This is the full list of commands that can be used in xTerminal: cmp -- Check if two files are identical by comparing MD5 hash. Example: cmp ; waifu -- Host temporary files on https://waifuvault.moe/. - -cb : Create bucket. - -u : Upload file (From path or URL). - -b : Specify bucket token. (optional) - -p : Specify file password. (optional) - -o : One time download. (optional) - -e : Expire download link. A string containing a number and a unit (1d = 1day). Valid units are m, h and d. (optional) - -h : Hide file name.(optional) - -db : Delete bucket. Example : waifu -db - -lb : List all files from bucket with detailed information: waifu -lb - -df : Delete file. Example : waifu -df - -gf : Get uploaded file information. waifu -gf - -lr : List wifuvault restrictions types. - + -cb : Create bucket. + -u : Upload file (From path or URL). + -b : Specify bucket token. (optional) + -p : Specify file password. (optional) + -o : One time download. (optional) + -e : Expire download link. A string containing a number and a unit (1d = 1day). Valid units are m, h and d. (optional) + -h : Hide file name.(optional) + -db : Delete bucket. Example : waifu -db + -lb : List all files from bucket with detailed information: waifu -lb + -df : Delete file. Example : waifu -df + -gf : Get uploaded file information. waifu -gf + -lr : List wifuvault restrictions types. Example: waifu -u -p -b -o -e 1h -h ---------------------- Networking ---------------------- From be658275304782eaee3b7766343fcc0a2dff133f Mon Sep 17 00:00:00 2001 From: xeL Date: Thu, 12 Sep 2024 23:33:03 +0300 Subject: [PATCH 34/34] removed unused ref --- Core/DirFiles/WaifuManage.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/Core/DirFiles/WaifuManage.cs b/Core/DirFiles/WaifuManage.cs index 8b08eb86..5fdccf52 100644 --- a/Core/DirFiles/WaifuManage.cs +++ b/Core/DirFiles/WaifuManage.cs @@ -4,7 +4,6 @@ using System.Linq; using Waifuvault; using System.Collections.Generic; -using System; namespace Core.DirFiles {