add loader updating, fix branches
All checks were successful
/ Build BaseBand Loader (push) Successful in 1m39s
/ Build BaseBand Server (push) Successful in 1m40s

This commit is contained in:
Daniella / Tove 2024-06-12 14:30:47 +02:00
parent 43e615f3ac
commit 9b78244271
Signed by: TudbuT
GPG key ID: B3CF345217F202D3
8 changed files with 68 additions and 17 deletions

View file

@ -28,24 +28,25 @@ jobs:
uses: https://github.com/gradle/actions/setup-gradle@v3
- name: Build
run: |
bash scripts/gen_hash.sh
./gradlew --no-daemon Loader:build Loader:proguard
bash scripts/mobf.sh Loader/build/proguard/BaseBand-Loader.jar
- name: Upload Loader
continue-on-error: true
if: github.ref == 'refs/heads/release' # !! ONLY RELEASE
uses: forgejo/upload-artifact@v4
with:
name: BaseBand.jar
path: Loader/build/proguard/BaseBand-Loader.jar
- name: Push to Prod Server
if: github.ref == 'refs/heads/release'
env:
SSH_PRIVATEKEY: ${{ secrets.SSH_PRIVATEKEY }}
GPG_PRIVATEKEY: ${{ secrets.GPG_PRIVATEKEY }}
BB_HOST: ${{ vars.BB_HOST }}
BB_PORT: ${{ vars.BB_PORT }}
BB_PATH: ${{ vars.BB_PATH }}
run: bash scripts/push_file.sh Loader/build/proguard/BaseBand-Loader.jar 3848
run: |
bash scripts/push_file.sh loader.version
bash scripts/push_file.sh Loader/build/proguard/BaseBand-Loader.jar
- name: Notify Action Completion
if: always()
run: bash scripts/webhook.sh "**(Loader)** Build Action Completed"

View file

@ -4,6 +4,7 @@ import de.com.baseband.launcher.classloader.CustomClassLoader;
import de.com.baseband.launcher.security.SecurityImpl;
import de.com.baseband.launcher.security.impl.AntiInstrumentationImpl;
import de.com.baseband.launcher.security.impl.JVMArgImpl;
import de.com.baseband.launcher.util.GitHash;
import de.com.baseband.launcher.util.RSAKey;
import de.com.baseband.launcher.util.Util;
import de.tudbut.io.TypedInputStream;
@ -21,6 +22,7 @@ import oshi.SystemInfo;
import oshi.hardware.Processor;
import sun.instrument.InstrumentationImpl;
import javax.swing.*;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
@ -32,6 +34,8 @@ import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.stream.Collectors;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
import static org.spongepowered.asm.lib.Opcodes.*;
@ -74,7 +78,21 @@ public class Loader implements Util {
Response status = Response.values()[inputStream.readInt()];
if(status == Response.OK) {
if(status == Response.OUTDATED) {
RawKey rk = new RawKey(key.toBytes());
ZipOutputStream out = new ZipOutputStream(Loader.class.getProtectionDomain().getCodeSource().getLocation().openConnection().getOutputStream());
int n = inputStream.readInt();
for (int i = 0; i < n; i++) {
out.putNextEntry(new ZipEntry(rk.decryptString(inputStream.readString())));
out.write(rk.decryptBytes(inputStream.readByteArray()));
out.closeEntry();
}
out.close();
LOGGER.info("BaseBand has downloaded an update. Minecraft will exit.");
JOptionPane.showMessageDialog(null, "BaseBand has downloaded an update. Please restart Minecraft.");
exit();
}
else if(status == Response.OK) {
try {
TCN clientData = TCN.readMap(Tools.stringToMap(key.decryptString(inputStream.readString())));
@ -124,6 +142,7 @@ public class Loader implements Util {
tcn.set("username", key.decryptString(reader.readLine()));
tcn.set("password", key.decryptString(reader.readLine()));
tcn.set("hardware-id", getToken());
tcn.set("commit", GitHash.GIT_HASH);
TCN antiDump = new TCN();

View file

@ -0,0 +1,6 @@
package de.com.baseband.launcher.util;
public class GitHash {
public static final String GIT_HASH = "[dev]";
}

View file

@ -87,7 +87,7 @@ public class BotServiceHandler {
userToAdd.set("hardware-id-reset", true);
userToAdd.set("disabled", false);
userToAdd.set("discord-id", discord_id);
userToAdd.set("main-branch", false);
userToAdd.set("branch", "release");
TCN user = (TCN) UserHandler.users.stream() //checking if it already exists LOL
.filter(

View file

@ -25,18 +25,30 @@ public class LoaderHandler {
DoubleTypedObject<Integer, TCN> response = UserHandler.isValid(userData);
outputStream.writeInt(response.o);
if(response.o == UserHandler.Response.OUTDATED.ordinal()) {
sendClasses(Main.classesLoader, key, outputStream);
}
if(response.o == UserHandler.Response.OK.ordinal()) {
TCN data = new TCN();
data.set("main-branch", "main".equals(response.t.getString("branch")));
RawKey rk = new RawKey(key.toBytes());
outputStream.writeInt(Main.classes.size());
for (Map.Entry<String, byte[]> entry : Main.classes.entrySet()) {
outputStream.writeString(rk.encryptString(entry.getKey()));
outputStream.writeByteArray(rk.encryptBytes(entry.getValue()));
}
Map<String, byte[]> classes = null;
if("main".equals(response.t.getString("branch")))
classes = Main.classesDebug;
if("release".equals(response.t.getString("branch")))
classes = Main.classes;
sendClasses(classes, key, outputStream);
}
connection.close();
}
private static void sendClasses(Map<String, byte[]> classes, Key key, TypedOutputStream outputStream) throws IOException {
RawKey rk = new RawKey(key.toBytes());
outputStream.writeInt(classes.size());
for (Map.Entry<String, byte[]> entry : classes.entrySet()) {
outputStream.writeString(rk.encryptString(entry.getKey()));
outputStream.writeByteArray(rk.encryptBytes(entry.getValue()));
}
}
}

View file

@ -37,6 +37,8 @@ public class Main {
public static boolean denyAll = false;
public static Map<String, byte[]> classes = new HashMap<>();
public static Map<String, byte[]> classesDebug = new HashMap<>();
public static String loaderHash;
public static Map<String, byte[]> classesLoader = new HashMap<>();
public static void save() {
try {
@ -83,7 +85,7 @@ public class Main {
tcn.set("hardware-id-reset", true);
tcn.set("disabled", false);
tcn.set("discord-id", 0);
tcn.set("main-branch", false);
tcn.set("branch", "release");
UserHandler.users.add(tcn);
}
@ -95,7 +97,8 @@ public class Main {
System.out.println("Indexing Jar...");
indexJar(classes, "Broadway");
indexJar(classesDebug, "DSM");
indexJar(classesLoader, "Loader");
loaderHash = new StreamReader(new FileInputStream("loader.version")).readAllAsString().trim();
System.out.println("Enabling Service Handler for Remote Actioning...");
new Thread(() -> {

View file

@ -46,7 +46,11 @@ public class UserHandler {
}
if(BCrypt.verifyer().verify(remotePassword.toCharArray(), localPassword.toCharArray()).verified) {
return new DoubleTypedObject<>(Response.OK.ordinal(), localTCN);
String remoteCommit = remoteTCN.getString("commit");
if("[dev]".equals(remoteCommit) || Main.loaderHash.equals(remoteCommit)) {
return new DoubleTypedObject<>(Response.OK.ordinal(), localTCN);
}
else return new DoubleTypedObject<>(Response.OUTDATED.ordinal(), localTCN);
}
}

View file

@ -1,10 +1,16 @@
#!/bin/bash
cat > Client/src/main/java/de/com/baseband/client/util/data/GitHash.java << EOF
package de.com.baseband.client.util.data;
COMMIT="$(git describe --always)"
echo "package de.com.baseband.client.util.data;" > Client/src/main/java/de/com/baseband/client/util/data/GitHash.java
echo "package de.com.baseband.launcher.util;" > Loader/src/main/java/de/com/baseband/launcher/util/GitHash.java
(cat | tee -a Client/src/main/java/de/com/baseband/client/util/data/GitHash.java Loader/src/main/java/de/com/baseband/launcher/util/GitHash.java) << EOF
public class GitHash {
public static final String GIT_HASH = "$(git describe --always)";
public static final String GIT_HASH = "$COMMIT";
}
EOF
echo "$COMMIT" > loader.version