Improve nitro constants

This commit is contained in:
UnfamiliarLegacy 2021-11-26 18:33:38 +01:00
parent 7a635ffe6a
commit dd0312c020
6 changed files with 11 additions and 9 deletions

View File

@ -2,10 +2,12 @@ package gearth.protocol.connection.proxy.nitro;
public final class NitroConstants {
public static final int PORT_WEBSOCKET = 2096;
public static final int PORT_HTTP = 9090;
public static final int HTTP_PORT = 9090;
public static final int HTTP_BUFFER_SIZE = 1024 * 1024 * 10;
public static final int WEBSOCKET_PORT = 2096;
public static final int WEBSOCKET_BUFFER_SIZE = 1024 * 1024 * 10;
public static final String WEBSOCKET_REVISION = "PRODUCTION-201611291003-338511768";
public static final String WEBSOCKET_CLIENT_IDENTIFIER = "HTML5";
}

View File

@ -79,7 +79,7 @@ public class NitroProxyProvider implements ProxyProvider, NitroHttpProxyServerCa
@Override
public String replaceWebsocketServer(String configUrl, String websocketUrl) {
originalWebsocketUrl = websocketUrl;
return String.format("ws://127.0.0.1:%d", NitroConstants.PORT_WEBSOCKET);
return String.format("ws://127.0.0.1:%d", NitroConstants.WEBSOCKET_PORT);
}
@Override

View File

@ -31,7 +31,7 @@ public class NitroHttpProxy {
* Register HTTP(s) proxy on the system.
*/
private boolean registerProxy() {
return this.osFunctions.registerSystemProxy("127.0.0.1", NitroConstants.PORT_HTTP);
return this.osFunctions.registerSystemProxy("127.0.0.1", NitroConstants.HTTP_PORT);
}
/**
@ -44,7 +44,7 @@ public class NitroHttpProxy {
public boolean start() {
try {
proxyServer = DefaultHttpProxyServer.bootstrap()
.withPort(NitroConstants.PORT_HTTP)
.withPort(NitroConstants.HTTP_PORT)
.withManInTheMiddle(new CertificateSniffingMitmManager(authority))
.withFiltersSource(new NitroHttpProxyFilterSource(serverCallback))
.start();

View File

@ -1,5 +1,6 @@
package gearth.protocol.connection.proxy.nitro.http;
import gearth.protocol.connection.proxy.nitro.NitroConstants;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.http.HttpMethod;
import io.netty.handler.codec.http.HttpRequest;
@ -41,6 +42,6 @@ public class NitroHttpProxyFilterSource extends HttpFiltersSourceAdapter {
@Override
public int getMaximumResponseBufferSizeInBytes() {
// Increasing this causes LittleProxy to output "FullHttpResponse" objects.
return 1024 * 1024 * 1024;
return NitroConstants.HTTP_BUFFER_SIZE;
}
}

View File

@ -5,7 +5,6 @@ import gearth.protocol.HMessage;
import gearth.protocol.connection.*;
import gearth.protocol.connection.proxy.nitro.NitroConstants;
import gearth.protocol.connection.proxy.nitro.NitroProxyProvider;
import gearth.services.internal_extensions.uilogger.hexdumper.Hexdump;
import javax.websocket.*;
import javax.websocket.server.ServerEndpoint;
@ -45,7 +44,7 @@ public class NitroWebsocketClient implements NitroSession {
this.server.getPacketHandler(),
this.packetHandler,
NitroConstants.WEBSOCKET_REVISION,
"HTML5" // TODO: What is its purpose?
NitroConstants.WEBSOCKET_CLIENT_IDENTIFIER
);
proxySetter.setProxy(proxy);

View File

@ -28,7 +28,7 @@ public class NitroWebsocketProxy {
this.stateSetter = stateSetter;
this.connection = connection;
this.proxyProvider = proxyProvider;
this.server = new Server(NitroConstants.PORT_WEBSOCKET);
this.server = new Server(NitroConstants.WEBSOCKET_PORT);
}
public boolean start() {