diff --git a/2chAPIProxy/DatProxy.cs b/2chAPIProxy/DatProxy.cs index 9977b1a..3e98681 100644 --- a/2chAPIProxy/DatProxy.cs +++ b/2chAPIProxy/DatProxy.cs @@ -13,6 +13,7 @@ using _2chAPIProxy.APIMediator; using System.Security.Cryptography; using System.Threading; +using System.ComponentModel; namespace _2chAPIProxy { @@ -22,7 +23,7 @@ class IPAuthData public String nonce = ""; } - public class DatProxy + public class DatProxy : ViewModels.VMBase { Dictionary Cookie = new Dictionary(); Dictionary AuthIPList = new Dictionary(); @@ -996,7 +997,7 @@ public string Monakey } else { - monakey = value; + _ = SetProperty(ref monakey, value, nameof(Monakey)); } } } diff --git a/2chAPIProxy/ViewModels/ViewModel.cs b/2chAPIProxy/ViewModels/ViewModel.cs index 577ca42..c5960a3 100644 --- a/2chAPIProxy/ViewModels/ViewModel.cs +++ b/2chAPIProxy/ViewModels/ViewModel.cs @@ -231,6 +231,17 @@ public void Init() DatProxy.HtmlConverter.IsHttpsReplace = _ReplaceHttpsLink; DatProxy.HtmlConverter.IsExternalConverterUse = _CEExternalRead; + // Monakeyの即時保存処理 + DatProxy.PropertyChanged += (sender, e) => + { + if (e.PropertyName == nameof(DatProxy.Monakey)) + { + // Monakeyを保存 + Setting.Monakey = DatProxy.Monakey; + SaveSettings(); + } + }; + //エラー通知用コールバック登録 DatProxy.APIMediator.PropertyChanged += (sender, e) => { @@ -348,6 +359,16 @@ private void HtmlConverter_PropertyChanged(object sender, PropertyChangedEventAr throw new NotImplementedException(); } + private void SaveSettings() + { + XmlSerializer xser = new XmlSerializer(typeof(AppSetting)); + using (StreamWriter sw = new StreamWriter("./settings.xml", false, Encoding.UTF8)) + { + xser.Serialize(sw, Setting); + } + Setting.change = false; + } + public void BeforeShutdown() { using (TaskTrayIcon) @@ -371,17 +392,10 @@ public void BeforeShutdown() } catch (ArgumentException) { } } - - // Monakeyが更新されてたら保存 - if (Setting.Monakey != DatProxy.Monakey) Setting.Monakey = DatProxy.Monakey; if (Setting.change) { - XmlSerializer xser = new XmlSerializer(typeof(AppSetting)); - using (StreamWriter sw = new StreamWriter("./settings.xml", false, Encoding.UTF8)) - { - xser.Serialize(sw, Setting); - } + SaveSettings(); } System.Windows.Application.Current.Shutdown(); } @@ -1303,14 +1317,12 @@ public RelayCommand OnClick } })); }); - XmlSerializer xser = new XmlSerializer(typeof(AppSetting)); - using (StreamWriter sw = new StreamWriter("./settings.xml", false, Encoding.UTF8)) - { - xser.Serialize(sw, Setting); - Setting.change = false; - SystemLog = "現在の設定を保存しました。"; - this.PopupVisible = true; - } + + // 無条件設定保存と通知 + SaveSettings(); + SystemLog = "現在の設定を保存しました。"; + this.PopupVisible = true; + // Monakeyをリセット DatProxy.ResetMonakey(); break; @@ -1428,13 +1440,9 @@ public RelayCommand SaveSetting { if (_SaveSetting == null) _SaveSetting = new RelayCommand(() => { - XmlSerializer xser = new XmlSerializer(typeof(AppSetting)); - using (StreamWriter sw = new StreamWriter("./settings.xml", false, Encoding.UTF8)) - { - xser.Serialize(sw, Setting); - Setting.change = false; - SystemLog = "現在の設定を保存しました。"; - } + // 無条件設定保存と通知 + SaveSettings(); + SystemLog = "現在の設定を保存しました。"; // Monakeyをリセット DatProxy.ResetMonakey(); diff --git "a/doc/\346\233\270\343\201\215\350\276\274\343\201\277\346\226\260\344\273\225\346\247\230\351\226\242\351\200\243.md" "b/doc/\346\233\270\343\201\215\350\276\274\343\201\277\346\226\260\344\273\225\346\247\230\351\226\242\351\200\243.md" index d2c439a..bcaee6c 100644 --- "a/doc/\346\233\270\343\201\215\350\276\274\343\201\277\346\226\260\344\273\225\346\247\230\351\226\242\351\200\243.md" +++ "b/doc/\346\233\270\343\201\215\350\276\274\343\201\277\346\226\260\344\273\225\346\247\230\351\226\242\351\200\243.md" @@ -1163,4 +1163,55 @@ Content-Encoding: Content-Type:text/html; charset=Shift_JIS Date:Sun, 24 Apr 2022 09:26:42 GMT Server:cloudflare +``` + + +# 失敗(鍵の有効期限が切れています) + +2022/05/27、鍵の期限切れパターンはこっち? + +``` +オリジナルリクエストヘッダ +Host:egg.5ch.net +User-Agent:Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Firefox/91.0 +Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8 +Accept-Language:ja,en-US;q=0.7,en;q=0.3 +Accept-Encoding:gzip, deflate +Referer:http://egg.5ch.net/test/read.cgi/software/1652008003/ +Upgrade-Insecure-Requests:1 +Content-Type:application/x-www-form-urlencoded +Content-Length:158 +Connection:keep-alive + +リクエストヘッダ +Referer:https://egg.5ch.net/test/read.cgi/software/1652008003/ +X-PostSig:93a1a370926e9ceb8bca8e829847faefff9675155c2106cf249ab52b12d7dcac +X-APIKey:8yoeAcaLXiEY1FjEuJBKgkPxirkDqn +X-PostNonce:1653578637.547 +X-MonaKey:b1fd22457df0fc0d096dbeb719f15a006449599cb5d181e0d90bdc382c91f964 +X-2ch-UA:2chMate/0.8.10.153 +User-Agent:Monazilla/1.00 2chMate/0.8.10.153 Dalvik/2.1.0 (Linux; U; Android 11; SC-52B Build/RP1A.200720.012; 60) +Accept-Encoding:gzip +Content-Type:application/x-www-form-urlencoded; charset=UTF-8 +Host:egg.5ch.net +Content-Length:175 + +レスポンスヘッダ +Connection:close +X-InqID:egg/71178b84c8b7fcc9; +X-Robots-Tag:noindex; +X-Chx-Error:E3324 Expired key.; +X-PostPlace:software/1652008003 +X-RONIN-Stat:NONE +X-Condition:0/0 +X-Proc-Time:0.017456 sec. +X-BBx-Stat:180.60.38.129, NONE +Vary:Accept-Encoding +CF-Cache-Status:DYNAMIC +Expect-CT:max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct" +CF-RAY:71178b84c8b7fcc9-KIX +Content-Encoding: +Content-Type:text/html; charset=Shift_JIS +Date:Thu, 26 May 2022 15:29:13 GMT +Server:cloudflare ``` \ No newline at end of file