Browse Source

Add menu item to copy local pac url

tags/3.4.1
noisyfox 7 years ago
parent
commit
76fbd808e3
6 changed files with 27 additions and 4 deletions
  1. +11
    -1
      shadowsocks-csharp/Controller/Service/PACServer.cs
  2. +6
    -0
      shadowsocks-csharp/Controller/ShadowsocksController.cs
  3. +1
    -2
      shadowsocks-csharp/Controller/System/SystemProxy.cs
  4. +1
    -0
      shadowsocks-csharp/Data/cn.txt
  5. +1
    -0
      shadowsocks-csharp/Data/zh_tw.txt
  6. +7
    -1
      shadowsocks-csharp/View/MenuViewController.cs

+ 11
- 1
shadowsocks-csharp/Controller/Service/PACServer.cs View File

@@ -18,7 +18,9 @@ namespace Shadowsocks.Controller
public const string USER_RULE_FILE = "user-rule.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 UserRuleFileWatcher;
@@ -47,6 +49,14 @@ namespace Shadowsocks.Controller
{
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)


+ 6
- 0
shadowsocks-csharp/Controller/ShadowsocksController.cs View File

@@ -6,6 +6,7 @@ using System.Net.Sockets;
using System.Text;
using System.Threading;
using System.Web;
using System.Windows.Forms;
using Newtonsoft.Json;
using Shadowsocks.Controller.Service;
using Shadowsocks.Controller.Strategy;
@@ -575,6 +576,11 @@ namespace Shadowsocks.Controller
File.WriteAllText(PACServer.PAC_FILE, abpContent, Encoding.UTF8);
}
public void CopyPacUrl()
{
Clipboard.SetDataObject(_pacServer.PacUrl);
}
#region Memory Management
private void StartReleasingMemory()


+ 1
- 2
shadowsocks-csharp/Controller/System/SystemProxy.cs View File

@@ -38,8 +38,7 @@ namespace Shadowsocks.Controller
}
else
{
pacUrl =
$"http://127.0.0.1:{config.localPort}/pac?t={GetTimestamp(DateTime.Now)}{pacSrv.PacSecret}";
pacUrl = pacSrv.PacUrl;
}
Sysproxy.SetIEProxy(true, false, "", pacUrl);
}


+ 1
- 0
shadowsocks-csharp/Data/cn.txt View File

@@ -20,6 +20,7 @@ Edit Local PAC File...=编辑本地 PAC 文件...
Update Local PAC from GFWList=从 GFWList 更新本地 PAC
Edit User Rule for GFWList...=编辑 GFWList 的用户规则...
Secure Local PAC=保护本地 PAC
Copy Local PAC URL=复制本地 PAC 网址
Show QRCode...=显示二维码...
Scan QRCode from Screen...=扫描屏幕上的二维码...
Availability Statistics=统计可用性


+ 1
- 0
shadowsocks-csharp/Data/zh_tw.txt View File

@@ -20,6 +20,7 @@ Edit Local PAC File...=編輯本地 PAC 文件...
Update Local PAC from GFWList=從 GFWList 更新本地 PAC
Edit User Rule for GFWList...=編輯 GFWList 的用戶規則...
Secure Local PAC=保護本地 PAC
Copy Local PAC URL=複製本地 PAC 網址
Show QRCode...=顯示 QR 碼...
Scan QRCode from Screen...=掃描螢幕上的 QR 碼...
Availability Statistics=統計可用性


+ 7
- 1
shadowsocks-csharp/View/MenuViewController.cs View File

@@ -271,8 +271,9 @@ namespace Shadowsocks.View
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.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)),
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)),
new MenuItem("-"),
@@ -805,6 +806,11 @@ namespace Shadowsocks.View
controller.ToggleSecureLocalPac(!configuration.secureLocalPac);
}
private void CopyLocalPacUrlItem_Click(object sender, EventArgs e)
{
controller.CopyPacUrl();
}
private void UpdatePACItemsEnabledStatus()
{
if (this.localPACItem.Checked)


Loading…
Cancel
Save