diff options
author | crupest <crupest@outlook.com> | 2023-09-05 17:18:11 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2023-09-05 17:18:11 +0800 |
commit | a418be478a915d9b0726e5d03e691c74f176fe65 (patch) | |
tree | d1df290107119dedadf094cb7e026554239b683c /tools/Crupest.V2ray/Crupest.V2ray/Program.cs | |
parent | 4f1862ca278020930631548726477ec1ebb8ecbf (diff) | |
download | crupest-a418be478a915d9b0726e5d03e691c74f176fe65.tar.gz crupest-a418be478a915d9b0726e5d03e691c74f176fe65.tar.bz2 crupest-a418be478a915d9b0726e5d03e691c74f176fe65.zip |
Continue to develop mysterious tool.
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(); + }); + } +} |