Skip to content
Merged
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
28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,34 @@ SPL opens a port to listen for HTTP connections. You can change this port in the
port = 8080
```

#### SSL Termination
By default, the included webserver does not expose a TLS based communication channel over HTTP.
This means that any server operator wishing to expose SPLs webserver over a secure channel must set this up themselves.
Luckily this can easily be done via a reverse proxy.

> [!WARNING]
> It is highly recommended to not expose SPLs own webserver to the public, but to apply a reverse proxy. Potentially including a Web Application Firewall, and logging of requests to trace bad-actors.

##### NGINX
Creating a reverse proxy based on NGINX is simple and you can find an example below:
```conf
server {
listen 444 ssl;
server_name yourdomain.com;

ssl_certificate /opt/ssl/fullchain.pem;
ssl_certificate_key /opt/ssl/privkey.pem;

location / {
proxy_pass http://localhost:8080;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
```

### Exposing Content

You also configure which directories to send to the client, and whether local changes by clients will be overwritten
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

neoforgeVersion=21.0.158
neoforgeVersion=21.5.6-beta

neoForge.parchment.minecraftVersion=1.21
neoForge.parchment.mappingsVersion=2024.07.07
16 changes: 14 additions & 2 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ pluginManagement {
id 'io.github.goooler.shadow' version '8.1.7'
id 'de.undercouch.download' version '5.6.0'
// https://projects.neoforged.net/neoforged/ModDevGradle
id 'net.neoforged.moddev' version '1.0.3'
id 'net.neoforged.moddev.repositories' version '1.0.3'
id 'net.neoforged.moddev' version '2.0.78'
id 'net.neoforged.moddev.repositories' version '2.0.78'
id 'net.neoforged.gradleutils' version '3.0.0'
}
}
Expand All @@ -19,9 +19,21 @@ plugins {
dependencyResolutionManagement {
repositoriesMode = RepositoriesMode.FAIL_ON_PROJECT_REPOS
rulesMode = RulesMode.FAIL_ON_PROJECT_RULES

repositories {
mavenCentral()
}

repositories {
maven {
name 'Maven for PR #2039' // https://github.com/neoforged/NeoForge/pull/2039
url 'https://prmaven.neoforged.net/NeoForge/pr2039'
content {
includeModule('net.neoforged', 'neoforge')
includeModule('net.neoforged', 'testframework')
}
}
}
}

rootProject.name = 'serverpacklocator'
Original file line number Diff line number Diff line change
Expand Up @@ -141,14 +141,9 @@ public ServerManifest download() throws IOException, InterruptedException {
for (var fileToDownload : filesToDownload) {
var bytesDownloadedAtStartOfFile = bytesDownloaded;
progressBar.setAbsolute(toDownloadProgress(bytesDownloadedAtStartOfFile));
MutableLong lastRenderTick = new MutableLong(System.currentTimeMillis());
progressBar.label("Downloading " + fileToDownload.localFile.getName() + "...");
downloadFile(fileToDownload, (downloaded, total) -> {
progressBar.setAbsolute(toDownloadProgress(bytesDownloadedAtStartOfFile + downloaded));
if (System.currentTimeMillis() - lastRenderTick.getValue() >= 50L) {
ImmediateWindowHandler.renderTick();
lastRenderTick.setValue(System.currentTimeMillis());
}
});
// The original estimate was based on this, and the progress bar should reflect it
// even if the server sent a different size
Expand Down
Original file line number Diff line number Diff line change
@@ -1,48 +1,40 @@
package net.forgecraft.serverpackutility.mixin.client;

import com.llamalad7.mixinextras.injector.wrapmethod.WrapMethod;
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
import com.mojang.realmsclient.client.RealmsClient;
import net.forgecraft.serverpacklocator.ModAccessor;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.screens.ConnectScreen;
import net.minecraft.client.gui.screens.TitleScreen;
import net.minecraft.client.gui.screens.multiplayer.JoinMultiplayerScreen;
import net.minecraft.client.multiplayer.ServerData;
import net.minecraft.client.main.GameConfig;
import net.minecraft.client.multiplayer.resolver.ServerAddress;
import org.jetbrains.annotations.Nullable;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.Unique;

@Mixin(Minecraft.class)
public abstract class MinecraftMixin {
@Inject(
method = "lambda$buildInitialScreens$9",
at = @At("HEAD"),
cancellable = true
)
private void inject(@Nullable Minecraft.GameLoadCookie cookie, CallbackInfo ci) {
// quit out if user requested quick play via vanilla client (launch args)
if (cookie != null && cookie.quickPlayData().isEnabled())
return;

@Unique
private Minecraft serverpacklocator$getCurrentInstance() {
return (Minecraft) (Object) this;
}

@WrapMethod(method = "buildInitialScreens")
private Runnable serverpacklocator$buildInitialScreens(@Nullable Minecraft.GameLoadCookie cookie, Operation<Runnable> operation) {
// parse server address
var serverAddress = ServerAddress.parseString(ModAccessor.getQuickPlayServer());

// quit out if invalid server address passed
if (serverAddress.getHost().equals("server.invalid"))
return;

// connect to server
ConnectScreen.startConnecting(
new JoinMultiplayerScreen(new TitleScreen()),
(Minecraft) (Object) this,
serverAddress,
new ServerData("ServerPackLocator - QuickPlay Server", serverAddress.toString(), ServerData.Type.OTHER),
true,
if ((cookie == null || !cookie.quickPlayData().isEnabled()) && !serverAddress.getHost().equals("server.invalid")) {
RealmsClient realmsclient = RealmsClient.getOrCreate(serverpacklocator$getCurrentInstance());
cookie = new Minecraft.GameLoadCookie(realmsclient, new GameConfig.QuickPlayData(
null,
null,
serverAddress.toString(),
null
);
));
}

// cancel vanilla code
ci.cancel();
return operation.call(cookie);
}
}