private void updateChinaIPChecker_NewChinaIPFound(object sender, EventArgs e) { int count = 0; if (!String.IsNullOrEmpty(updateChinaIPChecker.ChinaIPResult)) { List <string> list = new List <string>(); string[] lines = updateChinaIPChecker.ChinaIPResult .Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries); foreach (var line in lines) { if (string.IsNullOrWhiteSpace(line)) { continue; } if (line.StartsWith("#")) { continue; } if (line.StartsWith("apnic|CN|ipv4")) { string[] temp = line.Split('|'); string[] array = temp[3].Split('.'); long value = long.Parse(array[0]) << 24 | long.Parse(array[1]) << 16 | long.Parse(array[2]) << 8 | long.Parse(array[3]); value += Convert.ToInt32(temp[4]) - 1; string result = $"{temp[3]} " + $"{(value >> 24) & 0xFF}." + $"{(value >> 16) & 0xFF}." + $"{(value >> 8) & 0xFF}." + $"{value & 0xFF}"; list.Add(result); count++; } } if (list.Count > 0) { string file = string.Join("\r\n", list) + "\r\n"; controller.ChinaIPFileUpdated(file); } } if (count > 0) { ShowBalloonTip("ShadowsocksR", I18N.GetString("Update China IP success"), ToolTipIcon.Info, 10000); } else { ShowBalloonTip("ShadowsocksR", I18N.GetString("Update China IP failure"), ToolTipIcon.Info, 10000); } updateChinaIPManager.Reset(); }