diff --git a/.gitignore b/.gitignore index 16faa08..c685a6c 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ -/obj \ No newline at end of file +/obj +/bin +/.mono \ No newline at end of file diff --git a/Helpers/ConfigHelper.cs b/Helpers/ConfigHelper.cs index 4268888..c176962 100644 --- a/Helpers/ConfigHelper.cs +++ b/Helpers/ConfigHelper.cs @@ -1,4 +1,5 @@ - +using System; +using System.IO; using Salaros.Configuration; using Stresser.Helpers.HLogger; @@ -6,32 +7,25 @@ namespace Stresser.Helpers.ConfigHelper { public class ConfigHelper { - - public static string? mysql_host; - public static string? mysql_port; - public static string? mysql_username; - public static string? mysql_password; - public static string? mysql_name; public static string GetSetting(string app, string setting) { + string path = Path.Combine(Program.appWorkDir, "config.ini"); + try { - string path = Path.Combine(Program.appWorkDir, "config.ini"); - if (File.Exists(path)) + if (!File.Exists(path)) { - var cfg = new ConfigParser(path); - var st = cfg.GetValue(app, setting); - return st; - } - else - { - Program.hLogger.Log(LogType.Warning, "Config file not found!"); - Program.Stop(); - return ""; + CreateDefaultConfigFile(path); } + + var cfg = new ConfigParser(path); + var st = cfg.GetValue(app, setting); + return st; } catch (Exception ex) { + CreateDefaultConfigFile(path); + Program.hLogger.Log(LogType.Error, "Failed to get setting: " + ex.Message); Program.Stop(); return ""; @@ -40,28 +34,47 @@ public static string GetSetting(string app, string setting) public static void UpdateSetting(string app, string setting, string value) { + string path = Path.Combine(Program.appWorkDir, "config.ini"); try { - string path = Path.Combine(Program.appWorkDir, "config.ini"); - if (File.Exists(path)) - { - var cfg = new ConfigParser(path); - cfg.SetValue(app, setting, value); - cfg.Save(); - Program.hLogger.Log(LogType.Info, $"Updated: {setting}"); - } - else + if (!File.Exists(path)) { - Program.hLogger.Log(LogType.Warning, "Config file not found!"); - Program.Stop(); + CreateDefaultConfigFile(path); } + + var cfg = new ConfigParser(path); + cfg.SetValue(app, setting, value); + cfg.Save(); + Program.hLogger.Log(LogType.Info, $"Updated: {setting}"); } catch (Exception ex) { + CreateDefaultConfigFile(path); Program.hLogger.Log(LogType.Error, "Failed to update settings: " + ex.Message); Program.Stop(); } } - } -} \ No newline at end of file + private static void CreateDefaultConfigFile(string path) + { + try + { + using (StreamWriter sw = new StreamWriter(path)) + { + sw.WriteLine("[webserver]"); + sw.WriteLine("port=1492"); + sw.WriteLine("host=0.0.0.0"); + sw.WriteLine("token=test"); + + sw.WriteLine("[os]"); + sw.WriteLine("forcewinsupport=false"); + sw.WriteLine("savelogs=false"); + } + } + catch (IOException ex) + { + Console.WriteLine("Error creating config file: " + ex.Message); + } + } + } +} diff --git a/StresserAMD b/StresserAMD new file mode 100755 index 0000000..3874906 Binary files /dev/null and b/StresserAMD differ diff --git a/StresserARM b/StresserARM new file mode 100755 index 0000000..fbbf3d0 Binary files /dev/null and b/StresserARM differ diff --git a/StresserARM64 b/StresserARM64 new file mode 100755 index 0000000..c7460b8 Binary files /dev/null and b/StresserARM64 differ diff --git a/build.bash b/build.bash new file mode 100644 index 0000000..1a2db16 --- /dev/null +++ b/build.bash @@ -0,0 +1,15 @@ +#!/bin/bash + +runtimes=("linux-x64" "linux-arm64" "linux-arm") + +dotnet clean + +for runtime in "${runtimes[@]}"; do + echo "Publishing for runtime: $runtime" + dotnet publish -c Release -r "$runtime" /p:PublishSingleFile=true -p:Version=1.0.0.1 + echo "----------------------------------" +done + +mv /var/www/Stresser/bin/Release/net8.0/linux-arm/publish/Stresser /var/www/Stresser/StresserARM +mv /var/www/Stresser/bin/Release/net8.0/linux-arm64/publish/Stresser /var/www/Stresser/StresserARM64 +mv /var/www/Stresser/bin/Release/net8.0/linux-x64/publish/Stresser /var/www/Stresser/StresserAMD diff --git a/config.ini b/config.ini index 6a031de..4e54a29 100644 --- a/config.ini +++ b/config.ini @@ -2,7 +2,6 @@ port=1492 host=0.0.0.0 token=test - [os] -forcewinsupport="false" -savelogs="false" +forcewinsupport=false +savelogs=false