From 0b870e2b4991f7cb07a959f934b30ab3c3bec69e Mon Sep 17 00:00:00 2001 From: ZizzyDizzyMC Date: Thu, 15 Oct 2015 21:20:29 -0400 Subject: [PATCH 1/2] Proxy Setting addition. Added 'loginonlyproxy' option with true / false boolean options. on 'true' only the minecraft login is redirected to the proxy. Otherwise both the login and the server connection are routed though the chosen proxy. Provides a semi-workaround to issues #89 and #80 on ORelio/Indev --- MinecraftClient/McTcpClient.cs | 9 ++++++++- MinecraftClient/Settings.cs | 4 +++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/MinecraftClient/McTcpClient.cs b/MinecraftClient/McTcpClient.cs index 0817755c..53e5965f 100644 --- a/MinecraftClient/McTcpClient.cs +++ b/MinecraftClient/McTcpClient.cs @@ -111,7 +111,14 @@ namespace MinecraftClient try { - client = ProxyHandler.newTcpClient(host, port); + if (Settings.LoginOnlyProxy = true) + { + client = new TcpClient(host, port); + } + else + { + client = ProxyHandler.newTcpClient(host, port); + } client.ReceiveBufferSize = 1024 * 1024; handler = Protocol.ProtocolHandler.getProtocolHandler(client, protocolversion, this); Console.WriteLine("Version is supported.\nLogging in..."); diff --git a/MinecraftClient/Settings.cs b/MinecraftClient/Settings.cs index 93beb6a8..5defadef 100644 --- a/MinecraftClient/Settings.cs +++ b/MinecraftClient/Settings.cs @@ -32,6 +32,7 @@ namespace MinecraftClient public static Proxy.ProxyHandler.Type proxyType = Proxy.ProxyHandler.Type.HTTP; public static string ProxyUsername = ""; public static string ProxyPassword = ""; + public static bool LoginOnlyProxy = false; //Other Settings public static string TranslationsFile_FromMCDir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\.minecraft\assets\objects\9e\9e2fdc43fc1c7024ff5922b998fadb2971a64ee0"; //MC 1.7.4 en_GB.lang @@ -290,7 +291,6 @@ namespace MinecraftClient case "enabled": RemoteCtrl_Enabled = str2bool(argValue); break; case "autotpaccept": RemoteCtrl_AutoTpaccept = str2bool(argValue); break; case "tpaccepteveryone": RemoteCtrl_AutoTpaccept_Everyone = str2bool(argValue); break; - case "herochatmessagesenabled": Hero_Chat_Messages_Enabled = str2bool(argValue); break; } break; @@ -308,6 +308,7 @@ namespace MinecraftClient switch (argName.ToLower()) { case "enabled": ProxyEnabled = str2bool(argValue); break; + case "loginonlyproxy": LoginOnlyProxy = str2bool(argValue); break; case "type": argValue = argValue.ToLower(); if (argValue == "http") { proxyType = Proxy.ProxyHandler.Type.HTTP; } @@ -402,6 +403,7 @@ namespace MinecraftClient + "server=0.0.0.0:0000\r\n" + "username=\r\n" + "password=\r\n" + + "loginonlyproxy=false # Change this to \"true\" if you only want to use a proxy for login." + "\r\n" + "#Bot Settings\r\n" + "\r\n" From a65e6325228149f2ee5e64051fdd60b0c2ea421c Mon Sep 17 00:00:00 2001 From: ZizzyDizzyMC Date: Fri, 16 Oct 2015 04:50:56 -0400 Subject: [PATCH 2/2] Fixed some things about pull request 99. Changed LoginOnlyProxy to OnlyForLogin in settings, changed McTcpClient so I was not using assignment operator. (Was a mistake anyway.) --- MinecraftClient/McTcpClient.cs | 2 +- MinecraftClient/Settings.cs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/MinecraftClient/McTcpClient.cs b/MinecraftClient/McTcpClient.cs index 53e5965f..41312158 100644 --- a/MinecraftClient/McTcpClient.cs +++ b/MinecraftClient/McTcpClient.cs @@ -111,7 +111,7 @@ namespace MinecraftClient try { - if (Settings.LoginOnlyProxy = true) + if (Settings.OnlyForLogin) { client = new TcpClient(host, port); } diff --git a/MinecraftClient/Settings.cs b/MinecraftClient/Settings.cs index 5defadef..b005e90c 100644 --- a/MinecraftClient/Settings.cs +++ b/MinecraftClient/Settings.cs @@ -32,7 +32,7 @@ namespace MinecraftClient public static Proxy.ProxyHandler.Type proxyType = Proxy.ProxyHandler.Type.HTTP; public static string ProxyUsername = ""; public static string ProxyPassword = ""; - public static bool LoginOnlyProxy = false; + public static bool OnlyForLogin = false; //Other Settings public static string TranslationsFile_FromMCDir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\.minecraft\assets\objects\9e\9e2fdc43fc1c7024ff5922b998fadb2971a64ee0"; //MC 1.7.4 en_GB.lang @@ -308,7 +308,7 @@ namespace MinecraftClient switch (argName.ToLower()) { case "enabled": ProxyEnabled = str2bool(argValue); break; - case "loginonlyproxy": LoginOnlyProxy = str2bool(argValue); break; + case "onlyforlogin": OnlyForLogin = str2bool(argValue); break; case "type": argValue = argValue.ToLower(); if (argValue == "http") { proxyType = Proxy.ProxyHandler.Type.HTTP; } @@ -403,7 +403,7 @@ namespace MinecraftClient + "server=0.0.0.0:0000\r\n" + "username=\r\n" + "password=\r\n" - + "loginonlyproxy=false # Change this to \"true\" if you only want to use a proxy for login." + + "onlyforlogin=false # Change this to \"true\" if you only want to use a proxy for login." + "\r\n" + "#Bot Settings\r\n" + "\r\n"