Komplettes G-Earth Paket inkl. JRE, Extensions und Tools. Extensions: - G-BuildTools, G-Click Ultimate, G-Loader, G-Manipulate - G-Presets, G-Translator, G-Trigger, G-itemViewer - Market Utils, Packet Info Explorer, Plants - RandomRoomVisitor, RoomLogger, Sanbovir Photo Inspector - SpyFriends, WallAligner, XabboScripter, xabbo
229 lines
6.7 KiB
Java
229 lines
6.7 KiB
Java
/*
|
|
* Decompiled with CFR 0.152.
|
|
*/
|
|
package gearth.protocol;
|
|
|
|
import gearth.misc.listenerpattern.Observable;
|
|
import gearth.protocol.HPacket;
|
|
import gearth.protocol.StateChangeListener;
|
|
import gearth.protocol.TrafficListener;
|
|
import gearth.protocol.connection.HClient;
|
|
import gearth.protocol.connection.HProxy;
|
|
import gearth.protocol.connection.HState;
|
|
import gearth.protocol.connection.proxy.ProxyProvider;
|
|
import gearth.protocol.connection.proxy.ProxyProviderFactory;
|
|
import gearth.protocol.connection.proxy.flash.unix.LinuxRawIpFlashProxyProvider;
|
|
import gearth.protocol.connection.proxy.nitro.NitroProxyProvider;
|
|
import gearth.protocol.connection.proxy.unity.UnityProxyProvider;
|
|
import gearth.services.extension_handler.ExtensionHandler;
|
|
import gearth.services.packet_info.PacketInfoManager;
|
|
import java.io.IOException;
|
|
|
|
public class HConnection {
|
|
public static volatile boolean DECRYPTPACKETS = true;
|
|
public static volatile boolean DEBUG = false;
|
|
private volatile ExtensionHandler extensionHandler = null;
|
|
private volatile Object[] trafficObservables = new Object[]{new Observable(), new Observable(), new Observable()};
|
|
private volatile Observable<StateChangeListener> stateObservable = new Observable();
|
|
private volatile HState state = HState.NOT_CONNECTED;
|
|
private volatile HProxy proxy = null;
|
|
private ProxyProviderFactory proxyProviderFactory;
|
|
private ProxyProvider proxyProvider = null;
|
|
|
|
public HConnection() {
|
|
HConnection selff = this;
|
|
this.proxyProviderFactory = new ProxyProviderFactory(proxy -> {
|
|
selff.proxy = proxy;
|
|
}, selff::setState, this);
|
|
}
|
|
|
|
public HState getState() {
|
|
return this.state;
|
|
}
|
|
|
|
private void setState(HState state) {
|
|
if (state != this.state) {
|
|
HState buffer = this.state;
|
|
this.state = state;
|
|
this.stateObservable.fireEvent(l -> l.stateChanged(buffer, state));
|
|
}
|
|
}
|
|
|
|
public void start() {
|
|
this.proxyProvider = this.proxyProviderFactory.provide();
|
|
this.startMITM();
|
|
}
|
|
|
|
public void start(String host, int port) {
|
|
this.proxyProvider = this.proxyProviderFactory.provide(host, port);
|
|
this.startMITM();
|
|
}
|
|
|
|
public void startUnity() {
|
|
HConnection selff = this;
|
|
this.proxyProvider = new UnityProxyProvider(proxy -> {
|
|
selff.proxy = proxy;
|
|
}, selff::setState, this);
|
|
this.startMITM();
|
|
}
|
|
|
|
public void startNitro() {
|
|
HConnection selff = this;
|
|
this.proxyProvider = new NitroProxyProvider(proxy -> {
|
|
selff.proxy = proxy;
|
|
}, selff::setState, this);
|
|
this.startMITM();
|
|
}
|
|
|
|
private void startMITM() {
|
|
try {
|
|
if (this.proxyProvider != null) {
|
|
this.proxyProvider.start();
|
|
} else {
|
|
this.setState(HState.ABORTING);
|
|
this.setState(HState.NOT_CONNECTED);
|
|
}
|
|
}
|
|
catch (IOException e) {
|
|
e.printStackTrace();
|
|
this.setState(HState.ABORTING);
|
|
this.setState(HState.NOT_CONNECTED);
|
|
}
|
|
}
|
|
|
|
public void abort() {
|
|
if (this.proxyProvider != null) {
|
|
this.proxyProvider.abort();
|
|
this.proxyProvider = null;
|
|
}
|
|
}
|
|
|
|
public Observable<StateChangeListener> getStateObservable() {
|
|
return this.stateObservable;
|
|
}
|
|
|
|
public void addTrafficListener(int order, TrafficListener listener) {
|
|
((Observable)this.trafficObservables[order]).addListener(listener);
|
|
}
|
|
|
|
public void removeTrafficListener(TrafficListener listener) {
|
|
((Observable)this.trafficObservables[0]).removeListener(listener);
|
|
((Observable)this.trafficObservables[1]).removeListener(listener);
|
|
((Observable)this.trafficObservables[2]).removeListener(listener);
|
|
}
|
|
|
|
public void setExtensionHandler(ExtensionHandler handler) {
|
|
this.extensionHandler = handler;
|
|
}
|
|
|
|
public ExtensionHandler getExtensionHandler() {
|
|
return this.extensionHandler;
|
|
}
|
|
|
|
public Object[] getTrafficObservables() {
|
|
return this.trafficObservables;
|
|
}
|
|
|
|
public int getServerPort() {
|
|
if (this.proxy == null) {
|
|
return -1;
|
|
}
|
|
return this.proxy.getIntercept_port();
|
|
}
|
|
|
|
public String getServerHost() {
|
|
if (this.proxy == null) {
|
|
return "<auto-detect>";
|
|
}
|
|
return this.proxy.getActual_domain();
|
|
}
|
|
|
|
public String getDomain() {
|
|
if (this.proxy == null) {
|
|
return "<auto-detect>";
|
|
}
|
|
return this.proxy.getInput_domain();
|
|
}
|
|
|
|
public boolean sendToClient(HPacket packet) {
|
|
HProxy proxy = this.proxy;
|
|
if (proxy == null) {
|
|
return false;
|
|
}
|
|
if (!packet.isPacketComplete()) {
|
|
PacketInfoManager packetInfoManager = this.getPacketInfoManager();
|
|
packet.completePacket(packetInfoManager);
|
|
if (!packet.isPacketComplete() || !packet.canSendToClient()) {
|
|
return false;
|
|
}
|
|
}
|
|
return proxy.sendToClient(packet);
|
|
}
|
|
|
|
public boolean sendToServer(HPacket packet) {
|
|
HProxy proxy = this.proxy;
|
|
if (proxy == null) {
|
|
return false;
|
|
}
|
|
if (!packet.isPacketComplete()) {
|
|
PacketInfoManager packetInfoManager = this.getPacketInfoManager();
|
|
packet.completePacket(packetInfoManager);
|
|
if (!packet.isPacketComplete() || !packet.canSendToServer()) {
|
|
return false;
|
|
}
|
|
}
|
|
return proxy.sendToServer(packet);
|
|
}
|
|
|
|
public String getClientHost() {
|
|
if (this.proxy == null) {
|
|
return "";
|
|
}
|
|
return this.proxy.getIntercept_host();
|
|
}
|
|
|
|
public int getClientPort() {
|
|
if (this.proxy == null) {
|
|
return -1;
|
|
}
|
|
return this.proxy.getIntercept_port();
|
|
}
|
|
|
|
public String getHotelVersion() {
|
|
if (this.proxy == null) {
|
|
return "";
|
|
}
|
|
return this.proxy.getHotelVersion();
|
|
}
|
|
|
|
public String getClientIdentifier() {
|
|
if (this.proxy == null) {
|
|
return "";
|
|
}
|
|
return this.proxy.getClientIdentifier();
|
|
}
|
|
|
|
public HClient getClientType() {
|
|
if (this.proxy == null) {
|
|
return null;
|
|
}
|
|
return this.proxy.gethClient();
|
|
}
|
|
|
|
public PacketInfoManager getPacketInfoManager() {
|
|
if (this.proxy == null) {
|
|
return null;
|
|
}
|
|
return this.proxy.getPacketInfoManager();
|
|
}
|
|
|
|
public boolean isRawIpMode() {
|
|
return this.proxyProvider != null && this.proxyProvider instanceof LinuxRawIpFlashProxyProvider;
|
|
}
|
|
|
|
public ProxyProvider getProxyProvider() {
|
|
return this.proxyProvider;
|
|
}
|
|
}
|
|
|