From 9adda68c9e75551c9433840fe0cc877426743bfd Mon Sep 17 00:00:00 2001 From: Kazuhiro Fujieda Date: Fri, 25 Sep 2015 20:57:51 +0900 Subject: [PATCH] =?utf8?q?=E3=82=B9=E3=83=AA=E3=83=BC=E3=83=97=E5=BE=A9?= =?utf8?q?=E5=B8=B0=E6=99=82=E3=81=AB=E3=83=97=E3=83=AD=E3=82=AD=E3=82=B7?= =?utf8?q?=E8=A8=AD=E5=AE=9A=E3=81=AE=E3=83=AA=E3=83=95=E3=83=AC=E3=83=83?= =?utf8?q?=E3=82=B7=E3=83=A5=E3=82=92=E7=B9=B0=E3=82=8A=E8=BF=94=E3=81=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- KancolleSniffer/MainForm.cs | 37 +++++++++++++++++++++++++++++++++---- 1 file changed, 33 insertions(+), 4 deletions(-) diff --git a/KancolleSniffer/MainForm.cs b/KancolleSniffer/MainForm.cs index bc12f2c..c82fc56 100644 --- a/KancolleSniffer/MainForm.cs +++ b/KancolleSniffer/MainForm.cs @@ -21,6 +21,7 @@ using System.Diagnostics; using System.Drawing; using System.IO; using System.Linq; +using System.Net; using System.Net.Sockets; using System.Runtime.InteropServices; using System.Text; @@ -90,8 +91,8 @@ namespace KancolleSniffer var request = session.Request.BodyAsString; if (_debugLogFile != null) { - File.AppendAllText(_debugLogFile, - string.Format("url: {0}\nrequest: {1}\nresponse: {2}\n", session.Request.PathAndQuery, request, json.ToString())); + File.AppendAllText(_debugLogFile, string.Format("url: {0}\nrequest: {1}\nresponse: {2}\n", + session.Request.PathAndQuery, request, json.ToString())); } try { @@ -148,8 +149,36 @@ namespace KancolleSniffer { if (e.Mode != PowerModes.Resume) return; - Thread.Sleep(10000); - SystemProxy.Refresh(); + Task.Run(() => + { + for (var i = 0; i < 5; Thread.Sleep(10000), i++) + { + WebResponse res = null; + SystemProxy.Refresh(); + var system = WebRequest.GetSystemWebProxy(); + if (!system.GetProxy(new Uri("http://125.6.184.16/")).IsLoopback) + { + File.AppendAllText("wakeup.log", + $"[{DateTime.Now.ToString("g")}] proxy settings doesn't work.\r\n"); + continue; + } + try + { + var req = WebRequest.Create("http://kancollesniffer.osdn.jp/version"); + res = req.GetResponse(); + break; + } + catch + { + File.AppendAllText("wakeup.log", + $"[{DateTime.Now.ToString("g")}] failed to connect internet.\r\n"); + } + finally + { + res?.Close(); + } + } + }); } private void MainForm_FormClosing(object sender, FormClosingEventArgs e) -- 2.11.0