private void ReadMSnifferFile(string filename) { SessionForm currentSession = null; Regex captureRegex = new Regex(@"MapleStory ([^\(]+)\(版本([0-9\.]+)\).*"); using (StreamReader sr = new StreamReader(filename)) { while (!sr.EndOfStream) { string line = sr.ReadLine(); if (line == "") { continue; } if (line[0] == '1') { // Most likely capturing text var matches = captureRegex.Match(line); if (matches.Captures.Count == 0) { continue; } Console.WriteLine("Version: {1} : {0} ", matches.Groups[2].Value, matches.Groups[1].Value); if (currentSession != null) { currentSession.Show(mDockPanel, DockState.Document); } currentSession = NewSession(); currentSession.SetMapleInfo((ushort)(double.Parse(matches.Groups[2].Value)), "", 8, matches.Groups[2].Value, 0); } //else if (line[0] == '[' && currentSession != null) else if (currentSession != null) { currentSession.ParseMSnifferLine(line); } } } if (currentSession != null) { currentSession.Show(mDockPanel, DockState.Document); } }
private void ReadMSnifferFile(string filename) { SessionForm currentSession = null; Regex captureRegex = new Regex(@"Capturing MapleStory version (\d+) on ([0-9\.]+):(\d+) with unknown ""(.*)"".*"); using (StreamReader sr = new StreamReader(filename)) { while (!sr.EndOfStream) { string line = sr.ReadLine(); if (line == "" || (line[0] != '[' && line[0] != 'C')) { continue; } if (line[0] == 'C') { // Most likely capturing text var matches = captureRegex.Match(line); if (matches.Captures.Count == 0) { continue; } Console.WriteLine("Version: {0}.{1} IP {2} Port {3}", matches.Groups[1].Value, matches.Groups[4].Value, matches.Groups[2].Value, matches.Groups[3].Value); if (currentSession != null) { currentSession.Show(mDockPanel, DockState.Document); } currentSession = NewSession(); currentSession.SetMapleInfo(ushort.Parse(matches.Groups[1].Value), matches.Groups[4].Value, 8, matches.Groups[2].Value, ushort.Parse(matches.Groups[3].Value)); } else if (line[0] == '[' && currentSession != null) { currentSession.ParseMSnifferLine(line); } } } if (currentSession != null) { currentSession.Show(mDockPanel, DockState.Document); } }