mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-12-22 16:41:46 +03:00
[FEATURE] Возможность отдавать нулевой HWID, а следовательно не использовать библиотеку OSHI если HWID не требуется
This commit is contained in:
parent
c85350821e
commit
486fae8ccf
29 changed files with 82 additions and 27 deletions
|
@ -37,6 +37,7 @@
|
|||
import pro.gravit.launcher.LauncherConfig;
|
||||
import pro.gravit.launcher.NeedGarbageCollection;
|
||||
import pro.gravit.launcher.hasher.HashedDir;
|
||||
import pro.gravit.launcher.hwid.HWIDProvider;
|
||||
import pro.gravit.launcher.managers.ConfigManager;
|
||||
import pro.gravit.launcher.managers.GarbageManager;
|
||||
import pro.gravit.launcher.profiles.ClientProfile;
|
||||
|
@ -495,6 +496,7 @@ public LaunchServer(Path dir, boolean testEnv, String[] args) throws IOException
|
|||
Component.registerComponents();
|
||||
ProtectHandler.registerHandlers();
|
||||
WebSocketService.registerResponses();
|
||||
HWIDProvider.registerHWIDs();
|
||||
//LaunchServer.server = this;
|
||||
|
||||
// Set command handler
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import pro.gravit.launcher.HWID;
|
||||
import pro.gravit.launcher.hwid.HWID;
|
||||
|
||||
public class AcceptHWIDHandler extends HWIDHandler {
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import pro.gravit.launcher.HWID;
|
||||
import pro.gravit.launcher.hwid.HWID;
|
||||
import pro.gravit.utils.ProviderMap;
|
||||
|
||||
public abstract class HWIDHandler implements AutoCloseable {
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
|
||||
import pro.gravit.launcher.HWID;
|
||||
import pro.gravit.launcher.hwid.HWID;
|
||||
import pro.gravit.launcher.Launcher;
|
||||
import pro.gravit.utils.helper.IOHelper;
|
||||
import pro.gravit.utils.helper.LogHelper;
|
||||
|
|
|
@ -9,8 +9,8 @@
|
|||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonElement;
|
||||
|
||||
import pro.gravit.launcher.HWID;
|
||||
import pro.gravit.launcher.OshiHWID;
|
||||
import pro.gravit.launcher.hwid.HWID;
|
||||
import pro.gravit.launcher.hwid.OshiHWID;
|
||||
import pro.gravit.utils.HTTPRequest;
|
||||
import pro.gravit.utils.helper.LogHelper;
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import pro.gravit.launcher.HWID;
|
||||
import pro.gravit.launcher.hwid.HWID;
|
||||
|
||||
public class MemoryHWIDHandler extends HWIDHandler {
|
||||
public class Entry {
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import pro.gravit.launcher.HWID;
|
||||
import pro.gravit.launcher.OshiHWID;
|
||||
import pro.gravit.launcher.hwid.HWID;
|
||||
import pro.gravit.launcher.hwid.OshiHWID;
|
||||
import pro.gravit.launchserver.auth.MySQLSourceConfig;
|
||||
import pro.gravit.utils.helper.CommonHelper;
|
||||
import pro.gravit.utils.helper.LogHelper;
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import pro.gravit.launcher.HWID;
|
||||
import pro.gravit.launcher.hwid.HWID;
|
||||
import pro.gravit.launchserver.LaunchServer;
|
||||
import pro.gravit.launchserver.command.Command;
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import pro.gravit.launcher.HWID;
|
||||
import pro.gravit.launcher.hwid.HWID;
|
||||
import pro.gravit.launchserver.LaunchServer;
|
||||
import pro.gravit.launchserver.command.Command;
|
||||
import pro.gravit.utils.helper.LogHelper;
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import pro.gravit.launcher.HWID;
|
||||
import pro.gravit.launcher.hwid.HWID;
|
||||
import pro.gravit.launchserver.LaunchServer;
|
||||
import pro.gravit.launchserver.command.Command;
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package pro.gravit.launchserver.dao;
|
||||
|
||||
import pro.gravit.launcher.OshiHWID;
|
||||
import pro.gravit.launcher.hwid.OshiHWID;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package pro.gravit.launchserver.dao;
|
||||
|
||||
import pro.gravit.launcher.HWID;
|
||||
import pro.gravit.launcher.OshiHWID;
|
||||
import pro.gravit.launcher.hwid.HWID;
|
||||
import pro.gravit.launcher.hwid.OshiHWID;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.util.function.Supplier;
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import pro.gravit.launcher.OshiHWID;
|
||||
import pro.gravit.launcher.hwid.OshiHWID;
|
||||
import pro.gravit.launchserver.LaunchServer;
|
||||
import pro.gravit.launchserver.dao.User;
|
||||
import pro.gravit.launchserver.dao.UserDAO;
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
import org.hibernate.SessionFactory;
|
||||
import org.hibernate.Transaction;
|
||||
|
||||
import pro.gravit.launcher.OshiHWID;
|
||||
import pro.gravit.launcher.hwid.OshiHWID;
|
||||
import pro.gravit.launchserver.dao.User;
|
||||
import pro.gravit.launchserver.dao.UserDAO;
|
||||
import pro.gravit.launchserver.dao.UserHWID;
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
|
||||
import pro.gravit.launcher.hasher.HashedEntry;
|
||||
import pro.gravit.launcher.hasher.HashedEntryAdapter;
|
||||
import pro.gravit.launcher.hwid.HWID;
|
||||
import pro.gravit.launcher.hwid.HWIDProvider;
|
||||
import pro.gravit.launcher.managers.GsonManager;
|
||||
import pro.gravit.launcher.request.JsonResultSerializeAdapter;
|
||||
import pro.gravit.launcher.request.WebSocketEvent;
|
||||
|
@ -31,6 +33,7 @@ public void registerAdapters(GsonBuilder builder) {
|
|||
builder.registerTypeAdapter(Component.class, new UniversalJsonAdapter<>(Component.providers));
|
||||
builder.registerTypeAdapter(ProtectHandler.class, new UniversalJsonAdapter<>(ProtectHandler.providers));
|
||||
builder.registerTypeAdapter(DaoProvider.class, new UniversalJsonAdapter<>(DaoProvider.providers));
|
||||
builder.registerTypeAdapter(HWID.class, new UniversalJsonAdapter<>(HWIDProvider.hwids));
|
||||
builder.registerTypeAdapter(WebSocketServerResponse.class, new UniversalJsonAdapter<>(WebSocketService.providers));
|
||||
builder.registerTypeAdapter(HashedEntry.class, new HashedEntryAdapter());
|
||||
builder.registerTypeAdapter(WebSocketEvent.class, new JsonResultSerializeAdapter());
|
||||
|
|
|
@ -9,7 +9,8 @@
|
|||
import javax.crypto.IllegalBlockSizeException;
|
||||
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import pro.gravit.launcher.OshiHWID;
|
||||
import pro.gravit.launcher.hwid.HWID;
|
||||
import pro.gravit.launcher.hwid.OshiHWID;
|
||||
import pro.gravit.launcher.events.request.AuthRequestEvent;
|
||||
import pro.gravit.launcher.profiles.ClientProfile;
|
||||
import pro.gravit.launchserver.auth.AuthException;
|
||||
|
@ -46,7 +47,7 @@ public AuthResponse(String login, String password, String auth_id, OshiHWID hwid
|
|||
public String auth_id;
|
||||
public boolean initProxy;
|
||||
public ConnectTypes authType;
|
||||
public OshiHWID hwid;
|
||||
public HWID hwid;
|
||||
|
||||
public enum ConnectTypes {
|
||||
SERVER, CLIENT, BOT
|
||||
|
@ -76,7 +77,7 @@ public void execute(ChannelHandlerContext ctx, Client clientData) throws Excepti
|
|||
AuthProviderPair pair;
|
||||
if (auth_id.isEmpty()) pair = server.config.getAuthProviderPair();
|
||||
else pair = server.config.getAuthProviderPair(auth_id);
|
||||
AuthContext context = new AuthContext(0, login, password.length(), customText, client, ip, null, authType);
|
||||
AuthContext context = new AuthContext(0, login, password.length(), customText, client, null, ip, authType);
|
||||
AuthProvider provider = pair.provider;
|
||||
server.authHookManager.preHook.hook(context, clientData);
|
||||
provider.preAuth(login, password, customText, ip);
|
||||
|
|
|
@ -59,6 +59,9 @@ var VerifyHelper = VerifyHelperClass.static;
|
|||
var NewLauncherSettings = NewLauncherSettingsClass.static;
|
||||
var SettingsManager = SettingsManagerClass.static;
|
||||
|
||||
var NoHWID = NoHWIDClass.static;
|
||||
var OshiHWID = OshiHWID.static;
|
||||
|
||||
// Helper JS class API imports
|
||||
var JSApplication = null;
|
||||
if (typeof JSApplicationClass !== 'undefined') {
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
import pro.gravit.launcher.guard.LauncherGuardManager;
|
||||
import pro.gravit.launcher.gui.JSRuntimeProvider;
|
||||
import pro.gravit.launcher.gui.RuntimeProvider;
|
||||
import pro.gravit.launcher.hwid.HWIDProvider;
|
||||
import pro.gravit.launcher.managers.ClientGsonManager;
|
||||
import pro.gravit.launcher.managers.ConsoleManager;
|
||||
import pro.gravit.launcher.request.Request;
|
||||
|
@ -34,6 +35,7 @@ public static void main(String... args) throws Throwable {
|
|||
// Start Launcher
|
||||
initGson();
|
||||
ConsoleManager.initConsole();
|
||||
HWIDProvider.registerHWIDs();
|
||||
LauncherConfig config = Launcher.getConfig();
|
||||
if (config.environment.equals(LauncherConfig.LauncherEnvironment.PROD)) {
|
||||
if (!LauncherAgent.isStarted()) throw new SecurityException("LauncherAgent must started");
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
import pro.gravit.launcher.gui.JSRuntimeProvider;
|
||||
import pro.gravit.launcher.hasher.FileNameMatcher;
|
||||
import pro.gravit.launcher.hasher.HashedDir;
|
||||
import pro.gravit.launcher.hwid.HWIDProvider;
|
||||
import pro.gravit.launcher.managers.ClientGsonManager;
|
||||
import pro.gravit.launcher.profiles.ClientProfile;
|
||||
import pro.gravit.launcher.profiles.PlayerProfile;
|
||||
|
@ -427,6 +428,7 @@ public static void main(String... args) throws Throwable {
|
|||
if (engine.runtimeProvider == null) engine.runtimeProvider = new JSRuntimeProvider();
|
||||
engine.runtimeProvider.init(true);
|
||||
engine.runtimeProvider.preLoad();
|
||||
HWIDProvider.registerHWIDs();
|
||||
LauncherGuardManager.initGuard(true);
|
||||
LogHelper.debug("Reading ClientLauncher params");
|
||||
Params params;
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
import pro.gravit.launcher.HWID;
|
||||
import pro.gravit.launcher.hwid.HWID;
|
||||
import pro.gravit.launcher.LauncherAPI;
|
||||
import pro.gravit.launcher.events.request.AuthRequestEvent;
|
||||
import pro.gravit.launcher.guard.LauncherGuardManager;
|
||||
|
|
|
@ -25,6 +25,8 @@
|
|||
import pro.gravit.launcher.hasher.HashedDir;
|
||||
import pro.gravit.launcher.hasher.HashedEntry;
|
||||
import pro.gravit.launcher.hasher.HashedFile;
|
||||
import pro.gravit.launcher.hwid.NoHWID;
|
||||
import pro.gravit.launcher.hwid.OshiHWID;
|
||||
import pro.gravit.launcher.managers.SettingsManager;
|
||||
import pro.gravit.launcher.profiles.ClientProfile;
|
||||
import pro.gravit.launcher.profiles.PlayerProfile;
|
||||
|
@ -130,6 +132,9 @@ public static void addLauncherClassBindings(Map<String, Object> bindings) {
|
|||
bindings.put("DirBridgeClass", DirBridge.class);
|
||||
bindings.put("FunctionalBridgeClass", FunctionalBridge.class);
|
||||
|
||||
bindings.put("NoHWIDClass", NoHWID.class);
|
||||
bindings.put("OshiHWIDClass", OshiHWID.class);
|
||||
|
||||
// Load JS API if available
|
||||
try {
|
||||
Class.forName("javafx.application.Application");
|
||||
|
|
|
@ -10,9 +10,6 @@
|
|||
import oshi.hardware.NetworkIF;
|
||||
import oshi.hardware.SoundCard;
|
||||
import oshi.hardware.UsbDevice;
|
||||
import pro.gravit.launcher.HWID;
|
||||
import pro.gravit.launcher.LauncherHWIDInterface;
|
||||
import pro.gravit.launcher.OshiHWID;
|
||||
import pro.gravit.utils.helper.LogHelper;
|
||||
|
||||
public class OshiHWIDProvider implements LauncherHWIDInterface {
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
import com.google.gson.GsonBuilder;
|
||||
|
||||
import pro.gravit.launcher.client.UserSettings;
|
||||
import pro.gravit.launcher.hwid.HWID;
|
||||
import pro.gravit.launcher.hwid.HWIDProvider;
|
||||
import pro.gravit.utils.UniversalJsonAdapter;
|
||||
|
||||
public class ClientGsonManager extends GsonManager {
|
||||
|
@ -10,5 +12,6 @@ public class ClientGsonManager extends GsonManager {
|
|||
public void registerAdapters(GsonBuilder builder) {
|
||||
super.registerAdapters(builder);
|
||||
builder.registerTypeAdapter(UserSettings.class, new UniversalJsonAdapter<>(UserSettings.providers));
|
||||
builder.registerTypeAdapter(HWID.class, new UniversalJsonAdapter<>(HWIDProvider.hwids));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package pro.gravit.launcher;
|
||||
package pro.gravit.launcher.hwid;
|
||||
|
||||
public interface HWID {
|
||||
String getSerializeString();
|
|
@ -0,0 +1,11 @@
|
|||
package pro.gravit.launcher.hwid;
|
||||
|
||||
import pro.gravit.utils.ProviderMap;
|
||||
|
||||
public class HWIDProvider {
|
||||
public static ProviderMap<HWID> hwids = new ProviderMap<>();
|
||||
public static void registerHWIDs()
|
||||
{
|
||||
hwids.register("oshi", OshiHWID.class);
|
||||
}
|
||||
}
|
|
@ -1,4 +1,6 @@
|
|||
package pro.gravit.launcher;
|
||||
package pro.gravit.launcher.hwid;
|
||||
|
||||
import pro.gravit.launcher.hwid.HWID;
|
||||
|
||||
@FunctionalInterface
|
||||
public interface LauncherHWIDInterface {
|
|
@ -0,0 +1,23 @@
|
|||
package pro.gravit.launcher.hwid;
|
||||
|
||||
public class NoHWID implements HWID {
|
||||
@Override
|
||||
public String getSerializeString() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLevel() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compare(HWID hwid) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNull() {
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -1,9 +1,10 @@
|
|||
package pro.gravit.launcher;
|
||||
package pro.gravit.launcher.hwid;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.StringJoiner;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import pro.gravit.launcher.LauncherAPI;
|
||||
|
||||
public class OshiHWID implements HWID {
|
||||
public static Gson gson = new Gson();
|
|
@ -1,6 +1,6 @@
|
|||
package pro.gravit.launcher.request.auth;
|
||||
|
||||
import pro.gravit.launcher.HWID;
|
||||
import pro.gravit.launcher.hwid.HWID;
|
||||
import pro.gravit.launcher.LauncherAPI;
|
||||
import pro.gravit.launcher.LauncherNetworkAPI;
|
||||
import pro.gravit.launcher.events.request.AuthRequestEvent;
|
||||
|
|
Loading…
Reference in a new issue