-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e527443
commit f69b301
Showing
14 changed files
with
161 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
...t/azisaba/azipluginmessaging/api/protocol/handler/ProxyboundEncryptionResponsePacket.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package net.azisaba.azipluginmessaging.api.protocol.handler; | ||
|
||
import net.azisaba.azipluginmessaging.api.AziPluginMessagingConfig; | ||
import net.azisaba.azipluginmessaging.api.Logger; | ||
import net.azisaba.azipluginmessaging.api.protocol.Protocol; | ||
import net.azisaba.azipluginmessaging.api.protocol.message.EmptyMessage; | ||
import net.azisaba.azipluginmessaging.api.server.PacketSender; | ||
import net.azisaba.azipluginmessaging.api.server.ServerConnection; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.io.DataInputStream; | ||
import java.io.IOException; | ||
|
||
public class ProxyboundEncryptionResponsePacket implements ProxyMessageHandler<EmptyMessage> { | ||
@Override | ||
public @NotNull EmptyMessage read(@NotNull ServerConnection server, @NotNull DataInputStream in) throws IOException { | ||
return EmptyMessage.INSTANCE; | ||
} | ||
|
||
@Override | ||
public void handle(@NotNull PacketSender sender, @NotNull EmptyMessage msg) throws Exception { | ||
// Enable encryption | ||
sender.setEncrypted(true); | ||
|
||
if (AziPluginMessagingConfig.debug) { | ||
Logger.getCurrentLogger().info("Encryption enabled for " + sender); | ||
} | ||
|
||
// Send response to server to set the "encrypted" flag to true | ||
Protocol.S_ENCRYPTION_RESPONSE.sendPacket(sender, EmptyMessage.INSTANCE); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
.../azisaba/azipluginmessaging/api/protocol/handler/ServerboundEncryptionResponsePacket.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package net.azisaba.azipluginmessaging.api.protocol.handler; | ||
|
||
import net.azisaba.azipluginmessaging.api.AziPluginMessagingConfig; | ||
import net.azisaba.azipluginmessaging.api.AziPluginMessagingProvider; | ||
import net.azisaba.azipluginmessaging.api.Logger; | ||
import net.azisaba.azipluginmessaging.api.protocol.message.EmptyMessage; | ||
import net.azisaba.azipluginmessaging.api.server.PacketSender; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.io.DataInputStream; | ||
import java.io.IOException; | ||
|
||
public class ServerboundEncryptionResponsePacket implements ServerMessageHandler<EmptyMessage> { | ||
@Override | ||
public @NotNull EmptyMessage read(@NotNull DataInputStream in) throws IOException { | ||
return EmptyMessage.INSTANCE; | ||
} | ||
|
||
@Override | ||
public void handle(@NotNull PacketSender sender, @NotNull EmptyMessage msg) throws Exception { | ||
// Enable encryption | ||
sender.setEncrypted(true); | ||
|
||
if (AziPluginMessagingConfig.debug) { | ||
Logger.getCurrentLogger().info("Encryption enabled for " + sender); | ||
} | ||
|
||
AziPluginMessagingProvider.get().getPacketQueue().flush(sender); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
api/src/main/java/net/azisaba/azipluginmessaging/api/protocol/message/EmptyMessage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package net.azisaba.azipluginmessaging.api.protocol.message; | ||
|
||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.io.DataOutputStream; | ||
import java.io.IOException; | ||
|
||
public class EmptyMessage implements Message { | ||
public static final EmptyMessage INSTANCE = new EmptyMessage(); | ||
|
||
private EmptyMessage() {} | ||
|
||
@Override | ||
public void write(@NotNull DataOutputStream out) throws IOException { | ||
// no-op | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters