header.Flush();\r
client.Send(((MemoryStream)header.BaseStream).ToArray());\r
}\r
- var pacFile = @"\r
-function FindProxyForURL(url, host) {\r
- if(isInNet(host, ""203.104.209.71"", ""255.255.255.255"") ||\r
- isInNet(host, ""203.104.209.87"", ""255.255.255.255"") ||\r
- isInNet(host, ""125.6.184.16"", ""255.255.255.255"") ||\r
- isInNet(host, ""125.6.187.205"", ""255.255.255.255"") ||\r
- isInNet(host, ""125.6.187.229"", ""255.255.255.255"") ||\r
- isInNet(host, ""203.104.209.134"", ""255.255.255.255"") ||\r
- isInNet(host, ""203.104.209.167"", ""255.255.255.255"") ||\r
- isInNet(host, ""203.104.248.135"", ""255.255.255.255"") ||\r
- isInNet(host, ""125.6.189.7"", ""255.255.255.255"") ||\r
- isInNet(host, ""125.6.189.39"", ""255.255.255.255"") ||\r
- isInNet(host, ""125.6.189.71"", ""255.255.255.255"") ||\r
- isInNet(host, ""125.6.189.103"", ""255.255.255.255"") ||\r
- isInNet(host, ""125.6.189.135"", ""255.255.255.255"") ||\r
- isInNet(host, ""125.6.189.167"", ""255.255.255.255"") ||\r
- isInNet(host, ""125.6.189.215"", ""255.255.255.255"") ||\r
- isInNet(host, ""125.6.189.247"", ""255.255.255.255"") ||\r
- isInNet(host, ""203.104.209.23"", ""255.255.255.255"") ||\r
- isInNet(host, ""203.104.209.39"", ""255.255.255.255"") ||\r
- isInNet(host, ""203.104.209.55"", ""255.255.255.255"") ||\r
- isInNet(host, ""203.104.209.102"", ""255.255.255.255"")) {\r
- return ""PROXY 127.0.0.1:8080"";\r
- }\r
- else {\r
- return ""DIRECT"";\r
- }\r
-}".Replace("8080", port.ToString());\r
+ string pacFile;\r
+ try\r
+ {\r
+ pacFile = File.ReadAllText("proxy.pac").Replace("8080", port.ToString());\r
+ }\r
+ catch\r
+ {\r
+ pacFile = "";\r
+ }\r
client.Send(Encoding.ASCII.GetBytes(pacFile));\r
}\r
}\r
}\r
_systemProxy.RestoreSettings();\r
}\r
+\r
+ public void UpdatePacFile()\r
+ {\r
+ var request = (HttpWebRequest)WebRequest.Create("https://kancollesniffer.osdn.jp/proxy.pac");\r
+ if (File.Exists("proxy.pac"))\r
+ {\r
+ var date = File.GetLastWriteTime("proxy.pac");\r
+ request.IfModifiedSince = date;\r
+ }\r
+ try\r
+ {\r
+ var response = (HttpWebResponse)request.GetResponse();\r
+ using (var stream = response.GetResponseStream())\r
+ using (var file = new FileStream("proxy.pac", FileMode.OpenOrCreate))\r
+ stream?.CopyTo(file);\r
+ }\r
+ // ReSharper disable once EmptyGeneralCatchClause\r
+ catch\r
+ {\r
+ }\r
+ }\r
}\r
}
\ No newline at end of file