diff --git a/G-Earth/src/main/java/gearth/services/extension_handler/ExtensionHandler.java b/G-Earth/src/main/java/gearth/services/extension_handler/ExtensionHandler.java index 61e01b7..87a57d8 100644 --- a/G-Earth/src/main/java/gearth/services/extension_handler/ExtensionHandler.java +++ b/G-Earth/src/main/java/gearth/services/extension_handler/ExtensionHandler.java @@ -200,11 +200,18 @@ public class ExtensionHandler { @Override public void sendMessage(HMessage.Direction direction, HPacket packet) { + boolean success; if (direction == HMessage.Direction.TOCLIENT) { - hConnection.sendToClient(packet); + success = hConnection.sendToClient(packet); } else { - hConnection.sendToServer(packet); + success = hConnection.sendToServer(packet); + } + + if (!success && hConnection.isPacketSendingAllowed(direction, packet) && !hConnection.isPacketSendingSafe(direction, packet)) { + extension.getExtensionObservable().fireEvent(extensionListener -> + extensionListener.log(String.format("Extension %s attempted to send an unsafe packet, but had no permission", + extension.getTitle()))); } } diff --git a/G-Earth/src/main/java/gearth/services/extension_handler/extensions/ExtensionListener.java b/G-Earth/src/main/java/gearth/services/extension_handler/extensions/ExtensionListener.java index 5e90397..59d5942 100644 --- a/G-Earth/src/main/java/gearth/services/extension_handler/extensions/ExtensionListener.java +++ b/G-Earth/src/main/java/gearth/services/extension_handler/extensions/ExtensionListener.java @@ -9,7 +9,7 @@ public abstract class ExtensionListener { protected void manipulatedPacket(HMessage hMessage) {} protected void flagsRequest() {} protected void sendMessage(HMessage.Direction direction, HPacket packet) {} - protected void log(String text) {} + public void log(String text) {} protected void hasClosed() {} protected void packetToStringRequest(HPacket packet) {} diff --git a/G-Earth/src/main/java/gearth/ui/subforms/extensions/ExtensionsController.java b/G-Earth/src/main/java/gearth/ui/subforms/extensions/ExtensionsController.java index d5c01c5..69b6546 100644 --- a/G-Earth/src/main/java/gearth/ui/subforms/extensions/ExtensionsController.java +++ b/G-Earth/src/main/java/gearth/ui/subforms/extensions/ExtensionsController.java @@ -75,7 +75,7 @@ public class ExtensionsController extends SubForm { extensionHandler.getObservable().addListener(e -> e.getExtensionObservable().addListener(new ExtensionListener() { @Override - protected void log(String text) { + public void log(String text) { extensionLogger.log(text); } }));