diff options
Diffstat (limited to 'tools/Crupest.V2ray/Crupest.V2ray/Program.cs')
-rw-r--r-- | tools/Crupest.V2ray/Crupest.V2ray/Program.cs | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/tools/Crupest.V2ray/Crupest.V2ray/Program.cs b/tools/Crupest.V2ray/Crupest.V2ray/Program.cs new file mode 100644 index 0000000..793f6e7 --- /dev/null +++ b/tools/Crupest.V2ray/Crupest.V2ray/Program.cs @@ -0,0 +1,45 @@ +using System.Diagnostics; +using System.Reflection; + +namespace Crupest.V2ray; + +public static class Program +{ + public const string ConfigTemplateFileName = "config.json.template"; + public const string VmessConfigFileName = "vmess.txt"; + public const string ProxyConfigFileName = "proxy.txt"; + public const string ConfigOutputFileName = "config.json"; + + public static string ExeDir { get; } = Path.GetFullPath(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) ?? throw new Exception("Can't get the path of exe.")); + + + public static void Main(string[] args) + { + if (args.Length != 0) + { + if (args.Length != 1) + { + throw new Exception("Invalid command line arguments."); + } + var verb = args[0].ToLower(); + if (verb == "download-geodata" || verb == "dg") + { + var geoDataDonwloader = new GeoDataDownloader(); + geoDataDonwloader.Download(ExeDir); + return; + } + } + + var v2rayController = new V2rayController(); + var configGenerationWatcher = new ConfigGenerationWatcher(); + + configGenerationWatcher.Generate(); + v2rayController.Start(); + + configGenerationWatcher.Run(() => + { + configGenerationWatcher.Generate(); + v2rayController.Restart(); + }); + } +} |