Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: upgrade WaterDog to v2 #1210

Draft
wants to merge 6 commits into
base: nightly
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ext/platform-inject-support/runtime/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

repositories {
maven("https://repo.waterdog.dev/releases/")
maven("https://repo.waterdog.dev/snapshots/")
maven("https://repo.md-5.net/repository/releases/")
maven("https://repo.md-5.net/repository/snapshots/")
maven("https://repo.opencollab.dev/maven-releases/")
Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ gulf = "1.0.0-SNAPSHOT"
# platform api versions
sponge = "9.0.0"
velocity = "3.1.1"
waterdogpe = "1.2.4"
waterdogpe = "2.0.0-SNAPSHOT"
nukkitX = "1.0-SNAPSHOT"
minestom = "79ce9570ea"
spigot = "1.8.8-R0.1-SNAPSHOT"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ public void onLoad() {

// register the WaterDog handlers
var handlers = new WaterDogPEHandlers(this.proxyServer, this.bridgeManagement);
this.proxyServer.setJoinHandler(handlers);
this.proxyServer.setReconnectHandler(handlers);
this.proxyServer.setForcedHostHandler(handlers);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,17 @@
package eu.cloudnetservice.modules.bridge.platform.waterdog;

import dev.waterdog.waterdogpe.ProxyServer;
import dev.waterdog.waterdogpe.network.connection.handler.IForcedHostHandler;
import dev.waterdog.waterdogpe.network.connection.handler.IJoinHandler;
import dev.waterdog.waterdogpe.network.connection.handler.IReconnectHandler;
import dev.waterdog.waterdogpe.network.serverinfo.ServerInfo;
import dev.waterdog.waterdogpe.player.ProxiedPlayer;
import dev.waterdog.waterdogpe.utils.types.IForcedHostHandler;
import dev.waterdog.waterdogpe.utils.types.IReconnectHandler;
import eu.cloudnetservice.modules.bridge.platform.PlatformBridgeManagement;
import java.util.Locale;
import lombok.NonNull;
import org.jetbrains.annotations.Nullable;

final class WaterDogPEHandlers implements IForcedHostHandler, IReconnectHandler {
final class WaterDogPEHandlers implements IJoinHandler, IForcedHostHandler, IReconnectHandler {

private final ProxyServer proxyServer;
private final PlatformBridgeManagement<ProxiedPlayer, ?> management;
Expand All @@ -40,14 +41,21 @@ public WaterDogPEHandlers(
}

@Override
public ServerInfo resolveForcedHost(@Nullable String domain, @NonNull ProxiedPlayer player) {
public @Nullable ServerInfo determineServer(@NonNull ProxiedPlayer player) {
return this.management.fallback(player.getUniqueId(), null, null, player::hasPermission)
.map(server -> this.proxyServer.getServerInfo(server.name()))
.orElse(null);
}

@Override
public @Nullable ServerInfo resolveForcedHost(@Nullable String domain, @NonNull ProxiedPlayer player) {
return this.management.fallback(player.getUniqueId(), null, domain, player::hasPermission)
.map(server -> this.proxyServer.getServerInfo(server.name()))
.orElse(null);
}

@Override
public ServerInfo getFallbackServer(
public @Nullable ServerInfo getFallbackServer(
@NonNull ProxiedPlayer player,
@NonNull ServerInfo oldServer,
@NonNull String kickMessage
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

import dev.waterdog.waterdogpe.event.EventManager;
import dev.waterdog.waterdogpe.event.defaults.InitialServerConnectedEvent;
import dev.waterdog.waterdogpe.event.defaults.PlayerDisconnectEvent;
import dev.waterdog.waterdogpe.event.defaults.PlayerDisconnectedEvent;
import dev.waterdog.waterdogpe.event.defaults.PlayerLoginEvent;
import dev.waterdog.waterdogpe.event.defaults.TransferCompleteEvent;
import dev.waterdog.waterdogpe.player.ProxiedPlayer;
Expand Down Expand Up @@ -57,7 +57,7 @@ public WaterDogPEPlayerManagementListener(
// subscribe to all events
eventManager.subscribe(PlayerLoginEvent.class, this::handleLogin);
eventManager.subscribe(TransferCompleteEvent.class, this::handleTransfer);
eventManager.subscribe(PlayerDisconnectEvent.class, this::handleDisconnected);
eventManager.subscribe(PlayerDisconnectedEvent.class, this::handleDisconnected);
eventManager.subscribe(InitialServerConnectedEvent.class, this::handleInitialConnect);
}

Expand Down Expand Up @@ -99,7 +99,7 @@ private void handleInitialConnect(@NonNull InitialServerConnectedEvent event) {
this.proxyPlatformHelper.sendChannelMessageLoginSuccess(
this.management.createPlayerInformation(event.getPlayer()),
this.management
.cachedService(service -> service.name().equals(event.getInitialDownstream().getServerInfo().getServerName()))
.cachedService(service -> service.name().equals(event.getServerInfo().getServerName()))
.map(NetworkServiceInfo::fromServiceInfoSnapshot)
.orElse(null));
// update the service info
Expand All @@ -110,7 +110,7 @@ private void handleInitialConnect(@NonNull InitialServerConnectedEvent event) {

private void handleTransfer(@NonNull TransferCompleteEvent event) {
this.management
.cachedService(service -> service.name().equals(event.getNewClient().getServerInfo().getServerName()))
.cachedService(service -> service.name().equals(event.getTargetServer().getServerName()))
.map(NetworkServiceInfo::fromServiceInfoSnapshot)
.ifPresent(serviceInfo -> {
// the player switched the service
Expand All @@ -120,7 +120,7 @@ private void handleTransfer(@NonNull TransferCompleteEvent event) {
this.management.handleFallbackConnectionSuccess(event.getPlayer());
}

private void handleDisconnected(@NonNull PlayerDisconnectEvent event) {
private void handleDisconnected(@NonNull PlayerDisconnectedEvent event) {
// check if the player successfully connected to a server before
if (event.getPlayer().getServerInfo() != null) {
this.proxyPlatformHelper.sendChannelMessageDisconnected(event.getPlayer().getUniqueId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public WaterDogPECloudCommand(
@NonNull PlatformBridgeManagement<?, ?> management
) {
super("cloudnet", CommandSettings.builder()
.setAliases(new String[]{"cloud", "cn"})
.setAliases("cloud", "cn")
.setPermission("cloudnet.command.cloudnet")
.build());
this.clusterNodeProvider = clusterNodeProvider;
Expand Down
2 changes: 1 addition & 1 deletion modules/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ subprojects {
}

repositories {
maven("https://repo.waterdog.dev/releases/")
maven("https://repo.waterdog.dev/snapshots/")
maven("https://repo.md-5.net/repository/releases/")
maven("https://repo.md-5.net/repository/snapshots/")
maven("https://repo.opencollab.dev/maven-releases/")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

import dev.waterdog.waterdogpe.event.EventManager;
import dev.waterdog.waterdogpe.event.EventPriority;
import dev.waterdog.waterdogpe.event.defaults.PlayerDisconnectEvent;
import dev.waterdog.waterdogpe.event.defaults.PlayerDisconnectedEvent;
import dev.waterdog.waterdogpe.event.defaults.PlayerLoginEvent;
import dev.waterdog.waterdogpe.event.defaults.PlayerPermissionCheckEvent;
import dev.waterdog.waterdogpe.utils.ConfigurationManager;
Expand Down Expand Up @@ -61,7 +61,7 @@ public WaterdogPECloudPermissionsPlayerListener(
});

eventManager.subscribe(
PlayerDisconnectEvent.class,
PlayerDisconnectedEvent.class,
event -> CloudPermissionsHelper.handlePlayerQuit(permissionManagement, event.getPlayer().getUniqueId()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,6 @@ public WaterdogPECloudPermissionsPlugin(
this.moduleHelper = moduleHelper;
}

@Override
public void onLoad() {
}

@Override
public void onDisable() {
this.moduleHelper.unregisterAll(this.getClass().getClassLoader());
Expand Down
50 changes: 35 additions & 15 deletions node/src/main/resources/files/waterdogpe/config.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
# Waterdog Main Configuration file
# Configure your desired network settings here.


# A list of all downstream servers that are available right after starting
# address field is formatted using ip:port
# publicAddress is optional and can be set to the ip players can directly connect through
servers: { }

listener:

# The Motd which will be displayed in the server tab of a player and returned during ping
motd: §bCloudNet §8[§cBlizzard§8] §7WaterdogPE §cProxy §7instance

# The name that is shown up in the player list (pause menu)
name: §bCloudNet §8[§cBlizzard§8] §7WaterdogPE §cProxy

# The server priority list. If not changed by plugins, the proxy will connect the player to the first of those servers
priorities: [ ]

Expand All @@ -26,13 +23,35 @@ listener:
# when a player connects using skywars-xyz.com as the serverIp, he will be connected to SkyWars-1 directly
forced_hosts: { }

# Additional ports to listen to
additional_ports: [ ]

# The join handler used to determine the first entered server. Possible options: DefaultJoinHandler
join_handler: DefaultJoinHandler

# The reconnect handler used to determine fallback connections. Possible options: DefaultReconnectHandler, RoundRobinReconnectHandler
reconnect_handler: DefaultReconnectHandler

# A list of all downstream servers that are available right after starting
# address field is formatted using ip:port
# publicAddress is optional and can be set to the ip players can directly connect through
servers: { }

# Connection and security related settings. Do NOT edit unless you know what you are doing!
network_settings:
connection_throttle: 10
connection_throttle_time: 1000
enable_ipv6: true
max_user_mtu: 1400
login_throttle: 2
max_downstream_mtu: 1400
connection_timeout: 15

# Case-Sensitive permission list for players (empty using {})
permissions: { }

# List of permissions each player should get by default (empty using [])
permissions_default:
- waterdog.command.help
- waterdog.command.info
permissions_default: [ ]

# Whether the debug output in the console should be enabled or not
enable_debug: false
Expand All @@ -43,9 +62,6 @@ upstream_encryption: true
# If enabled, only players which are authenticated with XBOX Live can join. If disabled, anyone can connect *with any name*
online_mode: true

# If enabled, the proxy will be able to bind to an Ipv6 Address
enable_ipv6: true

# If enabled, the proxy will pass information like XUID or IP to the downstream server using custom fields in the LoginPacket
use_login_extras: true

Expand All @@ -58,12 +74,13 @@ enable_query: true
# If enabled, when receiving a McpeTransferPacket, the proxy will check if the target server is in the downstream list, and if yes, use the fast transfer mechanism
prefer_fast_transfer: true

# Fast-codec only decodes the packets required by the proxy, everything else will be passed rawly. Disabling this can create a performance hit
use_fast_codec: true

# If enabled, the proxy will inject all the proxy commands in the AvailableCommandsPacket, enabling autocompletion
inject_proxy_commands: true

# Algorithm used for upstream compression. Currently supported: zlib, snappy
# This is only applicable on 1.19.30 and newer versions
compression: zlib

# Upstream server compression ratio(proxy to client), higher = less bandwidth, more cpu, lower vice versa
upstream_compression_level: 6

Expand All @@ -87,3 +104,6 @@ pack_cache_size: 16

# Creating threads may be in some situations expensive. Specify minimum count of idle threads per internal thread executors. Set to -1 to auto-detect by core count.
default_idle_threads: -1

# Enable anonymous statistics that are sent to bstats. For more information, check out our bstats page at https://bstats.org/plugin/server-implementation/WaterdogPE/15678
enable_statistics: true