mirror of
https://github.com/sirjonasxx/G-Earth.git
synced 2025-01-31 12:52:36 +01:00
integrate into extensions and packetlogger
This commit is contained in:
parent
9698348503
commit
0975d66379
@ -1,8 +1,10 @@
|
|||||||
package gearth.extensions;
|
package gearth.extensions;
|
||||||
|
|
||||||
import gearth.misc.listenerpattern.Observable;
|
import gearth.misc.listenerpattern.Observable;
|
||||||
|
import gearth.misc.packet_info.PacketInfoManager;
|
||||||
import gearth.protocol.HMessage;
|
import gearth.protocol.HMessage;
|
||||||
import gearth.protocol.HPacket;
|
import gearth.protocol.HPacket;
|
||||||
|
import gearth.protocol.connection.HClient;
|
||||||
import gearth.services.Constants;
|
import gearth.services.Constants;
|
||||||
import gearth.services.extensionhandler.extensions.implementations.network.NetworkExtensionInfo;
|
import gearth.services.extensionhandler.extensions.implementations.network.NetworkExtensionInfo;
|
||||||
|
|
||||||
@ -140,10 +142,15 @@ public abstract class Extension implements IExtension {
|
|||||||
String host = packet.readString();
|
String host = packet.readString();
|
||||||
int connectionPort = packet.readInteger();
|
int connectionPort = packet.readInteger();
|
||||||
String hotelVersion = packet.readString();
|
String hotelVersion = packet.readString();
|
||||||
String harbleMessagesPath = packet.readString();
|
String clientIdentifier = packet.readString();
|
||||||
String clientType = packet.readString();
|
HClient clientType = HClient.valueOf(packet.readString());
|
||||||
Constants.UNITY_PACKETS = clientType.toLowerCase().contains("unity");
|
PacketInfoManager packetInfoManager = PacketInfoManager.readFromPacket(packet);
|
||||||
onConnectionObservable.fireEvent(l -> l.onConnection(host, connectionPort, hotelVersion, clientType, harbleMessagesPath));
|
|
||||||
|
Constants.UNITY_PACKETS = clientType == HClient.UNITY;
|
||||||
|
onConnectionObservable.fireEvent(l -> l.onConnection(
|
||||||
|
host, connectionPort, hotelVersion,
|
||||||
|
clientIdentifier, clientType, packetInfoManager)
|
||||||
|
);
|
||||||
onStartConnection();
|
onStartConnection();
|
||||||
}
|
}
|
||||||
else if (packet.headerId() == NetworkExtensionInfo.OUTGOING_MESSAGES_IDS.CONNECTIONEND) {
|
else if (packet.headerId() == NetworkExtensionInfo.OUTGOING_MESSAGES_IDS.CONNECTIONEND) {
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
package gearth.extensions;
|
package gearth.extensions;
|
||||||
|
|
||||||
|
import gearth.misc.packet_info.PacketInfoManager;
|
||||||
|
import gearth.protocol.connection.HClient;
|
||||||
|
|
||||||
public interface OnConnectionListener {
|
public interface OnConnectionListener {
|
||||||
void onConnection(String host, int port, String hotelversion, String clientType, String harbleMessagesPath);
|
void onConnection(String host, int port, String hotelversion, String clientIdentifier, HClient clientType, PacketInfoManager packetInfoManager);
|
||||||
}
|
}
|
||||||
|
@ -4,8 +4,10 @@ import gearth.extensions.ExtensionInfo;
|
|||||||
import gearth.extensions.IExtension;
|
import gearth.extensions.IExtension;
|
||||||
import gearth.extensions.OnConnectionListener;
|
import gearth.extensions.OnConnectionListener;
|
||||||
import gearth.misc.listenerpattern.Observable;
|
import gearth.misc.listenerpattern.Observable;
|
||||||
|
import gearth.misc.packet_info.PacketInfoManager;
|
||||||
import gearth.protocol.HMessage;
|
import gearth.protocol.HMessage;
|
||||||
import gearth.protocol.HPacket;
|
import gearth.protocol.HPacket;
|
||||||
|
import gearth.protocol.connection.HClient;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Jonas on 3/12/2018.
|
* Created by Jonas on 3/12/2018.
|
||||||
@ -18,31 +20,33 @@ public class ChatConsole {
|
|||||||
|
|
||||||
private volatile int chatid;
|
private volatile int chatid;
|
||||||
private volatile String name;
|
private volatile String name;
|
||||||
private volatile HashSupport hashSupport;
|
private volatile PacketInfoSupport packetInfoSupport;
|
||||||
private volatile String infoMessage;
|
private volatile String infoMessage;
|
||||||
|
|
||||||
private volatile boolean firstTime = true;
|
private volatile boolean firstTime = true;
|
||||||
private volatile Observable<ChatInputListener> chatInputObservable = new Observable<>();
|
private volatile Observable<ChatInputListener> chatInputObservable = new Observable<>();
|
||||||
|
|
||||||
|
|
||||||
public ChatConsole(final HashSupport hashSupport, IExtension extension) {
|
public ChatConsole(final PacketInfoSupport packetInfoSupport, IExtension extension) {
|
||||||
this(hashSupport, extension, null);
|
this(packetInfoSupport, extension, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* infomessage will be used as response for :info and for initialize
|
* infomessage will be used as response for :info and for initialize
|
||||||
* @param hashSupport
|
* @param packetInfoSupport
|
||||||
* @param extension
|
* @param extension
|
||||||
* @param infoMessage
|
* @param infoMessage
|
||||||
*/
|
*/
|
||||||
public ChatConsole(final HashSupport hashSupport, IExtension extension, String infoMessage) {
|
public ChatConsole(final PacketInfoSupport packetInfoSupport, IExtension extension, String infoMessage) {
|
||||||
this.hashSupport = hashSupport;
|
this.packetInfoSupport = packetInfoSupport;
|
||||||
this.name = extension.getClass().getAnnotation(ExtensionInfo.class).Title();
|
this.name = extension.getClass().getAnnotation(ExtensionInfo.class).Title();
|
||||||
chatid = (this.name.hashCode() % 300000000) + 300000000;
|
chatid = (this.name.hashCode() % 300000000) + 300000000;
|
||||||
this.infoMessage = infoMessage;
|
this.infoMessage = infoMessage;
|
||||||
|
|
||||||
final boolean[] doOncePerConnection = {false};
|
final boolean[] doOncePerConnection = {false};
|
||||||
extension.onConnect((s, i, s1, ct, h1) -> doOncePerConnection[0] = true);
|
extension.onConnect((host, port, hotelversion, clientIdentifier, clientType, packetInfoManager) ->
|
||||||
|
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
|
||||||
@ -55,7 +59,7 @@ public class ChatConsole {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
hashSupport.intercept(HMessage.Direction.TOCLIENT, "FriendListFragment", hMessage -> {
|
packetInfoSupport.intercept(HMessage.Direction.TOCLIENT, "FriendListFragment", hMessage -> {
|
||||||
if (doOncePerConnection[0]) {
|
if (doOncePerConnection[0]) {
|
||||||
doOncePerConnection[0] = false;
|
doOncePerConnection[0] = false;
|
||||||
|
|
||||||
@ -71,7 +75,7 @@ public class ChatConsole {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
hashSupport.intercept(HMessage.Direction.TOSERVER, "SendMsg", hMessage -> {
|
packetInfoSupport.intercept(HMessage.Direction.TOSERVER, "SendMsg", hMessage -> {
|
||||||
HPacket packet = hMessage.getPacket();
|
HPacket packet = hMessage.getPacket();
|
||||||
if (packet.readInteger() == chatid) {
|
if (packet.readInteger() == chatid) {
|
||||||
hMessage.setBlocked(true);
|
hMessage.setBlocked(true);
|
||||||
@ -87,7 +91,7 @@ public class ChatConsole {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void createChat() {
|
private void createChat() {
|
||||||
hashSupport.sendToClient("FriendListUpdate",
|
packetInfoSupport.sendToClient("FriendListUpdate",
|
||||||
0, 1, 0, chatid, " [G-Earth] - " + name,
|
0, 1, 0, chatid, " [G-Earth] - " + name,
|
||||||
1, true, false, "ha-1015-64.hd-209-30.cc-260-64.ch-235-64.sh-305-64.lg-285-64",
|
1, true, false, "ha-1015-64.hd-209-30.cc-260-64.ch-235-64.sh-305-64.lg-285-64",
|
||||||
0, "", 0, true, false, true, ""
|
0, "", 0, true, false, true, ""
|
||||||
@ -100,10 +104,10 @@ public class ChatConsole {
|
|||||||
|
|
||||||
public void writeOutput(String string, boolean asInvite) {
|
public void writeOutput(String string, boolean asInvite) {
|
||||||
if (asInvite) {
|
if (asInvite) {
|
||||||
hashSupport.sendToClient("RoomInvite", chatid, string);
|
packetInfoSupport.sendToClient("RoomInvite", chatid, string);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
hashSupport.sendToClient("NewConsole", chatid, string, 0, "");
|
packetInfoSupport.sendToClient("NewConsole", chatid, string, 0, "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,135 +0,0 @@
|
|||||||
package gearth.extensions.extra.harble;
|
|
||||||
|
|
||||||
import gearth.extensions.Extension;
|
|
||||||
import gearth.extensions.IExtension;
|
|
||||||
import gearth.misc.harble_api.PacketInfoManager;
|
|
||||||
import gearth.protocol.HMessage;
|
|
||||||
import gearth.protocol.HPacket;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.security.InvalidParameterException;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by Jonas on 10/11/2018.
|
|
||||||
*/
|
|
||||||
public class HashSupport {
|
|
||||||
|
|
||||||
private final Object lock = new Object();
|
|
||||||
|
|
||||||
private PacketInfoManager packetInfoManager = new PacketInfoManager(""); //empty
|
|
||||||
private Map<String, List<Extension.MessageListener>> incomingMessageListeners = new HashMap<>();
|
|
||||||
private Map<String, List<Extension.MessageListener>> outgoingMessageListeners = new HashMap<>();
|
|
||||||
|
|
||||||
private IExtension extension;
|
|
||||||
|
|
||||||
public HashSupport(IExtension extension) {
|
|
||||||
this.extension = extension;
|
|
||||||
|
|
||||||
extension.onConnect((host, port, hotelversion, clientType, cachePath) -> {
|
|
||||||
// synchronized (lock) {
|
|
||||||
packetInfoManager = new PacketInfoManager(new File(cachePath));
|
|
||||||
// }
|
|
||||||
});
|
|
||||||
|
|
||||||
extension.intercept(HMessage.Direction.TOSERVER, message -> {
|
|
||||||
// synchronized (lock) {
|
|
||||||
PacketInfoManager.HarbleMessage haMessage = packetInfoManager.getHarbleMessageFromHeaderId(HMessage.Direction.TOSERVER, message.getPacket().headerId());
|
|
||||||
if (haMessage != null) {
|
|
||||||
List<Extension.MessageListener> listeners_hash = outgoingMessageListeners.get(haMessage.getHash());
|
|
||||||
List<Extension.MessageListener> listeners_name = outgoingMessageListeners.get(haMessage.getName());
|
|
||||||
if (listeners_hash != null) {
|
|
||||||
for (Extension.MessageListener listener : listeners_hash) {
|
|
||||||
listener.act(message);
|
|
||||||
message.getPacket().resetReadIndex();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (listeners_name != null) {
|
|
||||||
for (Extension.MessageListener listener : listeners_name) {
|
|
||||||
listener.act(message);
|
|
||||||
message.getPacket().resetReadIndex();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// }
|
|
||||||
});
|
|
||||||
extension.intercept(HMessage.Direction.TOCLIENT, message -> {
|
|
||||||
// synchronized (lock) {
|
|
||||||
PacketInfoManager.HarbleMessage haMessage = packetInfoManager.getHarbleMessageFromHeaderId(HMessage.Direction.TOCLIENT, message.getPacket().headerId());
|
|
||||||
if (haMessage != null) {
|
|
||||||
List<Extension.MessageListener> listeners_hash = incomingMessageListeners.get(haMessage.getHash());
|
|
||||||
List<Extension.MessageListener> listeners_name = incomingMessageListeners.get(haMessage.getName());
|
|
||||||
if (listeners_hash != null) {
|
|
||||||
for (Extension.MessageListener listener : listeners_hash) {
|
|
||||||
listener.act(message);
|
|
||||||
message.getPacket().resetReadIndex();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (listeners_name != null) {
|
|
||||||
for (Extension.MessageListener listener : listeners_name) {
|
|
||||||
listener.act(message);
|
|
||||||
message.getPacket().resetReadIndex();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// }
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public void intercept(HMessage.Direction direction, String hashOrName, Extension.MessageListener messageListener) {
|
|
||||||
Map<String, List<Extension.MessageListener>> messageListeners =
|
|
||||||
(direction == HMessage.Direction.TOSERVER
|
|
||||||
? outgoingMessageListeners
|
|
||||||
: incomingMessageListeners);
|
|
||||||
|
|
||||||
messageListeners.computeIfAbsent(hashOrName, k -> new ArrayList<>());
|
|
||||||
messageListeners.get(hashOrName).add(messageListener);
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean send(HMessage.Direction direction, String hashOrName, Object... objects) {
|
|
||||||
int headerId;
|
|
||||||
PacketInfoManager.HarbleMessage fromname = packetInfoManager.getHarbleMessageFromName(direction, hashOrName);
|
|
||||||
if (fromname != null) {
|
|
||||||
headerId = fromname.getHeaderId();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
List<PacketInfoManager.HarbleMessage> possibilities = packetInfoManager.getHarbleMessagesFromHash(direction, hashOrName);
|
|
||||||
if (possibilities.size() == 0) return false;
|
|
||||||
headerId = possibilities.get(0).getHeaderId();
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
HPacket packetToSend = new HPacket(headerId, objects);
|
|
||||||
|
|
||||||
return (direction == HMessage.Direction.TOCLIENT
|
|
||||||
? extension.sendToClient(packetToSend)
|
|
||||||
: extension.sendToServer(packetToSend));
|
|
||||||
}
|
|
||||||
catch (InvalidParameterException e) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @return if no errors occurred (invalid hash/invalid parameters/connection error)
|
|
||||||
*/
|
|
||||||
public boolean sendToClient(String hashOrName, Object... objects) {
|
|
||||||
return send(HMessage.Direction.TOCLIENT, hashOrName, objects);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @return if no errors occurred (invalid hash/invalid parameters/connection error)
|
|
||||||
*/
|
|
||||||
public boolean sendToServer(String hashOrName, Object... objects) {
|
|
||||||
return send(HMessage.Direction.TOSERVER, hashOrName, objects);
|
|
||||||
}
|
|
||||||
|
|
||||||
public PacketInfoManager getPacketInfoManager() {
|
|
||||||
return packetInfoManager;
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,118 @@
|
|||||||
|
package gearth.extensions.extra.harble;
|
||||||
|
|
||||||
|
import gearth.extensions.Extension;
|
||||||
|
import gearth.extensions.IExtension;
|
||||||
|
import gearth.extensions.OnConnectionListener;
|
||||||
|
import gearth.misc.packet_info.PacketInfo;
|
||||||
|
import gearth.misc.packet_info.PacketInfoManager;
|
||||||
|
import gearth.protocol.HMessage;
|
||||||
|
import gearth.protocol.HPacket;
|
||||||
|
import gearth.protocol.connection.HClient;
|
||||||
|
|
||||||
|
import java.security.InvalidParameterException;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by Jonas on 10/11/2018.
|
||||||
|
*/
|
||||||
|
public class PacketInfoSupport {
|
||||||
|
|
||||||
|
private final Object lock = new Object();
|
||||||
|
|
||||||
|
private PacketInfoManager packetInfoManager = new PacketInfoManager(new ArrayList<>()); //empty
|
||||||
|
private Map<String, List<Extension.MessageListener>> incomingMessageListeners = new HashMap<>();
|
||||||
|
private Map<String, List<Extension.MessageListener>> outgoingMessageListeners = new HashMap<>();
|
||||||
|
|
||||||
|
private IExtension extension;
|
||||||
|
|
||||||
|
public PacketInfoSupport(IExtension extension) {
|
||||||
|
this.extension = extension;
|
||||||
|
|
||||||
|
extension.onConnect((host, port, hotelversion, clientIdentifier, clientType, packetInfoManager) ->
|
||||||
|
this.packetInfoManager = packetInfoManager
|
||||||
|
);
|
||||||
|
|
||||||
|
extension.intercept(HMessage.Direction.TOSERVER, message -> onReceivePacket(HMessage.Direction.TOSERVER, message));
|
||||||
|
extension.intercept(HMessage.Direction.TOCLIENT, message -> onReceivePacket(HMessage.Direction.TOCLIENT, message));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void onReceivePacket(HMessage.Direction direction, HMessage message) {
|
||||||
|
Set<Extension.MessageListener> callbacks = new HashSet<>();
|
||||||
|
Map<String, List<Extension.MessageListener>> messageListeners =
|
||||||
|
(direction == HMessage.Direction.TOSERVER
|
||||||
|
? outgoingMessageListeners
|
||||||
|
: incomingMessageListeners);
|
||||||
|
|
||||||
|
List<PacketInfo> packetInfos = packetInfoManager.getAllPacketInfoFromHeaderId(HMessage.Direction.TOCLIENT, message.getPacket().headerId());
|
||||||
|
|
||||||
|
for (PacketInfo packetInfo : packetInfos) {
|
||||||
|
List<Extension.MessageListener> listeners_hash = messageListeners.get(packetInfo.getHash());
|
||||||
|
List<Extension.MessageListener> listeners_name = messageListeners.get(packetInfo.getName());
|
||||||
|
if (listeners_hash != null) {
|
||||||
|
callbacks.addAll(listeners_hash);
|
||||||
|
}
|
||||||
|
if (listeners_name != null) {
|
||||||
|
callbacks.addAll(listeners_name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Extension.MessageListener listener : callbacks) {
|
||||||
|
listener.act(message);
|
||||||
|
message.getPacket().resetReadIndex();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void intercept(HMessage.Direction direction, String hashOrName, Extension.MessageListener messageListener) {
|
||||||
|
Map<String, List<Extension.MessageListener>> messageListeners =
|
||||||
|
(direction == HMessage.Direction.TOSERVER
|
||||||
|
? outgoingMessageListeners
|
||||||
|
: incomingMessageListeners);
|
||||||
|
|
||||||
|
messageListeners.computeIfAbsent(hashOrName, k -> new ArrayList<>());
|
||||||
|
messageListeners.get(hashOrName).add(messageListener);
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean send(HMessage.Direction direction, String hashOrName, Object... objects) {
|
||||||
|
int headerId;
|
||||||
|
PacketInfo fromname = packetInfoManager.getPacketInfoFromName(direction, hashOrName);
|
||||||
|
if (fromname != null) {
|
||||||
|
headerId = fromname.getHeaderId();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
PacketInfo fromHash = packetInfoManager.getPacketInfoFromHash(direction, hashOrName);
|
||||||
|
if (fromHash == null) return false;
|
||||||
|
headerId = fromHash.getHeaderId();
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
HPacket packetToSend = new HPacket(headerId, objects);
|
||||||
|
|
||||||
|
return (direction == HMessage.Direction.TOCLIENT
|
||||||
|
? extension.sendToClient(packetToSend)
|
||||||
|
: extension.sendToServer(packetToSend));
|
||||||
|
}
|
||||||
|
catch (InvalidParameterException e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return if no errors occurred (invalid hash/invalid parameters/connection error)
|
||||||
|
*/
|
||||||
|
public boolean sendToClient(String hashOrName, Object... objects) {
|
||||||
|
return send(HMessage.Direction.TOCLIENT, hashOrName, objects);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return if no errors occurred (invalid hash/invalid parameters/connection error)
|
||||||
|
*/
|
||||||
|
public boolean sendToServer(String hashOrName, Object... objects) {
|
||||||
|
return send(HMessage.Direction.TOSERVER, hashOrName, objects);
|
||||||
|
}
|
||||||
|
|
||||||
|
public PacketInfoManager getPacketInfoManager() {
|
||||||
|
return packetInfoManager;
|
||||||
|
}
|
||||||
|
}
|
@ -1,60 +0,0 @@
|
|||||||
package gearth.misc.harble_api;
|
|
||||||
|
|
||||||
import gearth.Main;
|
|
||||||
import gearth.misc.Cacher;
|
|
||||||
import org.jsoup.Connection;
|
|
||||||
import org.jsoup.Jsoup;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.net.URISyntaxException;
|
|
||||||
|
|
||||||
|
|
||||||
public class HarbleAPIFetcher {
|
|
||||||
|
|
||||||
public static final String CACHE_PREFIX = "HARBLE_API-";
|
|
||||||
public static final String HARBLE_API_URL = "https://api.harble.net/messages/$hotelversion$.json";
|
|
||||||
|
|
||||||
//latest fetched
|
|
||||||
public static PacketInfoManager HARBLEAPI = null;
|
|
||||||
|
|
||||||
public synchronized static void fetch(String hotelversion, String clientType) {
|
|
||||||
// if unity
|
|
||||||
if (clientType.toLowerCase().contains("unity")) {
|
|
||||||
try {
|
|
||||||
HARBLEAPI = new PacketInfoManager(
|
|
||||||
new File(new File(Main.class.getProtectionDomain().getCodeSource().getLocation().toURI())
|
|
||||||
.getParentFile(), "messages.json"
|
|
||||||
)
|
|
||||||
);
|
|
||||||
} catch (URISyntaxException e) {
|
|
||||||
HARBLEAPI = null;
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
String cacheName = CACHE_PREFIX + hotelversion;
|
|
||||||
|
|
||||||
if (Cacher.cacheFileExists(cacheName)) {
|
|
||||||
HARBLEAPI = new PacketInfoManager(hotelversion);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
Connection connection = Jsoup.connect(HARBLE_API_URL.replace("$hotelversion$", hotelversion)).ignoreContentType(true);
|
|
||||||
try {
|
|
||||||
connection.timeout(3000);
|
|
||||||
Connection.Response response = connection.execute();
|
|
||||||
if (response.statusCode() == 200) {
|
|
||||||
String messagesBodyJson = response.body();
|
|
||||||
Cacher.updateCache(messagesBodyJson, cacheName);
|
|
||||||
HARBLEAPI = new PacketInfoManager(hotelversion);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
HARBLEAPI = null;
|
|
||||||
}
|
|
||||||
} catch (IOException e) {
|
|
||||||
HARBLEAPI = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,224 +0,0 @@
|
|||||||
package gearth.misc.harble_api;
|
|
||||||
|
|
||||||
import gearth.misc.Cacher;
|
|
||||||
import gearth.protocol.HMessage;
|
|
||||||
import org.json.JSONArray;
|
|
||||||
import org.json.JSONObject;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.nio.file.Files;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by Jonas on 10/11/2018.
|
|
||||||
*/
|
|
||||||
public class PacketInfoManager {
|
|
||||||
|
|
||||||
public class HarbleMessage {
|
|
||||||
private HMessage.Direction destination;
|
|
||||||
private int headerId;
|
|
||||||
private String hash;
|
|
||||||
private String name;
|
|
||||||
private String structure;
|
|
||||||
|
|
||||||
//name can be NULL
|
|
||||||
public HarbleMessage(HMessage.Direction destination, int headerId, String hash, String name, String structure) {
|
|
||||||
this.destination = destination;
|
|
||||||
this.headerId = headerId;
|
|
||||||
this.hash = hash;
|
|
||||||
this.name = (name == null || name.equals("null") ? null : name);
|
|
||||||
this.structure = (structure == null || structure.equals("null") ? null : structure);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getName() {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getHeaderId() {
|
|
||||||
return headerId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public HMessage.Direction getDestination() {
|
|
||||||
return destination;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getHash() {
|
|
||||||
return hash;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getStructure() {
|
|
||||||
return structure;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String toString() {
|
|
||||||
String s = (headerId + ": " + "[" + hash + "][" + name + "][" + structure + "]");
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private Map<Integer, HarbleMessage> headerIdToMessage_incoming = new HashMap<>();
|
|
||||||
private Map<Integer, HarbleMessage> headerIdToMessage_outgoing = new HashMap<>();
|
|
||||||
|
|
||||||
private Map<String, List<HarbleMessage>> hashToMessage_incoming = new HashMap<>();
|
|
||||||
private Map<String, List<HarbleMessage>> hashToMessage_outgoing = new HashMap<>();
|
|
||||||
|
|
||||||
private Map<String, HarbleMessage> nameToMessage_incoming = new HashMap<>();
|
|
||||||
private Map<String, HarbleMessage> nameToMessage_outgoing = new HashMap<>();
|
|
||||||
|
|
||||||
private boolean success = false;
|
|
||||||
private String fullPath = null;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* cache file must be generated first within G-Earth, inb4 20 extensions requesting it at the same time
|
|
||||||
*
|
|
||||||
* @param hotelversion
|
|
||||||
*/
|
|
||||||
|
|
||||||
public static PacketInfoManager get(String hotelversion) {
|
|
||||||
PacketInfoManager wannabe = new PacketInfoManager(hotelversion);
|
|
||||||
if (!wannabe.success) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return wannabe;
|
|
||||||
}
|
|
||||||
|
|
||||||
public PacketInfoManager(String hotelversion) {
|
|
||||||
String possibleCachedMessagesPath = HarbleAPIFetcher.CACHE_PREFIX + hotelversion;
|
|
||||||
if (Cacher.cacheFileExists(possibleCachedMessagesPath)) {
|
|
||||||
JSONObject object = Cacher.getCacheContents(possibleCachedMessagesPath);
|
|
||||||
success = true;
|
|
||||||
fullPath = Cacher.getCacheDir() + File.separator + possibleCachedMessagesPath;
|
|
||||||
parse(object);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public PacketInfoManager(File f) {
|
|
||||||
if (f.exists() && !f.isDirectory()) {
|
|
||||||
try {
|
|
||||||
String contents = String.join("\n", Files.readAllLines(f.toPath()));
|
|
||||||
JSONObject object = new JSONObject(contents);
|
|
||||||
success = true;
|
|
||||||
fullPath = f.getAbsolutePath();
|
|
||||||
parse(object);
|
|
||||||
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void addMessage(HMessage.Direction direction, JSONObject object) {
|
|
||||||
String name;
|
|
||||||
String hash;
|
|
||||||
try { name = object.getString("Name"); }
|
|
||||||
catch (Exception e) { name = null; }
|
|
||||||
try { hash = object.getString("Hash"); }
|
|
||||||
catch (Exception e) { hash = null; }
|
|
||||||
|
|
||||||
|
|
||||||
int headerId = object.getInt("Id");
|
|
||||||
|
|
||||||
String structure;
|
|
||||||
try {
|
|
||||||
structure = object.getString("Structure");
|
|
||||||
} catch (Exception e) {
|
|
||||||
structure = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
HarbleMessage message = new HarbleMessage(direction, headerId, hash, name, structure);
|
|
||||||
|
|
||||||
|
|
||||||
Map<Integer, HarbleMessage> headerIdToMessage =
|
|
||||||
message.getDestination() == HMessage.Direction.TOCLIENT
|
|
||||||
? headerIdToMessage_incoming :
|
|
||||||
headerIdToMessage_outgoing;
|
|
||||||
|
|
||||||
Map<String, List<HarbleMessage>> hashToMessage =
|
|
||||||
message.getDestination() == HMessage.Direction.TOCLIENT
|
|
||||||
? hashToMessage_incoming
|
|
||||||
: hashToMessage_outgoing;
|
|
||||||
|
|
||||||
Map<String, HarbleMessage> nameToMessag =
|
|
||||||
message.getDestination() == HMessage.Direction.TOCLIENT
|
|
||||||
? nameToMessage_incoming
|
|
||||||
: nameToMessage_outgoing;
|
|
||||||
|
|
||||||
headerIdToMessage.put(message.getHeaderId(), message);
|
|
||||||
hashToMessage.computeIfAbsent(message.getHash(), k -> new ArrayList<>());
|
|
||||||
hashToMessage.get(message.getHash()).add(message);
|
|
||||||
if (message.getName() != null && !message.getName().equals("null")) {
|
|
||||||
nameToMessag.put(message.getName(), message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void parse(JSONObject object) {
|
|
||||||
try {
|
|
||||||
JSONArray incoming = object.getJSONArray("Incoming");
|
|
||||||
JSONArray outgoing = object.getJSONArray("Outgoing");
|
|
||||||
|
|
||||||
if (incoming != null && outgoing != null) {
|
|
||||||
for (int i = 0; i < incoming.length(); i++) {
|
|
||||||
try {
|
|
||||||
JSONObject message = incoming.getJSONObject(i);
|
|
||||||
addMessage(HMessage.Direction.TOCLIENT, message);
|
|
||||||
}
|
|
||||||
catch (Exception e){
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (int i = 0; i < outgoing.length(); i++) {
|
|
||||||
try{
|
|
||||||
JSONObject message = outgoing.getJSONObject(i);
|
|
||||||
addMessage(HMessage.Direction.TOSERVER, message);
|
|
||||||
}
|
|
||||||
catch (Exception e){
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
success = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public HarbleMessage getHarbleMessageFromHeaderId(HMessage.Direction direction, int headerId) {
|
|
||||||
Map<Integer, HarbleMessage> headerIdToMessage =
|
|
||||||
(direction == HMessage.Direction.TOSERVER
|
|
||||||
? headerIdToMessage_outgoing
|
|
||||||
: headerIdToMessage_incoming);
|
|
||||||
|
|
||||||
return headerIdToMessage.get(headerId);
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<HarbleMessage> getHarbleMessagesFromHash(HMessage.Direction direction, String hash) {
|
|
||||||
Map<String, List<HarbleMessage>> hashToMessage =
|
|
||||||
(direction == HMessage.Direction.TOSERVER
|
|
||||||
? hashToMessage_outgoing
|
|
||||||
: hashToMessage_incoming);
|
|
||||||
|
|
||||||
List<HarbleMessage> result = hashToMessage.get(hash);
|
|
||||||
return result == null ? new ArrayList<>() : result;
|
|
||||||
}
|
|
||||||
|
|
||||||
public HarbleMessage getHarbleMessageFromName(HMessage.Direction direction, String name) {
|
|
||||||
Map<String, HarbleMessage> nameToMessage =
|
|
||||||
(direction == HMessage.Direction.TOSERVER
|
|
||||||
? nameToMessage_outgoing
|
|
||||||
: nameToMessage_incoming);
|
|
||||||
|
|
||||||
return nameToMessage.get(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getPath() {
|
|
||||||
if (success) {
|
|
||||||
return fullPath;
|
|
||||||
}
|
|
||||||
return "null";
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,13 +1,14 @@
|
|||||||
package gearth.misc.packet_info;
|
package gearth.misc.packet_info;
|
||||||
|
|
||||||
import gearth.misc.Cacher;
|
import gearth.misc.Cacher;
|
||||||
import gearth.misc.harble_api.HarbleAPIFetcher;
|
|
||||||
import gearth.misc.packet_info.providers.RemotePacketInfoProvider;
|
import gearth.misc.packet_info.providers.RemotePacketInfoProvider;
|
||||||
import gearth.misc.packet_info.providers.implementations.HarblePacketInfoProvider;
|
import gearth.misc.packet_info.providers.implementations.HarblePacketInfoProvider;
|
||||||
import gearth.misc.packet_info.providers.implementations.SulekPacketInfoProvider;
|
import gearth.misc.packet_info.providers.implementations.SulekPacketInfoProvider;
|
||||||
import gearth.misc.packet_info.providers.implementations.UnityPacketInfoProvider;
|
import gearth.misc.packet_info.providers.implementations.UnityPacketInfoProvider;
|
||||||
import gearth.protocol.HMessage;
|
import gearth.protocol.HMessage;
|
||||||
|
import gearth.protocol.HPacket;
|
||||||
import gearth.protocol.connection.HClient;
|
import gearth.protocol.connection.HClient;
|
||||||
|
import org.fxmisc.undo.impl.ChangeQueue;
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
@ -28,7 +29,10 @@ public class PacketInfoManager {
|
|||||||
private Map<String, List<PacketInfo>> nameToMessage_incoming = new HashMap<>();
|
private Map<String, List<PacketInfo>> nameToMessage_incoming = new HashMap<>();
|
||||||
private Map<String, List<PacketInfo>> nameToMessage_outgoing = new HashMap<>();
|
private Map<String, List<PacketInfo>> nameToMessage_outgoing = new HashMap<>();
|
||||||
|
|
||||||
|
private List<PacketInfo> packetInfoList;
|
||||||
|
|
||||||
public PacketInfoManager(List<PacketInfo> packetInfoList) {
|
public PacketInfoManager(List<PacketInfo> packetInfoList) {
|
||||||
|
this.packetInfoList = packetInfoList;
|
||||||
for (PacketInfo packetInfo : packetInfoList) {
|
for (PacketInfo packetInfo : packetInfoList) {
|
||||||
addMessage(packetInfo);
|
addMessage(packetInfo);
|
||||||
}
|
}
|
||||||
@ -66,37 +70,6 @@ public class PacketInfoManager {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public PacketInfo getPacketInfoFromHeaderId(HMessage.Direction direction, int headerId) {
|
|
||||||
Map<Integer, List<PacketInfo>> headerIdToMessage =
|
|
||||||
(direction == HMessage.Direction.TOSERVER
|
|
||||||
? headerIdToMessage_outgoing
|
|
||||||
: headerIdToMessage_incoming);
|
|
||||||
|
|
||||||
if (headerIdToMessage.get(headerId) == null) return null;
|
|
||||||
return headerIdToMessage.get(headerId).get(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
public PacketInfo getHarbleMessagesFromHash(HMessage.Direction direction, String hash) {
|
|
||||||
Map<String, List<PacketInfo>> hashToMessage =
|
|
||||||
(direction == HMessage.Direction.TOSERVER
|
|
||||||
? hashToMessage_outgoing
|
|
||||||
: hashToMessage_incoming);
|
|
||||||
|
|
||||||
if (hashToMessage.get(hash) == null) return null;
|
|
||||||
return hashToMessage.get(hash).get(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
public PacketInfo getHarbleMessageFromName(HMessage.Direction direction, String name) {
|
|
||||||
Map<String, List<PacketInfo>> nameToMessage =
|
|
||||||
(direction == HMessage.Direction.TOSERVER
|
|
||||||
? nameToMessage_outgoing
|
|
||||||
: nameToMessage_incoming);
|
|
||||||
|
|
||||||
if (nameToMessage.get(name) == null) return null;
|
|
||||||
return nameToMessage.get(name).get(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public List<PacketInfo> getAllPacketInfoFromHeaderId(HMessage.Direction direction, int headerId) {
|
public List<PacketInfo> getAllPacketInfoFromHeaderId(HMessage.Direction direction, int headerId) {
|
||||||
Map<Integer, List<PacketInfo>> headerIdToMessage =
|
Map<Integer, List<PacketInfo>> headerIdToMessage =
|
||||||
(direction == HMessage.Direction.TOSERVER
|
(direction == HMessage.Direction.TOSERVER
|
||||||
@ -106,7 +79,7 @@ public class PacketInfoManager {
|
|||||||
return headerIdToMessage.get(headerId) == null ? new ArrayList<>() : headerIdToMessage.get(headerId);
|
return headerIdToMessage.get(headerId) == null ? new ArrayList<>() : headerIdToMessage.get(headerId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<PacketInfo> getAllHarbleMessagesFromHash(HMessage.Direction direction, String hash) {
|
public List<PacketInfo> getAllPacketInfoFromHash(HMessage.Direction direction, String hash) {
|
||||||
Map<String, List<PacketInfo>> hashToMessage =
|
Map<String, List<PacketInfo>> hashToMessage =
|
||||||
(direction == HMessage.Direction.TOSERVER
|
(direction == HMessage.Direction.TOSERVER
|
||||||
? hashToMessage_outgoing
|
? hashToMessage_outgoing
|
||||||
@ -115,7 +88,7 @@ public class PacketInfoManager {
|
|||||||
return hashToMessage.get(hash) == null ? new ArrayList<>() : hashToMessage.get(hash);
|
return hashToMessage.get(hash) == null ? new ArrayList<>() : hashToMessage.get(hash);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<PacketInfo> getAllHarbleMessageFromName(HMessage.Direction direction, String name) {
|
public List<PacketInfo> getAllPacketInfoFromName(HMessage.Direction direction, String name) {
|
||||||
Map<String, List<PacketInfo>> nameToMessage =
|
Map<String, List<PacketInfo>> nameToMessage =
|
||||||
(direction == HMessage.Direction.TOSERVER
|
(direction == HMessage.Direction.TOSERVER
|
||||||
? nameToMessage_outgoing
|
? nameToMessage_outgoing
|
||||||
@ -124,6 +97,24 @@ public class PacketInfoManager {
|
|||||||
return nameToMessage.get(name) == null ? new ArrayList<>() : nameToMessage.get(name);
|
return nameToMessage.get(name) == null ? new ArrayList<>() : nameToMessage.get(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PacketInfo getPacketInfoFromHeaderId(HMessage.Direction direction, int headerId) {
|
||||||
|
List<PacketInfo> all = getAllPacketInfoFromHeaderId(direction, headerId);
|
||||||
|
return all.size() == 0 ? null : all.get(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public PacketInfo getPacketInfoFromHash(HMessage.Direction direction, String hash) {
|
||||||
|
List<PacketInfo> all = getAllPacketInfoFromHash(direction, hash);
|
||||||
|
return all.size() == 0 ? null : all.get(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public PacketInfo getPacketInfoFromName(HMessage.Direction direction, String name) {
|
||||||
|
List<PacketInfo> all = getAllPacketInfoFromName(direction, name);
|
||||||
|
return all.size() == 0 ? null : all.get(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<PacketInfo> getPacketInfoList() {
|
||||||
|
return packetInfoList;
|
||||||
|
}
|
||||||
|
|
||||||
public static PacketInfoManager fromHotelVersion(String hotelversion, HClient clientType) {
|
public static PacketInfoManager fromHotelVersion(String hotelversion, HClient clientType) {
|
||||||
List<PacketInfo> result = new ArrayList<>();
|
List<PacketInfo> result = new ArrayList<>();
|
||||||
@ -158,4 +149,38 @@ public class PacketInfoManager {
|
|||||||
|
|
||||||
return new PacketInfoManager(result);
|
return new PacketInfoManager(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static PacketInfoManager readFromPacket(HPacket hPacket) {
|
||||||
|
List<PacketInfo> packetInfoList = new ArrayList<>();
|
||||||
|
int size = hPacket.readInteger();
|
||||||
|
|
||||||
|
for (int i = 0; i < size; i++) {
|
||||||
|
int headerId = hPacket.readInteger();
|
||||||
|
String hash = hPacket.readString();
|
||||||
|
String name = hPacket.readString();
|
||||||
|
String structure = hPacket.readString();
|
||||||
|
boolean isOutgoing = hPacket.readBoolean();
|
||||||
|
|
||||||
|
packetInfoList.add(new PacketInfo(
|
||||||
|
isOutgoing ? HMessage.Direction.TOSERVER : HMessage.Direction.TOCLIENT,
|
||||||
|
headerId,
|
||||||
|
hash.equals("NULL") ? null : hash,
|
||||||
|
name.equals("NULL") ? null : name,
|
||||||
|
structure.equals("NULL") ? null : structure
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
return new PacketInfoManager(packetInfoList);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void appendToPacket(HPacket hPacket) {
|
||||||
|
hPacket.appendInt(packetInfoList.size());
|
||||||
|
for (PacketInfo packetInfo : packetInfoList) {
|
||||||
|
hPacket.appendInt(packetInfo.getHeaderId());
|
||||||
|
hPacket.appendString(packetInfo.getHash() == null ? "NULL" : packetInfo.getHash());
|
||||||
|
hPacket.appendString(packetInfo.getName() == null ? "NULL" : packetInfo.getName());
|
||||||
|
hPacket.appendString(packetInfo.getStructure() == null ? "NULL" : packetInfo.getStructure());
|
||||||
|
hPacket.appendBoolean(packetInfo.getDestination() == HMessage.Direction.TOSERVER);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package gearth.misc.packet_info.providers;
|
package gearth.misc.packet_info.providers;
|
||||||
|
|
||||||
import gearth.misc.Cacher;
|
import gearth.misc.Cacher;
|
||||||
import gearth.misc.harble_api.PacketInfoManager;
|
|
||||||
import org.jsoup.Connection;
|
import org.jsoup.Connection;
|
||||||
import org.jsoup.Jsoup;
|
import org.jsoup.Jsoup;
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package gearth.protocol;
|
package gearth.protocol;
|
||||||
|
|
||||||
import gearth.misc.listenerpattern.Observable;
|
import gearth.misc.listenerpattern.Observable;
|
||||||
|
import gearth.misc.packet_info.PacketInfoManager;
|
||||||
import gearth.protocol.connection.HClient;
|
import gearth.protocol.connection.HClient;
|
||||||
import gearth.protocol.connection.HProxy;
|
import gearth.protocol.connection.HProxy;
|
||||||
import gearth.protocol.connection.HState;
|
import gearth.protocol.connection.HState;
|
||||||
@ -186,6 +187,13 @@ public class HConnection {
|
|||||||
return proxy.gethClient();
|
return proxy.gethClient();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PacketInfoManager getPacketInfoManager() {
|
||||||
|
if (proxy == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return proxy.getPacketInfoManager();
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isRawIpMode() {
|
public boolean isRawIpMode() {
|
||||||
return proxyProvider != null && proxyProvider instanceof LinuxRawIpFlashProxyProvider;
|
return proxyProvider != null && proxyProvider instanceof LinuxRawIpFlashProxyProvider;
|
||||||
// WindowsRawIpProxyProvider extends LinuxRawIpProxyProvider
|
// WindowsRawIpProxyProvider extends LinuxRawIpProxyProvider
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
package gearth.protocol;
|
package gearth.protocol;
|
||||||
|
|
||||||
import gearth.misc.StringifyAble;
|
import gearth.misc.StringifyAble;
|
||||||
import gearth.misc.harble_api.PacketInfoManager;
|
|
||||||
import gearth.misc.harble_api.HarbleAPIFetcher;
|
|
||||||
import gearth.misc.packetrepresentation.InvalidPacketException;
|
import gearth.misc.packetrepresentation.InvalidPacketException;
|
||||||
import gearth.misc.packetrepresentation.PacketStringUtils;
|
import gearth.misc.packetrepresentation.PacketStringUtils;
|
||||||
|
|
||||||
@ -579,44 +577,49 @@ public class HPacket implements StringifyAble {
|
|||||||
isEdited = edited;
|
isEdited = edited;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getHarbleStructure(HMessage.Direction direction) {
|
// private String getHarbleStructure(HMessage.Direction direction) {
|
||||||
PacketInfoManager.HarbleMessage msg;
|
// PacketInfoManager.HarbleMessage msg;
|
||||||
if (HarbleAPIFetcher.HARBLEAPI != null &&
|
// if (HarbleAPIFetcher.HARBLEAPI != null &&
|
||||||
((msg = HarbleAPIFetcher.HARBLEAPI.getHarbleMessageFromHeaderId(direction, headerId())) != null)) {
|
// ((msg = HarbleAPIFetcher.HARBLEAPI.getHarbleMessageFromHeaderId(direction, headerId())) != null)) {
|
||||||
if (msg.getStructure() != null && structureEquals(msg.getStructure())) {
|
// if (msg.getStructure() != null && structureEquals(msg.getStructure())) {
|
||||||
return msg.getStructure();
|
// return msg.getStructure();
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
|
// return null;
|
||||||
|
// }
|
||||||
|
|
||||||
return null;
|
// public String toExpression(HMessage.Direction direction) {
|
||||||
}
|
// if (isCorrupted()) return "";
|
||||||
|
//
|
||||||
|
// String structure = getHarbleStructure(direction);
|
||||||
|
// if (structure != null) {
|
||||||
|
// return PacketStringUtils.toExpressionFromGivenStructure(this, structure);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// return PacketStringUtils.predictedExpression(this);
|
||||||
|
// }
|
||||||
|
|
||||||
public String toExpression(HMessage.Direction direction) {
|
// /**
|
||||||
if (isCorrupted()) return "";
|
// * returns "" if not found or not sure enough
|
||||||
|
// */
|
||||||
|
// public String toExpression() {
|
||||||
|
// if (isCorrupted()) return "";
|
||||||
|
//
|
||||||
|
// String structure1 = getHarbleStructure(HMessage.Direction.TOCLIENT);
|
||||||
|
// String structure2 = getHarbleStructure(HMessage.Direction.TOSERVER);
|
||||||
|
// if (structure1 != null && structure2 == null) {
|
||||||
|
// return PacketStringUtils.toExpressionFromGivenStructure(this, structure1);
|
||||||
|
// }
|
||||||
|
// else if (structure1 == null && structure2 != null) {
|
||||||
|
// return PacketStringUtils.toExpressionFromGivenStructure(this, structure2);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// return PacketStringUtils.predictedExpression(this);
|
||||||
|
// }
|
||||||
|
|
||||||
String structure = getHarbleStructure(direction);
|
|
||||||
if (structure != null) {
|
|
||||||
return PacketStringUtils.toExpressionFromGivenStructure(this, structure);
|
|
||||||
}
|
|
||||||
|
|
||||||
return PacketStringUtils.predictedExpression(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* returns "" if not found or not sure enough
|
|
||||||
*/
|
|
||||||
public String toExpression() {
|
public String toExpression() {
|
||||||
if (isCorrupted()) return "";
|
if (isCorrupted()) return "";
|
||||||
|
|
||||||
String structure1 = getHarbleStructure(HMessage.Direction.TOCLIENT);
|
|
||||||
String structure2 = getHarbleStructure(HMessage.Direction.TOSERVER);
|
|
||||||
if (structure1 != null && structure2 == null) {
|
|
||||||
return PacketStringUtils.toExpressionFromGivenStructure(this, structure1);
|
|
||||||
}
|
|
||||||
else if (structure1 == null && structure2 != null) {
|
|
||||||
return PacketStringUtils.toExpressionFromGivenStructure(this, structure2);
|
|
||||||
}
|
|
||||||
|
|
||||||
return PacketStringUtils.predictedExpression(this);
|
return PacketStringUtils.predictedExpression(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package gearth.protocol.connection;
|
package gearth.protocol.connection;
|
||||||
|
|
||||||
|
import gearth.misc.packet_info.PacketInfoManager;
|
||||||
import gearth.protocol.packethandler.PacketHandler;
|
import gearth.protocol.packethandler.PacketHandler;
|
||||||
|
|
||||||
import java.net.ServerSocket;
|
import java.net.ServerSocket;
|
||||||
@ -22,6 +23,8 @@ public class HProxy {
|
|||||||
|
|
||||||
private volatile String hotelVersion = "";
|
private volatile String hotelVersion = "";
|
||||||
private volatile String clientIdentifier = "";
|
private volatile String clientIdentifier = "";
|
||||||
|
private volatile PacketInfoManager packetInfoManager = null;
|
||||||
|
|
||||||
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) {
|
||||||
@ -42,6 +45,7 @@ public class HProxy {
|
|||||||
this.outHandler = outgoingHandler;
|
this.outHandler = outgoingHandler;
|
||||||
this.hotelVersion = hotelVersion;
|
this.hotelVersion = hotelVersion;
|
||||||
this.clientIdentifier = clientIdentifier;
|
this.clientIdentifier = clientIdentifier;
|
||||||
|
this.packetInfoManager = PacketInfoManager.fromHotelVersion(hotelVersion, hClient);
|
||||||
this.asyncPacketSender = new AsyncPacketSender(this);
|
this.asyncPacketSender = new AsyncPacketSender(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -92,4 +96,8 @@ public class HProxy {
|
|||||||
public HClient gethClient() {
|
public HClient gethClient() {
|
||||||
return hClient;
|
return hClient;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PacketInfoManager getPacketInfoManager() {
|
||||||
|
return packetInfoManager;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package gearth.services.extensionhandler;
|
package gearth.services.extensionhandler;
|
||||||
|
|
||||||
import gearth.Main;
|
import gearth.Main;
|
||||||
import gearth.misc.harble_api.HarbleAPIFetcher;
|
|
||||||
import gearth.misc.listenerpattern.Observable;
|
import gearth.misc.listenerpattern.Observable;
|
||||||
import gearth.protocol.HConnection;
|
import gearth.protocol.HConnection;
|
||||||
import gearth.protocol.HMessage;
|
import gearth.protocol.HMessage;
|
||||||
@ -48,7 +47,6 @@ 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(), hConnection.getClientIdentifier());
|
|
||||||
synchronized (gEarthExtensions) {
|
synchronized (gEarthExtensions) {
|
||||||
for (GEarthExtension extension : gEarthExtensions) {
|
for (GEarthExtension extension : gEarthExtensions) {
|
||||||
extension.connectionStart(
|
extension.connectionStart(
|
||||||
@ -57,7 +55,7 @@ public class ExtensionHandler {
|
|||||||
hConnection.getHotelVersion(),
|
hConnection.getHotelVersion(),
|
||||||
hConnection.getClientIdentifier(),
|
hConnection.getClientIdentifier(),
|
||||||
hConnection.getClientType(),
|
hConnection.getClientType(),
|
||||||
HarbleAPIFetcher.HARBLEAPI == null ? "null" : HarbleAPIFetcher.HARBLEAPI.getPath()
|
hConnection.getPacketInfoManager()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -247,7 +245,7 @@ public class ExtensionHandler {
|
|||||||
hConnection.getHotelVersion(),
|
hConnection.getHotelVersion(),
|
||||||
hConnection.getClientIdentifier(),
|
hConnection.getClientIdentifier(),
|
||||||
hConnection.getClientType(),
|
hConnection.getClientType(),
|
||||||
HarbleAPIFetcher.HARBLEAPI == null ? "null" : HarbleAPIFetcher.HARBLEAPI.getPath()
|
hConnection.getPacketInfoManager()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@ package gearth.services.extensionhandler.extensions;
|
|||||||
|
|
||||||
import gearth.misc.listenerpattern.Observable;
|
import gearth.misc.listenerpattern.Observable;
|
||||||
import gearth.misc.listenerpattern.SynchronizedObservable;
|
import gearth.misc.listenerpattern.SynchronizedObservable;
|
||||||
|
import gearth.misc.packet_info.PacketInfoManager;
|
||||||
import gearth.protocol.HMessage;
|
import gearth.protocol.HMessage;
|
||||||
import gearth.protocol.HPacket;
|
import gearth.protocol.HPacket;
|
||||||
import gearth.protocol.connection.HClient;
|
import gearth.protocol.connection.HClient;
|
||||||
@ -39,7 +40,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 clientIdentifier, HClient clientType, String harbleMessagesPath);
|
public abstract void connectionStart(String host, int port, String hotelVersion, String clientIdentifier, HClient clientType, PacketInfoManager packetInfoManager);
|
||||||
public abstract void connectionEnd();
|
public abstract void connectionEnd();
|
||||||
public abstract void init();
|
public abstract void init();
|
||||||
public abstract void close();
|
public abstract void close();
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package gearth.services.extensionhandler.extensions.implementations.network;
|
package gearth.services.extensionhandler.extensions.implementations.network;
|
||||||
|
|
||||||
|
import gearth.misc.packet_info.PacketInfoManager;
|
||||||
import gearth.protocol.HMessage;
|
import gearth.protocol.HMessage;
|
||||||
import gearth.protocol.connection.HClient;
|
import gearth.protocol.connection.HClient;
|
||||||
import gearth.services.extensionhandler.extensions.GEarthExtension;
|
import gearth.services.extensionhandler.extensions.GEarthExtension;
|
||||||
@ -191,16 +192,16 @@ public class NetworkExtension extends GEarthExtension {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void connectionStart(String host, int port, String hotelVersion, String clientIdentifier, HClient clientType, String harbleMessagesPath) {
|
public void connectionStart(String host, int port, String hotelVersion, String clientIdentifier, HClient clientType, PacketInfoManager packetInfoManager) {
|
||||||
sendMessage(
|
HPacket connectionStartPacket = 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(clientIdentifier)
|
||||||
.appendString(harbleMessagesPath)
|
.appendString(clientType.name());
|
||||||
.appendString(clientIdentifier)
|
|
||||||
.appendString(clientType.name())
|
packetInfoManager.appendToPacket(connectionStartPacket);
|
||||||
);
|
sendMessage(connectionStartPacket);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package gearth.services.extensionhandler.extensions.implementations.simple;
|
package gearth.services.extensionhandler.extensions.implementations.simple;
|
||||||
|
|
||||||
|
import gearth.misc.packet_info.PacketInfoManager;
|
||||||
import gearth.protocol.HMessage;
|
import gearth.protocol.HMessage;
|
||||||
import gearth.protocol.HPacket;
|
import gearth.protocol.HPacket;
|
||||||
import gearth.protocol.connection.HClient;
|
import gearth.protocol.connection.HClient;
|
||||||
@ -84,7 +85,7 @@ public class ExampleExtension extends GEarthExtension {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void connectionStart(String host, int port, String hotelVersion, String clientIdentifier, HClient clientType, String harbleMessagesPath) {
|
public void connectionStart(String host, int port, String hotelVersion, String clientIdentifier, HClient clientType, PacketInfoManager packetInfoManager) {
|
||||||
// a new habbo client has connected
|
// a new habbo client has connected
|
||||||
System.out.println("Connected to " + host);
|
System.out.println("Connected to " + host);
|
||||||
}
|
}
|
||||||
|
@ -42,7 +42,7 @@ public class LoggerController extends SubForm {
|
|||||||
}
|
}
|
||||||
if (newState == HState.CONNECTED) {
|
if (newState == HState.CONNECTED) {
|
||||||
miniLogText(Color.GREEN, "Connected to "+getHConnection().getDomain() + ":" + getHConnection().getServerPort());
|
miniLogText(Color.GREEN, "Connected to "+getHConnection().getDomain() + ":" + getHConnection().getServerPort());
|
||||||
packetLogger.start();
|
packetLogger.start(getHConnection());
|
||||||
}
|
}
|
||||||
if (newState == HState.NOT_CONNECTED) {
|
if (newState == HState.NOT_CONNECTED) {
|
||||||
miniLogText(Color.RED, "End of connection");
|
miniLogText(Color.RED, "End of connection");
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package gearth.ui.logger.loggerdisplays;
|
package gearth.ui.logger.loggerdisplays;
|
||||||
|
|
||||||
|
import gearth.protocol.HConnection;
|
||||||
import gearth.protocol.HPacket;
|
import gearth.protocol.HPacket;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -27,7 +28,7 @@ public interface PacketLogger {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void start();
|
void start(HConnection hConnection);
|
||||||
void stop();
|
void stop();
|
||||||
|
|
||||||
void appendSplitLine();
|
void appendSplitLine();
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package gearth.ui.logger.loggerdisplays;
|
package gearth.ui.logger.loggerdisplays;
|
||||||
|
|
||||||
|
import gearth.protocol.HConnection;
|
||||||
import gearth.protocol.HPacket;
|
import gearth.protocol.HPacket;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -7,7 +8,7 @@ import gearth.protocol.HPacket;
|
|||||||
*/
|
*/
|
||||||
class SimpleTerminalLogger implements PacketLogger {
|
class SimpleTerminalLogger implements PacketLogger {
|
||||||
@Override
|
@Override
|
||||||
public void start() {
|
public void start(HConnection hConnection) {
|
||||||
// System.out.println("-- START OF SESSION --");
|
// System.out.println("-- START OF SESSION --");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package gearth.ui.logger.loggerdisplays.uilogger;
|
package gearth.ui.logger.loggerdisplays.uilogger;
|
||||||
|
|
||||||
|
import gearth.protocol.HConnection;
|
||||||
import gearth.protocol.HPacket;
|
import gearth.protocol.HPacket;
|
||||||
import gearth.ui.logger.loggerdisplays.PacketLogger;
|
import gearth.ui.logger.loggerdisplays.PacketLogger;
|
||||||
import javafx.event.ActionEvent;
|
import javafx.event.ActionEvent;
|
||||||
@ -18,9 +19,10 @@ import java.util.List;
|
|||||||
public class UiLogger implements PacketLogger {
|
public class UiLogger implements PacketLogger {
|
||||||
private Stage stage;
|
private Stage stage;
|
||||||
private UiLoggerController controller = null;
|
private UiLoggerController controller = null;
|
||||||
|
private HConnection hConnection = null;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void start() {
|
public void start(HConnection hConnection) {
|
||||||
FXMLLoader loader = new FXMLLoader(getClass().getResource("/gearth/ui/logger/uilogger/UiLogger.fxml"));
|
FXMLLoader loader = new FXMLLoader(getClass().getResource("/gearth/ui/logger/uilogger/UiLogger.fxml"));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -41,30 +43,13 @@ public class UiLogger implements PacketLogger {
|
|||||||
Scene scene = new Scene(root);
|
Scene scene = new Scene(root);
|
||||||
scene.getStylesheets().add("/gearth/ui/bootstrap3.css");
|
scene.getStylesheets().add("/gearth/ui/bootstrap3.css");
|
||||||
scene.getStylesheets().add("/gearth/ui/logger/uilogger/logger.css");
|
scene.getStylesheets().add("/gearth/ui/logger/uilogger/logger.css");
|
||||||
UiLoggerController controller = (UiLoggerController) loader.getController();
|
UiLoggerController controller = loader.getController();
|
||||||
controller.setStage(stage);
|
controller.setStage(stage);
|
||||||
|
controller.setPacketInfoManager(hConnection.getPacketInfoManager());
|
||||||
|
|
||||||
// scene.addEventFilter(KeyEvent.KEY_PRESSED, new EventHandler<KeyEvent>() {
|
|
||||||
// final KeyCombination keyCombIncoming = new KeyCodeCombination(KeyCode.I,
|
|
||||||
// KeyCombination.CONTROL_DOWN);
|
|
||||||
// final KeyCombination keyCombOutgoing = new KeyCodeCombination(KeyCode.O,
|
|
||||||
// KeyCombination.CONTROL_DOWN);
|
|
||||||
//
|
|
||||||
// public void handle(KeyEvent ke) {
|
|
||||||
// if (keyCombIncoming.match(ke)) {
|
|
||||||
// controller.toggleViewIncoming();
|
|
||||||
// ke.consume();
|
|
||||||
// } else if (keyCombOutgoing.match(ke)) {
|
|
||||||
// controller.toggleViewOutgoing();
|
|
||||||
// ke.consume();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
|
|
||||||
stage.setScene(scene);
|
stage.setScene(scene);
|
||||||
|
|
||||||
// ScenicView.show(scene);
|
|
||||||
|
|
||||||
// don't let the user close this window on their own
|
// don't let the user close this window on their own
|
||||||
stage.setOnCloseRequest(Event::consume);
|
stage.setOnCloseRequest(Event::consume);
|
||||||
|
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
package gearth.ui.logger.loggerdisplays.uilogger;
|
package gearth.ui.logger.loggerdisplays.uilogger;
|
||||||
|
|
||||||
import gearth.misc.harble_api.PacketInfoManager;
|
import gearth.misc.packet_info.PacketInfo;
|
||||||
import gearth.misc.harble_api.HarbleAPIFetcher;
|
import gearth.misc.packet_info.PacketInfoManager;
|
||||||
import gearth.protocol.HMessage;
|
import gearth.protocol.HMessage;
|
||||||
import gearth.protocol.HPacket;
|
import gearth.protocol.HPacket;
|
||||||
import gearth.ui.logger.loggerdisplays.PacketLogger;
|
import gearth.ui.logger.loggerdisplays.PacketLogger;
|
||||||
import javafx.application.Platform;
|
import javafx.application.Platform;
|
||||||
@ -38,6 +38,7 @@ public class UiLoggerController implements Initializable {
|
|||||||
private StyleClassedTextArea area;
|
private StyleClassedTextArea area;
|
||||||
|
|
||||||
private Stage stage;
|
private Stage stage;
|
||||||
|
private PacketInfoManager packetInfoManager;
|
||||||
|
|
||||||
private boolean viewIncoming = true;
|
private boolean viewIncoming = true;
|
||||||
private boolean viewOutgoing = true;
|
private boolean viewOutgoing = true;
|
||||||
@ -92,19 +93,21 @@ public class UiLoggerController implements Initializable {
|
|||||||
|
|
||||||
ArrayList<Element> elements = new ArrayList<>();
|
ArrayList<Element> elements = new ArrayList<>();
|
||||||
|
|
||||||
lblHarbleAPI.setText("Messages: " + (HarbleAPIFetcher.HARBLEAPI == null ? "False" : "True"));
|
|
||||||
if ((viewMessageName || viewMessageHash) && HarbleAPIFetcher.HARBLEAPI != null) {
|
boolean packetInfoAvailable = packetInfoManager.getPacketInfoList().size() > 0;
|
||||||
PacketInfoManager api = HarbleAPIFetcher.HARBLEAPI;
|
lblHarbleAPI.setText("Packet info: " + (packetInfoAvailable ? "True" : "False"));
|
||||||
PacketInfoManager.HarbleMessage message = api.getHarbleMessageFromHeaderId(
|
|
||||||
|
if ((viewMessageName || viewMessageHash) && packetInfoAvailable) {
|
||||||
|
PacketInfo message = packetInfoManager.getPacketInfoFromHeaderId(
|
||||||
(isIncoming ? HMessage.Direction.TOCLIENT : HMessage.Direction.TOSERVER),
|
(isIncoming ? HMessage.Direction.TOCLIENT : HMessage.Direction.TOSERVER),
|
||||||
packet.headerId()
|
packet.headerId()
|
||||||
);
|
);
|
||||||
|
|
||||||
if ( message != null && !(viewMessageName && !viewMessageHash && message.getName() == null)) {
|
if (message != null && !(viewMessageName && !viewMessageHash && message.getName() == null)) {
|
||||||
if (viewMessageName && message.getName() != null) {
|
if (viewMessageName && message.getName() != null) {
|
||||||
elements.add(new Element("["+message.getName()+"]", "messageinfo"));
|
elements.add(new Element("["+message.getName()+"]", "messageinfo"));
|
||||||
}
|
}
|
||||||
if (viewMessageHash) {
|
if (viewMessageHash && message.getHash() != null) {
|
||||||
elements.add(new Element("["+message.getHash()+"]", "messageinfo"));
|
elements.add(new Element("["+message.getHash()+"]", "messageinfo"));
|
||||||
}
|
}
|
||||||
elements.add(new Element("\n", ""));
|
elements.add(new Element("\n", ""));
|
||||||
@ -134,7 +137,7 @@ public class UiLoggerController implements Initializable {
|
|||||||
|
|
||||||
elements.add(new Element(" -> ", ""));
|
elements.add(new Element(" -> ", ""));
|
||||||
|
|
||||||
if (skiphugepackets && packet.length() > 8000) {
|
if (skiphugepackets && packet.length() > 4000) {
|
||||||
elements.add(new Element("<packet skipped>", "skipped"));
|
elements.add(new Element("<packet skipped>", "skipped"));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -143,7 +146,8 @@ public class UiLoggerController implements Initializable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (packet.length() <= 2000) {
|
if (packet.length() <= 2000) {
|
||||||
String expr = packet.toExpression(isIncoming ? HMessage.Direction.TOCLIENT : HMessage.Direction.TOSERVER);
|
// String expr = packet.toExpression(isIncoming ? HMessage.Direction.TOCLIENT : HMessage.Direction.TOSERVER);
|
||||||
|
String expr = packet.toExpression();
|
||||||
String cleaned = cleanTextContent(expr);
|
String cleaned = cleanTextContent(expr);
|
||||||
if (cleaned.equals(expr)) {
|
if (cleaned.equals(expr)) {
|
||||||
if (!expr.equals("") && displayStructure)
|
if (!expr.equals("") && displayStructure)
|
||||||
@ -192,6 +196,10 @@ public class UiLoggerController implements Initializable {
|
|||||||
this.stage = stage;
|
this.stage = stage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setPacketInfoManager(PacketInfoManager packetInfoManager) {
|
||||||
|
this.packetInfoManager = packetInfoManager;
|
||||||
|
}
|
||||||
|
|
||||||
public void toggleViewIncoming() {
|
public void toggleViewIncoming() {
|
||||||
viewIncoming = !viewIncoming;
|
viewIncoming = !viewIncoming;
|
||||||
lblViewIncoming.setText("View Incoming: " + (viewIncoming ? "True" : "False"));
|
lblViewIncoming.setText("View Incoming: " + (viewIncoming ? "True" : "False"));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user