From a44f810890516abf32bf2f54583f8dc0f7c0dd36 Mon Sep 17 00:00:00 2001 From: Student Main Date: Sun, 6 Oct 2019 01:13:06 +0800 Subject: [PATCH] Reformatting some string literals --- .../Controller/Service/GfwListUpdater.cs | 8 ++++---- shadowsocks-csharp/Controller/Service/PACServer.cs | 14 ++++++-------- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/shadowsocks-csharp/Controller/Service/GfwListUpdater.cs b/shadowsocks-csharp/Controller/Service/GfwListUpdater.cs index 277269e4..c47a70a2 100644 --- a/shadowsocks-csharp/Controller/Service/GfwListUpdater.cs +++ b/shadowsocks-csharp/Controller/Service/GfwListUpdater.cs @@ -81,10 +81,10 @@ namespace Shadowsocks.Controller List gfwLines = new List(); gfwLines = ParseBase64ToValidList(gfwListResult); - abpContent = $"var __USERRULES__ = {JsonConvert.SerializeObject(userruleLines, Formatting.Indented)};\n" + - $"var __RULES__ = {JsonConvert.SerializeObject(gfwLines, Formatting.Indented)};\n"; - //abpContent = abpContent.Replace("__USERRULES__", JsonConvert.SerializeObject(userruleLines, Formatting.Indented)) - // .Replace("__RULES__", JsonConvert.SerializeObject(gfwLines, Formatting.Indented)); + abpContent = +$@"var __USERRULES__ = {JsonConvert.SerializeObject(userruleLines, Formatting.Indented)}; +var __RULES__ = {JsonConvert.SerializeObject(gfwLines, Formatting.Indented)}; +"; return abpContent; } diff --git a/shadowsocks-csharp/Controller/Service/PACServer.cs b/shadowsocks-csharp/Controller/Service/PACServer.cs index f50731bf..d5813f0d 100644 --- a/shadowsocks-csharp/Controller/Service/PACServer.cs +++ b/shadowsocks-csharp/Controller/Service/PACServer.cs @@ -164,17 +164,15 @@ namespace Shadowsocks.Controller string proxy = GetPACAddress(localEndPoint, useSocks); - string pacContent = $"var __PROXY__ = \"{proxy}\";\n" + _pacDaemon.GetPACContent(); - - //string pacContent = _pacDaemon.GetPACContent().Replace("__PROXY__", proxy); - - string responseHead = String.Format(@"HTTP/1.1 200 OK -Server: Shadowsocks + string pacContent = $"var __PROXY__ = '{proxy}';\n" + _pacDaemon.GetPACContent(); + string responseHead = +$@"HTTP/1.1 200 OK +Server: ShadowsocksWindows/{UpdateChecker.Version} Content-Type: application/x-ns-proxy-autoconfig -Content-Length: {0} +Content-Length: { Encoding.UTF8.GetBytes(pacContent).Length} Connection: Close -", Encoding.UTF8.GetBytes(pacContent).Length); +"; byte[] response = Encoding.UTF8.GetBytes(responseHead + pacContent); socket.BeginSend(response, 0, response.Length, 0, new AsyncCallback(SendCallback), socket); Utils.ReleaseMemory(true);