proxy work + custom settings
This commit is contained in:
parent
a2e2ca0a5f
commit
62c1ae2f8b
34001
javascript/classes.js
34001
javascript/classes.js
File diff suppressed because it is too large
Load Diff
|
@ -15,8 +15,10 @@
|
|||
|
||||
<script type="text/javascript" src="music.js"></script>
|
||||
|
||||
<script type="text/javascript" src="classes.js?t=updateme5"></script>
|
||||
<script type="text/javascript" src="classes.js?t=updateme6"></script>
|
||||
<script type="text/javascript">
|
||||
//window.eag_self_proxy=true;//set to true to set the default proxy to the current url
|
||||
//window.eag_proxy_list="";//set to a string of comma-separated proxy ip:port combinations for a custom proxy list
|
||||
var name="PixelCraft",motd="A public 1.5.2 server",ip="pixelcraft.me";
|
||||
window.addEventListener("load", function(){
|
||||
document.requestPointerLock=document.requestPointerLock||function(){};
|
||||
|
|
|
@ -65,6 +65,7 @@ public class WebsocketNetworkManager implements INetworkManager {
|
|||
byte[] out = ("{\"port\":\""+port+"\",\"host\":\""+ip+"\"}").getBytes(StandardCharsets.UTF_8);
|
||||
http.setFixedLengthStreamingMode(out.length);
|
||||
http.setRequestProperty("Content-Type","application/json; charset=UTF-8");
|
||||
http.setConnectTimeout(5000);
|
||||
http.connect();
|
||||
http.getOutputStream().write(out);
|
||||
Reader in = new BufferedReader(new InputStreamReader(http.getInputStream(), "UTF-8"));
|
||||
|
|
|
@ -90,6 +90,19 @@ public class EaglerAdapterImpl2 {
|
|||
return "#version 150";
|
||||
}
|
||||
|
||||
public static final boolean getSelfProxy(){
|
||||
//todo: implement local proxy for desktop mode??
|
||||
return true;
|
||||
}
|
||||
|
||||
public static final String[] getCustomProxyList(){
|
||||
return new String[]{};
|
||||
}
|
||||
|
||||
public static final String getHostString(){
|
||||
return "localhost";
|
||||
}
|
||||
|
||||
public static final InputStream loadResource(String path) {
|
||||
byte[] file = loadResourceBytes(path);
|
||||
if (file != null) {
|
||||
|
|
|
@ -7,7 +7,7 @@ public class ConfigConstants {
|
|||
public static boolean profanity = false;
|
||||
|
||||
public static final String version = "22w04b";
|
||||
public static final String mainMenuString = "eaglercraft " + version;
|
||||
public static final String mainMenuString = "ayuncraft " + version;
|
||||
|
||||
public static final String forkMe = "https://github.com/ayunami2000/ayuncraft";
|
||||
|
||||
|
|
|
@ -6,7 +6,10 @@ import net.minecraft.src.GuiTextField;
|
|||
import net.minecraft.src.NBTTagCompound;
|
||||
import net.minecraft.src.StringTranslate;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.Reader;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
|
@ -211,8 +214,9 @@ public class GuiScreenEditProfile extends GuiScreen {
|
|||
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.setConnectTimeout(5000);
|
||||
http.connect();
|
||||
if(http.getResponseCode()!=HttpURLConnection.HTTP_OK&&http.getResponseCode()!=HttpURLConnection.HTTP_NOT_FOUND){
|
||||
if(http.getResponseCode()!=HttpURLConnection.HTTP_NOT_FOUND){
|
||||
http.disconnect();
|
||||
throw new IOException("lol");
|
||||
}
|
||||
|
|
|
@ -5,16 +5,22 @@ import net.lax1dude.eaglercraft.EaglerAdapter;
|
|||
import net.lax1dude.eaglercraft.LocalStorageManager;
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class GameSettings {
|
||||
public static boolean useDefaultProtocol = true;
|
||||
public static String proxy = "";
|
||||
public static String getNewProxy(){
|
||||
if(ConfigConstants.proxies.length==1)return ConfigConstants.proxies[0];
|
||||
String res=proxy;
|
||||
//inefficient but i dont care
|
||||
while(res.equals(proxy)) res = ConfigConstants.proxies[(int) Math.floor(Math.random() * ConfigConstants.proxies.length)];
|
||||
return res;
|
||||
}
|
||||
static {
|
||||
proxy = getNewProxy();
|
||||
String[] proxyList = EaglerAdapter.getCustomProxyList();
|
||||
if(proxyList.length!=0&&!proxyList[0].equals(""))ConfigConstants.proxies=proxyList;
|
||||
proxy = EaglerAdapter.getSelfProxy()?EaglerAdapter.getHostString():getNewProxy();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -57,6 +57,7 @@ public class WebsocketNetworkManager implements INetworkManager {
|
|||
byte[] out = ("{\"port\":\""+port+"\",\"host\":\""+ip+"\"}").getBytes(StandardCharsets.UTF_8);
|
||||
http.setFixedLengthStreamingMode(out.length);
|
||||
http.setRequestProperty("Content-Type","application/json; charset=UTF-8");
|
||||
http.setConnectTimeout(5000);
|
||||
http.connect();
|
||||
http.getOutputStream().write(out);
|
||||
Reader in = new BufferedReader(new InputStreamReader(http.getInputStream(), "UTF-8"));
|
||||
|
|
|
@ -84,6 +84,19 @@ public class EaglerAdapterImpl2 {
|
|||
return "#version 300 es";
|
||||
}
|
||||
|
||||
@JSBody(params = { }, script = "return !!window.eag_self_proxy;")
|
||||
public static native boolean getSelfProxy();
|
||||
|
||||
@JSBody(params = { }, script = "return (window.eag_proxy_list+\"\")||\"\";")
|
||||
private static native String getCustomProxyListString();
|
||||
|
||||
public static String[] getCustomProxyList(){
|
||||
return getCustomProxyListString().split(",");
|
||||
}
|
||||
|
||||
@JSBody(params = { }, script = "return window.location.host;")
|
||||
public static native String getHostString();
|
||||
|
||||
@JSBody(params = { }, script = "return window.location.href;")
|
||||
private static native String getLocationString();
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user