mirror of
https://github.com/sirjonasxx/G-Earth.git
synced 2024-11-27 02:40:51 +01:00
advanced; option to override connection info with raw values
This commit is contained in:
parent
148fd93cf8
commit
fc7b86dc95
@ -5,6 +5,7 @@ import gearth.misc.OSValidator;
|
|||||||
import gearth.protocol.hostreplacer.HostReplacer;
|
import gearth.protocol.hostreplacer.HostReplacer;
|
||||||
import gearth.protocol.hostreplacer.HostReplacerFactory;
|
import gearth.protocol.hostreplacer.HostReplacerFactory;
|
||||||
import gearth.protocol.memory.Rc4Obtainer;
|
import gearth.protocol.memory.Rc4Obtainer;
|
||||||
|
import gearth.protocol.misc.ConnectionInfoOverrider;
|
||||||
import gearth.protocol.packethandler.Handler;
|
import gearth.protocol.packethandler.Handler;
|
||||||
import gearth.protocol.packethandler.IncomingHandler;
|
import gearth.protocol.packethandler.IncomingHandler;
|
||||||
import gearth.protocol.packethandler.OutgoingHandler;
|
import gearth.protocol.packethandler.OutgoingHandler;
|
||||||
@ -101,8 +102,9 @@ public class HConnection {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static boolean DECRYPTPACKETS = true;
|
private static volatile ConnectionInfoOverrider connectionInfoOverrider;
|
||||||
public static boolean DEBUG = false;
|
public static volatile boolean DECRYPTPACKETS = true;
|
||||||
|
public static volatile boolean DEBUG = false;
|
||||||
private static final HostReplacer hostsReplacer = HostReplacerFactory.get();
|
private static final HostReplacer hostsReplacer = HostReplacerFactory.get();
|
||||||
|
|
||||||
private volatile boolean hostRedirected = false;
|
private volatile boolean hostRedirected = false;
|
||||||
@ -110,7 +112,7 @@ public class HConnection {
|
|||||||
private volatile List<StateChangeListener> stateChangeListeners = new ArrayList<>();
|
private volatile List<StateChangeListener> stateChangeListeners = new ArrayList<>();
|
||||||
private volatile State state = State.NOT_CONNECTED;
|
private volatile State state = State.NOT_CONNECTED;
|
||||||
|
|
||||||
private class Proxy {
|
public static class Proxy {
|
||||||
private volatile String input_domain; //string representation of the domain to intercept
|
private volatile String input_domain; //string representation of the domain to intercept
|
||||||
private volatile String actual_domain; //dns resolved domain (ignoring hosts file)
|
private volatile String actual_domain; //dns resolved domain (ignoring hosts file)
|
||||||
private volatile int actual_port; //port of the server
|
private volatile int actual_port; //port of the server
|
||||||
@ -178,7 +180,6 @@ public class HConnection {
|
|||||||
private volatile Proxy actual_proxy = null;
|
private volatile Proxy actual_proxy = null;
|
||||||
private volatile String hotelVersion = "";
|
private volatile String hotelVersion = "";
|
||||||
|
|
||||||
|
|
||||||
public State getState() {
|
public State getState() {
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
@ -214,10 +215,12 @@ public class HConnection {
|
|||||||
removeFromHosts();
|
removeFromHosts();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (connectionInfoOverrider.mustOverrideConnection()) {
|
||||||
|
potentialProxies.add(connectionInfoOverrider.getOverrideProxy());
|
||||||
|
}
|
||||||
|
else {
|
||||||
List<String> willremove = new ArrayList<>();
|
List<String> willremove = new ArrayList<>();
|
||||||
|
|
||||||
int c = 0;
|
int c = 0;
|
||||||
|
|
||||||
for (String host : allPotentialHosts) {
|
for (String host : allPotentialHosts) {
|
||||||
String[] split = host.split(":");
|
String[] split = host.split(":");
|
||||||
String input_dom = split[0];
|
String input_dom = split[0];
|
||||||
@ -240,7 +243,6 @@ public class HConnection {
|
|||||||
c++;
|
c++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
List<Object> additionalCachedHotels = Cacher.getList(HOTELS_CACHE_KEY);
|
List<Object> additionalCachedHotels = Cacher.getList(HOTELS_CACHE_KEY);
|
||||||
if (additionalCachedHotels != null) {
|
if (additionalCachedHotels != null) {
|
||||||
for (String host : willremove) {
|
for (String host : willremove) {
|
||||||
@ -248,6 +250,8 @@ public class HConnection {
|
|||||||
}
|
}
|
||||||
Cacher.put(HOTELS_CACHE_KEY, additionalCachedHotels);
|
Cacher.put(HOTELS_CACHE_KEY, additionalCachedHotels);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
setState(State.PREPARED);
|
setState(State.PREPARED);
|
||||||
}
|
}
|
||||||
@ -567,4 +571,8 @@ public class HConnection {
|
|||||||
public String getHotelVersion() {
|
public String getHotelVersion() {
|
||||||
return hotelVersion;
|
return hotelVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void setConnectionInfoOverrider(ConnectionInfoOverrider connectionInfoOverrider) {
|
||||||
|
HConnection.connectionInfoOverrider = connectionInfoOverrider;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,12 @@
|
|||||||
|
package gearth.protocol.misc;
|
||||||
|
|
||||||
|
import gearth.protocol.HConnection;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by Jeunez on 30/01/2019.
|
||||||
|
*/
|
||||||
|
public interface ConnectionInfoOverrider {
|
||||||
|
|
||||||
|
boolean mustOverrideConnection();
|
||||||
|
HConnection.Proxy getOverrideProxy();
|
||||||
|
}
|
@ -2,6 +2,7 @@ package gearth.ui.extra;
|
|||||||
|
|
||||||
import gearth.misc.Cacher;
|
import gearth.misc.Cacher;
|
||||||
import gearth.protocol.HConnection;
|
import gearth.protocol.HConnection;
|
||||||
|
import gearth.protocol.misc.ConnectionInfoOverrider;
|
||||||
import gearth.ui.SubForm;
|
import gearth.ui.SubForm;
|
||||||
import gearth.ui.info.Info;
|
import gearth.ui.info.Info;
|
||||||
import javafx.beans.InvalidationListener;
|
import javafx.beans.InvalidationListener;
|
||||||
@ -12,7 +13,7 @@ import javafx.scene.layout.GridPane;
|
|||||||
/**
|
/**
|
||||||
* Created by Jonas on 06/04/18.
|
* Created by Jonas on 06/04/18.
|
||||||
*/
|
*/
|
||||||
public class Extra extends SubForm {
|
public class Extra extends SubForm implements ConnectionInfoOverrider {
|
||||||
|
|
||||||
public static final String NOTEPAD_CACHE_KEY = "notepad_text";
|
public static final String NOTEPAD_CACHE_KEY = "notepad_text";
|
||||||
|
|
||||||
@ -36,6 +37,8 @@ public class Extra extends SubForm {
|
|||||||
public CheckBox cbx_debug;
|
public CheckBox cbx_debug;
|
||||||
|
|
||||||
public void initialize() {
|
public void initialize() {
|
||||||
|
HConnection.setConnectionInfoOverrider(this);
|
||||||
|
|
||||||
url_troubleshooting.setTooltip(new Tooltip("https://github.com/sirjonasxx/G-Earth/wiki/Troubleshooting"));
|
url_troubleshooting.setTooltip(new Tooltip("https://github.com/sirjonasxx/G-Earth/wiki/Troubleshooting"));
|
||||||
Info.activateHyperlink(url_troubleshooting);
|
Info.activateHyperlink(url_troubleshooting);
|
||||||
|
|
||||||
@ -82,4 +85,20 @@ public class Extra extends SubForm {
|
|||||||
|
|
||||||
cbx_disableDecryption.setDisable(getHConnection().getState() != HConnection.State.NOT_CONNECTED);
|
cbx_disableDecryption.setDisable(getHConnection().getState() != HConnection.State.NOT_CONNECTED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean mustOverrideConnection() {
|
||||||
|
return cbx_ovcinfo.isSelected();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HConnection.Proxy getOverrideProxy() {
|
||||||
|
return new HConnection.Proxy(
|
||||||
|
txt_realIp.getText(),
|
||||||
|
txt_realIp.getText(),
|
||||||
|
Integer.parseInt(txt_realPort.getText()),
|
||||||
|
Integer.parseInt(txt_mitmPort.getText()),
|
||||||
|
txt_mitmIP.getText()
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -71,7 +71,7 @@
|
|||||||
<Label text="MITM IP:" GridPane.rowIndex="1" />
|
<Label text="MITM IP:" GridPane.rowIndex="1" />
|
||||||
<Label text="Real port:" GridPane.rowIndex="2" />
|
<Label text="Real port:" GridPane.rowIndex="2" />
|
||||||
<Label text="MITM port:" GridPane.rowIndex="3" />
|
<Label text="MITM port:" GridPane.rowIndex="3" />
|
||||||
<TextField fx:id="txt_realPort" editable="false" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" GridPane.columnIndex="1" GridPane.rowIndex="2">
|
<TextField fx:id="txt_realPort" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" GridPane.columnIndex="1" GridPane.rowIndex="2">
|
||||||
<opaqueInsets>
|
<opaqueInsets>
|
||||||
<Insets />
|
<Insets />
|
||||||
</opaqueInsets>
|
</opaqueInsets>
|
||||||
@ -79,7 +79,7 @@
|
|||||||
<Insets bottom="3.0" right="7.0" top="3.0" />
|
<Insets bottom="3.0" right="7.0" top="3.0" />
|
||||||
</GridPane.margin>
|
</GridPane.margin>
|
||||||
</TextField>
|
</TextField>
|
||||||
<TextField fx:id="txt_mitmIP" editable="false" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" GridPane.columnIndex="1" GridPane.rowIndex="1">
|
<TextField fx:id="txt_mitmIP" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" GridPane.columnIndex="1" GridPane.rowIndex="1">
|
||||||
<opaqueInsets>
|
<opaqueInsets>
|
||||||
<Insets />
|
<Insets />
|
||||||
</opaqueInsets>
|
</opaqueInsets>
|
||||||
@ -87,7 +87,7 @@
|
|||||||
<Insets bottom="3.0" right="7.0" top="3.0" />
|
<Insets bottom="3.0" right="7.0" top="3.0" />
|
||||||
</GridPane.margin>
|
</GridPane.margin>
|
||||||
</TextField>
|
</TextField>
|
||||||
<TextField fx:id="txt_realIp" editable="false" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" GridPane.columnIndex="1">
|
<TextField fx:id="txt_realIp" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" GridPane.columnIndex="1">
|
||||||
<opaqueInsets>
|
<opaqueInsets>
|
||||||
<Insets />
|
<Insets />
|
||||||
</opaqueInsets>
|
</opaqueInsets>
|
||||||
@ -95,7 +95,7 @@
|
|||||||
<Insets bottom="3.0" right="7.0" top="3.0" />
|
<Insets bottom="3.0" right="7.0" top="3.0" />
|
||||||
</GridPane.margin>
|
</GridPane.margin>
|
||||||
</TextField>
|
</TextField>
|
||||||
<TextField fx:id="txt_mitmPort" editable="false" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" GridPane.columnIndex="1" GridPane.rowIndex="3">
|
<TextField fx:id="txt_mitmPort" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" GridPane.columnIndex="1" GridPane.rowIndex="3">
|
||||||
<opaqueInsets>
|
<opaqueInsets>
|
||||||
<Insets />
|
<Insets />
|
||||||
</opaqueInsets>
|
</opaqueInsets>
|
||||||
|
Loading…
Reference in New Issue
Block a user