diff --git a/FWManager.cs b/FWManager.cs index be9e640..1cd2337 100644 --- a/FWManager.cs +++ b/FWManager.cs @@ -22,6 +22,8 @@ public class FWManager public string chat_ip = string.Empty; + public string chat_dom = string.Empty; + public string RunAction(string strCmdText) { @@ -60,8 +62,10 @@ public void blockLOL() if (str.Contains("LeftSpace_LolOfflineMode")) { + LDebug.WriteLine("Chat endpoint already blocked"); - return; + unblockLOL(); + } diff --git a/LChatHelper.cs b/LChatHelper.cs index 0d93bb1..5c1691e 100644 --- a/LChatHelper.cs +++ b/LChatHelper.cs @@ -14,6 +14,21 @@ namespace LeagueOFFLINE public class LChatHelper { + public static List servers = new List() + { + "tr1.chat.si.riotgames.com", + "br.chat.si.riotgames.com", + "eun1.chat.si.riotgames.com", + "euw1.chat.si.riotgames.com", + "jp1.chat.si.riotgames.com", + "la1.chat.si.riotgames.com", + "la2.chat.si.riotgames.com", + "na2.chat.si.riotgames.com", + "oc1.chat.si.riotgames.com", + "ru1.chat.si.riotgames.com", + "na2.chat.si.riotgames.com" + }; + public string lolPath = @"C:\Riot Games\League of Legends\"; public string GetLOLPath() { @@ -43,6 +58,7 @@ public string GetLOLPath() public void Init() { + lolPath = GetLOLPath(); if (!Directory.Exists(lolPath)) { LDebug.WriteLine("Trying get LOL Path"); @@ -55,56 +71,12 @@ public void Init() } } - public string GetLog() - { - var defaultPath = Path.Combine(lolPath, @"Logs\LeagueClient Logs"); ; - var dir = Directory.GetFiles(defaultPath, "*_LeagueClient.log"); - var mlog = ""; - var ltime = TimeSpan.MaxValue; - foreach (var d in dir) - { - var curDelta = ltime.Subtract(new TimeSpan(File.GetLastAccessTime(d).Ticks)); - if (curDelta < ltime) - { - ltime = curDelta; - mlog = d; - } - } - if (string.IsNullOrEmpty(mlog)) - throw new ArgumentException("empty string", "mlog"); - - return mlog; - } - 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"); - - } + public string GetIPFromDomain() { try { - var dns = Dns.GetHostAddresses(GetChatDomain()).FirstOrDefault(); + var dns = Dns.GetHostAddresses(Globals.fw.chat_dom).FirstOrDefault(); if (dns != null) return dns.ToString(); } @@ -115,29 +87,7 @@ public string GetIPFromDomain() throw new ArgumentException("ip null", "ping"); } - 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"); - } + } } diff --git a/LSLolOffline.Designer.cs b/LSLolOffline.Designer.cs index 28349b0..3e206db 100644 --- a/LSLolOffline.Designer.cs +++ b/LSLolOffline.Designer.cs @@ -28,86 +28,78 @@ protected override void Dispose(bool disposing) /// private void InitializeComponent() { - this.pathText = new System.Windows.Forms.TextBox(); - this.lblPath = new System.Windows.Forms.Label(); this.switchButton = new System.Windows.Forms.Button(); - this.statusStrip1 = new System.Windows.Forms.StatusStrip(); - this.toolStripStatusLabel1 = new System.Windows.Forms.ToolStripStatusLabel(); - this.statusStrip1.SuspendLayout(); + this.srvLabel = new System.Windows.Forms.Label(); + this.srvbox = new System.Windows.Forms.ComboBox(); this.SuspendLayout(); // - // pathText - // - this.pathText.Location = new System.Drawing.Point(50, 98); - this.pathText.Name = "pathText"; - this.pathText.ReadOnly = true; - this.pathText.Size = new System.Drawing.Size(252, 20); - this.pathText.TabIndex = 0; - // - // lblPath - // - this.lblPath.AutoSize = true; - this.lblPath.Location = new System.Drawing.Point(12, 101); - this.lblPath.Name = "lblPath"; - this.lblPath.Size = new System.Drawing.Size(32, 13); - this.lblPath.TabIndex = 1; - this.lblPath.Text = "Path:"; - // // switchButton // - this.switchButton.Location = new System.Drawing.Point(68, 23); + this.switchButton.Location = new System.Drawing.Point(231, 12); this.switchButton.Name = "switchButton"; - this.switchButton.Size = new System.Drawing.Size(173, 55); + this.switchButton.Size = new System.Drawing.Size(82, 44); this.switchButton.TabIndex = 2; this.switchButton.Text = "Switch Offline"; this.switchButton.UseVisualStyleBackColor = true; this.switchButton.Click += new System.EventHandler(this.switchButton_Click); // - // statusStrip1 + // srvLabel // - this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.toolStripStatusLabel1}); - this.statusStrip1.Location = new System.Drawing.Point(0, 131); - this.statusStrip1.Name = "statusStrip1"; - this.statusStrip1.Size = new System.Drawing.Size(311, 22); - this.statusStrip1.TabIndex = 4; - this.statusStrip1.Text = "statusStrip1"; + this.srvLabel.AutoSize = true; + this.srvLabel.Location = new System.Drawing.Point(12, 28); + this.srvLabel.Name = "srvLabel"; + this.srvLabel.Size = new System.Drawing.Size(41, 13); + this.srvLabel.TabIndex = 3; + this.srvLabel.Text = "Server:"; // - // toolStripStatusLabel1 + // srvbox // - this.toolStripStatusLabel1.Name = "toolStripStatusLabel1"; - this.toolStripStatusLabel1.Size = new System.Drawing.Size(66, 17); - this.toolStripStatusLabel1.Text = "statusLabel"; + this.srvbox.BackColor = System.Drawing.SystemColors.ActiveCaptionText; + this.srvbox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.srvbox.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.srvbox.ForeColor = System.Drawing.SystemColors.InactiveCaptionText; + this.srvbox.FormattingEnabled = true; + this.srvbox.Items.AddRange(new object[] { + "tr1.chat.si.riotgames.com", + "br.chat.si.riotgames.com", + "eun1.chat.si.riotgames.com", + "euw1.chat.si.riotgames.com", + "jp1.chat.si.riotgames.com", + "la1.chat.si.riotgames.com", + "la2.chat.si.riotgames.com", + "na2.chat.si.riotgames.com", + "oc1.chat.si.riotgames.com", + "ru1.chat.si.riotgames.com", + "na2.chat.si.riotgames.com"}); + this.srvbox.Location = new System.Drawing.Point(59, 25); + this.srvbox.Name = "srvbox"; + this.srvbox.Size = new System.Drawing.Size(158, 21); + this.srvbox.TabIndex = 4; + this.srvbox.SelectedIndexChanged += new System.EventHandler(this.srvbox_SelectedIndexChanged); // // LSLolOffline // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(311, 153); - this.Controls.Add(this.statusStrip1); + this.ClientSize = new System.Drawing.Size(325, 68); + this.Controls.Add(this.srvbox); + this.Controls.Add(this.srvLabel); this.Controls.Add(this.switchButton); - this.Controls.Add(this.lblPath); - this.Controls.Add(this.pathText); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow; this.MaximizeBox = false; this.Name = "LSLolOffline"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "LOFFLINE By LeftSpace"; this.Load += new System.EventHandler(this.LSLolOffline_Load); - this.statusStrip1.ResumeLayout(false); - this.statusStrip1.PerformLayout(); this.ResumeLayout(false); this.PerformLayout(); } #endregion - - private System.Windows.Forms.TextBox pathText; - private System.Windows.Forms.Label lblPath; private System.Windows.Forms.Button switchButton; - private System.Windows.Forms.StatusStrip statusStrip1; - private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel1; + private System.Windows.Forms.Label srvLabel; + private System.Windows.Forms.ComboBox srvbox; } } diff --git a/LSLolOffline.cs b/LSLolOffline.cs index 27eabb5..4215257 100644 --- a/LSLolOffline.cs +++ b/LSLolOffline.cs @@ -24,8 +24,8 @@ private void switchButton_Click(object sender, EventArgs e) try { - - if (Globals.fw.isBlocked()) + var isBlocked = Globals.fw.isBlocked(); + if (isBlocked) { Globals.fw.unblockLOL(); } @@ -33,9 +33,9 @@ private void switchButton_Click(object sender, EventArgs e) { Globals.fw.blockLOL(); } + - UpdateState(); - + UpdateState(!isBlocked); } catch (Exception ex) @@ -44,36 +44,18 @@ private void switchButton_Click(object sender, EventArgs e) } } - private void UpdateState() - { - - - if (Globals.fw.isBlocked()) - { - switchButton.Text = "Switch to Online"; - toolStripStatusLabel1.Text = "[OFFLINE MODE]"; - statusStrip1.ForeColor = Color.DarkRed; - } - else - { - switchButton.Text = "Switch to Offline"; - toolStripStatusLabel1.Text = "[ONLINE MODE]"; - statusStrip1.ForeColor = Color.DarkGreen; - - } - } + private void LSLolOffline_Load(object sender, EventArgs e) { try { + srvbox.SelectedIndex = 0; + Globals.lc.Init(); Globals.fw.chat_ip = Globals.lc.GetIPFromDomain(); Globals.fw.test(); - - pathText.Text = Globals.lc.lolPath; - UpdateState(); - + } catch(Exception ex) @@ -81,5 +63,36 @@ private void LSLolOffline_Load(object sender, EventArgs e) Console.WriteLine(ex.ToString()); } } + + private void pathText_TextChanged(object sender, EventArgs e) + { + + } + + private void UpdateState(bool isBlocked) + { + if (isBlocked) + { + switchButton.Text = "Switch to Online"; + } + else + { + switchButton.Text = "Switch to Offline"; + } + + srvbox.ForeColor = isBlocked ? System.Drawing.Color.Red : System.Drawing.Color.Green; + } + private void srvbox_SelectedIndexChanged(object sender, EventArgs e) + { + + Globals.fw.chat_dom = srvbox.Items[srvbox.SelectedIndex].ToString(); + + var isBlocked = Globals.fw.isBlocked(); + srvLabel.Focus(); + UpdateState(isBlocked); + + + + } } } diff --git a/LSLolOffline.resx b/LSLolOffline.resx index 174ebc7..1af7de1 100644 --- a/LSLolOffline.resx +++ b/LSLolOffline.resx @@ -117,7 +117,4 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - 17, 17 - \ No newline at end of file diff --git a/bin/Debug/LeagueOFFLINE.exe.config b/bin/Debug/LeagueOFFLINE.exe.config new file mode 100644 index 0000000..731f6de --- /dev/null +++ b/bin/Debug/LeagueOFFLINE.exe.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/bin/Debug/Log.txt b/bin/Debug/Log.txt new file mode 100644 index 0000000..d5c3572 --- /dev/null +++ b/bin/Debug/Log.txt @@ -0,0 +1,2 @@ +Chat endpoint already blocked +Chat endpoint already blocked diff --git a/bin/Release/LeagueOFFLINE.exe.config b/bin/Release/LeagueOFFLINE.exe.config new file mode 100644 index 0000000..731f6de --- /dev/null +++ b/bin/Release/LeagueOFFLINE.exe.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/obj/Debug/LeagueOFFLINE.LSLolOffline.resources b/obj/Debug/LeagueOFFLINE.LSLolOffline.resources new file mode 100644 index 0000000..6c05a97 Binary files /dev/null and b/obj/Debug/LeagueOFFLINE.LSLolOffline.resources differ diff --git a/obj/Debug/LeagueOFFLINE.Properties.Resources.resources b/obj/Debug/LeagueOFFLINE.Properties.Resources.resources new file mode 100644 index 0000000..6c05a97 Binary files /dev/null and b/obj/Debug/LeagueOFFLINE.Properties.Resources.resources differ diff --git a/obj/Debug/LeagueOFFLINE.csproj.FileListAbsolute.txt b/obj/Debug/LeagueOFFLINE.csproj.FileListAbsolute.txt new file mode 100644 index 0000000..141f4f6 --- /dev/null +++ b/obj/Debug/LeagueOFFLINE.csproj.FileListAbsolute.txt @@ -0,0 +1,10 @@ +C:\Users\ZwRaidMode\source\repos\LolOfflineMode\LolOfflineMode\bin\Debug\LeagueOFFLINE.exe.config +C:\Users\ZwRaidMode\source\repos\LolOfflineMode\LolOfflineMode\bin\Debug\LeagueOFFLINE.exe +C:\Users\ZwRaidMode\source\repos\LolOfflineMode\LolOfflineMode\bin\Debug\LeagueOFFLINE.pdb +C:\Users\ZwRaidMode\source\repos\LolOfflineMode\LolOfflineMode\obj\Debug\LeagueOFFLINE.LSLolOffline.resources +C:\Users\ZwRaidMode\source\repos\LolOfflineMode\LolOfflineMode\obj\Debug\LeagueOFFLINE.Properties.Resources.resources +C:\Users\ZwRaidMode\source\repos\LolOfflineMode\LolOfflineMode\obj\Debug\LeagueOFFLINE.csproj.GenerateResource.cache +C:\Users\ZwRaidMode\source\repos\LolOfflineMode\LolOfflineMode\obj\Debug\LeagueOFFLINE.csproj.CoreCompileInputs.cache +C:\Users\ZwRaidMode\source\repos\LolOfflineMode\LolOfflineMode\obj\Debug\LeagueOFFLINE.exe +C:\Users\ZwRaidMode\source\repos\LolOfflineMode\LolOfflineMode\obj\Debug\LeagueOFFLINE.pdb +C:\Users\ZwRaidMode\source\repos\LolOfflineMode\LolOfflineMode\obj\Debug\LeagueOFFLINE.csprojAssemblyReference.cache diff --git a/obj/Release/LeagueOFFLINE.LSLolOffline.resources b/obj/Release/LeagueOFFLINE.LSLolOffline.resources new file mode 100644 index 0000000..6c05a97 Binary files /dev/null and b/obj/Release/LeagueOFFLINE.LSLolOffline.resources differ diff --git a/obj/Release/LeagueOFFLINE.Properties.Resources.resources b/obj/Release/LeagueOFFLINE.Properties.Resources.resources new file mode 100644 index 0000000..6c05a97 Binary files /dev/null and b/obj/Release/LeagueOFFLINE.Properties.Resources.resources differ diff --git a/obj/Release/LeagueOFFLINE.csproj.FileListAbsolute.txt b/obj/Release/LeagueOFFLINE.csproj.FileListAbsolute.txt new file mode 100644 index 0000000..fab2300 --- /dev/null +++ b/obj/Release/LeagueOFFLINE.csproj.FileListAbsolute.txt @@ -0,0 +1,10 @@ +C:\Users\ZwRaidMode\source\repos\LolOfflineMode\LolOfflineMode\bin\Release\LeagueOFFLINE.exe.config +C:\Users\ZwRaidMode\source\repos\LolOfflineMode\LolOfflineMode\bin\Release\LeagueOFFLINE.exe +C:\Users\ZwRaidMode\source\repos\LolOfflineMode\LolOfflineMode\bin\Release\LeagueOFFLINE.pdb +C:\Users\ZwRaidMode\source\repos\LolOfflineMode\LolOfflineMode\obj\Release\LeagueOFFLINE.LSLolOffline.resources +C:\Users\ZwRaidMode\source\repos\LolOfflineMode\LolOfflineMode\obj\Release\LeagueOFFLINE.Properties.Resources.resources +C:\Users\ZwRaidMode\source\repos\LolOfflineMode\LolOfflineMode\obj\Release\LeagueOFFLINE.csproj.GenerateResource.cache +C:\Users\ZwRaidMode\source\repos\LolOfflineMode\LolOfflineMode\obj\Release\LeagueOFFLINE.csproj.CoreCompileInputs.cache +C:\Users\ZwRaidMode\source\repos\LolOfflineMode\LolOfflineMode\obj\Release\LeagueOFFLINE.exe +C:\Users\ZwRaidMode\source\repos\LolOfflineMode\LolOfflineMode\obj\Release\LeagueOFFLINE.pdb +C:\Users\ZwRaidMode\source\repos\LolOfflineMode\LolOfflineMode\obj\Release\LeagueOFFLINE.csprojAssemblyReference.cache diff --git a/obj/Release/Log.txt b/obj/Release/Log.txt new file mode 100644 index 0000000..1bdb7e9 --- /dev/null +++ b/obj/Release/Log.txt @@ -0,0 +1,4 @@ +System.ArgumentException: failed to read client log +Parametre adı: IPRegex + konum: LeagueOFFLINE.LChatHelper.GetChatDomain() C:\Users\ZwRaidMode\source\repos\LolOfflineMode\LolOfflineMode\LChatHelper.cs içinde: satır 139 + konum: LeagueOFFLINE.LChatHelper.GetIPFromDomain() C:\Users\ZwRaidMode\source\repos\LolOfflineMode\LolOfflineMode\LChatHelper.cs içinde: satır 107