Search in sources :

Example 6 with ProxyServer

use of de.dytanic.cloudnetcore.network.components.ProxyServer in project CloudNet by Dytanic.

the class ScreenProvider method disableScreen.

public void disableScreen(String server) {
    MinecraftServer minecraftServer = CloudNet.getInstance().getServer(server);
    if (minecraftServer != null) {
        minecraftServer.getWrapper().disableScreen(minecraftServer.getServerInfo());
        return;
    }
    ProxyServer proxyServer = CloudNet.getInstance().getProxy(server);
    if (proxyServer != null) {
        proxyServer.getWrapper().disableScreen(proxyServer.getProxyInfo());
    }
}
Also used : MinecraftServer(de.dytanic.cloudnetcore.network.components.MinecraftServer) ProxyServer(de.dytanic.cloudnetcore.network.components.ProxyServer)

Example 7 with ProxyServer

use of de.dytanic.cloudnetcore.network.components.ProxyServer in project CloudNet by Dytanic.

the class PacketInServerDispatchCommand method handleInput.

@Override
public void handleInput(Document data, PacketSender packetSender) {
    DefaultType defaultType = data.getObject("defaultType", new TypeToken<DefaultType>() {
    }.getType());
    String serverId = data.getString("serverId");
    String commandLine = data.getString("commandLine");
    if (defaultType == DefaultType.BUKKIT) {
        MinecraftServer minecraftServer = CloudNet.getInstance().getServer(serverId);
        if (minecraftServer != null) {
            minecraftServer.getWrapper().writeServerCommand(commandLine, minecraftServer.getServerInfo());
        }
        CloudServer cloudServer = CloudNet.getInstance().getCloudGameServer(serverId);
        if (cloudServer != null) {
            cloudServer.getWrapper().writeServerCommand(commandLine, minecraftServer.getServerInfo());
        }
    } else {
        ProxyServer proxyServer = CloudNet.getInstance().getProxy(serverId);
        if (proxyServer != null) {
            proxyServer.getWrapper().writeProxyCommand(commandLine, proxyServer.getProxyInfo());
        }
    }
}
Also used : DefaultType(de.dytanic.cloudnet.lib.DefaultType) TypeToken(com.google.gson.reflect.TypeToken) CloudServer(de.dytanic.cloudnetcore.network.components.CloudServer) MinecraftServer(de.dytanic.cloudnetcore.network.components.MinecraftServer) ProxyServer(de.dytanic.cloudnetcore.network.components.ProxyServer)

Example 8 with ProxyServer

use of de.dytanic.cloudnetcore.network.components.ProxyServer in project CloudNet by Dytanic.

the class PacketInAuthHandler method handleAuth.

@Override
public void handleAuth(Auth auth, AuthType authType, Document authData, PacketSender packetSender) {
    if (!(packetSender instanceof CloudNetClientAuth))
        return;
    CloudNetClientAuth client = (CloudNetClientAuth) packetSender;
    switch(authType) {
        case CLOUD_NET:
            {
                String key = authData.getString("key");
                String id = authData.getString("id");
                if (CloudNet.getInstance().getWrappers().containsKey(id)) {
                    Wrapper cn = CloudNet.getInstance().getWrappers().get(id);
                    String wrapperKey = CloudNet.getInstance().getConfig().getWrapperKey();
                    if (wrapperKey != null && cn.getChannel() == null && wrapperKey.equals(key)) {
                        Channel channel = client.getChannel();
                        channel.pipeline().remove("client");
                        client.getChannel().writeAndFlush(new PacketOutAuthResult(new AuthLoginResult(true))).syncUninterruptibly();
                        channel.pipeline().addLast(new CloudNetClient(cn, channel));
                        return;
                    } else {
                        client.getChannel().writeAndFlush(new PacketOutAuthResult(new AuthLoginResult(false))).syncUninterruptibly();
                        CloudNet.getLogger().info("Authentication failed [" + (wrapperKey != null ? "Invalid WrapperKey or Wrapper is already connected!" : "WrapperKey not found, please copy a wrapper key to this instance") + "]");
                    }
                } else {
                    client.getChannel().writeAndFlush(new PacketOutAuthResult(new AuthLoginResult(false))).syncUninterruptibly();
                }
            }
            return;
        case GAMESERVER_OR_BUNGEE:
            {
                ServiceId serviceId = authData.getObject("serviceId", ServiceId.class);
                if (CloudNet.getInstance().getWrappers().containsKey(serviceId.getWrapperId())) {
                    Wrapper wrapper = CloudNet.getInstance().getWrappers().get(serviceId.getWrapperId());
                    if (wrapper.getServers().containsKey(serviceId.getServerId())) {
                        MinecraftServer minecraftServer = wrapper.getServers().get(serviceId.getServerId());
                        if (minecraftServer.getChannel() == null && minecraftServer.getServerInfo().getServiceId().getUniqueId().equals(serviceId.getUniqueId())) {
                            Channel channel = client.getChannel();
                            channel.pipeline().remove("client");
                            channel.pipeline().addLast(new CloudNetClient(minecraftServer, channel));
                            return;
                        }
                    } else if (wrapper.getCloudServers().containsKey(serviceId.getServerId())) {
                        CloudServer minecraftServer = wrapper.getCloudServers().get(serviceId.getServerId());
                        if (minecraftServer.getChannel() == null && minecraftServer.getServerInfo().getServiceId().getUniqueId().equals(serviceId.getUniqueId())) {
                            Channel channel = client.getChannel();
                            channel.pipeline().remove("client");
                            channel.pipeline().addLast(new CloudNetClient(minecraftServer, channel));
                            return;
                        }
                    } else if (wrapper.getProxys().containsKey(serviceId.getServerId())) {
                        ProxyServer minecraftServer = wrapper.getProxys().get(serviceId.getServerId());
                        if (minecraftServer.getChannel() == null && minecraftServer.getProxyInfo().getServiceId().getUniqueId().equals(serviceId.getUniqueId())) {
                            Channel channel = client.getChannel();
                            channel.pipeline().remove("client");
                            channel.pipeline().addLast(new CloudNetClient(minecraftServer, channel));
                            return;
                        }
                    } else {
                        client.getChannel().close().syncUninterruptibly();
                    }
                } else {
                    client.getChannel().close().syncUninterruptibly();
                }
            }
            return;
        default:
            return;
    }
}
Also used : AuthLoginResult(de.dytanic.cloudnet.lib.network.auth.AuthLoginResult) Wrapper(de.dytanic.cloudnetcore.network.components.Wrapper) PacketOutAuthResult(de.dytanic.cloudnet.lib.network.auth.packetio.PacketOutAuthResult) Channel(io.netty.channel.Channel) CloudNetClientAuth(de.dytanic.cloudnetcore.network.CloudNetClientAuth) CloudNetClient(de.dytanic.cloudnetcore.network.CloudNetClient) CloudServer(de.dytanic.cloudnetcore.network.components.CloudServer) ServiceId(de.dytanic.cloudnet.lib.service.ServiceId) MinecraftServer(de.dytanic.cloudnetcore.network.components.MinecraftServer) ProxyServer(de.dytanic.cloudnetcore.network.components.ProxyServer)

Example 9 with ProxyServer

use of de.dytanic.cloudnetcore.network.components.ProxyServer in project CloudNet by Dytanic.

the class ServerLogManager method append.

public void append(String rnd, String serverId) {
    for (String key : screenInfos.keySet()) {
        if (this.screenInfos.getF(key).getFirst().equals(serverId)) {
            screenInfos.add(rnd, new MultiValue<>(serverId, (System.currentTimeMillis() + 600000L)), new ConcurrentLinkedQueue<>(this.screenInfos.getS(key)));
            return;
        }
    }
    MinecraftServer minecraftServer = CloudNet.getInstance().getServer(serverId);
    if (minecraftServer != null) {
        minecraftServer.getWrapper().enableScreen(minecraftServer.getServerInfo());
        screenInfos.add(rnd, new MultiValue<>(serverId, (System.currentTimeMillis() + 600000L)), new ConcurrentLinkedQueue<>());
        return;
    }
    ProxyServer proxyServer = CloudNet.getInstance().getProxy(serverId);
    if (proxyServer != null) {
        proxyServer.getWrapper().enableScreen(proxyServer.getProxyInfo());
        screenInfos.add(rnd, new MultiValue<>(serverId, (System.currentTimeMillis() + 600000L)), new ConcurrentLinkedQueue<>());
    }
}
Also used : MinecraftServer(de.dytanic.cloudnetcore.network.components.MinecraftServer) ProxyServer(de.dytanic.cloudnetcore.network.components.ProxyServer)

Example 10 with ProxyServer

use of de.dytanic.cloudnetcore.network.components.ProxyServer in project CloudNet by Dytanic.

the class PacketInAddProxy method handleInput.

@Override
public void handleInput(Document data, PacketSender packetSender) {
    if (!(packetSender instanceof Wrapper))
        return;
    Wrapper cn = ((Wrapper) packetSender);
    ProxyInfo nullServerInfo = data.getObject("proxyInfo", new TypeToken<ProxyInfo>() {
    }.getType());
    ProxyProcessMeta proxyProcessMeta = data.getObject("proxyProcess", new TypeToken<ProxyProcessMeta>() {
    }.getType());
    ProxyServer minecraftServer = new ProxyServer(proxyProcessMeta, cn, nullServerInfo);
    cn.getProxys().put(proxyProcessMeta.getServiceId().getServerId(), minecraftServer);
    cn.getWaitingServices().remove(minecraftServer.getServerId());
    CloudNet.getInstance().getNetworkManager().handleProxyAdd(minecraftServer);
}
Also used : Wrapper(de.dytanic.cloudnetcore.network.components.Wrapper) ProxyInfo(de.dytanic.cloudnet.lib.server.info.ProxyInfo) TypeToken(com.google.gson.reflect.TypeToken) ProxyProcessMeta(de.dytanic.cloudnet.lib.server.ProxyProcessMeta) ProxyServer(de.dytanic.cloudnetcore.network.components.ProxyServer)

Aggregations

ProxyServer (de.dytanic.cloudnetcore.network.components.ProxyServer)16 MinecraftServer (de.dytanic.cloudnetcore.network.components.MinecraftServer)12 Wrapper (de.dytanic.cloudnetcore.network.components.Wrapper)9 TypeToken (com.google.gson.reflect.TypeToken)4 CloudServer (de.dytanic.cloudnetcore.network.components.CloudServer)4 DefaultType (de.dytanic.cloudnet.lib.DefaultType)2 CloudPlayer (de.dytanic.cloudnet.lib.player.CloudPlayer)2 ProxyInfo (de.dytanic.cloudnet.lib.server.info.ProxyInfo)2 ServiceId (de.dytanic.cloudnet.lib.service.ServiceId)2 Document (de.dytanic.cloudnet.lib.utility.document.Document)2 AuthLoginResult (de.dytanic.cloudnet.lib.network.auth.AuthLoginResult)1 PacketOutAuthResult (de.dytanic.cloudnet.lib.network.auth.packetio.PacketOutAuthResult)1 PlayerConnection (de.dytanic.cloudnet.lib.player.PlayerConnection)1 ProxyProcessMeta (de.dytanic.cloudnet.lib.server.ProxyProcessMeta)1 User (de.dytanic.cloudnet.lib.user.User)1 CollectionWrapper (de.dytanic.cloudnet.lib.utility.CollectionWrapper)1 WrapperChannelDisconnectEvent (de.dytanic.cloudnetcore.api.event.network.WrapperChannelDisconnectEvent)1 CloudNetClient (de.dytanic.cloudnetcore.network.CloudNetClient)1 CloudNetClientAuth (de.dytanic.cloudnetcore.network.CloudNetClientAuth)1 INetworkComponent (de.dytanic.cloudnetcore.network.components.INetworkComponent)1