-
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.
Support forwarding bungeecord plugin channel to the ENTRY server. Bun…
…geecord PROXIES can now support direct connection from client. Version 2.0.0
- Loading branch information
Showing
13 changed files
with
185 additions
and
30 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
42 changes: 42 additions & 0 deletions
42
src/main/java/com/velocitypowered/proxy/connection/backend/VBungeeCordMessageResponder.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,42 @@ | ||
package com.velocitypowered.proxy.connection.backend; | ||
|
||
import com.velocitypowered.proxy.VelocityServer; | ||
import com.velocitypowered.proxy.connection.client.ConnectedPlayer; | ||
import com.velocitypowered.proxy.protocol.packet.PluginMessage; | ||
import com.velocitypowered.proxy.protocol.util.ByteBufDataInput; | ||
import work.art1st.proxiedproxy.PPlugin; | ||
|
||
public class VBungeeCordMessageResponder extends BungeeCordMessageResponder { | ||
private final VelocityServer proxy; | ||
public VBungeeCordMessageResponder(VelocityServer proxy, ConnectedPlayer player) { | ||
super(proxy, player); | ||
this.proxy = proxy; | ||
} | ||
|
||
/* Send the PluginMessage to ENTRY */ | ||
@Override | ||
boolean process(PluginMessage message) { | ||
if (PPlugin.getProxyConfig().sendSwitchServerPluginMessageToEntry) { | ||
ByteBufDataInput in = new ByteBufDataInput(message.content()); | ||
String subChannel = in.readUTF(); | ||
String target; | ||
switch (subChannel) { | ||
case "Connect": | ||
case "ConnectOther": | ||
target = in.readUTF(); | ||
if (this.proxy.getServer(target).isEmpty()) { | ||
return false; | ||
} | ||
break; | ||
case "PlayerCount": | ||
case "PlayerList": | ||
target = in.readUTF(); | ||
if (!target.equals("ALL") && this.proxy.getServer(target).isEmpty()) { | ||
return false; | ||
} | ||
break; | ||
} | ||
} | ||
return super.process(message); | ||
} | ||
} |
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
51 changes: 51 additions & 0 deletions
51
src/main/java/work/art1st/proxiedproxy/platform/bungeecord/connection/BDownstreamBridge.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,51 @@ | ||
package work.art1st.proxiedproxy.platform.bungeecord.connection; | ||
|
||
import com.google.common.io.ByteArrayDataOutput; | ||
import com.google.common.io.ByteStreams; | ||
import net.md_5.bungee.ServerConnection; | ||
import net.md_5.bungee.UserConnection; | ||
import net.md_5.bungee.api.ProxyServer; | ||
import net.md_5.bungee.connection.DownstreamBridge; | ||
import net.md_5.bungee.protocol.packet.PluginMessage; | ||
import work.art1st.proxiedproxy.PPlugin; | ||
|
||
import java.io.DataInput; | ||
|
||
public class BDownstreamBridge extends DownstreamBridge { | ||
private final ProxyServer bungee; | ||
public BDownstreamBridge(ProxyServer bungee, UserConnection con, ServerConnection server) { | ||
super(bungee, con, server); | ||
this.bungee = bungee; | ||
} | ||
|
||
/* Send the PluginMessage to ENTRY */ | ||
@Override | ||
@SuppressWarnings("checkstyle:avoidnestedblocks") | ||
public void handle(PluginMessage pluginMessage) throws Exception | ||
{ | ||
if (PPlugin.getProxyConfig().sendSwitchServerPluginMessageToEntry) { | ||
DataInput in = pluginMessage.getStream(); | ||
if (pluginMessage.getTag().equals("BungeeCord")) { | ||
String subChannel = in.readUTF(); | ||
String target; | ||
switch (subChannel) { | ||
case "Connect": | ||
case "ConnectOther": | ||
target = in.readUTF(); | ||
if (this.bungee.getServerInfo(target) == null) { | ||
return; | ||
} | ||
break; | ||
case "PlayerCount": | ||
case "PlayerList": | ||
target = in.readUTF(); | ||
if (!target.equals("ALL") && this.bungee.getServerInfo(target) == null) { | ||
return; | ||
} | ||
break; | ||
} | ||
} | ||
} | ||
super.handle(pluginMessage); | ||
} | ||
} |
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