mirror of
https://github.com/sirjonasxx/G-Earth.git
synced 2025-02-21 13:22:37 +01:00
connect from commandline
This commit is contained in:
parent
0e84169f9e
commit
35d18da4da
@ -130,6 +130,17 @@ public class Main extends Application {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String getArgument(String... arg) {
|
||||||
|
for (int i = 0; i < args.length - 1; i++) {
|
||||||
|
for (String str : arg) {
|
||||||
|
if (args[i].toLowerCase().equals(str.toLowerCase())) {
|
||||||
|
return args[i+1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Hi
|
// Hi
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package gearth.ui;
|
package gearth.ui;
|
||||||
|
|
||||||
|
import gearth.protocol.connection.proxy.ProxyProviderFactory;
|
||||||
|
import gearth.protocol.connection.proxy.SocksConfiguration;
|
||||||
import gearth.ui.logger.loggerdisplays.PacketLoggerFactory;
|
import gearth.ui.logger.loggerdisplays.PacketLoggerFactory;
|
||||||
import javafx.event.Event;
|
import javafx.event.Event;
|
||||||
import javafx.event.EventHandler;
|
import javafx.event.EventHandler;
|
||||||
@ -41,6 +43,15 @@ public class GEarthController {
|
|||||||
|
|
||||||
public Pane mover;
|
public Pane mover;
|
||||||
public GEarthController() {
|
public GEarthController() {
|
||||||
|
SocksConfiguration temporary_socks = new SocksConfiguration() {
|
||||||
|
public boolean useSocks() { return false; }
|
||||||
|
public int getSocksPort() { return 0; }
|
||||||
|
public String getSocksHost() { return null; }
|
||||||
|
public boolean onlyUseIfNeeded() { return true; }
|
||||||
|
};
|
||||||
|
|
||||||
|
ProxyProviderFactory.setSocksConfig(temporary_socks);
|
||||||
|
|
||||||
hConnection = new HConnection();
|
hConnection = new HConnection();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package gearth.ui.connection;
|
package gearth.ui.connection;
|
||||||
|
|
||||||
|
import gearth.Main;
|
||||||
import gearth.misc.Cacher;
|
import gearth.misc.Cacher;
|
||||||
import gearth.protocol.connection.HState;
|
import gearth.protocol.connection.HState;
|
||||||
import gearth.protocol.connection.proxy.ProxyProviderFactory;
|
import gearth.protocol.connection.proxy.ProxyProviderFactory;
|
||||||
@ -12,7 +13,6 @@ import gearth.ui.SubForm;
|
|||||||
import javafx.scene.layout.GridPane;
|
import javafx.scene.layout.GridPane;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -44,6 +44,8 @@ public class ConnectionController extends SubForm {
|
|||||||
public RadioButton rd_flash;
|
public RadioButton rd_flash;
|
||||||
public GridPane grd_clientSelection;
|
public GridPane grd_clientSelection;
|
||||||
|
|
||||||
|
private volatile int initcount = 0;
|
||||||
|
|
||||||
public void initialize() {
|
public void initialize() {
|
||||||
|
|
||||||
Constants.UNITY_PACKETS = rd_unity.isSelected();
|
Constants.UNITY_PACKETS = rd_unity.isSelected();
|
||||||
@ -114,6 +116,10 @@ public class ConnectionController extends SubForm {
|
|||||||
Platform.runLater(this::updateInputUI);
|
Platform.runLater(this::updateInputUI);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
synchronized (this) {
|
||||||
|
tryMaybeConnectOnInit();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -190,6 +196,47 @@ public class ConnectionController extends SubForm {
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
Platform.runLater(this::updateInputUI);
|
Platform.runLater(this::updateInputUI);
|
||||||
|
|
||||||
|
synchronized (this) {
|
||||||
|
tryMaybeConnectOnInit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void tryMaybeConnectOnInit() {
|
||||||
|
if (++initcount == 2) {
|
||||||
|
maybeConnectOnInit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void maybeConnectOnInit() {
|
||||||
|
String connectMode = Main.getArgument("--connect", "-c");
|
||||||
|
if (connectMode != null) {
|
||||||
|
if (connectMode.equals("flash")) {
|
||||||
|
Platform.runLater(() -> rd_flash.setSelected(true));
|
||||||
|
String host = Main.getArgument("--host");
|
||||||
|
String port = Main.getArgument("--port");
|
||||||
|
if (host != null && port != null) {
|
||||||
|
Platform.runLater(() -> {
|
||||||
|
if (!inpHost.getItems().contains(host)) inpHost.getItems().add(host);
|
||||||
|
inpHost.getSelectionModel().select(host);
|
||||||
|
if (!inpPort.getItems().contains(port)) inpPort.getItems().add(port);
|
||||||
|
inpPort.getSelectionModel().select(port);
|
||||||
|
cbx_autodetect.setSelected(false);
|
||||||
|
});
|
||||||
|
getHConnection().start(host, Integer.parseInt(port));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Platform.runLater(() -> cbx_autodetect.setSelected(true));
|
||||||
|
getHConnection().start();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (connectMode.equals("unity")) {
|
||||||
|
Platform.runLater(() -> rd_unity.setSelected(true));
|
||||||
|
getHConnection().startUnity();
|
||||||
|
}
|
||||||
|
Platform.runLater(this::updateInputUI);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void btnConnect_clicked(ActionEvent actionEvent) {
|
public void btnConnect_clicked(ActionEvent actionEvent) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user