public void test() { var str = RunAction("advfirewall show allprofiles state"); if (str.Contains("OFF")) { LDebug.WriteLine("Firewall is not enabled"); MessageBox.Show("Firewall is not enabled please enable your firewall"); Environment.Exit(0); return; } }
public void Init() { if (!Directory.Exists(lolPath)) { LDebug.WriteLine("Trying get LOL Path"); lolPath = GetLOLPath(); } if (!Directory.Exists(lolPath)) { LDebug.WriteLine("can't get LOL Path"); } }
public string GetIPFromDomain() { try { var dns = Dns.GetHostAddresses(GetChatDomain()).FirstOrDefault(); if (dns != null) { return(dns.ToString()); } } catch (Exception ex) { LDebug.WriteLine(ex.ToString()); } throw new ArgumentException("ip null", "ping"); }
public void blockLOL() { if (string.IsNullOrEmpty(chat_ip) || string.IsNullOrWhiteSpace(chat_ip)) { throw new ArgumentException("empty or null", "chat_ip"); } var str = RunAction("advfirewall firewall show rule name=all"); if (str.Contains("LeftSpace_LolOfflineMode")) { LDebug.WriteLine("Chat endpoint already blocked"); unblockLOL(); } string strCmdText = $"advfirewall firewall add rule name=\"LeftSpace_LolOfflineMode\" dir=out remoteip={chat_ip} protocol=any action=block"; RunAction(strCmdText); }
public string GetChatDomain() { try { string pattern = @"rcp-be-lol-chat\| Chat configured to (.*):5223"; var content = ReadClientLog().Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries).Where(x => x.Contains("rcp-be-lol-chat")); foreach (var s in content) { var IPRegex = Regex.Match(s, pattern); if (IPRegex.Success) { return(IPRegex.Groups[1].Value.ToString()); } } } catch (Exception ex) { LDebug.WriteLine(ex.ToString()); } throw new ArgumentException("failed to read client log", "IPRegex"); }
public string GetLOLPath() { try { var p = Process.GetProcessesByName("LeagueClient").FirstOrDefault(); if (p != null) { return(Path.GetDirectoryName(p.MainModule.FileName)); } if (p == null) { MessageBox.Show("Please run league client before start application"); Environment.Exit(0); } } catch (Exception ex) { LDebug.WriteLine(ex.ToString()); } return(string.Empty); }
public string ReadClientLog() { try { var path = GetLog(); using (FileStream fileStream = new FileStream( path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) { using (StreamReader streamReader = new StreamReader(fileStream)) { return(streamReader.ReadToEnd()); } } } catch (Exception ex) { LDebug.WriteLine(ex.ToString()); } throw new ArgumentException("failed to read client log", "streamReader"); }