Make the pac.txt file be recreated at every startup

This commit is contained in:
Wydy 2025-03-15 21:26:12 +08:00 committed by GitHub
parent d0e2cc9442
commit f10ce6588f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -33,11 +33,12 @@ namespace ServiceLib.Handler
private static async Task InitText() private static async Task InitText()
{ {
var path = Path.Combine(_configPath, "pac.txt"); var path = Path.Combine(_configPath, "pac.txt");
if (!File.Exists(path)) if (File.Exists(path))
{ {
File.Delete(path);
}
var pac = EmbedUtils.GetEmbedText(Global.PacFileName); var pac = EmbedUtils.GetEmbedText(Global.PacFileName);
await File.AppendAllTextAsync(path, pac); await File.AppendAllTextAsync(path, pac);
}
var pacText = var pacText =
(await File.ReadAllTextAsync(path)).Replace("__PROXY__", $"PROXY 127.0.0.1:{_httpPort};DIRECT;"); (await File.ReadAllTextAsync(path)).Replace("__PROXY__", $"PROXY 127.0.0.1:{_httpPort};DIRECT;");