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

Implemented ViaProxy bootstrap #4201

Merged
merged 35 commits into from
Feb 19, 2024
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
c84b1c5
Implemented ViaProxy bootstrap
RaphiMC Oct 8, 2023
ad53b12
Applied requested changes to code
RaphiMC Oct 8, 2023
b59fc66
Override indra settings to Java 17
RaphiMC Oct 20, 2023
a1265ca
Removed explicit java source/target version
RaphiMC Oct 20, 2023
9585120
Added ViaProxy artifact to build.yml
RaphiMC Oct 20, 2023
f9731e7
Added ViaProxy artifact to pullrequest.yml
RaphiMC Oct 20, 2023
2b5b91a
Merge branch 'master' into feature/viaproxy-platform
RaphiMC Nov 2, 2023
1b855d6
Updated ViaProxy API usage
RaphiMC Nov 2, 2023
cbb84d9
Merge branch 'master' into feature/viaproxy-platform
RaphiMC Nov 4, 2023
4e49063
Implemented floodgate support for ViaProxy
RaphiMC Nov 4, 2023
b1f055d
Merge branch 'master' into feature/viaproxy-platform
RaphiMC Nov 19, 2023
ad9d161
Merge branch 'master' into feature/viaproxy-platform
RaphiMC Nov 26, 2023
9ba51de
Merge branch 'master' into feature/viaproxy-platform
RaphiMC Dec 1, 2023
f9a30d1
Merge branch 'master' into feature/viaproxy-platform
RaphiMC Dec 8, 2023
c706014
Depend on stable ViaProxy release
RaphiMC Dec 8, 2023
6c8434b
Merge remote-tracking branch 'origin/feature/viaproxy-platform' into …
RaphiMC Dec 8, 2023
3935607
Initialize command manager and ping passthrough before Geyser#start
RaphiMC Dec 8, 2023
3db495e
Revert "Initialize command manager and ping passthrough before Geyser…
RaphiMC Dec 8, 2023
4212851
Some ping passthrough improvements
RaphiMC Dec 8, 2023
084d85b
Merge branch 'master' into feature/viaproxy-platform
RaphiMC Dec 15, 2023
ae230ca
Merged code properly
RaphiMC Dec 15, 2023
7f10221
Updated ViaProxy API usage
RaphiMC Dec 17, 2023
81f9226
Merge branch 'master' into feature/viaproxy-platform
RaphiMC Dec 17, 2023
0040b6a
Implemented better command handling
RaphiMC Dec 18, 2023
92b5051
Merge branch 'master' into feature/viaproxy-platform
RaphiMC Jan 19, 2024
3e9440d
Merge branch 'master' into feature/viaproxy-platform
RaphiMC Feb 11, 2024
94a15b0
Merge branch 'master' into feature/viaproxy-platform
RaphiMC Feb 14, 2024
caf24e0
Updated ViaProxy and Geyser API usage
RaphiMC Feb 14, 2024
fc34b1a
Combine bootstrap and plugin into one class
RaphiMC Feb 15, 2024
92eaff0
Minor code improvements
RaphiMC Feb 15, 2024
1bf188d
Call Geyser shutdown on plugin disable
RaphiMC Feb 16, 2024
1f93cd3
Merge branch 'master' into feature/viaproxy-platform
RaphiMC Feb 16, 2024
7810080
Only call disable if Geyser was enabled once
RaphiMC Feb 16, 2024
5556a37
Don't send two shutdown done messages
RaphiMC Feb 16, 2024
e76e8a2
Use setter for enabled boolean
RaphiMC Feb 16, 2024
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
7 changes: 7 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,13 @@ jobs:
name: Geyser Velocity
path: bootstrap/velocity/build/libs/Geyser-Velocity.jar
if-no-files-found: error
- name: Archive artifacts (Geyser ViaProxy)
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32
if: success()
with:
name: Geyser ViaProxy
path: bootstrap/viaproxy/build/libs/Geyser-ViaProxy.jar
if-no-files-found: error

- name: Publish to Maven Repository
if: ${{ success() && github.repository == 'GeyserMC/Geyser' && github.ref_name == 'master' }}
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/pullrequest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,10 @@ jobs:
name: Geyser Velocity
path: geyser/bootstrap/velocity/build/libs/Geyser-Velocity.jar
if-no-files-found: error
- name: Archive artifacts (Geyser ViaProxy)
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32
if: success()
with:
name: Geyser ViaProxy
path: geyser/bootstrap/viaproxy/build/libs/Geyser-ViaProxy.jar
if-no-files-found: error
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,5 @@ public record PlatformType(String platformName) {
public static final PlatformType SPONGE = new PlatformType("Sponge");
public static final PlatformType STANDALONE = new PlatformType("Standalone");
public static final PlatformType VELOCITY = new PlatformType("Velocity");
public static final PlatformType VIAPROXY = new PlatformType("ViaProxy");
}
32 changes: 32 additions & 0 deletions bootstrap/viaproxy/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
indra {
javaVersions {
target(17)
}
}

dependencies {
api(projects.core)
}

platformRelocate("net.kyori")
platformRelocate("org.yaml")
platformRelocate("it.unimi.dsi.fastutil")
platformRelocate("org.cloudburstmc.netty")

// These dependencies are already present on the platform
provided(libs.viaproxy)

application {
mainClass.set("org.geysermc.geyser.platform.viaproxy.GeyserViaProxyMain")
}

tasks.withType<com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar> {
archiveBaseName.set("Geyser-ViaProxy")

dependencies {
exclude(dependency("com.google.*:.*"))
exclude(dependency("io.netty:.*"))
exclude(dependency("org.slf4j:.*"))
exclude(dependency("org.ow2.asm:.*"))
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
/*
* Copyright (c) 2019-2023 GeyserMC. http://geysermc.org
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* @author GeyserMC
* @link https://github.com/GeyserMC/Geyser
*/
package org.geysermc.geyser.platform.viaproxy;

import net.raphimc.vialoader.util.VersionEnum;
import net.raphimc.viaproxy.cli.options.Options;
import org.apache.logging.log4j.Logger;
import org.geysermc.geyser.GeyserBootstrap;
import org.geysermc.geyser.GeyserImpl;
import org.geysermc.geyser.GeyserLogger;
import org.geysermc.geyser.api.network.AuthType;
import org.geysermc.geyser.api.util.PlatformType;
import org.geysermc.geyser.command.GeyserCommandManager;
import org.geysermc.geyser.configuration.GeyserConfiguration;
import org.geysermc.geyser.dump.BootstrapDumpInfo;
import org.geysermc.geyser.ping.GeyserLegacyPingPassthrough;
import org.geysermc.geyser.ping.IGeyserPingPassthrough;
import org.geysermc.geyser.text.GeyserLocale;
import org.geysermc.geyser.util.FileUtils;
import org.geysermc.geyser.util.LoopbackUtil;
import org.jetbrains.annotations.NotNull;

import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.UUID;

public class GeyserViaProxyBootstrap implements GeyserBootstrap {

private final File rootFolder;
private final GeyserViaProxyLogger logger;
private GeyserViaProxyConfiguration config;

private GeyserImpl geyser;
private GeyserCommandManager commandManager;
private IGeyserPingPassthrough pingPassthrough;

public GeyserViaProxyBootstrap(final Logger logger, final File rootFolder) {
this.logger = new GeyserViaProxyLogger(logger);
this.rootFolder = rootFolder;
}

@Override
public void onEnable() {
LoopbackUtil.checkAndApplyLoopback(this.logger);

try {
final File configFile = FileUtils.fileOrCopiedFromResource(new File(this.rootFolder, "config.yml"), "config.yml", s -> s.replaceAll("generateduuid", UUID.randomUUID().toString()), this);
this.config = FileUtils.loadConfig(configFile, GeyserViaProxyConfiguration.class);
} catch (IOException e) {
this.logger.severe(GeyserLocale.getLocaleStringLog("geyser.config.failed"), e);
return;
}

config.getRemote().setAuthType(Files.isRegularFile(this.config.getFloodgateKeyPath()) ? AuthType.FLOODGATE : AuthType.OFFLINE);
GeyserConfiguration.checkGeyserConfiguration(this.config, this.logger);

this.geyser = GeyserImpl.load(PlatformType.VIAPROXY, this);
GeyserImpl.start();

this.commandManager = new GeyserCommandManager(this.geyser);
this.commandManager.init();

if (Options.PROTOCOL_VERSION != null && Options.PROTOCOL_VERSION.isNewerThanOrEqualTo(VersionEnum.b1_8tob1_8_1)) {
// Only initialize the ping passthrough if the protocol version is above beta 1.7.3, as that's when the status protocol was added
this.pingPassthrough = GeyserLegacyPingPassthrough.init(this.geyser);
}
}

@Override
public void onDisable() {
this.geyser.shutdown();
}

@Override
public GeyserConfiguration getGeyserConfig() {
return this.config;
}

@Override
public GeyserLogger getGeyserLogger() {
return this.logger;
}

@Override
public GeyserCommandManager getGeyserCommandManager() {
return this.commandManager;
}

@Override
public IGeyserPingPassthrough getGeyserPingPassthrough() {
return this.pingPassthrough;
}

@Override
public Path getConfigFolder() {
return this.rootFolder.toPath();
}

@Override
public BootstrapDumpInfo getDumpInfo() {
return new GeyserViaProxyDumpInfo();
}

@NotNull
@Override
public String getServerBindAddress() {
return Options.BIND_ADDRESS;
}

@Override
public int getServerPort() {
return Options.BIND_PORT;
}

@Override
public boolean testFloodgatePluginPresent() {
return false;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
* Copyright (c) 2019-2023 GeyserMC. http://geysermc.org
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* @author GeyserMC
* @link https://github.com/GeyserMC/Geyser
*/
package org.geysermc.geyser.platform.viaproxy;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import net.raphimc.vialoader.util.VersionEnum;
import net.raphimc.viaproxy.cli.options.Options;
import org.geysermc.geyser.configuration.GeyserJacksonConfiguration;

import java.io.File;
import java.nio.file.Path;

@JsonIgnoreProperties(ignoreUnknown = true)
public class GeyserViaProxyConfiguration extends GeyserJacksonConfiguration {

@Override
public Path getFloodgateKeyPath() {
return new File(GeyserViaProxyPlugin.ROOT_FOLDER, this.getFloodgateKeyFile()).toPath();
}

@Override
public int getPingPassthroughInterval() {
int interval = super.getPingPassthroughInterval();
if (interval < 15 && Options.PROTOCOL_VERSION != null && Options.PROTOCOL_VERSION.isOlderThanOrEqualTo(VersionEnum.r1_6_4)) {
// <= 1.6.4 servers sometimes block incoming connections from an IP address if too many connections are made
interval = 15;
}
return interval;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
* Copyright (c) 2019-2023 GeyserMC. http://geysermc.org
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* @author GeyserMC
* @link https://github.com/GeyserMC/Geyser
*/
package org.geysermc.geyser.platform.viaproxy;

import lombok.Getter;
import net.raphimc.viaproxy.ViaProxy;
import net.raphimc.viaproxy.cli.options.Options;
import net.raphimc.viaproxy.plugins.ViaProxyPlugin;
import org.geysermc.geyser.dump.BootstrapDumpInfo;
import org.geysermc.geyser.text.AsteriskSerializer;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

@Getter
public class GeyserViaProxyDumpInfo extends BootstrapDumpInfo {

private final String platformVersion;
private final boolean onlineMode;

@AsteriskSerializer.Asterisk(isIp = true)
private final String serverIP;
private final int serverPort;
private final List<PluginInfo> plugins;

public GeyserViaProxyDumpInfo() {
this.platformVersion = ViaProxy.VERSION;
this.onlineMode = Options.ONLINE_MODE;
this.serverIP = Options.BIND_ADDRESS;
this.serverPort = Options.BIND_PORT;
this.plugins = new ArrayList<>();

for (ViaProxyPlugin plugin : ViaProxy.getPluginManager().getPlugins()) {
this.plugins.add(new PluginInfo(true, plugin.getName(), plugin.getVersion(), "unknown", Collections.singletonList(plugin.getAuthor())));
}
}

}
Loading