mirror of
https://github.com/ViaVersion/ViaFabricPlus.git
synced 2024-12-22 16:48:25 +01:00
Implemented partial encryption
This commit is contained in:
parent
fcff14dc44
commit
f8b031719e
@ -19,7 +19,7 @@ ViaFabricPlus is intended to replace [multiconnect](https://github.com/Earthcomp
|
||||
- Alpha (a1.0.15 - a1.2.6)
|
||||
- Classic (c0.0.15 - c0.30 including [CPE](https://wiki.vg/Classic_Protocol_Extension))
|
||||
- Snapshots (3D Shareware, 20w14infinite, Combat Test 8C)
|
||||
- Bedrock (1.19.70)
|
||||
- Bedrock (1.19.80)
|
||||
|
||||
# For users
|
||||
### Detailed instructions for use are available here [here](.github/USAGE.md)
|
||||
|
@ -26,7 +26,7 @@ import java.security.NoSuchAlgorithmException;
|
||||
|
||||
public interface IClientConnection {
|
||||
|
||||
void viafabricplus_setupPreNettyEncryption();
|
||||
void viafabricplus_setupPreNettyDecryption();
|
||||
|
||||
InetSocketAddress viafabricplus_capturedAddress();
|
||||
void viafabricplus_captureAddress(final InetSocketAddress socketAddress);
|
||||
|
@ -62,9 +62,6 @@ public abstract class MixinClientConnection extends SimpleChannelInboundHandler<
|
||||
@Unique
|
||||
private Cipher viafabricplus_decryptionCipher;
|
||||
|
||||
@Unique
|
||||
private Cipher viafabricplus_encryptionCipher;
|
||||
|
||||
@Unique
|
||||
private boolean viafabricplus_compressionEnabled = false;
|
||||
|
||||
@ -81,7 +78,7 @@ public abstract class MixinClientConnection extends SimpleChannelInboundHandler<
|
||||
if (ProtocolHack.getTargetVersion(channel).isOlderThanOrEqualTo(LegacyProtocolVersion.r1_6_4)) {
|
||||
ci.cancel();
|
||||
this.viafabricplus_decryptionCipher = decryptionCipher;
|
||||
this.viafabricplus_encryptionCipher = encryptionCipher;
|
||||
this.viafabricplus_setupPreNettyEncryption(encryptionCipher);
|
||||
}
|
||||
}
|
||||
|
||||
@ -111,10 +108,16 @@ public abstract class MixinClientConnection extends SimpleChannelInboundHandler<
|
||||
DisconnectConnectionCallback.EVENT.invoker().onDisconnect();
|
||||
}
|
||||
|
||||
@Unique
|
||||
public void viafabricplus_setupPreNettyEncryption(final Cipher encryptionCipher) {
|
||||
this.encrypted = true;
|
||||
this.channel.pipeline().addBefore(ViaFabricPlusVLBPipeline.VIA_LEGACY_PRE_NETTY_LENGTH_REMOVER_HANDLER_NAME, "encrypt", new PacketEncryptor(encryptionCipher));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void viafabricplus_setupPreNettyEncryption() {
|
||||
public void viafabricplus_setupPreNettyDecryption() {
|
||||
this.encrypted = true;
|
||||
this.channel.pipeline().addBefore(ViaFabricPlusVLBPipeline.VIA_LEGACY_PRE_NETTY_LENGTH_PREPENDER_HANDLER_NAME, "decrypt", new PacketDecryptor(this.viafabricplus_decryptionCipher));
|
||||
this.channel.pipeline().addBefore(ViaFabricPlusVLBPipeline.VIA_LEGACY_PRE_NETTY_LENGTH_REMOVER_HANDLER_NAME, "encrypt", new PacketEncryptor(this.viafabricplus_encryptionCipher));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -29,7 +29,7 @@ public class ViaFabricPlusEncryptionProvider extends EncryptionProvider {
|
||||
public void enableDecryption(UserConnection user) {
|
||||
final ClientConnection clientConnection = user.getChannel().attr(ProtocolHack.LOCAL_MINECRAFT_CONNECTION).get();
|
||||
if (clientConnection != null) {
|
||||
((IClientConnection) clientConnection).viafabricplus_setupPreNettyEncryption();
|
||||
((IClientConnection) clientConnection).viafabricplus_setupPreNettyDecryption();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user