Skip to content

Commit

Permalink
Merge pull request #57 from 0x78654C/v1.8.9.1-fixes
Browse files Browse the repository at this point in the history
V1.8.9.1 fixes
  • Loading branch information
0x78654C authored Sep 12, 2024
2 parents 398b58c + be65827 commit 59d8641
Show file tree
Hide file tree
Showing 17 changed files with 419 additions and 27 deletions.
2 changes: 1 addition & 1 deletion Commands/Commands.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.9.2" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.11.0" />
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
<PackageReference Include="Microsoft.VisualBasic" Version="10.3.0" />
<PackageReference Include="System.Buffers" Version="4.5.1" />
Expand Down
2 changes: 1 addition & 1 deletion Commands/ExtensionMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,6 @@ internal static string MiddleString(this string input, string firstParam, string
/// <param name="arg"></param>
/// <param name="param"></param>
/// <returns></returns>
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];
}
}
4 changes: 2 additions & 2 deletions Commands/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
20 changes: 10 additions & 10 deletions Commands/TerminalCommands/ConsoleSystem/Firewall.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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 "))
{
Expand Down Expand Up @@ -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!");
}
}
}
Expand Down
1 change: 1 addition & 0 deletions Commands/TerminalCommands/ConsoleSystem/Help.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
162 changes: 162 additions & 0 deletions Commands/TerminalCommands/DirFiles/Waifu.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
using Core;
using System;
using System.Collections.Generic;
using System.Runtime.Versioning;
using WaifuManager = Core.DirFiles.WaifuManage;

namespace Commands.TerminalCommands.DirFiles
{
[SupportedOSPlatform("windows")]
public class Waifu : ITerminalCommand
{
public string Name => "waifu";
private string _currentLocation;
private List<string> _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.
Usage of waifu command:
-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 <bucket_token>
-lb : List all files from bucket with detailed information: waifu -lb <bucket_token>
-df : Delete file. Example : waifu -df <file_token>
-gf : Get uploaded file information. waifu -gf <file_token>
-lr : List wifuvault restrictions types.
Example: waifu -u <file_path> -p <password> -b <bucket_token> -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/
";
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!");
return;
}

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;
}

// List waifuvault restrictions.
if (arg.Trim().StartsWith("-lr"))
{
waifu.ListRestrictions();
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);
fileUrl = arg.GetParamValue("-u ");

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!");
}

}
}
}
4 changes: 2 additions & 2 deletions Commands/TerminalCommands/Network/WakeOverLan.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 5 additions & 5 deletions Core/Core.csproj
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0-windows7.0</TargetFramework>
<OutputType>Library</OutputType>
<LangVersion>8.0</LangVersion>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<UseWindowsForms>true</UseWindowsForms>
<ImportWindowsDesktopTargets>true</ImportWindowsDesktopTargets>
Expand Down Expand Up @@ -48,16 +47,17 @@
</COMReference>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.Common" Version="4.9.2" />
<PackageReference Include="Microsoft.CodeAnalysis.Common" Version="4.11.0" />
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
<PackageReference Include="System.Data.DataSetExtensions" Version="4.5.0" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Konscious.Security.Cryptography.Argon2" Version="1.3.0" />
<PackageReference Include="Konscious.Security.Cryptography.Blake2" Version="1.1.0" />
<PackageReference Include="Konscious.Security.Cryptography.Argon2" Version="1.3.1" />
<PackageReference Include="Konscious.Security.Cryptography.Blake2" Version="1.1.1" />
<PackageReference Include="System.Management" Version="8.0.0" />
<PackageReference Include="System.Numerics.Vectors" Version="4.5.0" />
<PackageReference Include="System.ServiceProcess.ServiceController" Version="8.0.0" />
<PackageReference Include="Waifuvault" Version="1.3.7" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\OpenAI.Api.Client\OpenAI.Api.Client.csproj" />
Expand Down
Loading

0 comments on commit 59d8641

Please sign in to comment.