Случайный порт при передаче параметров

This commit is contained in:
Gravit 2018-10-13 15:20:23 +07:00
parent 311fee0443
commit a9a9a78983
No known key found for this signature in database
GPG key ID: 061981E1E85D3216
5 changed files with 12 additions and 1 deletions

View file

@ -83,6 +83,11 @@ public void setPort(int port) {
body.append(port); body.append(port);
body.append(";"); body.append(";");
} }
public void setClientPort(int port) {
body.append("this.clientPort = ");
body.append(port);
body.append(";");
}
public ClassPool getPool() { public ClassPool getPool() {
return pool; return pool;

View file

@ -173,6 +173,7 @@ private void stdBuild() throws IOException {
jaConfigurator.setPort(server.config.port); jaConfigurator.setPort(server.config.port);
jaConfigurator.setProjectName(server.config.projectName); jaConfigurator.setProjectName(server.config.projectName);
jaConfigurator.setSecretKey(SecurityHelper.randomStringToken()); jaConfigurator.setSecretKey(SecurityHelper.randomStringToken());
jaConfigurator.setClientPort(32148 + SecurityHelper.newRandom().nextInt(512));
server.buildHookManager.registerAllClientModuleClass(jaConfigurator); server.buildHookManager.registerAllClientModuleClass(jaConfigurator);
try (ZipInputStream input = new ZipInputStream( try (ZipInputStream input = new ZipInputStream(
IOHelper.newInput(IOHelper.getResourceURL("Launcher.jar")))) { IOHelper.newInput(IOHelper.getResourceURL("Launcher.jar")))) {

View file

@ -160,7 +160,7 @@ public void write(HOutput output) throws IOException {
private static final String[] EMPTY_ARRAY = new String[0]; private static final String[] EMPTY_ARRAY = new String[0];
private static final String SOCKET_HOST = "127.0.0.1"; private static final String SOCKET_HOST = "127.0.0.1";
private static final int SOCKET_PORT = 32148; private static final int SOCKET_PORT = Launcher.getConfig().clientPort;
private static final String MAGICAL_INTEL_OPTION = "-XX:HeapDumpPath=ThisTricksIntelDriversForPerformance_javaw.exe_minecraft.exe.heapdump"; private static final String MAGICAL_INTEL_OPTION = "-XX:HeapDumpPath=ThisTricksIntelDriversForPerformance_javaw.exe_minecraft.exe.heapdump";
private static final boolean isUsingWrapper = true; private static final boolean isUsingWrapper = true;
@SuppressWarnings("unused") @SuppressWarnings("unused")

View file

@ -4,6 +4,7 @@ public class AutogenConfig {
public String projectname; public String projectname;
public String address; public String address;
public int port; public int port;
public int clientPort;
private boolean isInitModules; private boolean isInitModules;
public String secretKeyClient; public String secretKeyClient;

View file

@ -34,6 +34,7 @@ public static AutogenConfig getAutogenConfig() {
public final InetSocketAddress address; public final InetSocketAddress address;
@LauncherAPI @LauncherAPI
public final String projectname; public final String projectname;
public final int clientPort;
public String secretKeyClient; public String secretKeyClient;
@LauncherAPI @LauncherAPI
public final RSAPublicKey publicKey; public final RSAPublicKey publicKey;
@ -48,6 +49,7 @@ public LauncherConfig(HInput input) throws IOException, InvalidKeySpecException
ADDRESS_OVERRIDE == null ? localAddress : ADDRESS_OVERRIDE, config.port); ADDRESS_OVERRIDE == null ? localAddress : ADDRESS_OVERRIDE, config.port);
publicKey = SecurityHelper.toPublicRSAKey(input.readByteArray(SecurityHelper.CRYPTO_MAX_LENGTH)); publicKey = SecurityHelper.toPublicRSAKey(input.readByteArray(SecurityHelper.CRYPTO_MAX_LENGTH));
projectname = config.projectname; projectname = config.projectname;
clientPort = config.clientPort;
secretKeyClient = config.secretKeyClient; secretKeyClient = config.secretKeyClient;
// Read signed runtime // Read signed runtime
int count = input.readLength(0); int count = input.readLength(0);
@ -72,6 +74,7 @@ public LauncherConfig(String address, int port, RSAPublicKey publicKey, Map<Stri
this.publicKey = Objects.requireNonNull(publicKey, "publicKey"); this.publicKey = Objects.requireNonNull(publicKey, "publicKey");
this.runtime = Collections.unmodifiableMap(new HashMap<>(runtime)); this.runtime = Collections.unmodifiableMap(new HashMap<>(runtime));
this.projectname = projectname; this.projectname = projectname;
this.clientPort = 32148;
} }
@LauncherAPI @LauncherAPI
@ -81,6 +84,7 @@ public LauncherConfig(String address, int port, RSAPublicKey publicKey, Map<Stri
this.publicKey = Objects.requireNonNull(publicKey, "publicKey"); this.publicKey = Objects.requireNonNull(publicKey, "publicKey");
this.runtime = Collections.unmodifiableMap(new HashMap<>(runtime)); this.runtime = Collections.unmodifiableMap(new HashMap<>(runtime));
this.projectname = "Minecraft"; this.projectname = "Minecraft";
this.clientPort = 32148;
} }
@Override @Override