Mirror von
https://github.com/PaperMC/Velocity.git
synchronisiert 2024-11-16 21:10:30 +01:00
Split natives. Add proper disposal for natives.
Dieser Commit ist enthalten in:
Ursprung
284a2a67a2
Commit
22dd4bbb99
@ -5,7 +5,7 @@ plugins {
|
||||
|
||||
dependencies {
|
||||
compile 'com.google.code.gson:gson:2.8.5'
|
||||
compile 'com.google.guava:guava:25.1-jre'
|
||||
compile "com.google.guava:guava:${guavaVersion}"
|
||||
compile 'net.kyori:text:1.12-1.6.0-SNAPSHOT'
|
||||
compile 'com.moandjiezana.toml:toml4j:0.7.2'
|
||||
testCompile "org.junit.jupiter:junit-jupiter-api:${junitVersion}"
|
||||
|
@ -14,6 +14,7 @@ allprojects {
|
||||
junitVersion = '5.3.0-M1'
|
||||
log4jVersion = '2.11.0'
|
||||
nettyVersion = '4.1.28.Final'
|
||||
guavaVersion = '25.1-jre'
|
||||
}
|
||||
|
||||
repositories {
|
||||
|
8
native/build.gradle
Normale Datei
8
native/build.gradle
Normale Datei
@ -0,0 +1,8 @@
|
||||
plugins {
|
||||
id 'java'
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile "com.google.guava:guava:${guavaVersion}"
|
||||
compile "io.netty:netty-buffer:${nettyVersion}"
|
||||
}
|
@ -1,9 +1,13 @@
|
||||
package com.velocitypowered.proxy.util;
|
||||
package com.velocitypowered.natives;
|
||||
|
||||
/**
|
||||
* This marker interface indicates that this object should be explicitly disposed before the object can no longer be used.
|
||||
* Not disposing these objects will likely leak native resources and eventually lead to resource exhaustion.
|
||||
*/
|
||||
public interface Disposable {
|
||||
/**
|
||||
* Disposes this object. After this call returns, any use of this object becomes invalid. Multiple calls to
|
||||
* this function should be safe: there should be no side-effects once an object is disposed.
|
||||
*/
|
||||
void dispose();
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package com.velocitypowered.proxy.protocol.compression;
|
||||
package com.velocitypowered.natives.compression;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
@ -50,7 +50,6 @@ public class JavaVelocityCompressor implements VelocityCompressor {
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
ensureNotDisposed();
|
||||
disposed = true;
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.velocitypowered.proxy.protocol.compression;
|
||||
package com.velocitypowered.natives.compression;
|
||||
|
||||
import com.velocitypowered.proxy.util.Disposable;
|
||||
import com.velocitypowered.natives.Disposable;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
import java.util.zip.DataFormatException;
|
@ -1,4 +1,4 @@
|
||||
package com.velocitypowered.proxy.protocol.encryption;
|
||||
package com.velocitypowered.natives.encryption;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
@ -33,7 +33,6 @@ public class JavaVelocityCipher implements VelocityCipher {
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
ensureNotDisposed();
|
||||
disposed = true;
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.velocitypowered.proxy.protocol.encryption;
|
||||
package com.velocitypowered.natives.encryption;
|
||||
|
||||
import com.velocitypowered.proxy.util.Disposable;
|
||||
import com.velocitypowered.natives.Disposable;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
import javax.crypto.ShortBufferException;
|
@ -20,6 +20,7 @@ jar {
|
||||
|
||||
dependencies {
|
||||
compile project(':velocity-api')
|
||||
compile project(':velocity-native')
|
||||
compile "io.netty:netty-codec:${nettyVersion}"
|
||||
compile "io.netty:netty-codec-http:${nettyVersion}"
|
||||
compile "io.netty:netty-handler:${nettyVersion}"
|
||||
|
@ -3,9 +3,9 @@ package com.velocitypowered.proxy.connection;
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.velocitypowered.proxy.protocol.PacketWrapper;
|
||||
import com.velocitypowered.proxy.protocol.StateRegistry;
|
||||
import com.velocitypowered.proxy.protocol.compression.JavaVelocityCompressor;
|
||||
import com.velocitypowered.proxy.protocol.encryption.JavaVelocityCipher;
|
||||
import com.velocitypowered.proxy.protocol.encryption.VelocityCipher;
|
||||
import com.velocitypowered.natives.compression.JavaVelocityCompressor;
|
||||
import com.velocitypowered.natives.encryption.JavaVelocityCipher;
|
||||
import com.velocitypowered.natives.encryption.VelocityCipher;
|
||||
import com.velocitypowered.proxy.protocol.netty.*;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelFutureListener;
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.velocitypowered.proxy.protocol.netty;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.velocitypowered.proxy.protocol.encryption.VelocityCipher;
|
||||
import com.velocitypowered.natives.encryption.VelocityCipher;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.handler.codec.ByteToMessageDecoder;
|
||||
@ -26,4 +26,9 @@ public class MinecraftCipherDecoder extends ByteToMessageDecoder {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handlerRemoved0(ChannelHandlerContext ctx) throws Exception {
|
||||
cipher.dispose();
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.velocitypowered.proxy.protocol.netty;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.velocitypowered.proxy.protocol.encryption.VelocityCipher;
|
||||
import com.velocitypowered.natives.encryption.VelocityCipher;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.handler.codec.MessageToByteEncoder;
|
||||
@ -17,4 +17,9 @@ public class MinecraftCipherEncoder extends MessageToByteEncoder<ByteBuf> {
|
||||
protected void encode(ChannelHandlerContext ctx, ByteBuf msg, ByteBuf out) throws Exception {
|
||||
cipher.process(msg, out);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlerRemoved(ChannelHandlerContext ctx) throws Exception {
|
||||
cipher.dispose();
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ package com.velocitypowered.proxy.protocol.netty;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
||||
import com.velocitypowered.proxy.protocol.compression.VelocityCompressor;
|
||||
import com.velocitypowered.natives.compression.VelocityCompressor;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.handler.codec.MessageToMessageDecoder;
|
||||
@ -42,4 +42,9 @@ public class MinecraftCompressDecoder extends MessageToMessageDecoder<ByteBuf> {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlerRemoved(ChannelHandlerContext ctx) throws Exception {
|
||||
compressor.dispose();
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,10 @@
|
||||
package com.velocitypowered.proxy.protocol.netty;
|
||||
|
||||
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
||||
import com.velocitypowered.proxy.protocol.compression.VelocityCompressor;
|
||||
import com.velocitypowered.natives.compression.VelocityCompressor;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.ChannelPromise;
|
||||
import io.netty.handler.codec.MessageToByteEncoder;
|
||||
|
||||
public class MinecraftCompressEncoder extends MessageToByteEncoder<ByteBuf> {
|
||||
@ -34,4 +35,9 @@ public class MinecraftCompressEncoder extends MessageToByteEncoder<ByteBuf> {
|
||||
compressedBuffer.release();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlerRemoved(ChannelHandlerContext ctx) throws Exception {
|
||||
compressor.dispose();
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,9 @@
|
||||
rootProject.name = 'velocity'
|
||||
include 'api'
|
||||
include 'proxy'
|
||||
include (
|
||||
'api',
|
||||
'proxy',
|
||||
'native'
|
||||
)
|
||||
findProject(':api')?.name = 'velocity-api'
|
||||
findProject(':proxy')?.name = 'velocity-proxy'
|
||||
|
||||
findProject(':native')?.name = 'velocity-native'
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren