mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-12-22 16:41:46 +03:00
Merge branch 'release/5.1.1'
This commit is contained in:
commit
79f12edee6
36 changed files with 463 additions and 83 deletions
|
@ -8,7 +8,7 @@
|
|||
url "https://oss.sonatype.org/content/repositories/snapshots"
|
||||
}
|
||||
maven {
|
||||
url "http://maven.geomajas.org/"
|
||||
url "https://maven.geomajas.org/"
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -24,7 +24,7 @@
|
|||
launch4j
|
||||
launch4jCJ
|
||||
bundleOnly.extendsFrom bundle
|
||||
compile.extendsFrom bundle, hikari, pack, launch4jCJ, launch4j
|
||||
api.extendsFrom bundle, hikari, pack, launch4jCJ, launch4j
|
||||
}
|
||||
|
||||
jar {
|
||||
|
@ -114,15 +114,17 @@ pack project(':LauncherAPI')
|
|||
compileOnlyA 'com.google.guava:guava:26.0-jre'
|
||||
compileOnlyA 'log4j:log4j:1.2.17' // Do not update (laggy dep).
|
||||
compileOnlyA 'org.apache.logging.log4j:log4j-core:2.11.2'
|
||||
testCompile 'org.junit.jupiter:junit-jupiter:5.4.1'
|
||||
testImplementation 'org.junit.jupiter:junit-jupiter:5.4.1'
|
||||
}
|
||||
|
||||
task hikari(type: Copy) {
|
||||
duplicatesStrategy = 'EXCLUDE'
|
||||
into "$buildDir/libs/libraries/hikaricp"
|
||||
from configurations.hikari
|
||||
}
|
||||
|
||||
task launch4jM(type: Copy) {
|
||||
duplicatesStrategy = 'EXCLUDE'
|
||||
into "$buildDir/libs/libraries/launch4j"
|
||||
from(configurations.launch4jCJ.collect { it.isDirectory() ? it : zipTree(it) })
|
||||
includeEmptyDirs false
|
||||
|
@ -139,6 +141,7 @@ task launch4jM(type: Copy) {
|
|||
}
|
||||
|
||||
task launch4jA(type: Copy) {
|
||||
duplicatesStrategy = 'EXCLUDE'
|
||||
into "$buildDir/libs/libraries/launch4j"
|
||||
from(configurations.launch4j)
|
||||
includeEmptyDirs false
|
||||
|
@ -151,20 +154,23 @@ task launch4jA(type: Copy) {
|
|||
}
|
||||
|
||||
task dumpLibs(type: Copy) {
|
||||
duplicatesStrategy = 'EXCLUDE'
|
||||
dependsOn tasks.hikari, tasks.launch4jM, tasks.launch4jA
|
||||
into "$buildDir/libs/libraries"
|
||||
from configurations.bundleOnly
|
||||
}
|
||||
|
||||
task dumpCompileOnlyLibs(type: Copy) {
|
||||
duplicatesStrategy = 'EXCLUDE'
|
||||
into "$buildDir/libs/launcher-libraries-compile"
|
||||
from configurations.compileOnlyA
|
||||
}
|
||||
|
||||
task bundle(type: Zip) {
|
||||
duplicatesStrategy = 'EXCLUDE'
|
||||
dependsOn parent.childProjects.Launcher.tasks.build, tasks.dumpLibs, tasks.dumpCompileOnlyLibs, tasks.jar
|
||||
archiveName 'LaunchServer.zip'
|
||||
destinationDir file("$buildDir")
|
||||
archiveFileName = 'LaunchServer.zip'
|
||||
destinationDirectory = file("$buildDir")
|
||||
from(tasks.dumpLibs.destinationDir) { into 'libraries' }
|
||||
from(tasks.dumpCompileOnlyLibs.destinationDir) { into 'launcher-libraries-compile' }
|
||||
from tasks.jar.archivePath
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
import pro.gravit.launchserver.manangers.LaunchServerGsonManager;
|
||||
import pro.gravit.launchserver.modules.impl.LaunchServerModulesManager;
|
||||
import pro.gravit.launchserver.socket.WebSocketService;
|
||||
import pro.gravit.utils.Version;
|
||||
import pro.gravit.utils.command.CommandHandler;
|
||||
import pro.gravit.utils.command.JLineCommandHandler;
|
||||
import pro.gravit.utils.command.StdCommandHandler;
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
import org.objectweb.asm.Type;
|
||||
import org.objectweb.asm.tree.*;
|
||||
import pro.gravit.utils.helper.IOHelper;
|
||||
import pro.gravit.utils.helper.JVMHelper;
|
||||
import pro.gravit.utils.helper.JarHelper;
|
||||
|
||||
import java.io.IOException;
|
||||
|
|
|
@ -63,7 +63,7 @@ public void invoke(String... args) throws Exception {
|
|||
public abstract void ban(List<HWID> hwid) throws HWIDException;
|
||||
|
||||
public void check(HWID hwid, String username) throws HWIDException {
|
||||
if (hwid.isNull()) return;
|
||||
if (hwid == null || hwid.isNull()) return;
|
||||
check0(hwid, username);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package pro.gravit.launchserver.binary;
|
||||
|
||||
import pro.gravit.launchserver.LaunchServer;
|
||||
import pro.gravit.launchserver.asm.NodeUtils;
|
||||
import pro.gravit.utils.helper.*;
|
||||
|
||||
import java.io.IOException;
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
import pro.gravit.launcher.NeedGarbageCollection;
|
||||
import pro.gravit.launchserver.socket.Client;
|
||||
import pro.gravit.launchserver.socket.response.auth.AuthResponse;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
|
@ -41,6 +40,11 @@ public Client getOrNewClient(long session) {
|
|||
return clientSet.computeIfAbsent(session, Client::new);
|
||||
}
|
||||
|
||||
public Client removeClient(long session)
|
||||
{
|
||||
return clientSet.remove(session);
|
||||
}
|
||||
|
||||
|
||||
public void updateClient(long session) {
|
||||
Client c = clientSet.get(session);
|
||||
|
|
|
@ -66,6 +66,11 @@ public WebSocketService(ChannelGroup channels, LaunchServer server) {
|
|||
public void process(ChannelHandlerContext ctx, TextWebSocketFrame frame, Client client, String ip) {
|
||||
String request = frame.text();
|
||||
WebSocketServerResponse response = gson.fromJson(request, WebSocketServerResponse.class);
|
||||
if(response == null)
|
||||
{
|
||||
RequestEvent event= new ErrorRequestEvent("This type of request is not supported");
|
||||
sendObject(ctx, event);
|
||||
}
|
||||
process(ctx, response, client, ip);
|
||||
}
|
||||
|
||||
|
@ -123,6 +128,7 @@ public static void registerResponses() {
|
|||
providers.register("getAvailabilityAuth", GetAvailabilityAuthResponse.class);
|
||||
providers.register("register", RegisterResponse.class);
|
||||
providers.register("setPassword", SetPasswordResponse.class);
|
||||
providers.register("exit", ExitResponse.class);
|
||||
}
|
||||
|
||||
public void sendObject(ChannelHandlerContext ctx, Object obj) {
|
||||
|
|
|
@ -0,0 +1,90 @@
|
|||
package pro.gravit.launchserver.socket.response.auth;
|
||||
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import pro.gravit.launcher.events.RequestEvent;
|
||||
import pro.gravit.launcher.events.request.ExitRequestEvent;
|
||||
import pro.gravit.launchserver.socket.Client;
|
||||
import pro.gravit.launchserver.socket.handlers.WebSocketFrameHandler;
|
||||
import pro.gravit.launchserver.socket.response.SimpleResponse;
|
||||
|
||||
public class ExitResponse extends SimpleResponse {
|
||||
public boolean exitAll;
|
||||
public String username;
|
||||
@Override
|
||||
public String getType() {
|
||||
return "exit";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(ChannelHandlerContext ctx, Client client) throws Exception {
|
||||
if(username != null && ( !client.isAuth || client.permissions == null || !client.permissions.canAdmin ))
|
||||
{
|
||||
sendError("Permissions denied");
|
||||
return;
|
||||
}
|
||||
if(username == null)
|
||||
{
|
||||
if(client.session == 0 && exitAll)
|
||||
{
|
||||
sendError("Session invalid");
|
||||
return;
|
||||
}
|
||||
WebSocketFrameHandler handler = ctx.pipeline().get(WebSocketFrameHandler.class);
|
||||
if(handler == null)
|
||||
{
|
||||
sendError("Exit internal error");
|
||||
return;
|
||||
}
|
||||
Client newClient = new Client(0);
|
||||
newClient.isSecure = client.isSecure;
|
||||
newClient.checkSign = client.checkSign;
|
||||
handler.setClient(newClient);
|
||||
if(client.session != 0) server.sessionManager.removeClient(client.session);
|
||||
if(exitAll)
|
||||
{
|
||||
service.channels.forEach((channel) -> {
|
||||
if(channel == null || channel.pipeline() == null) return;
|
||||
WebSocketFrameHandler wsHandler = channel.pipeline().get(WebSocketFrameHandler.class);
|
||||
if(wsHandler == null || wsHandler == handler) return;
|
||||
Client chClient = wsHandler.getClient();
|
||||
if(client.isAuth && client.username != null)
|
||||
{
|
||||
if(!chClient.isAuth || !client.username.equals(chClient.username)) return;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(chClient.session != client.session) return;
|
||||
}
|
||||
Client newCusClient = new Client(0);
|
||||
newCusClient.isSecure = chClient.isSecure;
|
||||
newCusClient.checkSign = chClient.checkSign;
|
||||
wsHandler.setClient(newCusClient);
|
||||
if(chClient.session != 0) server.sessionManager.removeClient(chClient.session);
|
||||
ExitRequestEvent event = new ExitRequestEvent(ExitRequestEvent.ExitReason.SERVER);
|
||||
event.requestUUID = RequestEvent.eventUUID;
|
||||
wsHandler.service.sendObject(channel, event);
|
||||
});
|
||||
}
|
||||
sendResult(new ExitRequestEvent(ExitRequestEvent.ExitReason.CLIENT));
|
||||
}
|
||||
else
|
||||
{
|
||||
service.channels.forEach((channel -> {
|
||||
if(channel == null || channel.pipeline() == null) return;
|
||||
WebSocketFrameHandler wsHandler = channel.pipeline().get(WebSocketFrameHandler.class);
|
||||
if(wsHandler == null) return;
|
||||
Client chClient = wsHandler.getClient();
|
||||
if(!chClient.isAuth || !username.equals(chClient.username)) return;
|
||||
Client newCusClient = new Client(0);
|
||||
newCusClient.isSecure = chClient.isSecure;
|
||||
newCusClient.checkSign = chClient.checkSign;
|
||||
wsHandler.setClient(newCusClient);
|
||||
if(chClient.session != 0) server.sessionManager.removeClient(chClient.session);
|
||||
ExitRequestEvent event = new ExitRequestEvent(ExitRequestEvent.ExitReason.SERVER);
|
||||
event.requestUUID = RequestEvent.eventUUID;
|
||||
wsHandler.service.sendObject(channel, event);
|
||||
}));
|
||||
sendResult(new ExitRequestEvent(ExitRequestEvent.ExitReason.NO_EXIT));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,6 +1,4 @@
|
|||
plugins {
|
||||
id 'org.openjfx.javafxplugin' version '0.0.5'
|
||||
}
|
||||
apply plugin: 'org.openjfx.javafxplugin'
|
||||
apply plugin: 'com.github.johnrengelman.shadow'
|
||||
|
||||
String mainClassName = "pro.gravit.launcher.ClientLauncherWrapper"
|
||||
|
@ -8,7 +6,7 @@
|
|||
|
||||
repositories {
|
||||
maven {
|
||||
url "http://repo.spring.io/plugins-release/"
|
||||
url "https://repo.spring.io/plugins-release/"
|
||||
}
|
||||
}
|
||||
javafx {
|
||||
|
@ -21,7 +19,7 @@
|
|||
configurations {
|
||||
bundle
|
||||
pack
|
||||
compile.extendsFrom bundle, pack
|
||||
api.extendsFrom bundle, pack
|
||||
}
|
||||
|
||||
jar {
|
||||
|
@ -45,6 +43,7 @@ task javadocJar(type: Jar) {
|
|||
}
|
||||
|
||||
shadowJar {
|
||||
duplicatesStrategy = 'EXCLUDE'
|
||||
classifier = null
|
||||
relocate 'org.objectweb.asm', 'pro.gravit.repackage.org.objectweb.asm'
|
||||
relocate 'io.netty', 'pro.gravit.repackage.io.netty'
|
||||
|
@ -60,12 +59,14 @@ pack project(':LauncherAPI')
|
|||
}
|
||||
|
||||
task genRuntimeJS(type: Zip) {
|
||||
archiveName = "runtime.zip"
|
||||
destinationDir = file("${buildDir}/tmp")
|
||||
duplicatesStrategy = 'EXCLUDE'
|
||||
archiveFileName = "runtime.zip"
|
||||
destinationDirectory = file("${buildDir}/tmp")
|
||||
from "runtime/"
|
||||
}
|
||||
|
||||
task dumpLibs(type: Copy) {
|
||||
duplicatesStrategy = 'EXCLUDE'
|
||||
into "$buildDir/libs/libraries"
|
||||
from configurations.bundle
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package pro.gravit.launcher;
|
||||
|
||||
import pro.gravit.launcher.api.SystemService;
|
||||
import pro.gravit.launcher.client.*;
|
||||
import pro.gravit.launcher.client.events.ClientEngineInitPhase;
|
||||
import pro.gravit.launcher.client.events.ClientExitPhase;
|
||||
|
@ -61,11 +60,10 @@ public static void exitLauncher(int code)
|
|||
modulesManager.invokeEvent(new ClientExitPhase(code));
|
||||
try {
|
||||
System.exit(code);
|
||||
} catch (Exception e) //Forge Security Manager?
|
||||
} catch (Throwable e) //Forge Security Manager?
|
||||
{
|
||||
NativeJVMHalt.haltA(code);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void main(String... args) throws Throwable {
|
||||
|
@ -99,7 +97,7 @@ public static void main(String... args) throws Throwable {
|
|||
LogHelper.debug("Launcher started in %dms", endTime - startTime);
|
||||
//Request.service.close();
|
||||
//FunctionalBridge.close();
|
||||
SystemService.exit(0);
|
||||
LauncherEngine.exitLauncher(0);
|
||||
}
|
||||
|
||||
public static void initGson(ClientModuleManager modulesManager) {
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
import pro.gravit.launcher.*;
|
||||
import pro.gravit.launcher.api.AuthService;
|
||||
import pro.gravit.launcher.api.ClientService;
|
||||
import pro.gravit.launcher.api.SystemService;
|
||||
import pro.gravit.launcher.client.events.ClientLaunchPhase;
|
||||
import pro.gravit.launcher.client.events.ClientLauncherInitPhase;
|
||||
import pro.gravit.launcher.client.events.ClientLauncherPostInitPhase;
|
||||
|
@ -13,6 +14,7 @@
|
|||
import pro.gravit.launcher.managers.ClientGsonManager;
|
||||
import pro.gravit.launcher.managers.ClientHookManager;
|
||||
import pro.gravit.launcher.modules.events.PreConfigPhase;
|
||||
import pro.gravit.launcher.patches.FMLPatcher;
|
||||
import pro.gravit.launcher.profiles.ClientProfile;
|
||||
import pro.gravit.launcher.profiles.PlayerProfile;
|
||||
import pro.gravit.launcher.request.Request;
|
||||
|
@ -32,10 +34,7 @@
|
|||
import java.lang.invoke.MethodHandle;
|
||||
import java.lang.invoke.MethodHandles;
|
||||
import java.lang.invoke.MethodType;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.ServerSocket;
|
||||
import java.net.Socket;
|
||||
import java.net.URL;
|
||||
import java.net.*;
|
||||
import java.nio.file.FileVisitResult;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.SimpleFileVisitor;
|
||||
|
@ -293,14 +292,19 @@ private static void launch(ClientProfile profile, Params params) throws Throwabl
|
|||
{
|
||||
LogHelper.info("ClassLoader URL: %s", u.toString());
|
||||
}
|
||||
FMLPatcher.apply();
|
||||
MethodHandle mainMethod = MethodHandles.publicLookup().findStatic(mainClass, "main", MethodType.methodType(void.class, String[].class)).asFixedArity();
|
||||
Launcher.LAUNCHED.set(true);
|
||||
JVMHelper.fullGC();
|
||||
// Invoke main method
|
||||
try {
|
||||
mainMethod.invokeWithArguments((Object) args.toArray(new String[0]));
|
||||
LogHelper.debug("Main exit successful");
|
||||
} catch (Throwable e) {
|
||||
LogHelper.error(e);
|
||||
throw e;
|
||||
} finally {
|
||||
Request.service.close();
|
||||
LauncherEngine.exitLauncher(0);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
import java.lang.invoke.MethodHandles;
|
||||
import java.lang.invoke.MethodType;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.Locale;
|
||||
import java.util.Random;
|
||||
import java.util.Vector;
|
||||
|
||||
|
@ -87,7 +88,8 @@ private static byte[] gen(final String name, final String exName) { // "cpw/mods
|
|||
}
|
||||
|
||||
public static String randomStr(final int lenght) {
|
||||
final String alphabet = "abcdefghijklmnopqrstuvwxyz";
|
||||
String alphabet = "abcdefghijklmnopqrstuvwxyz";
|
||||
alphabet += alphabet.toUpperCase(Locale.US);
|
||||
final StringBuilder sb = new StringBuilder(lenght);
|
||||
final Random random = SecurityHelper.newRandom();
|
||||
for (int i = 0; i < lenght; i++)
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
import pro.gravit.launcher.patches.FMLPatcher;
|
||||
import pro.gravit.utils.helper.JVMHelper;
|
||||
import pro.gravit.utils.helper.LogHelper;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.event.WindowEvent;
|
||||
|
@ -22,23 +23,30 @@ private boolean aaabBooleanC_D() {
|
|||
}
|
||||
|
||||
public static void haltA(int code) {
|
||||
Throwable[] th = new Throwable[3];
|
||||
NativeJVMHalt halt = new NativeJVMHalt(code);
|
||||
try {
|
||||
JVMHelper.RUNTIME.exit(code);
|
||||
} catch (Throwable ignored) {
|
||||
} catch (Throwable exitExc) {
|
||||
th[0] = exitExc;
|
||||
try {
|
||||
new WindowShutdown();
|
||||
} catch (Throwable ignored1) {
|
||||
} catch (Throwable windowExc) {
|
||||
th[1] = windowExc;
|
||||
}
|
||||
}
|
||||
try {
|
||||
FMLPatcher.exit(code);
|
||||
} catch (Throwable ignored) {
|
||||
} catch (Throwable fmlExc) {
|
||||
th[2] = fmlExc;
|
||||
}
|
||||
for(Throwable t : th)
|
||||
{
|
||||
if(t != null) LogHelper.error(t);
|
||||
}
|
||||
|
||||
halt.aaabbb38C_D();
|
||||
boolean a = halt.aaabBooleanC_D();
|
||||
System.out.println(a);
|
||||
halt.aaabbb38C_D();
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
targetCompatibility = '1.8'
|
||||
|
||||
dependencies {
|
||||
compile project(':LauncherCore')
|
||||
api project(':LauncherCore')
|
||||
compileOnly 'io.netty:netty-codec-http:4.1.43.Final'
|
||||
testCompile 'org.junit.jupiter:junit-jupiter:5.4.1'
|
||||
testImplementation 'org.junit.jupiter:junit-jupiter:5.4.1'
|
||||
}
|
||||
|
||||
test {
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
package pro.gravit.launcher.events.request;
|
||||
|
||||
import pro.gravit.launcher.events.RequestEvent;
|
||||
|
||||
public class ExitRequestEvent extends RequestEvent {
|
||||
public enum ExitReason
|
||||
{
|
||||
SERVER, CLIENT, TIMEOUT, NO_EXIT
|
||||
}
|
||||
public final ExitReason reason;
|
||||
|
||||
public ExitRequestEvent(ExitReason reason) {
|
||||
this.reason = reason;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType() {
|
||||
return "exit";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
package pro.gravit.launcher.request.auth;
|
||||
|
||||
import pro.gravit.launcher.events.request.ExitRequestEvent;
|
||||
import pro.gravit.launcher.request.Request;
|
||||
|
||||
public class ExitRequest extends Request<ExitRequestEvent> {
|
||||
public final boolean exitAll;
|
||||
public final String username;
|
||||
|
||||
public ExitRequest() {
|
||||
this.exitAll = false;
|
||||
this.username = null;
|
||||
}
|
||||
|
||||
public ExitRequest(boolean exitAll) {
|
||||
this.exitAll = exitAll;
|
||||
this.username = null;
|
||||
}
|
||||
|
||||
public ExitRequest(boolean exitAll, String username) {
|
||||
this.exitAll = exitAll;
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType() {
|
||||
return "exit";
|
||||
}
|
||||
}
|
|
@ -107,6 +107,7 @@ public void registerResults() {
|
|||
results.register("setpassword", SetPasswordRequestEvent.class);
|
||||
results.register("notification", NotificationEvent.class);
|
||||
results.register("signal", SignalEvent.class);
|
||||
results.register("exit", ExitRequestEvent.class);
|
||||
}
|
||||
|
||||
public void waitIfNotConnected() {
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
targetCompatibility = '1.8'
|
||||
|
||||
dependencies {
|
||||
compile project(':LauncherAPI')
|
||||
api project(':LauncherAPI')
|
||||
compileOnly 'com.google.guava:guava:26.0-jre'
|
||||
compile files('../compat/authlib/authlib-clean.jar')
|
||||
api files('../compat/authlib/authlib-clean.jar')
|
||||
}
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
apply plugin: 'java-library'
|
||||
sourceCompatibility = '1.8'
|
||||
targetCompatibility = '1.8'
|
||||
|
||||
|
@ -8,8 +7,8 @@
|
|||
compileOnly 'org.jline:jline-reader:3.11.0'
|
||||
compileOnly 'org.jline:jline-terminal:3.11.0'
|
||||
compileOnly 'org.bouncycastle:bcprov-jdk15:1.46'
|
||||
compile 'com.google.code.gson:gson:2.8.5'
|
||||
testCompile 'org.junit.jupiter:junit-jupiter:5.4.1'
|
||||
api 'com.google.code.gson:gson:2.8.5'
|
||||
testImplementation 'org.junit.jupiter:junit-jupiter:5.4.1'
|
||||
}
|
||||
|
||||
test {
|
||||
|
|
|
@ -15,24 +15,41 @@ public class UniversalJsonAdapter<R> implements JsonSerializer<R>, JsonDeseriali
|
|||
public final ProviderMap<R> providerMap;
|
||||
public final String name;
|
||||
public final String PROP_NAME;
|
||||
public final boolean printErrorIfUnknownType;
|
||||
|
||||
public UniversalJsonAdapter(ProviderMap<R> providerMap) {
|
||||
this.providerMap = providerMap;
|
||||
this.name = providerMap.getName();
|
||||
this.PROP_NAME = "type";
|
||||
printErrorIfUnknownType = true;
|
||||
}
|
||||
|
||||
public UniversalJsonAdapter(ProviderMap<R> providerMap, String PROP_NAME) {
|
||||
this.providerMap = providerMap;
|
||||
this.name = providerMap.getName();
|
||||
this.PROP_NAME = PROP_NAME;
|
||||
printErrorIfUnknownType = true;
|
||||
}
|
||||
|
||||
public UniversalJsonAdapter(ProviderMap<R> providerMap, String name, String PROP_NAME, boolean printErrorIfUnknownType) {
|
||||
this.providerMap = providerMap;
|
||||
this.name = name;
|
||||
this.PROP_NAME = PROP_NAME;
|
||||
this.printErrorIfUnknownType = printErrorIfUnknownType;
|
||||
}
|
||||
|
||||
public UniversalJsonAdapter(ProviderMap<R> providerMap, String name, boolean printErrorIfUnknownType) {
|
||||
this.providerMap = providerMap;
|
||||
this.name = name;
|
||||
this.PROP_NAME = "type";
|
||||
this.printErrorIfUnknownType = printErrorIfUnknownType;
|
||||
}
|
||||
|
||||
public R deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
|
||||
String typename = json.getAsJsonObject().getAsJsonPrimitive(PROP_NAME).getAsString();
|
||||
Class<? extends R> cls = providerMap.getClass(typename);
|
||||
if (cls == null) {
|
||||
LogHelper.error("%s %s not found", name, typename);
|
||||
if(printErrorIfUnknownType) LogHelper.error("%s %s not found", name, typename);
|
||||
return null;
|
||||
}
|
||||
return context.deserialize(json, cls);
|
||||
|
@ -48,9 +65,9 @@ public JsonElement serialize(R src, Type typeOfSrc, JsonSerializationContext con
|
|||
}
|
||||
if(classPath == null)
|
||||
{
|
||||
LogHelper.warning("Class %s type null", src.getClass());
|
||||
if(printErrorIfUnknownType) LogHelper.warning("Class %s type null", src.getClass());
|
||||
}
|
||||
jo.add(PROP_NAME, new JsonPrimitive(classPath));
|
||||
else jo.add(PROP_NAME, new JsonPrimitive(classPath));
|
||||
|
||||
return jo;
|
||||
}
|
||||
|
|
|
@ -15,8 +15,8 @@ public final class Version {
|
|||
public final Type release;
|
||||
public static final int MAJOR = 5;
|
||||
public static final int MINOR = 1;
|
||||
public static final int PATCH = 0;
|
||||
public static final int BUILD = 1;
|
||||
public static final int PATCH = 1;
|
||||
public static final int BUILD = 2;
|
||||
public static final Version.Type RELEASE = Type.BETA;
|
||||
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package pro.gravit.utils.helper;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.file.Path;
|
||||
|
@ -100,6 +101,21 @@ public static InputStream getClassBytesStream(Class<?> clazz, ClassLoader classL
|
|||
{
|
||||
return classLoader.getResourceAsStream(getClassFile(clazz));
|
||||
}
|
||||
|
||||
|
||||
public static byte[] getClassFromJar(String name, Path file) throws IOException
|
||||
{
|
||||
String filename = getClassFile(name);
|
||||
try(ZipInputStream inputStream = IOHelper.newZipInput(file))
|
||||
{
|
||||
ZipEntry entry = inputStream.getNextEntry();
|
||||
while(entry != null)
|
||||
{
|
||||
if(entry.getName().equals(filename))
|
||||
{
|
||||
return IOHelper.read(inputStream);
|
||||
}
|
||||
entry = inputStream.getNextEntry();
|
||||
}
|
||||
}
|
||||
throw new FileNotFoundException(filename);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,12 +5,12 @@
|
|||
|
||||
configurations {
|
||||
pack
|
||||
compile.extendsFrom pack
|
||||
api.extendsFrom pack
|
||||
}
|
||||
|
||||
repositories {
|
||||
maven {
|
||||
url "http://repo.spring.io/plugins-release/"
|
||||
url "https://repo.spring.io/plugins-release/"
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -42,6 +42,7 @@ pack project(':LauncherAuthlib')
|
|||
}
|
||||
|
||||
shadowJar {
|
||||
duplicatesStrategy = 'EXCLUDE'
|
||||
classifier = null
|
||||
relocate 'io.netty', 'pro.gravit.repackage.io.netty'
|
||||
configurations = [project.configurations.pack]
|
||||
|
|
28
build.gradle
28
build.gradle
|
@ -1,39 +1,43 @@
|
|||
plugins {
|
||||
id 'com.github.johnrengelman.shadow' version '5.0.0' apply false
|
||||
id 'com.github.johnrengelman.shadow' version '5.2.0' apply false
|
||||
id 'maven-publish'
|
||||
id 'signing'
|
||||
id 'org.openjfx.javafxplugin' version '0.0.7' apply false
|
||||
}
|
||||
group = 'pro.gravit.launcher'
|
||||
version = '5.1.0'
|
||||
version = '5.1.1'
|
||||
|
||||
configure(subprojects.findAll { it.name != 'modules' }) {
|
||||
apply plugin: 'idea'
|
||||
apply plugin: 'eclipse'
|
||||
apply plugin: 'java'
|
||||
apply plugin: 'java-library'
|
||||
|
||||
|
||||
group = 'pro.gravit'
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven { url 'http://oss.sonatype.org/content/groups/public' }
|
||||
maven { url 'https://oss.sonatype.org/content/groups/public' }
|
||||
maven {
|
||||
url "http://clojars.org/repo/"
|
||||
url "https://clojars.org/repo/"
|
||||
}
|
||||
}
|
||||
|
||||
configurations {
|
||||
apt
|
||||
aptCompileOnly
|
||||
aptOnly
|
||||
aptOnly.extendsFrom apt, aptCompileOnly
|
||||
compile.extendsFrom apt
|
||||
compileOnly.extendsFrom aptCompileOnly
|
||||
jar {
|
||||
duplicatesStrategy = 'EXCLUDE'
|
||||
}
|
||||
|
||||
eclipse {
|
||||
classpath {
|
||||
downloadSources = true
|
||||
downloadJavadoc = true
|
||||
}
|
||||
}
|
||||
|
||||
tasks.withType(JavaCompile) {
|
||||
options.encoding = "UTF-8"
|
||||
options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation"
|
||||
options.annotationProcessorPath = configurations.aptOnly
|
||||
options.incremental = true // one flag, and things will get MUCH faster
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class LauncherAuthController extends Controller
|
||||
{
|
||||
public function json(Request $request) {
|
||||
$data = json_decode($request->getContent());
|
||||
|
||||
if ($data->apiKey !== env('LAUNCHER_APIKEY')) {
|
||||
return response()->json([
|
||||
'error' => 'Неверный ключ. Обратитесь к администратору',
|
||||
]);
|
||||
}
|
||||
|
||||
if (Auth::attempt(['name' => $data->username, 'password' => $data->password])) {
|
||||
$perm = DB::table('users')
|
||||
->select('launcher_permission')
|
||||
->where('name', '=', $data->username)
|
||||
->first();
|
||||
|
||||
return response()->json([
|
||||
'username' => $data->username,
|
||||
'permission' => $perm->launcher_permission,
|
||||
]);
|
||||
} else {
|
||||
return response()->json([
|
||||
'error' => 'Неверный логин или пароль',
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
9
compat/auth/laravel/authcontroller/README.MD
Normal file
9
compat/auth/laravel/authcontroller/README.MD
Normal file
|
@ -0,0 +1,9 @@
|
|||
#Контроллер авторизации методом json
|
||||
|
||||
Route:
|
||||
```php
|
||||
Route::put('launcher/auth', 'LauncherAuthController@json');
|
||||
```
|
||||
|
||||
Добавить в **.env** строку `LAUNCHER_APIKEY=none`
|
||||
Где `none` ваш apiKey
|
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class AddPermissionCollum extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->integer('launcher_permission')->default('0');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->dropColumn('launcher_permission');
|
||||
});
|
||||
}
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateHwidTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('users_hwids', function (Blueprint $table) {
|
||||
$table->bigIncrements('id');
|
||||
$table->tinyInteger('isBanned')->default('0');
|
||||
$table->text('totalMemory');
|
||||
$table->text('serialNumber');
|
||||
$table->text('HWDiskSerial');
|
||||
$table->text('processorID');
|
||||
$table->text('macAddr');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('users_hwids');
|
||||
}
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class AddAuthHandlerCollums extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->char('uuid', '36')->unique()->nullable();
|
||||
$table->char('accessToken', '32')->nullable();
|
||||
$table->string('serverID', '41')->nullable();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->dropColumn('uuid');
|
||||
$table->dropColumn('accessToken');
|
||||
$table->dropColumn('serverID');
|
||||
});
|
||||
}
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class AddHwidHandlerCollums extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->bigInteger('hwid')->nullable();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->dropColumn('hwid');
|
||||
});
|
||||
}
|
||||
}
|
1
compat/auth/laravel/migrations/README.MD
Normal file
1
compat/auth/laravel/migrations/README.MD
Normal file
|
@ -0,0 +1 @@
|
|||
# Миграции для Laravel
|
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
|
@ -1,5 +1,5 @@
|
|||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
|
35
gradlew
vendored
35
gradlew
vendored
|
@ -7,7 +7,7 @@
|
|||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
# https://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
|
@ -125,8 +125,8 @@ if $darwin; then
|
|||
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
||||
fi
|
||||
|
||||
# For Cygwin, switch paths to Windows format before running java
|
||||
if $cygwin ; then
|
||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
|
||||
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||
JAVACMD=`cygpath --unix "$JAVACMD"`
|
||||
|
@ -154,19 +154,19 @@ if $cygwin ; then
|
|||
else
|
||||
eval `echo args$i`="\"$arg\""
|
||||
fi
|
||||
i=$((i+1))
|
||||
i=`expr $i + 1`
|
||||
done
|
||||
case $i in
|
||||
(0) set -- ;;
|
||||
(1) set -- "$args0" ;;
|
||||
(2) set -- "$args0" "$args1" ;;
|
||||
(3) set -- "$args0" "$args1" "$args2" ;;
|
||||
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
||||
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
||||
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
||||
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
||||
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
||||
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
||||
0) set -- ;;
|
||||
1) set -- "$args0" ;;
|
||||
2) set -- "$args0" "$args1" ;;
|
||||
3) set -- "$args0" "$args1" "$args2" ;;
|
||||
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
||||
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
||||
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
||||
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
||||
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
||||
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
|
@ -175,14 +175,9 @@ save () {
|
|||
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
||||
echo " "
|
||||
}
|
||||
APP_ARGS=$(save "$@")
|
||||
APP_ARGS=`save "$@"`
|
||||
|
||||
# Collect all arguments for the java command, following the shell quoting and substitution rules
|
||||
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
|
||||
|
||||
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
|
||||
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
|
||||
cd "$(dirname "$0")"
|
||||
fi
|
||||
|
||||
exec "$JAVACMD" "$@"
|
||||
|
|
2
gradlew.bat
vendored
2
gradlew.bat
vendored
|
@ -5,7 +5,7 @@
|
|||
@rem you may not use this file except in compliance with the License.
|
||||
@rem You may obtain a copy of the License at
|
||||
@rem
|
||||
@rem http://www.apache.org/licenses/LICENSE-2.0
|
||||
@rem https://www.apache.org/licenses/LICENSE-2.0
|
||||
@rem
|
||||
@rem Unless required by applicable law or agreed to in writing, software
|
||||
@rem distributed under the License is distributed on an "AS IS" BASIS,
|
||||
|
|
2
modules
2
modules
|
@ -1 +1 @@
|
|||
Subproject commit 0fbc3fb26c505800a61976cdf1310cad6ab7808d
|
||||
Subproject commit 2edb2c7259d5a7dba3fa82c503f88a8a0e171840
|
Loading…
Reference in a new issue