Direct set the system PAC to the online PAC URL
This commit is contained in:
@@ -71,10 +71,7 @@ namespace Shadowsocks.Controller
|
||||
}
|
||||
if (hostMatch && pathMatch)
|
||||
{
|
||||
if (_config.useOnlinePac && !string.IsNullOrEmpty(_config.pacUrl))
|
||||
RedirectToOnlinePAC(firstPacket, length, socket, useSocks);
|
||||
else
|
||||
SendResponse(firstPacket, length, socket, useSocks);
|
||||
SendResponse(firstPacket, length, socket, useSocks);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -124,30 +121,6 @@ namespace Shadowsocks.Controller
|
||||
}
|
||||
}
|
||||
|
||||
private void RedirectToOnlinePAC(byte[] firstPacket, int length, Socket socket, bool useSocks)
|
||||
{
|
||||
try
|
||||
{
|
||||
string friendlyMessage = "Redirect to online pac " + _config.pacUrl;
|
||||
string text = String.Format(@"HTTP/1.1 302 Found
|
||||
Server: Shadowsocks
|
||||
Content-Type: text/html; charset=utf-8
|
||||
Location: {0}
|
||||
Content-Length: {1}
|
||||
Connection: Close
|
||||
|
||||
", _config.pacUrl, System.Text.Encoding.UTF8.GetBytes(friendlyMessage).Length) + friendlyMessage;
|
||||
byte[] response = System.Text.Encoding.UTF8.GetBytes(text);
|
||||
socket.BeginSend(response, 0, response.Length, 0, new AsyncCallback(SendCallback), socket);
|
||||
Util.Utils.ReleaseMemory();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine(e);
|
||||
socket.Close();
|
||||
}
|
||||
}
|
||||
|
||||
public void SendResponse(byte[] firstPacket, int length, Socket socket, bool useSocks)
|
||||
{
|
||||
try
|
||||
|
||||
@@ -49,9 +49,14 @@ namespace Shadowsocks.Controller
|
||||
}
|
||||
else
|
||||
{
|
||||
string pacUrl;
|
||||
if (config.useOnlinePac && !string.IsNullOrEmpty(config.pacUrl))
|
||||
pacUrl = config.pacUrl;
|
||||
else
|
||||
pacUrl = "http://127.0.0.1:" + config.localPort.ToString() + "/pac?t=" + GetTimestamp(DateTime.Now);
|
||||
registry.SetValue("ProxyEnable", 0);
|
||||
registry.SetValue("ProxyServer", "");
|
||||
registry.SetValue("AutoConfigURL", "http://127.0.0.1:" + config.localPort.ToString() + "/pac?t=" + GetTimestamp(DateTime.Now));
|
||||
registry.SetValue("AutoConfigURL", pacUrl);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user