@@ -18,7 +18,9 @@ namespace Shadowsocks.Controller | |||||
public const string USER_RULE_FILE = "user-rule.txt"; | public const string USER_RULE_FILE = "user-rule.txt"; | ||||
public const string USER_ABP_FILE = "abp.txt"; | public const string USER_ABP_FILE = "abp.txt"; | ||||
public string PacSecret { get; private set; } = ""; | |||||
private string PacSecret { get; set; } = ""; | |||||
public string PacUrl { get; private set; } = ""; | |||||
FileSystemWatcher PACFileWatcher; | FileSystemWatcher PACFileWatcher; | ||||
FileSystemWatcher UserRuleFileWatcher; | FileSystemWatcher UserRuleFileWatcher; | ||||
@@ -47,6 +49,14 @@ namespace Shadowsocks.Controller | |||||
{ | { | ||||
PacSecret = ""; | PacSecret = ""; | ||||
} | } | ||||
PacUrl = $"http://127.0.0.1:{config.localPort}/pac?t={GetTimestamp(DateTime.Now)}{PacSecret}"; | |||||
} | |||||
private static string GetTimestamp(DateTime value) | |||||
{ | |||||
return value.ToString("yyyyMMddHHmmssfff"); | |||||
} | } | ||||
public override bool Handle(byte[] firstPacket, int length, Socket socket, object state) | public override bool Handle(byte[] firstPacket, int length, Socket socket, object state) | ||||
@@ -6,6 +6,7 @@ using System.Net.Sockets; | |||||
using System.Text; | using System.Text; | ||||
using System.Threading; | using System.Threading; | ||||
using System.Web; | using System.Web; | ||||
using System.Windows.Forms; | |||||
using Newtonsoft.Json; | using Newtonsoft.Json; | ||||
using Shadowsocks.Controller.Service; | using Shadowsocks.Controller.Service; | ||||
using Shadowsocks.Controller.Strategy; | using Shadowsocks.Controller.Strategy; | ||||
@@ -575,6 +576,11 @@ namespace Shadowsocks.Controller | |||||
File.WriteAllText(PACServer.PAC_FILE, abpContent, Encoding.UTF8); | File.WriteAllText(PACServer.PAC_FILE, abpContent, Encoding.UTF8); | ||||
} | } | ||||
public void CopyPacUrl() | |||||
{ | |||||
Clipboard.SetDataObject(_pacServer.PacUrl); | |||||
} | |||||
#region Memory Management | #region Memory Management | ||||
private void StartReleasingMemory() | private void StartReleasingMemory() | ||||
@@ -38,8 +38,7 @@ namespace Shadowsocks.Controller | |||||
} | } | ||||
else | else | ||||
{ | { | ||||
pacUrl = | |||||
$"http://127.0.0.1:{config.localPort}/pac?t={GetTimestamp(DateTime.Now)}{pacSrv.PacSecret}"; | |||||
pacUrl = pacSrv.PacUrl; | |||||
} | } | ||||
Sysproxy.SetIEProxy(true, false, "", pacUrl); | Sysproxy.SetIEProxy(true, false, "", pacUrl); | ||||
} | } | ||||
@@ -20,6 +20,7 @@ Edit Local PAC File...=编辑本地 PAC 文件... | |||||
Update Local PAC from GFWList=从 GFWList 更新本地 PAC | Update Local PAC from GFWList=从 GFWList 更新本地 PAC | ||||
Edit User Rule for GFWList...=编辑 GFWList 的用户规则... | Edit User Rule for GFWList...=编辑 GFWList 的用户规则... | ||||
Secure Local PAC=保护本地 PAC | Secure Local PAC=保护本地 PAC | ||||
Copy Local PAC URL=复制本地 PAC 网址 | |||||
Show QRCode...=显示二维码... | Show QRCode...=显示二维码... | ||||
Scan QRCode from Screen...=扫描屏幕上的二维码... | Scan QRCode from Screen...=扫描屏幕上的二维码... | ||||
Availability Statistics=统计可用性 | Availability Statistics=统计可用性 | ||||
@@ -20,6 +20,7 @@ Edit Local PAC File...=編輯本地 PAC 文件... | |||||
Update Local PAC from GFWList=從 GFWList 更新本地 PAC | Update Local PAC from GFWList=從 GFWList 更新本地 PAC | ||||
Edit User Rule for GFWList...=編輯 GFWList 的用戶規則... | Edit User Rule for GFWList...=編輯 GFWList 的用戶規則... | ||||
Secure Local PAC=保護本地 PAC | Secure Local PAC=保護本地 PAC | ||||
Copy Local PAC URL=複製本地 PAC 網址 | |||||
Show QRCode...=顯示 QR 碼... | Show QRCode...=顯示 QR 碼... | ||||
Scan QRCode from Screen...=掃描螢幕上的 QR 碼... | Scan QRCode from Screen...=掃描螢幕上的 QR 碼... | ||||
Availability Statistics=統計可用性 | Availability Statistics=統計可用性 | ||||
@@ -271,8 +271,9 @@ namespace Shadowsocks.View | |||||
this.editLocalPACItem = CreateMenuItem("Edit Local PAC File...", new EventHandler(this.EditPACFileItem_Click)), | this.editLocalPACItem = CreateMenuItem("Edit Local PAC File...", new EventHandler(this.EditPACFileItem_Click)), | ||||
this.updateFromGFWListItem = CreateMenuItem("Update Local PAC from GFWList", new EventHandler(this.UpdatePACFromGFWListItem_Click)), | this.updateFromGFWListItem = CreateMenuItem("Update Local PAC from GFWList", new EventHandler(this.UpdatePACFromGFWListItem_Click)), | ||||
this.editGFWUserRuleItem = CreateMenuItem("Edit User Rule for GFWList...", new EventHandler(this.EditUserRuleFileForGFWListItem_Click)), | this.editGFWUserRuleItem = CreateMenuItem("Edit User Rule for GFWList...", new EventHandler(this.EditUserRuleFileForGFWListItem_Click)), | ||||
this.editOnlinePACItem = CreateMenuItem("Edit Online PAC URL...", new EventHandler(this.UpdateOnlinePACURLItem_Click)), | |||||
this.secureLocalPacUrlToggleItem = CreateMenuItem("Secure Local PAC", new EventHandler(this.SecureLocalPacUrlToggleItem_Click)), | this.secureLocalPacUrlToggleItem = CreateMenuItem("Secure Local PAC", new EventHandler(this.SecureLocalPacUrlToggleItem_Click)), | ||||
CreateMenuItem("Copy Local PAC URL", new EventHandler(this.CopyLocalPacUrlItem_Click)), | |||||
this.editOnlinePACItem = CreateMenuItem("Edit Online PAC URL...", new EventHandler(this.UpdateOnlinePACURLItem_Click)), | |||||
}), | }), | ||||
this.proxyItem = CreateMenuItem("Forward Proxy...", new EventHandler(this.proxyItem_Click)), | this.proxyItem = CreateMenuItem("Forward Proxy...", new EventHandler(this.proxyItem_Click)), | ||||
new MenuItem("-"), | new MenuItem("-"), | ||||
@@ -805,6 +806,11 @@ namespace Shadowsocks.View | |||||
controller.ToggleSecureLocalPac(!configuration.secureLocalPac); | controller.ToggleSecureLocalPac(!configuration.secureLocalPac); | ||||
} | } | ||||
private void CopyLocalPacUrlItem_Click(object sender, EventArgs e) | |||||
{ | |||||
controller.CopyPacUrl(); | |||||
} | |||||
private void UpdatePACItemsEnabledStatus() | private void UpdatePACItemsEnabledStatus() | ||||
{ | { | ||||
if (this.localPACItem.Checked) | if (this.localPACItem.Checked) | ||||