mirror of
https://github.com/azaion/annotations.git
synced 2026-04-22 21:56:31 +00:00
c0f8dd792d
fix same files problem in python different libs correct command logging in command handler
80 lines
2.5 KiB
C#
80 lines
2.5 KiB
C#
using System.IO;
|
|
using Azaion.Common.DTO;
|
|
using Newtonsoft.Json;
|
|
using Serilog;
|
|
|
|
namespace Azaion.Common;
|
|
|
|
public class SecurityConstants
|
|
{
|
|
public const string CONFIG_PATH = "config.json";
|
|
|
|
private const string DEFAULT_API_URL = "https://api.azaion.com";
|
|
|
|
#region ExternalClientsConfig
|
|
|
|
private const string DEFAULT_ZMQ_LOADER_HOST = "127.0.0.1";
|
|
private const int DEFAULT_ZMQ_LOADER_PORT = 5025;
|
|
|
|
public const string EXTERNAL_LOADER_PATH = "azaion-loader.exe";
|
|
public const string EXTERNAL_INFERENCE_PATH = "azaion-inference.exe";
|
|
public const string EXTERNAL_GPS_DENIED_FOLDER = "gps-denied";
|
|
public static readonly string ExternalGpsDeniedPath = Path.Combine(EXTERNAL_GPS_DENIED_FOLDER, "image-matcher.exe");
|
|
|
|
public const string DEFAULT_ZMQ_INFERENCE_HOST = "127.0.0.1";
|
|
public const int DEFAULT_ZMQ_INFERENCE_PORT = 5227;
|
|
|
|
public const string DEFAULT_ZMQ_GPS_DENIED_HOST = "127.0.0.1";
|
|
public const int DEFAULT_ZMQ_GPS_DENIED_PORT = 5227;
|
|
|
|
# region Cache keys
|
|
|
|
public const string CURRENT_USER_CACHE_KEY = "CurrentUser";
|
|
public const string HARDWARE_INFO_KEY = "HardwareInfo";
|
|
|
|
# endregion
|
|
|
|
public static readonly InitConfig DefaultInitConfig = new()
|
|
{
|
|
LoaderClientConfig = new LoaderClientConfig
|
|
{
|
|
ZeroMqHost = DEFAULT_ZMQ_LOADER_HOST,
|
|
ZeroMqPort = DEFAULT_ZMQ_LOADER_PORT,
|
|
ApiUrl = DEFAULT_API_URL
|
|
},
|
|
InferenceClientConfig = new InferenceClientConfig
|
|
{
|
|
ZeroMqHost = DEFAULT_ZMQ_INFERENCE_HOST,
|
|
ZeroMqPort = DEFAULT_ZMQ_INFERENCE_PORT,
|
|
ApiUrl = DEFAULT_API_URL
|
|
},
|
|
GpsDeniedClientConfig = new GpsDeniedClientConfig
|
|
{
|
|
ZeroMqHost = DEFAULT_ZMQ_GPS_DENIED_HOST,
|
|
ZeroMqPort = DEFAULT_ZMQ_GPS_DENIED_PORT
|
|
},
|
|
DirectoriesConfig = new DirectoriesConfig
|
|
{
|
|
ApiResourcesDirectory = ""
|
|
}
|
|
};
|
|
#endregion ExternalClientsConfig
|
|
|
|
public static InitConfig ReadInitConfig(ILogger logger)
|
|
{
|
|
try
|
|
{
|
|
if (!File.Exists(CONFIG_PATH))
|
|
throw new FileNotFoundException(CONFIG_PATH);
|
|
var configStr = File.ReadAllText(CONFIG_PATH);
|
|
var config = JsonConvert.DeserializeObject<InitConfig>(configStr);
|
|
|
|
return config ?? DefaultInitConfig;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
logger.Error(e, e.Message);
|
|
return DefaultInitConfig;
|
|
}
|
|
}
|
|
} |