48 lines
No EOL
1.4 KiB
C#
48 lines
No EOL
1.4 KiB
C#
namespace LarpixVoice;
|
|
|
|
public class Utils
|
|
{
|
|
public static int PORT = 8091;
|
|
public static int MAIN_PORT = 8090;
|
|
public static string SERVER_KEY = "SecretThingOMGSoHardToGuess";
|
|
|
|
public static void LoadEnv()
|
|
{
|
|
if (File.Exists(".env"))
|
|
{
|
|
|
|
foreach (var line in File.ReadAllLines(".env"))
|
|
{
|
|
var trimmed = line.Trim();
|
|
if (string.IsNullOrWhiteSpace(trimmed) || trimmed.StartsWith("#")) continue;
|
|
|
|
var parts = trimmed.Split('=', 2, StringSplitOptions.None);
|
|
if (parts.Length == 2)
|
|
{
|
|
var key = parts[0].Trim();
|
|
var val = parts[1];
|
|
int commentIndex = val.IndexOf('#');
|
|
if (commentIndex >= 0)
|
|
{
|
|
val = val.Substring(0, commentIndex);
|
|
}
|
|
val = val.Trim();
|
|
|
|
Environment.SetEnvironmentVariable(key, val);
|
|
}
|
|
}
|
|
}
|
|
|
|
string? port = Environment.GetEnvironmentVariable("PORT_VOICE");
|
|
if (port != null)
|
|
{
|
|
PORT = int.Parse(port);
|
|
}
|
|
port = Environment.GetEnvironmentVariable("PORT");
|
|
if (port != null)
|
|
{
|
|
MAIN_PORT = int.Parse(port);
|
|
}
|
|
SERVER_KEY = Environment.GetEnvironmentVariable("SERVER_KEY") ?? SERVER_KEY;
|
|
}
|
|
} |