clienttype, correct harble api, 1.3.3

This commit is contained in:
sirjonasxx 2021-03-02 02:17:29 +01:00
parent 96b47481b5
commit ea2bea6990
20 changed files with 47 additions and 32 deletions

View File

@ -13,7 +13,7 @@
<parent> <parent>
<groupId>G-Earth</groupId> <groupId>G-Earth</groupId>
<artifactId>G-Earth-Parent</artifactId> <artifactId>G-Earth-Parent</artifactId>
<version>1.3.2</version> <version>1.3.3</version>
<relativePath>../../</relativePath> <relativePath>../../</relativePath>
</parent> </parent>
@ -106,7 +106,7 @@
<dependency> <dependency>
<groupId>G-Earth</groupId> <groupId>G-Earth</groupId>
<artifactId>G-Earth</artifactId> <artifactId>G-Earth</artifactId>
<version>1.3.2</version> <version>1.3.3</version>
<!--<scope>provided</scope>--> <!--<scope>provided</scope>-->
</dependency> </dependency>
</dependencies> </dependencies>

View File

@ -13,7 +13,7 @@
<parent> <parent>
<groupId>G-Earth</groupId> <groupId>G-Earth</groupId>
<artifactId>G-Earth-Parent</artifactId> <artifactId>G-Earth-Parent</artifactId>
<version>1.3.2</version> <version>1.3.3</version>
<relativePath>../../</relativePath> <relativePath>../../</relativePath>
</parent> </parent>
@ -106,7 +106,7 @@
<dependency> <dependency>
<groupId>G-Earth</groupId> <groupId>G-Earth</groupId>
<artifactId>G-Earth</artifactId> <artifactId>G-Earth</artifactId>
<version>1.3.2</version> <version>1.3.3</version>
<!--<scope>provided</scope>--> <!--<scope>provided</scope>-->
</dependency> </dependency>
</dependencies> </dependencies>

View File

@ -8,7 +8,7 @@
<packaging>jar</packaging> <packaging>jar</packaging>
<version>1.3.2</version> <version>1.3.3</version>
<properties> <properties>
<javafx.version>1.8</javafx.version> <javafx.version>1.8</javafx.version>
@ -18,7 +18,7 @@
<parent> <parent>
<groupId>G-Earth</groupId> <groupId>G-Earth</groupId>
<artifactId>G-Earth-Parent</artifactId> <artifactId>G-Earth-Parent</artifactId>
<version>1.3.2</version> <version>1.3.3</version>
</parent> </parent>
<build> <build>

View File

@ -28,7 +28,7 @@ import java.util.Set;
public class Main extends Application { public class Main extends Application {
public static Application main; public static Application main;
public static String version = "1.3.2"; public static String version = "1.3.3";
private static String gitApi = "https://api.github.com/repos/sirjonasxx/G-Earth/releases/latest"; private static String gitApi = "https://api.github.com/repos/sirjonasxx/G-Earth/releases/latest";
@Override @Override

View File

@ -3,6 +3,7 @@ package gearth.extensions;
import gearth.misc.listenerpattern.Observable; import gearth.misc.listenerpattern.Observable;
import gearth.protocol.HMessage; import gearth.protocol.HMessage;
import gearth.protocol.HPacket; import gearth.protocol.HPacket;
import gearth.services.Constants;
import gearth.services.extensionhandler.extensions.implementations.network.NetworkExtensionInfo; import gearth.services.extensionhandler.extensions.implementations.network.NetworkExtensionInfo;
import java.io.*; import java.io.*;
@ -140,7 +141,9 @@ public abstract class Extension implements IExtension {
int connectionPort = packet.readInteger(); int connectionPort = packet.readInteger();
String hotelVersion = packet.readString(); String hotelVersion = packet.readString();
String harbleMessagesPath = packet.readString(); String harbleMessagesPath = packet.readString();
onConnectionObservable.fireEvent(l -> l.onConnection(host, connectionPort, hotelVersion, harbleMessagesPath)); String clientType = packet.readString();
Constants.UNITY_PACKETS = clientType.toLowerCase().contains("unity");
onConnectionObservable.fireEvent(l -> l.onConnection(host, connectionPort, hotelVersion, clientType, harbleMessagesPath));
onStartConnection(); onStartConnection();
} }
else if (packet.headerId() == NetworkExtensionInfo.OUTGOING_MESSAGES_IDS.CONNECTIONEND) { else if (packet.headerId() == NetworkExtensionInfo.OUTGOING_MESSAGES_IDS.CONNECTIONEND) {

View File

@ -1,5 +1,5 @@
package gearth.extensions; package gearth.extensions;
public interface OnConnectionListener { public interface OnConnectionListener {
void onConnection(String host, int port, String hotelversion, String harbleMessagesPath); void onConnection(String host, int port, String hotelversion, String clientType, String harbleMessagesPath);
} }

View File

@ -42,7 +42,7 @@ public class ChatConsole {
this.infoMessage = infoMessage; this.infoMessage = infoMessage;
final boolean[] doOncePerConnection = {false}; final boolean[] doOncePerConnection = {false};
extension.onConnect((s, i, s1, h1) -> doOncePerConnection[0] = true); extension.onConnect((s, i, s1, ct, h1) -> doOncePerConnection[0] = true);
extension.intercept(HMessage.Direction.TOSERVER, hMessage -> { extension.intercept(HMessage.Direction.TOSERVER, hMessage -> {
// if the first packet on init is not 4000, the extension was already running, so we open the chat instantly // if the first packet on init is not 4000, the extension was already running, so we open the chat instantly

View File

@ -29,7 +29,7 @@ public class HashSupport {
public HashSupport(IExtension extension) { public HashSupport(IExtension extension) {
this.extension = extension; this.extension = extension;
extension.onConnect((host, port, hotelversion, cachePath) -> { extension.onConnect((host, port, hotelversion, clientType, cachePath) -> {
// synchronized (lock) { // synchronized (lock) {
harbleAPI = new HarbleAPI(new File(cachePath)); harbleAPI = new HarbleAPI(new File(cachePath));
// } // }

View File

@ -38,9 +38,9 @@ public class HarbleAPIFetcher {
//latest fetched //latest fetched
public static HarbleAPI HARBLEAPI = null; public static HarbleAPI HARBLEAPI = null;
public synchronized static void fetch(String hotelversion) { public synchronized static void fetch(String hotelversion, String clientType) {
// if unity // if unity
if (!(hotelversion.toLowerCase().contains("production") || hotelversion.toLowerCase().contains("release"))) { if (clientType.toLowerCase().contains("unity")) {
try { try {
HARBLEAPI = new HarbleAPI( HARBLEAPI = new HarbleAPI(
new File(new File(Main.class.getProtectionDomain().getCodeSource().getLocation().toURI()) new File(new File(Main.class.getProtectionDomain().getCodeSource().getLocation().toURI())
@ -77,12 +77,4 @@ public class HarbleAPIFetcher {
} }
} }
public static void main(String[] args) {
fetch("PRODUCTION-201901141210-114421986");
HarbleAPI api = HARBLEAPI;
HarbleAPI.HarbleMessage haMessage = api.getHarbleMessageFromHeaderId(HMessage.Direction.TOSERVER, 525);
System.out.println(haMessage);
}
} }

View File

@ -172,6 +172,13 @@ public class HConnection {
return proxy.getHotelVersion(); return proxy.getHotelVersion();
} }
public String getClientType() {
if (proxy == null) {
return "";
}
return proxy.getClientType();
}
public boolean isRawIpMode() { public boolean isRawIpMode() {
return proxyProvider != null && proxyProvider instanceof LinuxRawIpFlashProxyProvider; return proxyProvider != null && proxyProvider instanceof LinuxRawIpFlashProxyProvider;
// WindowsRawIpProxyProvider extends LinuxRawIpProxyProvider // WindowsRawIpProxyProvider extends LinuxRawIpProxyProvider

View File

@ -21,6 +21,7 @@ public class HProxy {
private volatile PacketHandler outHandler = null; //connection with server (only initialized when verified habbo connection) private volatile PacketHandler outHandler = null; //connection with server (only initialized when verified habbo connection)
private volatile String hotelVersion = ""; private volatile String hotelVersion = "";
private volatile String clientType = "";
private volatile AsyncPacketSender asyncPacketSender = null; private volatile AsyncPacketSender asyncPacketSender = null;
public HProxy(HClient hClient, String input_domain, String actual_domain, int actual_port, int intercept_port, String intercept_host) { public HProxy(HClient hClient, String input_domain, String actual_domain, int actual_port, int intercept_port, String intercept_host) {
@ -36,13 +37,18 @@ public class HProxy {
this.proxy_server = socket; this.proxy_server = socket;
} }
public void verifyProxy(PacketHandler incomingHandler, PacketHandler outgoingHandler, String hotelVersion) { public void verifyProxy(PacketHandler incomingHandler, PacketHandler outgoingHandler, String hotelVersion, String clientType) {
this.inHandler = incomingHandler; this.inHandler = incomingHandler;
this.outHandler = outgoingHandler; this.outHandler = outgoingHandler;
this.hotelVersion = hotelVersion; this.hotelVersion = hotelVersion;
this.clientType = clientType;
this.asyncPacketSender = new AsyncPacketSender(this); this.asyncPacketSender = new AsyncPacketSender(this);
} }
public String getClientType() {
return clientType;
}
public int getActual_port() { public int getActual_port() {
return actual_port; return actual_port;
} }

View File

@ -51,9 +51,9 @@ public abstract class FlashProxyProvider implements ProxyProvider {
Semaphore abort = new Semaphore(0); Semaphore abort = new Semaphore(0);
outgoingHandler.addOnDatastreamConfirmedListener(hotelVersion -> { outgoingHandler.addOnDatastreamConfirmedListener((hotelVersion, clientType) -> {
incomingHandler.setAsDataStream(); incomingHandler.setAsDataStream();
proxy.verifyProxy(incomingHandler, outgoingHandler, hotelVersion); proxy.verifyProxy(incomingHandler, outgoingHandler, hotelVersion, clientType);
proxySetter.setProxy(proxy); proxySetter.setProxy(proxy);
datastream[0] = true; datastream[0] = true;
abortSemaphore = abort; abortSemaphore = abort;

View File

@ -58,10 +58,13 @@ public class UnityCommunicator {
HPacket maybe = new HPacket(packet); HPacket maybe = new HPacket(packet);
if (maybe.getBytesLength() > 6 && maybe.headerId() == 4000) { if (maybe.getBytesLength() > 6 && maybe.headerId() == 4000) {
hProxy = new HProxy(HClient.UNITY, "", "", -1, -1, ""); hProxy = new HProxy(HClient.UNITY, "", "", -1, -1, "");
String ignore = maybe.readString();
String clientType = maybe.readString();
hProxy.verifyProxy( hProxy.verifyProxy(
new UnityPacketHandler(hConnection.getExtensionHandler(), hConnection.getTrafficObservables(), session, HMessage.Direction.TOCLIENT), new UnityPacketHandler(hConnection.getExtensionHandler(), hConnection.getTrafficObservables(), session, HMessage.Direction.TOCLIENT),
new UnityPacketHandler(hConnection.getExtensionHandler(), hConnection.getTrafficObservables(), session, HMessage.Direction.TOSERVER), new UnityPacketHandler(hConnection.getExtensionHandler(), hConnection.getTrafficObservables(), session, HMessage.Direction.TOSERVER),
revision revision,
clientType
); );
proxySetter.setProxy(hProxy); proxySetter.setProxy(hProxy);
stateSetter.setState(HState.CONNECTED); stateSetter.setState(HState.CONNECTED);

View File

@ -2,6 +2,6 @@ package gearth.protocol.packethandler.flash;
public interface OnDatastreamConfirmedListener { public interface OnDatastreamConfirmedListener {
void confirm(String hotelVersion); void confirm(String hotelVersion, String clientType);
} }

View File

@ -27,7 +27,8 @@ public class OutgoingFlashPacketHandler extends FlashPacketHandler {
isDataStream = (hpacket.getBytesLength() > 6 && hpacket.length() < 100); isDataStream = (hpacket.getBytesLength() > 6 && hpacket.length() < 100);
if (isDataStream) { if (isDataStream) {
String version = hpacket.readString(); String version = hpacket.readString();
datastreamConfirmedObservable.fireEvent(l -> l.confirm(version)); String clientType = hpacket.readString();
datastreamConfirmedObservable.fireEvent(l -> l.confirm(version, clientType));
} }
} }
} }

View File

@ -48,13 +48,14 @@ public class ExtensionHandler {
hConnection.getStateObservable().addListener((oldState, newState) -> { hConnection.getStateObservable().addListener((oldState, newState) -> {
if (newState == HState.CONNECTED) { if (newState == HState.CONNECTED) {
HarbleAPIFetcher.fetch(hConnection.getHotelVersion()); HarbleAPIFetcher.fetch(hConnection.getHotelVersion(), hConnection.getClientType());
synchronized (gEarthExtensions) { synchronized (gEarthExtensions) {
for (GEarthExtension extension : gEarthExtensions) { for (GEarthExtension extension : gEarthExtensions) {
extension.connectionStart( extension.connectionStart(
hConnection.getDomain(), hConnection.getDomain(),
hConnection.getServerPort(), hConnection.getServerPort(),
hConnection.getHotelVersion(), hConnection.getHotelVersion(),
hConnection.getClientType(),
HarbleAPIFetcher.HARBLEAPI == null ? "null" : HarbleAPIFetcher.HARBLEAPI.getPath() HarbleAPIFetcher.HARBLEAPI == null ? "null" : HarbleAPIFetcher.HARBLEAPI.getPath()
); );
} }
@ -243,6 +244,7 @@ public class ExtensionHandler {
hConnection.getDomain(), hConnection.getDomain(),
hConnection.getServerPort(), hConnection.getServerPort(),
hConnection.getHotelVersion(), hConnection.getHotelVersion(),
hConnection.getClientType(),
HarbleAPIFetcher.HARBLEAPI == null ? "null" : HarbleAPIFetcher.HARBLEAPI.getPath() HarbleAPIFetcher.HARBLEAPI == null ? "null" : HarbleAPIFetcher.HARBLEAPI.getPath()
); );
} }

View File

@ -38,7 +38,7 @@ public abstract class GEarthExtension {
public abstract void doubleclick(); public abstract void doubleclick();
public abstract void packetIntercept(HMessage hMessage); public abstract void packetIntercept(HMessage hMessage);
public abstract void provideFlags(String[] flags); public abstract void provideFlags(String[] flags);
public abstract void connectionStart(String host, int port, String hotelVersion, String harbleMessagesPath); public abstract void connectionStart(String host, int port, String hotelVersion, String clientType, String harbleMessagesPath);
public abstract void connectionEnd(); public abstract void connectionEnd();
public abstract void init(); public abstract void init();
public abstract void close(); public abstract void close();

View File

@ -190,13 +190,14 @@ public class NetworkExtension extends GEarthExtension {
} }
@Override @Override
public void connectionStart(String host, int port, String hotelVersion, String harbleMessagesPath) { public void connectionStart(String host, int port, String hotelVersion, String clientType, String harbleMessagesPath) {
sendMessage( sendMessage(
new HPacket(NetworkExtensionInfo.OUTGOING_MESSAGES_IDS.CONNECTIONSTART) new HPacket(NetworkExtensionInfo.OUTGOING_MESSAGES_IDS.CONNECTIONSTART)
.appendString(host) .appendString(host)
.appendInt(port) .appendInt(port)
.appendString(hotelVersion) .appendString(hotelVersion)
.appendString(harbleMessagesPath) .appendString(harbleMessagesPath)
.appendString(clientType)
); );
} }

View File

@ -83,7 +83,7 @@ public class ExampleExtension extends GEarthExtension {
} }
@Override @Override
public void connectionStart(String host, int port, String hotelVersion, String harbleMessagesPath) { public void connectionStart(String host, int port, String hotelVersion, String clientType, String harbleMessagesPath) {
// a new habbo client has connected // a new habbo client has connected
System.out.println("Connected to " + host); System.out.println("Connected to " + host);
} }

View File

@ -7,7 +7,7 @@
<groupId>G-Earth</groupId> <groupId>G-Earth</groupId>
<artifactId>G-Earth-Parent</artifactId> <artifactId>G-Earth-Parent</artifactId>
<packaging>pom</packaging> <packaging>pom</packaging>
<version>1.3.2</version> <version>1.3.3</version>
<name>G-Earth-Parent</name> <name>G-Earth-Parent</name>
<url>https://github.com/sirjonasxx/G-Earth</url> <url>https://github.com/sirjonasxx/G-Earth</url>