mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-12-23 00:51:01 +03:00
Compare commits
17 commits
ae1d9e3d19
...
bd5e557a29
Author | SHA1 | Date | |
---|---|---|---|
|
bd5e557a29 | ||
|
912caa6b8a | ||
|
926094076c | ||
|
a1af61a599 | ||
|
81b16cb54e | ||
|
a486f21fa2 | ||
|
86ea247f07 | ||
|
d26b179006 | ||
|
c4d1251429 | ||
|
f16f5fbc6d | ||
|
abe904d73c | ||
|
eaf685897f | ||
|
c8934d887a | ||
|
070a5d9b69 | ||
|
cc2bce4300 | ||
|
c7f4d8ac49 | ||
|
7dcb08fdaf |
14 changed files with 418 additions and 23 deletions
|
@ -9,15 +9,22 @@
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
public class HikariSQLSourceConfig implements SQLSourceConfig {
|
public class HikariSQLSourceConfig implements SQLSourceConfig {
|
||||||
private transient HikariDataSource dataSource;
|
private transient volatile HikariDataSource dataSource;
|
||||||
private String dsClass;
|
private String dsClass;
|
||||||
private Properties dsProps;
|
private Properties dsProps;
|
||||||
private String driverClass;
|
private String driverClass;
|
||||||
private String jdbcUrl;
|
private String jdbcUrl;
|
||||||
private String username;
|
private String username;
|
||||||
private String password;
|
private String password;
|
||||||
|
private boolean initializeAtStart;
|
||||||
|
|
||||||
public void init() {
|
public void init() {
|
||||||
|
if(initializeAtStart) {
|
||||||
|
initializeConnection();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initializeConnection() {
|
||||||
if (dataSource != null) {
|
if (dataSource != null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -34,6 +41,11 @@ public void init() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Connection getConnection() throws SQLException {
|
public Connection getConnection() throws SQLException {
|
||||||
|
if(dataSource == null && !initializeAtStart) {
|
||||||
|
synchronized (this) {
|
||||||
|
initializeConnection();
|
||||||
|
}
|
||||||
|
}
|
||||||
return dataSource.getConnection();
|
return dataSource.getConnection();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -295,7 +295,9 @@ private SQLUser queryUser(String sql, String value) throws SQLException {
|
||||||
user = constructUser(set);
|
user = constructUser(set);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
user.permissions = requestPermissions(user.uuid.toString());
|
if(user != null) {
|
||||||
|
user.permissions = requestPermissions(user.uuid.toString());
|
||||||
|
}
|
||||||
return user;
|
return user;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -44,6 +44,7 @@ public SQLSourceConfig getSQLConfig() {
|
||||||
@Override
|
@Override
|
||||||
public void init(LaunchServer server, AuthProviderPair pair) {
|
public void init(LaunchServer server, AuthProviderPair pair) {
|
||||||
super.init(server, pair);
|
super.init(server, pair);
|
||||||
|
logger.warn("Method 'mysql' deprecated and may be removed in future release. Please use new 'sql' method: https://gravitlauncher.com/auth");
|
||||||
String userInfoCols = makeUserCols();
|
String userInfoCols = makeUserCols();
|
||||||
String hardwareInfoCols = "id, hwDiskId, baseboardSerialNumber, displayId, bitness, totalMemory, logicalProcessors, physicalProcessors, processorMaxFreq, battery, id, graphicCard, banned, publicKey";
|
String hardwareInfoCols = "id, hwDiskId, baseboardSerialNumber, displayId, bitness, totalMemory, logicalProcessors, physicalProcessors, processorMaxFreq, battery, id, graphicCard, banned, publicKey";
|
||||||
if (sqlFindHardwareByPublicKey == null)
|
if (sqlFindHardwareByPublicKey == null)
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package pro.gravit.launchserver.auth.core;
|
package pro.gravit.launchserver.auth.core;
|
||||||
|
|
||||||
|
import pro.gravit.launchserver.LaunchServer;
|
||||||
|
import pro.gravit.launchserver.auth.AuthProviderPair;
|
||||||
import pro.gravit.launchserver.auth.PostgreSQLSourceConfig;
|
import pro.gravit.launchserver.auth.PostgreSQLSourceConfig;
|
||||||
import pro.gravit.launchserver.auth.SQLSourceConfig;
|
import pro.gravit.launchserver.auth.SQLSourceConfig;
|
||||||
|
|
||||||
|
@ -10,4 +12,10 @@ public class PostgresSQLCoreProvider extends AbstractSQLCoreProvider {
|
||||||
public SQLSourceConfig getSQLConfig() {
|
public SQLSourceConfig getSQLConfig() {
|
||||||
return postgresSQLHolder;
|
return postgresSQLHolder;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init(LaunchServer server, AuthProviderPair pair) {
|
||||||
|
super.init(server, pair);
|
||||||
|
logger.warn("Method 'postgresql' deprecated and may be removed in future release. Please use new 'sql' method: https://gravitlauncher.com/auth");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,27 @@
|
||||||
package pro.gravit.launchserver.auth.core;
|
package pro.gravit.launchserver.auth.core;
|
||||||
|
|
||||||
|
import pro.gravit.launcher.base.request.secure.HardwareReportRequest;
|
||||||
import pro.gravit.launchserver.LaunchServer;
|
import pro.gravit.launchserver.LaunchServer;
|
||||||
import pro.gravit.launchserver.auth.AuthProviderPair;
|
import pro.gravit.launchserver.auth.AuthProviderPair;
|
||||||
import pro.gravit.launchserver.auth.HikariSQLSourceConfig;
|
import pro.gravit.launchserver.auth.HikariSQLSourceConfig;
|
||||||
|
import pro.gravit.launchserver.auth.MySQLSourceConfig;
|
||||||
import pro.gravit.launchserver.auth.SQLSourceConfig;
|
import pro.gravit.launchserver.auth.SQLSourceConfig;
|
||||||
|
import pro.gravit.launchserver.auth.core.interfaces.UserHardware;
|
||||||
|
import pro.gravit.launchserver.auth.core.interfaces.provider.AuthSupportExtendedCheckServer;
|
||||||
|
import pro.gravit.launchserver.auth.core.interfaces.provider.AuthSupportHardware;
|
||||||
|
import pro.gravit.launchserver.auth.core.interfaces.session.UserSessionSupportHardware;
|
||||||
|
import pro.gravit.launchserver.socket.Client;
|
||||||
|
import pro.gravit.utils.helper.IOHelper;
|
||||||
|
|
||||||
public class SQLCoreProvider extends AbstractSQLCoreProvider {
|
import java.io.ByteArrayInputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.sql.*;
|
||||||
|
import java.util.Base64;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public class SQLCoreProvider extends AbstractSQLCoreProvider implements AuthSupportHardware, AuthSupportExtendedCheckServer {
|
||||||
public HikariSQLSourceConfig holder;
|
public HikariSQLSourceConfig holder;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -14,14 +30,364 @@ public void close() {
|
||||||
holder.close();
|
holder.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void init(LaunchServer server, AuthProviderPair pair) {
|
|
||||||
holder.init();
|
|
||||||
super.init(server, pair);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SQLSourceConfig getSQLConfig() {
|
public SQLSourceConfig getSQLConfig() {
|
||||||
return holder;
|
return holder;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public String hardwareIdColumn;
|
||||||
|
public String tableHWID = "hwids";
|
||||||
|
public String tableHWIDLog = "hwidLog";
|
||||||
|
public double criticalCompareLevel = 1.0;
|
||||||
|
private transient String sqlFindHardwareByPublicKey;
|
||||||
|
private transient String sqlFindHardwareByData;
|
||||||
|
private transient String sqlFindHardwareById;
|
||||||
|
private transient String sqlCreateHardware;
|
||||||
|
private transient String sqlCreateHWIDLog;
|
||||||
|
private transient String sqlUpdateHardwarePublicKey;
|
||||||
|
private transient String sqlUpdateHardwareBanned;
|
||||||
|
private transient String sqlUpdateUsers;
|
||||||
|
private transient String sqlUsersByHwidId;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init(LaunchServer server, AuthProviderPair pair) {
|
||||||
|
holder.init();
|
||||||
|
super.init(server, pair);
|
||||||
|
String userInfoCols = makeUserCols();
|
||||||
|
String hardwareInfoCols = "id, hwDiskId, baseboardSerialNumber, displayId, bitness, totalMemory, logicalProcessors, physicalProcessors, processorMaxFreq, battery, id, graphicCard, banned, publicKey";
|
||||||
|
if (sqlFindHardwareByPublicKey == null)
|
||||||
|
sqlFindHardwareByPublicKey = "SELECT %s FROM %s WHERE publicKey = ?".formatted(hardwareInfoCols, tableHWID);
|
||||||
|
if (sqlFindHardwareById == null)
|
||||||
|
sqlFindHardwareById = "SELECT %s FROM %s WHERE id = ?".formatted(hardwareInfoCols, tableHWID);
|
||||||
|
if (sqlUsersByHwidId == null)
|
||||||
|
sqlUsersByHwidId = "SELECT %s FROM %s WHERE %s = ?".formatted(userInfoCols, table, hardwareIdColumn);
|
||||||
|
if (sqlFindHardwareByData == null)
|
||||||
|
sqlFindHardwareByData = "SELECT %s FROM %s".formatted(hardwareInfoCols, tableHWID);
|
||||||
|
if (sqlCreateHardware == null)
|
||||||
|
sqlCreateHardware = "INSERT INTO %s (publickey, hwDiskId, baseboardSerialNumber, displayId, bitness, totalMemory, logicalProcessors, physicalProcessors, processorMaxFreq, graphicCard, battery, banned) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, '0')".formatted(tableHWID);
|
||||||
|
if (sqlCreateHWIDLog == null)
|
||||||
|
sqlCreateHWIDLog = "INSERT INTO %s (hwidId, newPublicKey) VALUES (?, ?)".formatted(tableHWIDLog);
|
||||||
|
if (sqlUpdateHardwarePublicKey == null)
|
||||||
|
sqlUpdateHardwarePublicKey = "UPDATE %s SET publicKey = ? WHERE id = ?".formatted(tableHWID);
|
||||||
|
sqlUpdateHardwareBanned = "UPDATE %s SET banned = ? WHERE id = ?".formatted(tableHWID);
|
||||||
|
sqlUpdateUsers = "UPDATE %s SET %s = ? WHERE %s = ?".formatted(table, hardwareIdColumn, uuidColumn);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String makeUserCols() {
|
||||||
|
return super.makeUserCols().concat(", ").concat(hardwareIdColumn);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected SQLUser constructUser(ResultSet set) throws SQLException {
|
||||||
|
return set.next() ? new SQLUser(UUID.fromString(set.getString(uuidColumn)), set.getString(usernameColumn),
|
||||||
|
set.getString(accessTokenColumn), set.getString(serverIDColumn), set.getString(passwordColumn), set.getLong(hardwareIdColumn)) : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private SQLUserHardware fetchHardwareInfo(ResultSet set) throws SQLException, IOException {
|
||||||
|
HardwareReportRequest.HardwareInfo hardwareInfo = new HardwareReportRequest.HardwareInfo();
|
||||||
|
hardwareInfo.hwDiskId = set.getString("hwDiskId");
|
||||||
|
hardwareInfo.baseboardSerialNumber = set.getString("baseboardSerialNumber");
|
||||||
|
byte[] displayId = set.getBytes("displayId");
|
||||||
|
hardwareInfo.displayId = displayId == null ? null : displayId;
|
||||||
|
hardwareInfo.bitness = set.getInt("bitness");
|
||||||
|
hardwareInfo.totalMemory = set.getLong("totalMemory");
|
||||||
|
hardwareInfo.logicalProcessors = set.getInt("logicalProcessors");
|
||||||
|
hardwareInfo.physicalProcessors = set.getInt("physicalProcessors");
|
||||||
|
hardwareInfo.processorMaxFreq = set.getLong("processorMaxFreq");
|
||||||
|
hardwareInfo.battery = set.getBoolean("battery");
|
||||||
|
hardwareInfo.graphicCard = set.getString("graphicCard");
|
||||||
|
byte[] publicKey = set.getBytes("publicKey");
|
||||||
|
long id = set.getLong("id");
|
||||||
|
boolean banned = set.getBoolean("banned");
|
||||||
|
return new SQLUserHardware(hardwareInfo, publicKey, id, banned);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setUserHardwareId(Connection connection, UUID uuid, long hwidId) throws SQLException {
|
||||||
|
PreparedStatement s = connection.prepareStatement(sqlUpdateUsers);
|
||||||
|
s.setLong(1, hwidId);
|
||||||
|
s.setString(2, uuid.toString());
|
||||||
|
s.executeUpdate();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public UserHardware getHardwareInfoByPublicKey(byte[] publicKey) {
|
||||||
|
try (Connection connection = holder.getConnection()) {
|
||||||
|
connection.setAutoCommit(false);
|
||||||
|
PreparedStatement s = connection.prepareStatement(sqlFindHardwareByPublicKey);
|
||||||
|
s.setBytes(1, publicKey);
|
||||||
|
try (ResultSet set = s.executeQuery()) {
|
||||||
|
if (set.next()) {
|
||||||
|
connection.commit();
|
||||||
|
return fetchHardwareInfo(set);
|
||||||
|
} else {
|
||||||
|
connection.commit();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (SQLException | IOException throwables) {
|
||||||
|
logger.error("SQL Error", throwables);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public UserHardware getHardwareInfoByData(HardwareReportRequest.HardwareInfo info) {
|
||||||
|
try (Connection connection = holder.getConnection()) {
|
||||||
|
connection.setAutoCommit(false);
|
||||||
|
PreparedStatement s = connection.prepareStatement(sqlFindHardwareByData);
|
||||||
|
try (ResultSet set = s.executeQuery()) {
|
||||||
|
while (set.next()) {
|
||||||
|
SQLUserHardware hw = fetchHardwareInfo(set);
|
||||||
|
AuthSupportHardware.HardwareInfoCompareResult result = compareHardwareInfo(hw.getHardwareInfo(), info);
|
||||||
|
if (result.compareLevel > criticalCompareLevel) {
|
||||||
|
connection.commit();
|
||||||
|
return hw;
|
||||||
|
} else {
|
||||||
|
connection.commit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (SQLException | IOException throwables) {
|
||||||
|
logger.error("SQL Error", throwables);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public UserHardware getHardwareInfoById(String id) {
|
||||||
|
try (Connection connection = holder.getConnection()) {
|
||||||
|
connection.setAutoCommit(false);
|
||||||
|
PreparedStatement s = connection.prepareStatement(sqlFindHardwareById);
|
||||||
|
s.setLong(1, Long.parseLong(id));
|
||||||
|
try (ResultSet set = s.executeQuery()) {
|
||||||
|
if (set.next()) {
|
||||||
|
connection.commit();
|
||||||
|
return fetchHardwareInfo(set);
|
||||||
|
} else {
|
||||||
|
connection.commit();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (SQLException | IOException throwables) {
|
||||||
|
logger.error("SQL Error", throwables);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public UserHardware createHardwareInfo(HardwareReportRequest.HardwareInfo hardwareInfo, byte[] publicKey) {
|
||||||
|
try (Connection connection = holder.getConnection()) {
|
||||||
|
connection.setAutoCommit(false);
|
||||||
|
PreparedStatement s = connection.prepareStatement(sqlCreateHardware, Statement.RETURN_GENERATED_KEYS);
|
||||||
|
s.setBytes(1, publicKey);
|
||||||
|
s.setString(2, hardwareInfo.hwDiskId);
|
||||||
|
s.setString(3, hardwareInfo.baseboardSerialNumber);
|
||||||
|
s.setBytes(4, hardwareInfo.displayId == null ? null : hardwareInfo.displayId);
|
||||||
|
s.setInt(5, hardwareInfo.bitness);
|
||||||
|
s.setLong(6, hardwareInfo.totalMemory);
|
||||||
|
s.setInt(7, hardwareInfo.logicalProcessors);
|
||||||
|
s.setInt(8, hardwareInfo.physicalProcessors);
|
||||||
|
s.setLong(9, hardwareInfo.processorMaxFreq);
|
||||||
|
s.setString(10, hardwareInfo.graphicCard);
|
||||||
|
s.setBoolean(11, hardwareInfo.battery);
|
||||||
|
s.executeUpdate();
|
||||||
|
try (ResultSet generatedKeys = s.getGeneratedKeys()) {
|
||||||
|
if (generatedKeys.next()) {
|
||||||
|
//writeHwidLog(connection, generatedKeys.getLong(1), publicKey);
|
||||||
|
long id = generatedKeys.getLong(1);
|
||||||
|
connection.commit();
|
||||||
|
return new SQLUserHardware(hardwareInfo, publicKey, id, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
connection.commit();
|
||||||
|
return null;
|
||||||
|
} catch (SQLException throwables) {
|
||||||
|
logger.error("SQL Error", throwables);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void connectUserAndHardware(UserSession userSession, UserHardware hardware) {
|
||||||
|
AbstractSQLCoreProvider.SQLUserSession SQLUserSession = (AbstractSQLCoreProvider.SQLUserSession) userSession;
|
||||||
|
SQLUser SQLUser = (SQLUser) SQLUserSession.getUser();
|
||||||
|
SQLUserHardware SQLUserHardware = (SQLUserHardware) hardware;
|
||||||
|
if (SQLUser.hwidId == SQLUserHardware.id) return;
|
||||||
|
SQLUser.hwidId = SQLUserHardware.id;
|
||||||
|
try (Connection connection = holder.getConnection()) {
|
||||||
|
setUserHardwareId(connection, SQLUser.getUUID(), SQLUserHardware.id);
|
||||||
|
} catch (SQLException throwables) {
|
||||||
|
logger.error("SQL Error", throwables);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addPublicKeyToHardwareInfo(UserHardware hardware, byte[] publicKey) {
|
||||||
|
SQLUserHardware SQLUserHardware = (SQLUserHardware) hardware;
|
||||||
|
SQLUserHardware.publicKey = publicKey;
|
||||||
|
try (Connection connection = holder.getConnection()) {
|
||||||
|
connection.setAutoCommit(false);
|
||||||
|
PreparedStatement s = connection.prepareStatement(sqlUpdateHardwarePublicKey);
|
||||||
|
s.setBytes(1, publicKey);
|
||||||
|
s.setLong(2, SQLUserHardware.id);
|
||||||
|
s.executeUpdate();
|
||||||
|
connection.commit();
|
||||||
|
} catch (SQLException e) {
|
||||||
|
logger.error("SQL error", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Iterable<User> getUsersByHardwareInfo(UserHardware hardware) {
|
||||||
|
List<User> users = new LinkedList<>();
|
||||||
|
try (Connection c = holder.getConnection()) {
|
||||||
|
c.setAutoCommit(false);
|
||||||
|
PreparedStatement s = c.prepareStatement(sqlUsersByHwidId);
|
||||||
|
s.setLong(1, Long.parseLong(hardware.getId()));
|
||||||
|
s.setQueryTimeout(MySQLSourceConfig.TIMEOUT);
|
||||||
|
try (ResultSet set = s.executeQuery()) {
|
||||||
|
while (!set.isLast()) {
|
||||||
|
users.add(constructUser(set));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
c.commit();
|
||||||
|
} catch (SQLException e) {
|
||||||
|
logger.error("SQL error", e);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return users;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void banHardware(UserHardware hardware) {
|
||||||
|
SQLUserHardware SQLUserHardware = (SQLUserHardware) hardware;
|
||||||
|
SQLUserHardware.banned = true;
|
||||||
|
try (Connection connection = holder.getConnection()) {
|
||||||
|
PreparedStatement s = connection.prepareStatement(sqlUpdateHardwareBanned);
|
||||||
|
s.setBoolean(1, true);
|
||||||
|
s.setLong(2, SQLUserHardware.id);
|
||||||
|
s.executeUpdate();
|
||||||
|
} catch (SQLException e) {
|
||||||
|
logger.error("SQL Error", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void unbanHardware(UserHardware hardware) {
|
||||||
|
SQLUserHardware SQLUserHardware = (SQLUserHardware) hardware;
|
||||||
|
SQLUserHardware.banned = false;
|
||||||
|
try (Connection connection = holder.getConnection()) {
|
||||||
|
PreparedStatement s = connection.prepareStatement(sqlUpdateHardwareBanned);
|
||||||
|
s.setBoolean(1, false);
|
||||||
|
s.setLong(2, SQLUserHardware.id);
|
||||||
|
s.executeUpdate();
|
||||||
|
} catch (SQLException e) {
|
||||||
|
logger.error("SQL error", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected AbstractSQLCoreProvider.SQLUserSession createSession(AbstractSQLCoreProvider.SQLUser user) {
|
||||||
|
return new SQLUserSession(user);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public UserSession extendedCheckServer(Client client, String username, String serverID) throws IOException {
|
||||||
|
AbstractSQLCoreProvider.SQLUser user = (AbstractSQLCoreProvider.SQLUser) getUserByUsername(username);
|
||||||
|
if (user == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (user.getUsername().equals(username) && user.getServerId().equals(serverID)) {
|
||||||
|
return createSession(user);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public class SQLUserSession extends AbstractSQLCoreProvider.SQLUserSession implements UserSessionSupportHardware {
|
||||||
|
private transient SQLUser SQLUser;
|
||||||
|
protected transient SQLUserHardware hardware;
|
||||||
|
|
||||||
|
public SQLUserSession(AbstractSQLCoreProvider.SQLUser user) {
|
||||||
|
super(user);
|
||||||
|
SQLUser = (SQLUser) user;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getHardwareId() {
|
||||||
|
return SQLUser.hwidId == 0 ? null : String.valueOf(SQLUser.hwidId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public UserHardware getHardware() {
|
||||||
|
if(hardware == null) {
|
||||||
|
hardware = (SQLUserHardware) getHardwareInfoById(String.valueOf(SQLUser.hwidId));
|
||||||
|
}
|
||||||
|
return hardware;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class SQLUserHardware implements UserHardware {
|
||||||
|
private final HardwareReportRequest.HardwareInfo hardwareInfo;
|
||||||
|
private final long id;
|
||||||
|
private byte[] publicKey;
|
||||||
|
private boolean banned;
|
||||||
|
|
||||||
|
public SQLUserHardware(HardwareReportRequest.HardwareInfo hardwareInfo, byte[] publicKey, long id, boolean banned) {
|
||||||
|
this.hardwareInfo = hardwareInfo;
|
||||||
|
this.publicKey = publicKey;
|
||||||
|
this.id = id;
|
||||||
|
this.banned = banned;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HardwareReportRequest.HardwareInfo getHardwareInfo() {
|
||||||
|
return hardwareInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public byte[] getPublicKey() {
|
||||||
|
return publicKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getId() {
|
||||||
|
return String.valueOf(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isBanned() {
|
||||||
|
return banned;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "SQLUserHardware{" +
|
||||||
|
"hardwareInfo=" + hardwareInfo +
|
||||||
|
", publicKey=" + (publicKey == null ? null : new String(Base64.getEncoder().encode(publicKey))) +
|
||||||
|
", id=" + id +
|
||||||
|
", banned=" + banned +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class SQLUser extends AbstractSQLCoreProvider.SQLUser {
|
||||||
|
protected long hwidId;
|
||||||
|
|
||||||
|
public SQLUser(UUID uuid, String username, String accessToken, String serverId, String password, long hwidId) {
|
||||||
|
super(uuid, username, accessToken, serverId, password);
|
||||||
|
this.hwidId = hwidId;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "SQLUser{" +
|
||||||
|
"uuid=" + uuid +
|
||||||
|
", username='" + username + '\'' +
|
||||||
|
", permissions=" + permissions +
|
||||||
|
", hwidId=" + hwidId +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -88,7 +88,7 @@ private static void realMain(String[] args) throws Throwable {
|
||||||
ClientParams params = readParams(new InetSocketAddress("127.0.0.1", Launcher.getConfig().clientPort));
|
ClientParams params = readParams(new InetSocketAddress("127.0.0.1", Launcher.getConfig().clientPort));
|
||||||
ClientLauncherMethods.verifyNoAgent();
|
ClientLauncherMethods.verifyNoAgent();
|
||||||
if(params.timestamp > System.currentTimeMillis() || params.timestamp + 30*1000 < System.currentTimeMillis() ) {
|
if(params.timestamp > System.currentTimeMillis() || params.timestamp + 30*1000 < System.currentTimeMillis() ) {
|
||||||
LogHelper.error("Timestamp failed. Exit");
|
LogHelper.error("Timestamp failed: current %d | params %d | diff %d", System.currentTimeMillis(), params.timestamp, System.currentTimeMillis() - params.timestamp);
|
||||||
ClientLauncherMethods.exitLauncher(-662);
|
ClientLauncherMethods.exitLauncher(-662);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@ public final class Version implements Comparable<Version> {
|
||||||
|
|
||||||
public static final int MAJOR = 5;
|
public static final int MAJOR = 5;
|
||||||
public static final int MINOR = 6;
|
public static final int MINOR = 6;
|
||||||
public static final int PATCH = 6;
|
public static final int PATCH = 8;
|
||||||
public static final int BUILD = 1;
|
public static final int BUILD = 1;
|
||||||
public static final Version.Type RELEASE = Type.STABLE;
|
public static final Version.Type RELEASE = Type.STABLE;
|
||||||
public final int major;
|
public final int major;
|
||||||
|
|
|
@ -123,6 +123,9 @@ protected Class<?> findClass(String name) throws ClassNotFoundException {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String findLibrary(String name) {
|
public String findLibrary(String name) {
|
||||||
|
if(nativePath == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
return nativePath.concat(IOHelper.PLATFORM_SEPARATOR).concat(JVMHelper.NATIVE_PREFIX).concat(name).concat(JVMHelper.NATIVE_EXTENSION);
|
return nativePath.concat(IOHelper.PLATFORM_SEPARATOR).concat(JVMHelper.NATIVE_PREFIX).concat(name).concat(JVMHelper.NATIVE_EXTENSION);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -262,6 +262,9 @@ protected Class<?> findClass(String moduleName, String name) {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String findLibrary(String name) {
|
public String findLibrary(String name) {
|
||||||
|
if(nativePath == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
return nativePath.concat(IOHelper.PLATFORM_SEPARATOR).concat(JVMHelper.NATIVE_PREFIX).concat(name).concat(JVMHelper.NATIVE_EXTENSION);
|
return nativePath.concat(IOHelper.PLATFORM_SEPARATOR).concat(JVMHelper.NATIVE_PREFIX).concat(name).concat(JVMHelper.NATIVE_EXTENSION);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
id 'org.openjfx.javafxplugin' version '0.1.0' apply false
|
id 'org.openjfx.javafxplugin' version '0.1.0' apply false
|
||||||
}
|
}
|
||||||
group = 'pro.gravit.launcher'
|
group = 'pro.gravit.launcher'
|
||||||
version = '5.6.6'
|
version = '5.6.8'
|
||||||
|
|
||||||
apply from: 'props.gradle'
|
apply from: 'props.gradle'
|
||||||
|
|
||||||
|
|
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,6 +1,6 @@
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-all.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-all.zip
|
||||||
networkTimeout=10000
|
networkTimeout=10000
|
||||||
validateDistributionUrl=true
|
validateDistributionUrl=true
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
|
|
2
modules
2
modules
|
@ -1 +1 @@
|
||||||
Subproject commit 65f882bd90623aa1581ad24cfa4f52563ea95bc0
|
Subproject commit 0d8cef927b1fda3097dc88c3adcffc4d0e33dd69
|
18
props.gradle
18
props.gradle
|
@ -1,18 +1,18 @@
|
||||||
project.ext {
|
project.ext {
|
||||||
verAsm = '9.7'
|
verAsm = '9.7.1'
|
||||||
verNetty = '4.1.111.Final'
|
verNetty = '4.1.114.Final'
|
||||||
verOshiCore = '6.6.4'
|
verOshiCore = '6.6.5'
|
||||||
verJunit = '5.10.2'
|
verJunit = '5.11.2'
|
||||||
verJansi = '2.4.1'
|
verJansi = '2.4.1'
|
||||||
verJline = '3.26.3'
|
verJline = '3.26.3'
|
||||||
verJwt = '0.12.5'
|
verJwt = '0.12.6'
|
||||||
verGson = '2.11.0'
|
verGson = '2.11.0'
|
||||||
verBcpkix = '1.78.1'
|
verBcpkix = '1.78.1'
|
||||||
verSlf4j = '2.0.13'
|
verSlf4j = '2.0.16'
|
||||||
verLog4j = '2.23.1'
|
verLog4j = '2.24.1'
|
||||||
verMySQLConn = '9.0.0'
|
verMySQLConn = '9.0.0'
|
||||||
verMariaDBConn = '3.4.0'
|
verMariaDBConn = '3.4.1'
|
||||||
verPostgreSQLConn = '42.7.4'
|
verPostgreSQLConn = '42.7.4'
|
||||||
verH2Conn = '2.3.232'
|
verH2Conn = '2.3.232'
|
||||||
verProguard = '7.5.0'
|
verProguard = '7.6.0'
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue