mirror of
https://github.com/sirjonasxx/G-Earth.git
synced 2024-11-26 18:30:52 +01:00
bugfixes, packet safety in scheduler
This commit is contained in:
parent
cd9f849d21
commit
76ce696186
@ -15,6 +15,7 @@ import gearth.protocol.connection.proxy.unity.UnityProxyProvider;
|
|||||||
import gearth.services.extension_handler.ExtensionHandler;
|
import gearth.services.extension_handler.ExtensionHandler;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
public class HConnection {
|
public class HConnection {
|
||||||
|
|
||||||
@ -25,6 +26,7 @@ public class HConnection {
|
|||||||
|
|
||||||
private volatile Object[] trafficObservables = {new Observable<TrafficListener>(), new Observable<TrafficListener>(), new Observable<TrafficListener>()};
|
private volatile Object[] trafficObservables = {new Observable<TrafficListener>(), new Observable<TrafficListener>(), new Observable<TrafficListener>()};
|
||||||
private volatile Observable<StateChangeListener> stateObservable = new Observable<>();
|
private volatile Observable<StateChangeListener> stateObservable = new Observable<>();
|
||||||
|
private volatile Observable<Consumer<Boolean>> developerModeChangeObservable = new Observable<>();
|
||||||
|
|
||||||
private volatile HState state = HState.NOT_CONNECTED;
|
private volatile HState state = HState.NOT_CONNECTED;
|
||||||
private volatile HProxy proxy = null;
|
private volatile HProxy proxy = null;
|
||||||
@ -196,6 +198,11 @@ public class HConnection {
|
|||||||
|
|
||||||
public void setDeveloperMode(boolean developerMode) {
|
public void setDeveloperMode(boolean developerMode) {
|
||||||
this.developerMode = developerMode;
|
this.developerMode = developerMode;
|
||||||
|
developerModeChangeObservable.fireEvent(listener -> listener.accept(developerMode));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onDeveloperModeChange(Consumer<Boolean> onChange) {
|
||||||
|
developerModeChangeObservable.addListener(onChange);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getClientHost() {
|
public String getClientHost() {
|
||||||
|
@ -33,6 +33,9 @@ public class SubForm {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected HConnection getHConnection() {
|
protected HConnection getHConnection() {
|
||||||
|
if (parentController == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
return parentController.getHConnection();
|
return parentController.getHConnection();
|
||||||
}
|
}
|
||||||
protected void writeToLog(javafx.scene.paint.Color color, String text) {
|
protected void writeToLog(javafx.scene.paint.Color color, String text) {
|
||||||
|
@ -79,6 +79,8 @@ public class ExtensionsController extends SubForm {
|
|||||||
extensionLogger.log(text);
|
extensionLogger.log(text);
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
getHConnection().onDeveloperModeChange(this::setLocalInstallingEnabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -117,7 +119,6 @@ public class ExtensionsController extends SubForm {
|
|||||||
btn_install.setDisable(!enabled);
|
btn_install.setDisable(!enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private volatile int gpytonShellCounter = 1;
|
private volatile int gpytonShellCounter = 1;
|
||||||
private volatile boolean pythonShellLaunching = false;
|
private volatile boolean pythonShellLaunching = false;
|
||||||
public void gpythonBtnClicked(ActionEvent actionEvent) {
|
public void gpythonBtnClicked(ActionEvent actionEvent) {
|
||||||
|
@ -266,7 +266,6 @@ public class ExtraController extends SubForm implements SocksConfiguration {
|
|||||||
private void setDevelopMode(boolean enabled) {
|
private void setDevelopMode(boolean enabled) {
|
||||||
cbx_develop.setSelected(enabled);
|
cbx_develop.setSelected(enabled);
|
||||||
getHConnection().setDeveloperMode(enabled);
|
getHConnection().setDeveloperMode(enabled);
|
||||||
parentController.extensionsController.setLocalInstallingEnabled(enabled);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void adminCbxClick(ActionEvent actionEvent) {
|
public void adminCbxClick(ActionEvent actionEvent) {
|
||||||
|
@ -38,6 +38,7 @@ public class InjectionController extends SubForm {
|
|||||||
private TranslatableString corruption, pcktInfo;
|
private TranslatableString corruption, pcktInfo;
|
||||||
|
|
||||||
protected void onParentSet() {
|
protected void onParentSet() {
|
||||||
|
getHConnection().onDeveloperModeChange(developMode -> updateUI());
|
||||||
getHConnection().getStateObservable().addListener((oldState, newState) -> Platform.runLater(this::updateUI));
|
getHConnection().getStateObservable().addListener((oldState, newState) -> Platform.runLater(this::updateUI));
|
||||||
|
|
||||||
inputPacket.textProperty().addListener(event -> Platform.runLater(this::updateUI));
|
inputPacket.textProperty().addListener(event -> Platform.runLater(this::updateUI));
|
||||||
|
@ -1,6 +1,10 @@
|
|||||||
package gearth.ui.subforms.scheduler;
|
package gearth.ui.subforms.scheduler;
|
||||||
|
|
||||||
import com.tulskiy.keymaster.common.Provider;
|
import com.tulskiy.keymaster.common.Provider;
|
||||||
|
import gearth.extensions.parsers.HDirection;
|
||||||
|
import gearth.protocol.HConnection;
|
||||||
|
import gearth.protocol.StateChangeListener;
|
||||||
|
import gearth.protocol.connection.HState;
|
||||||
import gearth.services.scheduler.Interval;
|
import gearth.services.scheduler.Interval;
|
||||||
import gearth.services.scheduler.Scheduler;
|
import gearth.services.scheduler.Scheduler;
|
||||||
import gearth.ui.translations.LanguageBundle;
|
import gearth.ui.translations.LanguageBundle;
|
||||||
@ -19,6 +23,7 @@ import javax.swing.*;
|
|||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Jonas on 06/04/18.
|
* Created by Jonas on 06/04/18.
|
||||||
@ -61,8 +66,6 @@ public class SchedulerController extends SubForm {
|
|||||||
txt_packet.textProperty().addListener(event -> Platform.runLater(this::updateUI));
|
txt_packet.textProperty().addListener(event -> Platform.runLater(this::updateUI));
|
||||||
txt_delay.textProperty().addListener(event -> Platform.runLater(this::updateUI));
|
txt_delay.textProperty().addListener(event -> Platform.runLater(this::updateUI));
|
||||||
|
|
||||||
updateUI();
|
|
||||||
|
|
||||||
//register hotkeys
|
//register hotkeys
|
||||||
//disable some output things
|
//disable some output things
|
||||||
PrintStream err = System.err;
|
PrintStream err = System.err;
|
||||||
@ -85,6 +88,9 @@ public class SchedulerController extends SubForm {
|
|||||||
@Override
|
@Override
|
||||||
protected void onParentSet() {
|
protected void onParentSet() {
|
||||||
scheduler = new Scheduler<>(getHConnection());
|
scheduler = new Scheduler<>(getHConnection());
|
||||||
|
getHConnection().onDeveloperModeChange(developMode -> updateUI());
|
||||||
|
getHConnection().getStateObservable().addListener((oldState, newState) -> updateUI());
|
||||||
|
updateUI();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void switchPauseHotkey(int index) {
|
private void switchPauseHotkey(int index) {
|
||||||
@ -104,7 +110,14 @@ public class SchedulerController extends SubForm {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void updateUI() {
|
private void updateUI() {
|
||||||
btn_addoredit.setDisable(!Interval.isValid(txt_delay.getText()) || new HPacket(txt_packet.getText()).isCorrupted());
|
HConnection connection = getHConnection();
|
||||||
|
if (connection == null) return;
|
||||||
|
|
||||||
|
HMessage.Direction direction = rb_incoming.isSelected() ? HMessage.Direction.TOCLIENT : HMessage.Direction.TOSERVER;
|
||||||
|
HPacket packet = new HPacket(txt_packet.getText());
|
||||||
|
boolean isPacketOk = connection.canSendPacket(direction, packet);
|
||||||
|
|
||||||
|
btn_addoredit.setDisable(!Interval.isValid(txt_delay.getText()) || !isPacketOk);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void scheduleBtnClicked(ActionEvent actionEvent) {
|
public void scheduleBtnClicked(ActionEvent actionEvent) {
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
<?import javafx.scene.control.*?>
|
<?import javafx.scene.control.*?>
|
||||||
<?import javafx.scene.layout.*?>
|
<?import javafx.scene.layout.*?>
|
||||||
|
|
||||||
<GridPane maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefHeight="258.0" prefWidth="650.0" xmlns="http://javafx.com/javafx/16" xmlns:fx="http://javafx.com/fxml/1" fx:controller="gearth.ui.subforms.extensions.ExtensionsController">
|
<GridPane maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefHeight="258.0" prefWidth="650.0" xmlns="http://javafx.com/javafx" xmlns:fx="http://javafx.com/fxml/1" fx:controller="gearth.ui.subforms.extensions.ExtensionsController">
|
||||||
<columnConstraints>
|
<columnConstraints>
|
||||||
<ColumnConstraints hgrow="SOMETIMES" maxWidth="1.7976931348623157E308" minWidth="10.0" prefWidth="277.0" />
|
<ColumnConstraints hgrow="SOMETIMES" maxWidth="1.7976931348623157E308" minWidth="10.0" prefWidth="277.0" />
|
||||||
</columnConstraints>
|
</columnConstraints>
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<?import javafx.scene.layout.*?>
|
<?import javafx.scene.layout.*?>
|
||||||
<?import javafx.scene.text.*?>
|
<?import javafx.scene.text.*?>
|
||||||
|
|
||||||
<GridPane maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefHeight="258.0" prefWidth="650.0" xmlns="http://javafx.com/javafx/16" xmlns:fx="http://javafx.com/fxml/1" fx:controller="gearth.ui.subforms.extra.ExtraController">
|
<GridPane maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefHeight="258.0" prefWidth="650.0" xmlns="http://javafx.com/javafx" xmlns:fx="http://javafx.com/fxml/1" fx:controller="gearth.ui.subforms.extra.ExtraController">
|
||||||
<columnConstraints>
|
<columnConstraints>
|
||||||
<ColumnConstraints hgrow="SOMETIMES" maxWidth="331.0" minWidth="10.0" prefWidth="318.0" />
|
<ColumnConstraints hgrow="SOMETIMES" maxWidth="331.0" minWidth="10.0" prefWidth="318.0" />
|
||||||
<ColumnConstraints hgrow="SOMETIMES" maxWidth="390.0" minWidth="10.0" prefWidth="247.0" />
|
<ColumnConstraints hgrow="SOMETIMES" maxWidth="390.0" minWidth="10.0" prefWidth="247.0" />
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<?import javafx.scene.layout.*?>
|
<?import javafx.scene.layout.*?>
|
||||||
<?import javafx.scene.text.*?>
|
<?import javafx.scene.text.*?>
|
||||||
|
|
||||||
<GridPane maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefHeight="258.0" prefWidth="650.0" xmlns="http://javafx.com/javafx/16" xmlns:fx="http://javafx.com/fxml/1" fx:controller="gearth.ui.subforms.info.InfoController">
|
<GridPane maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefHeight="258.0" prefWidth="650.0" xmlns="http://javafx.com/javafx" xmlns:fx="http://javafx.com/fxml/1" fx:controller="gearth.ui.subforms.info.InfoController">
|
||||||
<columnConstraints>
|
<columnConstraints>
|
||||||
<ColumnConstraints hgrow="SOMETIMES" maxWidth="1.7976931348623157E308" minWidth="10.0" prefWidth="332.0" />
|
<ColumnConstraints hgrow="SOMETIMES" maxWidth="1.7976931348623157E308" minWidth="10.0" prefWidth="332.0" />
|
||||||
</columnConstraints>
|
</columnConstraints>
|
||||||
|
Loading…
Reference in New Issue
Block a user