Complete private authentication, server integrations and activity reporting
Add Fabric/Forge version builds and Paper integration, preserve permanent player identities across renames, harden session authorization, and surface privacy-conscious launcher/server activity in the panel.
This commit is contained in:
commit
a1f19e86c6
74 files changed
+2108
-95
No files matched your search
@@ -0,0 +1,39 @@
|
||||
package net.scopenet.integration;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Reader;
|
||||
import java.net.URI;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Properties;
|
||||
|
||||
public record Settings(URI panel, String token) {
|
||||
public Settings {
|
||||
if (panel == null || panel.getHost() == null || panel.getRawUserInfo() != null
|
||||
|| panel.getRawQuery() != null || panel.getRawFragment() != null
|
||||
|| !("https".equals(panel.getScheme()) || "http".equals(panel.getScheme()))) {
|
||||
throw new IllegalArgumentException("panel-url must be an HTTP(S) URL without credentials, query or fragment");
|
||||
}
|
||||
token = token == null ? "" : token.trim();
|
||||
if (!token.matches("sn_[A-Za-z0-9]{40}")) {
|
||||
throw new IllegalArgumentException("Set the server token from the panel's Servers page");
|
||||
}
|
||||
}
|
||||
|
||||
public static Settings of(String panel, String token) {
|
||||
return new Settings(URI.create(panel.trim().replaceAll("/+$", "")), token);
|
||||
}
|
||||
|
||||
public static Settings load(Path path) throws IOException {
|
||||
if (!Files.exists(path)) {
|
||||
Files.createDirectories(path.toAbsolutePath().getParent());
|
||||
Files.writeString(path, "# SCOPENET server integration\npanel-url=https://panel.example.com\ntoken=\n", StandardCharsets.UTF_8);
|
||||
}
|
||||
Properties properties = new Properties();
|
||||
try (Reader reader = Files.newBufferedReader(path, StandardCharsets.UTF_8)) {
|
||||
properties.load(reader);
|
||||
}
|
||||
return of(properties.getProperty("panel-url", ""), properties.getProperty("token", ""));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user