mirror of
https://github.com/sirjonasxx/G-Earth.git
synced 2024-12-03 13:16:28 +01:00
packet structure predictor unity
This commit is contained in:
parent
6ae5306899
commit
d252c33c8b
@ -0,0 +1,40 @@
|
||||
package gearth.misc.packetrepresentation.prediction.checkers;
|
||||
|
||||
import gearth.protocol.HPacket;
|
||||
|
||||
public class LongChecker extends TypeChecker<Long> {
|
||||
|
||||
private IntegerChecker integerChecker;
|
||||
|
||||
protected LongChecker(HPacket hPacket) {
|
||||
super("l", hPacket);
|
||||
integerChecker = new IntegerChecker(hPacket);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canRead(int index) {
|
||||
return index >= 6 && !(index + 8 > hPacket.getBytesLength());
|
||||
}
|
||||
|
||||
@Override
|
||||
public double score(int index) {
|
||||
int split1 = hPacket.readInteger(index);
|
||||
int split2 = hPacket.readInteger(index + 4);
|
||||
|
||||
if (split2 > 256 * 256 * 3 && split1 == 0) {
|
||||
return integerChecker.score(index);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
Long get(int index) {
|
||||
return hPacket.readLong(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
int nextIndexSafe(int index) {
|
||||
return index + 8;
|
||||
}
|
||||
}
|
@ -2,18 +2,26 @@ package gearth.misc.packetrepresentation.prediction.checkers;
|
||||
|
||||
import gearth.protocol.HPacket;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class TypeCheckerProducer {
|
||||
|
||||
public static volatile boolean USE_LONG_DATATYPE = false;
|
||||
|
||||
public static List<TypeChecker> getValidators(HPacket packet) {
|
||||
return Arrays.asList(
|
||||
List<TypeChecker> typeCheckers = new ArrayList<>(Arrays.asList(
|
||||
new BooleanChecker(packet),
|
||||
new ByteChecker(packet),
|
||||
new IntegerChecker(packet),
|
||||
new StringChecker(packet)
|
||||
);
|
||||
new StringChecker(packet)));
|
||||
|
||||
if (USE_LONG_DATATYPE) {
|
||||
typeCheckers.add(new LongChecker(packet));
|
||||
}
|
||||
|
||||
return typeCheckers;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2,6 +2,8 @@ package gearth.ui.extra;
|
||||
|
||||
import gearth.Main;
|
||||
import gearth.misc.Cacher;
|
||||
import gearth.misc.packetrepresentation.prediction.StructurePredictor;
|
||||
import gearth.misc.packetrepresentation.prediction.checkers.TypeCheckerProducer;
|
||||
import gearth.protocol.HConnection;
|
||||
import gearth.protocol.connection.HState;
|
||||
import gearth.protocol.connection.proxy.ProxyProviderFactory;
|
||||
@ -62,7 +64,11 @@ public class ExtraController extends SubForm implements SocksConfiguration {
|
||||
public RadioButton rd_flash;
|
||||
|
||||
public void initialize() {
|
||||
tgl_clientMode.selectedToggleProperty().addListener(observable -> parentController.connectionController.changeClientMode());
|
||||
TypeCheckerProducer.USE_LONG_DATATYPE = rd_unity.isSelected();
|
||||
tgl_clientMode.selectedToggleProperty().addListener(observable -> {
|
||||
parentController.connectionController.changeClientMode();
|
||||
TypeCheckerProducer.USE_LONG_DATATYPE = rd_unity.isSelected();
|
||||
});
|
||||
|
||||
url_troubleshooting.setTooltip(new Tooltip("https://github.com/sirjonasxx/G-Earth/wiki/Troubleshooting"));
|
||||
InfoController.activateHyperlink(url_troubleshooting);
|
||||
|
Loading…
Reference in New Issue
Block a user