add proxy checking thingy
This commit is contained in:
parent
a71351177b
commit
ceb5b8f2b3
96038
javascript/classes.js
96038
javascript/classes.js
File diff suppressed because it is too large
Load Diff
|
@ -1,5 +1,7 @@
|
||||||
package net.lax1dude.eaglercraft;
|
package net.lax1dude.eaglercraft;
|
||||||
|
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
public class ConfigConstants {
|
public class ConfigConstants {
|
||||||
|
|
||||||
public static boolean profanity = false;
|
public static boolean profanity = false;
|
||||||
|
@ -11,4 +13,14 @@ public class ConfigConstants {
|
||||||
|
|
||||||
public static final boolean html5build = true;
|
public static final boolean html5build = true;
|
||||||
|
|
||||||
|
public static String[] proxies = new String[]{"pproxy.rom1504.fr","webmcproxy.glitch.me"};
|
||||||
|
|
||||||
|
public static Pattern ipPattern = Pattern.compile("^"
|
||||||
|
+ "(((?!-)[A-Za-z0-9-]{1,63}(?<!-)\\.)+[A-Za-z]{2,6}" // Domain name
|
||||||
|
+ "|"
|
||||||
|
+ "localhost" // localhost
|
||||||
|
+ "|"
|
||||||
|
+ "(([0-9]{1,3}\\.){3})[0-9]{1,3})" // Ip
|
||||||
|
+ "(:"
|
||||||
|
+ "[0-9]{1,5})?$"); // Port
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,12 @@ import net.minecraft.src.GuiTextField;
|
||||||
import net.minecraft.src.NBTTagCompound;
|
import net.minecraft.src.NBTTagCompound;
|
||||||
import net.minecraft.src.StringTranslate;
|
import net.minecraft.src.StringTranslate;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.net.HttpURLConnection;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.net.URLConnection;
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
public class GuiScreenEditProfile extends GuiScreen {
|
public class GuiScreenEditProfile extends GuiScreen {
|
||||||
|
|
||||||
private GuiScreen parent;
|
private GuiScreen parent;
|
||||||
|
@ -22,6 +28,8 @@ public class GuiScreenEditProfile extends GuiScreen {
|
||||||
private int mousex = 0;
|
private int mousex = 0;
|
||||||
private int mousey = 0;
|
private int mousey = 0;
|
||||||
|
|
||||||
|
private int proxyInvalid = 0;
|
||||||
|
|
||||||
private static final TextureLocation gui = new TextureLocation("/gui/gui.png");
|
private static final TextureLocation gui = new TextureLocation("/gui/gui.png");
|
||||||
|
|
||||||
public static final String[] defaultOptions = new String[] {
|
public static final String[] defaultOptions = new String[] {
|
||||||
|
@ -92,6 +100,10 @@ public class GuiScreenEditProfile extends GuiScreen {
|
||||||
public void drawScreen(int mx, int my, float par3) {
|
public void drawScreen(int mx, int my, float par3) {
|
||||||
StringTranslate var1 = StringTranslate.getInstance();
|
StringTranslate var1 = StringTranslate.getInstance();
|
||||||
this.drawDefaultBackground();
|
this.drawDefaultBackground();
|
||||||
|
if(proxyInvalid>0){
|
||||||
|
--proxyInvalid;
|
||||||
|
this.drawCenteredString(this.fontRenderer, "error: proxy is invalid! switching proxy... (if it fails too often, backspace out the proxy)", this.width / 2, 5, 16777215);
|
||||||
|
}
|
||||||
this.drawCenteredString(this.fontRenderer, this.screenTitle, this.width / 2, 15, 16777215);
|
this.drawCenteredString(this.fontRenderer, this.screenTitle, this.width / 2, 15, 16777215);
|
||||||
this.drawString(this.fontRenderer, var1.translateKey("profile.screenname"), this.width / 2 - 20, this.height / 6 + 8, 10526880);
|
this.drawString(this.fontRenderer, var1.translateKey("profile.screenname"), this.width / 2 - 20, this.height / 6 + 8, 10526880);
|
||||||
this.drawString(this.fontRenderer, var1.translateKey("profile.playerSkin"), this.width / 2 - 20, this.height / 6 + 66, 10526880);
|
this.drawString(this.fontRenderer, var1.translateKey("profile.playerSkin"), this.width / 2 - 20, this.height / 6 + 66, 10526880);
|
||||||
|
@ -189,6 +201,33 @@ public class GuiScreenEditProfile extends GuiScreen {
|
||||||
if(par1GuiButton.id == 200) {
|
if(par1GuiButton.id == 200) {
|
||||||
EaglerProfile.username = this.username.getText().length() == 0 ? "null" : this.username.getText();
|
EaglerProfile.username = this.username.getText().length() == 0 ? "null" : this.username.getText();
|
||||||
this.mc.gameSettings.proxy=proxy.getText();
|
this.mc.gameSettings.proxy=proxy.getText();
|
||||||
|
|
||||||
|
//check proxy
|
||||||
|
if(!this.mc.gameSettings.proxy.equals("")) {
|
||||||
|
proxyInvalid=0;
|
||||||
|
this.drawCenteredString(this.fontRenderer, "checking proxy...", this.width / 2, 5, 16777215);
|
||||||
|
try {
|
||||||
|
if(!ConfigConstants.ipPattern.matcher(this.mc.gameSettings.proxy).matches())throw new IOException("lol");
|
||||||
|
URL url = new URL("http" + (EaglerAdapter.isSSLPage() ? "s" : "") + "://" + this.mc.gameSettings.proxy + "/api/vm/net/connect");
|
||||||
|
URLConnection con = url.openConnection();
|
||||||
|
HttpURLConnection http = (HttpURLConnection) con;
|
||||||
|
http.connect();
|
||||||
|
if(http.getResponseCode()!=HttpURLConnection.HTTP_OK&&http.getResponseCode()!=HttpURLConnection.HTTP_NOT_FOUND){
|
||||||
|
http.disconnect();
|
||||||
|
throw new IOException("lol");
|
||||||
|
}
|
||||||
|
http.disconnect();
|
||||||
|
} catch (IOException e) {
|
||||||
|
//change proxy and then do nothing else if it fails
|
||||||
|
this.mc.gameSettings.proxy=this.mc.gameSettings.getNewProxy();
|
||||||
|
proxy.setText(this.mc.gameSettings.proxy);
|
||||||
|
proxyInvalid = 300;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
EaglerProfile.presetSkinId = selectedSlot - EaglerProfile.skinNames.size();
|
EaglerProfile.presetSkinId = selectedSlot - EaglerProfile.skinNames.size();
|
||||||
if(EaglerProfile.presetSkinId < 0) {
|
if(EaglerProfile.presetSkinId < 0) {
|
||||||
EaglerProfile.presetSkinId = -1;
|
EaglerProfile.presetSkinId = -1;
|
||||||
|
|
|
@ -1,13 +1,21 @@
|
||||||
package net.minecraft.src;
|
package net.minecraft.src;
|
||||||
|
|
||||||
|
import net.lax1dude.eaglercraft.ConfigConstants;
|
||||||
import net.lax1dude.eaglercraft.EaglerAdapter;
|
import net.lax1dude.eaglercraft.EaglerAdapter;
|
||||||
import net.lax1dude.eaglercraft.EaglercraftRandom;
|
|
||||||
import net.lax1dude.eaglercraft.LocalStorageManager;
|
import net.lax1dude.eaglercraft.LocalStorageManager;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
|
|
||||||
public class GameSettings {
|
public class GameSettings {
|
||||||
public static boolean useDefaultProtocol = true;
|
public static boolean useDefaultProtocol = true;
|
||||||
public static String proxy = (new String[]{"pproxy.rom1504.fr","webmcproxy.glitch.me"})[(int)Math.floor(Math.random()*2)];
|
public static String proxy = "";
|
||||||
|
public static String getNewProxy(){
|
||||||
|
String res=proxy;
|
||||||
|
while(res.equals(proxy)) res = ConfigConstants.proxies[(int) Math.floor(Math.random() * 2)];
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
static {
|
||||||
|
proxy = getNewProxy();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private static final String[] RENDER_DISTANCES = new String[] { "options.renderDistance.far", "options.renderDistance.normal", "options.renderDistance.short", "options.renderDistance.tiny" };
|
private static final String[] RENDER_DISTANCES = new String[] { "options.renderDistance.far", "options.renderDistance.normal", "options.renderDistance.short", "options.renderDistance.tiny" };
|
||||||
|
|
|
@ -31,15 +31,6 @@ public class WebsocketNetworkManager implements INetworkManager {
|
||||||
|
|
||||||
private NetHandler netHandler;
|
private NetHandler netHandler;
|
||||||
|
|
||||||
Pattern ipPattern = Pattern.compile("^"
|
|
||||||
+ "(((?!-)[A-Za-z0-9-]{1,63}(?<!-)\\.)+[A-Za-z]{2,6}" // Domain name
|
|
||||||
+ "|"
|
|
||||||
+ "localhost" // localhost
|
|
||||||
+ "|"
|
|
||||||
+ "(([0-9]{1,3}\\.){3})[0-9]{1,3})" // Ip
|
|
||||||
+ "(:"
|
|
||||||
+ "[0-9]{1,5})?$"); // Port
|
|
||||||
|
|
||||||
public WebsocketNetworkManager(String uri, String eagler, NetHandler netHandler) throws IOException {
|
public WebsocketNetworkManager(String uri, String eagler, NetHandler netHandler) throws IOException {
|
||||||
this.netHandler = netHandler;
|
this.netHandler = netHandler;
|
||||||
this.sharedKeyForEncryption = null;
|
this.sharedKeyForEncryption = null;
|
||||||
|
@ -49,7 +40,7 @@ public class WebsocketNetworkManager implements INetworkManager {
|
||||||
boolean stillConnect=true;
|
boolean stillConnect=true;
|
||||||
if(!proxyUrl.equals("")&&!uri.contains("/")){
|
if(!proxyUrl.equals("")&&!uri.contains("/")){
|
||||||
stillConnect=false;
|
stillConnect=false;
|
||||||
if (ipPattern.matcher(proxyUrl).matches()&&ipPattern.matcher(uri).matches()) {
|
if (ConfigConstants.ipPattern.matcher(proxyUrl).matches()&&ConfigConstants.ipPattern.matcher(uri).matches()) {
|
||||||
String ip = uri;
|
String ip = uri;
|
||||||
String port = "25565";
|
String port = "25565";
|
||||||
if (uri.contains(":")) {
|
if (uri.contains(":")) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user