mirror of
https://github.com/sirjonasxx/G-Earth.git
synced 2024-11-23 00:40:51 +01:00
Packet safety in extensions
This commit is contained in:
parent
76ce696186
commit
f10b847830
@ -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())));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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) {}
|
||||
|
@ -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);
|
||||
}
|
||||
}));
|
||||
|
Loading…
Reference in New Issue
Block a user