mirror of
https://github.com/ViaVersion/ViaProxy.git
synced 2024-12-21 16:28:10 +01:00
Updated NetMinecraft
This commit is contained in:
parent
d140757715
commit
8d2e5e57ef
@ -95,7 +95,7 @@ dependencies {
|
|||||||
exclude group: "com.google.code.gson", module: "gson"
|
exclude group: "com.google.code.gson", module: "gson"
|
||||||
}
|
}
|
||||||
include "net.lenni0451.commons:swing:1.6.1"
|
include "net.lenni0451.commons:swing:1.6.1"
|
||||||
include("net.raphimc.netminecraft:all:3.0.1") {
|
include("net.raphimc.netminecraft:all:3.1.0-SNAPSHOT") {
|
||||||
exclude group: "com.google.code.gson", module: "gson"
|
exclude group: "com.google.code.gson", module: "gson"
|
||||||
}
|
}
|
||||||
include("net.raphimc:MinecraftAuth:4.1.1") {
|
include("net.raphimc:MinecraftAuth:4.1.1") {
|
||||||
|
@ -260,7 +260,7 @@ public class ViaProxy {
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
Logger.LOGGER.info("Starting proxy server");
|
Logger.LOGGER.info("Starting proxy server");
|
||||||
currentProxyServer = new NetServer(() -> EVENT_MANAGER.call(new Client2ProxyHandlerCreationEvent(new Client2ProxyHandler(), false)).getHandler(), Client2ProxyChannelInitializer::new);
|
currentProxyServer = new NetServer(new Client2ProxyChannelInitializer(() -> EVENT_MANAGER.call(new Client2ProxyHandlerCreationEvent(new Client2ProxyHandler(), false)).getHandler()));
|
||||||
EVENT_MANAGER.call(new ProxyStartEvent());
|
EVENT_MANAGER.call(new ProxyStartEvent());
|
||||||
Logger.LOGGER.info("Binding proxy server to " + AddressUtil.toString(CONFIG.getBindAddress()));
|
Logger.LOGGER.info("Binding proxy server to " + AddressUtil.toString(CONFIG.getBindAddress()));
|
||||||
currentProxyServer.bind(CONFIG.getBindAddress(), false);
|
currentProxyServer.bind(CONFIG.getBindAddress(), false);
|
||||||
|
@ -219,9 +219,9 @@ public class Client2ProxyHandler extends SimpleChannelInboundHandler<Packet> {
|
|||||||
final Supplier<ChannelHandler> handlerSupplier = () -> ViaProxy.EVENT_MANAGER.call(new Proxy2ServerHandlerCreationEvent(new Proxy2ServerHandler(), false)).getHandler();
|
final Supplier<ChannelHandler> handlerSupplier = () -> ViaProxy.EVENT_MANAGER.call(new Proxy2ServerHandlerCreationEvent(new Proxy2ServerHandler(), false)).getHandler();
|
||||||
final ProxyConnection proxyConnection;
|
final ProxyConnection proxyConnection;
|
||||||
if (serverVersion.equals(BedrockProtocolVersion.bedrockLatest)) {
|
if (serverVersion.equals(BedrockProtocolVersion.bedrockLatest)) {
|
||||||
proxyConnection = new BedrockProxyConnection(handlerSupplier, Proxy2ServerChannelInitializer::new, this.proxyConnection.getC2P());
|
proxyConnection = new BedrockProxyConnection(new Proxy2ServerChannelInitializer(handlerSupplier), this.proxyConnection.getC2P());
|
||||||
} else {
|
} else {
|
||||||
proxyConnection = new ProxyConnection(handlerSupplier, Proxy2ServerChannelInitializer::new, this.proxyConnection.getC2P());
|
proxyConnection = new ProxyConnection(new Proxy2ServerChannelInitializer(handlerSupplier), this.proxyConnection.getC2P());
|
||||||
}
|
}
|
||||||
this.proxyConnection = ViaProxy.EVENT_MANAGER.call(new ProxySessionCreationEvent<>(proxyConnection, false)).getProxySession();
|
this.proxyConnection = ViaProxy.EVENT_MANAGER.call(new ProxySessionCreationEvent<>(proxyConnection, false)).getProxySession();
|
||||||
this.proxyConnection.getC2P().attr(ProxyConnection.PROXY_CONNECTION_ATTRIBUTE_KEY).set(this.proxyConnection);
|
this.proxyConnection.getC2P().attr(ProxyConnection.PROXY_CONNECTION_ATTRIBUTE_KEY).set(this.proxyConnection);
|
||||||
|
@ -74,7 +74,7 @@ public class PassthroughClient2ProxyHandler extends SimpleChannelInboundHandler<
|
|||||||
|
|
||||||
protected void connectToServer(final Channel c2pChannel) {
|
protected void connectToServer(final Channel c2pChannel) {
|
||||||
final Supplier<ChannelHandler> handlerSupplier = () -> ViaProxy.EVENT_MANAGER.call(new Proxy2ServerHandlerCreationEvent(new PassthroughProxy2ServerHandler(), true)).getHandler();
|
final Supplier<ChannelHandler> handlerSupplier = () -> ViaProxy.EVENT_MANAGER.call(new Proxy2ServerHandlerCreationEvent(new PassthroughProxy2ServerHandler(), true)).getHandler();
|
||||||
final LegacyProxyConnection proxyConnection = new LegacyProxyConnection(handlerSupplier, PassthroughProxy2ServerChannelInitializer::new, c2pChannel);
|
final LegacyProxyConnection proxyConnection = new LegacyProxyConnection(new PassthroughProxy2ServerChannelInitializer(handlerSupplier), c2pChannel);
|
||||||
this.proxyConnection = ViaProxy.EVENT_MANAGER.call(new ProxySessionCreationEvent<>(proxyConnection, true)).getProxySession();
|
this.proxyConnection = ViaProxy.EVENT_MANAGER.call(new ProxySessionCreationEvent<>(proxyConnection, true)).getProxySession();
|
||||||
this.proxyConnection.getC2P().attr(LegacyProxyConnection.LEGACY_PROXY_CONNECTION_ATTRIBUTE_KEY).set(this.proxyConnection);
|
this.proxyConnection.getC2P().attr(LegacyProxyConnection.LEGACY_PROXY_CONNECTION_ATTRIBUTE_KEY).set(this.proxyConnection);
|
||||||
|
|
||||||
|
@ -19,7 +19,10 @@ package net.raphimc.viaproxy.proxy.session;
|
|||||||
|
|
||||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||||
import io.netty.bootstrap.Bootstrap;
|
import io.netty.bootstrap.Bootstrap;
|
||||||
import io.netty.channel.*;
|
import io.netty.channel.Channel;
|
||||||
|
import io.netty.channel.ChannelFuture;
|
||||||
|
import io.netty.channel.ChannelInitializer;
|
||||||
|
import io.netty.channel.ChannelOption;
|
||||||
import io.netty.channel.socket.DatagramChannel;
|
import io.netty.channel.socket.DatagramChannel;
|
||||||
import net.lenni0451.reflect.stream.RStream;
|
import net.lenni0451.reflect.stream.RStream;
|
||||||
import net.raphimc.netminecraft.constants.ConnectionState;
|
import net.raphimc.netminecraft.constants.ConnectionState;
|
||||||
@ -35,13 +38,11 @@ import org.cloudburstmc.netty.channel.raknet.config.RakChannelOption;
|
|||||||
import java.net.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
||||||
import java.net.SocketAddress;
|
import java.net.SocketAddress;
|
||||||
import java.util.concurrent.ThreadLocalRandom;
|
import java.util.concurrent.ThreadLocalRandom;
|
||||||
import java.util.function.Function;
|
|
||||||
import java.util.function.Supplier;
|
|
||||||
|
|
||||||
public class BedrockProxyConnection extends ProxyConnection {
|
public class BedrockProxyConnection extends ProxyConnection {
|
||||||
|
|
||||||
public BedrockProxyConnection(Supplier<ChannelHandler> handlerSupplier, Function<Supplier<ChannelHandler>, ChannelInitializer<Channel>> channelInitializerSupplier, Channel c2p) {
|
public BedrockProxyConnection(final ChannelInitializer<Channel> channelInitializer, Channel c2p) {
|
||||||
super(handlerSupplier, channelInitializerSupplier, c2p);
|
super(channelInitializer, c2p);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -64,7 +65,7 @@ public class BedrockProxyConnection extends ProxyConnection {
|
|||||||
.option(RakChannelOption.RAK_SESSION_TIMEOUT, 30_000L)
|
.option(RakChannelOption.RAK_SESSION_TIMEOUT, 30_000L)
|
||||||
.option(RakChannelOption.RAK_GUID, ThreadLocalRandom.current().nextLong())
|
.option(RakChannelOption.RAK_GUID, ThreadLocalRandom.current().nextLong())
|
||||||
.attr(ProxyConnection.PROXY_CONNECTION_ATTRIBUTE_KEY, this)
|
.attr(ProxyConnection.PROXY_CONNECTION_ATTRIBUTE_KEY, this)
|
||||||
.handler(this.channelInitializerSupplier.apply(this.handlerSupplier));
|
.handler(this.channelInitializer);
|
||||||
|
|
||||||
this.channelFuture = bootstrap.register().syncUninterruptibly();
|
this.channelFuture = bootstrap.register().syncUninterruptibly();
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ import java.security.Key;
|
|||||||
public class DummyProxyConnection extends ProxyConnection {
|
public class DummyProxyConnection extends ProxyConnection {
|
||||||
|
|
||||||
public DummyProxyConnection(final Channel c2p) {
|
public DummyProxyConnection(final Channel c2p) {
|
||||||
super(null, null, c2p);
|
super(null, c2p);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -18,15 +18,16 @@
|
|||||||
package net.raphimc.viaproxy.proxy.session;
|
package net.raphimc.viaproxy.proxy.session;
|
||||||
|
|
||||||
import io.netty.bootstrap.Bootstrap;
|
import io.netty.bootstrap.Bootstrap;
|
||||||
import io.netty.channel.*;
|
import io.netty.channel.Channel;
|
||||||
|
import io.netty.channel.ChannelFuture;
|
||||||
|
import io.netty.channel.ChannelInitializer;
|
||||||
|
import io.netty.channel.ChannelOption;
|
||||||
import io.netty.util.AttributeKey;
|
import io.netty.util.AttributeKey;
|
||||||
import net.raphimc.netminecraft.netty.connection.NetClient;
|
import net.raphimc.netminecraft.netty.connection.NetClient;
|
||||||
import net.raphimc.netminecraft.util.ChannelType;
|
import net.raphimc.netminecraft.util.ChannelType;
|
||||||
import net.raphimc.viaproxy.ViaProxy;
|
import net.raphimc.viaproxy.ViaProxy;
|
||||||
|
|
||||||
import java.net.SocketAddress;
|
import java.net.SocketAddress;
|
||||||
import java.util.function.Function;
|
|
||||||
import java.util.function.Supplier;
|
|
||||||
|
|
||||||
public class LegacyProxyConnection extends NetClient {
|
public class LegacyProxyConnection extends NetClient {
|
||||||
|
|
||||||
@ -35,8 +36,8 @@ public class LegacyProxyConnection extends NetClient {
|
|||||||
private final Channel c2p;
|
private final Channel c2p;
|
||||||
private SocketAddress serverAddress;
|
private SocketAddress serverAddress;
|
||||||
|
|
||||||
public LegacyProxyConnection(final Supplier<ChannelHandler> handlerSupplier, final Function<Supplier<ChannelHandler>, ChannelInitializer<Channel>> channelInitializerSupplier, final Channel c2p) {
|
public LegacyProxyConnection(final ChannelInitializer<Channel> channelInitializer, final Channel c2p) {
|
||||||
super(handlerSupplier, channelInitializerSupplier);
|
super(channelInitializer);
|
||||||
this.c2p = c2p;
|
this.c2p = c2p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,8 +48,6 @@ import java.security.GeneralSecurityException;
|
|||||||
import java.security.Key;
|
import java.security.Key;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.function.Function;
|
|
||||||
import java.util.function.Supplier;
|
|
||||||
|
|
||||||
public class ProxyConnection extends NetClient {
|
public class ProxyConnection extends NetClient {
|
||||||
|
|
||||||
@ -74,8 +72,8 @@ public class ProxyConnection extends NetClient {
|
|||||||
private ConnectionState c2pConnectionState = ConnectionState.HANDSHAKING;
|
private ConnectionState c2pConnectionState = ConnectionState.HANDSHAKING;
|
||||||
private ConnectionState p2sConnectionState = ConnectionState.HANDSHAKING;
|
private ConnectionState p2sConnectionState = ConnectionState.HANDSHAKING;
|
||||||
|
|
||||||
public ProxyConnection(final Supplier<ChannelHandler> handlerSupplier, final Function<Supplier<ChannelHandler>, ChannelInitializer<Channel>> channelInitializerSupplier, final Channel c2p) {
|
public ProxyConnection(final ChannelInitializer<Channel> channelInitializer, final Channel c2p) {
|
||||||
super(handlerSupplier, channelInitializerSupplier);
|
super(channelInitializer);
|
||||||
this.c2p = c2p;
|
this.c2p = c2p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user