mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-12-23 00:51:01 +03:00
[REFACTOR] Switch to log4j 2
This commit is contained in:
parent
66db1eb861
commit
5d35c0823e
14 changed files with 69 additions and 58 deletions
|
@ -1,11 +1,12 @@
|
||||||
package pro.gravit.launchserver.auth.protect.hwid;
|
package pro.gravit.launchserver.auth.protect.hwid;
|
||||||
|
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
import pro.gravit.launcher.request.secure.HardwareReportRequest;
|
import pro.gravit.launcher.request.secure.HardwareReportRequest;
|
||||||
import pro.gravit.launchserver.LaunchServer;
|
import pro.gravit.launchserver.LaunchServer;
|
||||||
import pro.gravit.launchserver.helper.DamerauHelper;
|
import pro.gravit.launchserver.helper.DamerauHelper;
|
||||||
import pro.gravit.launchserver.socket.Client;
|
import pro.gravit.launchserver.socket.Client;
|
||||||
import pro.gravit.utils.ProviderMap;
|
import pro.gravit.utils.ProviderMap;
|
||||||
import pro.gravit.utils.helper.LogHelper;
|
|
||||||
import pro.gravit.utils.helper.SecurityHelper;
|
import pro.gravit.utils.helper.SecurityHelper;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
@ -13,6 +14,7 @@
|
||||||
public abstract class HWIDProvider {
|
public abstract class HWIDProvider {
|
||||||
public static final ProviderMap<HWIDProvider> providers = new ProviderMap<>("HWIDProvider");
|
public static final ProviderMap<HWIDProvider> providers = new ProviderMap<>("HWIDProvider");
|
||||||
private static boolean registredProv = false;
|
private static boolean registredProv = false;
|
||||||
|
private final Logger logger = LogManager.getLogger();
|
||||||
|
|
||||||
public static void registerProviders() {
|
public static void registerProviders() {
|
||||||
if (!registredProv) {
|
if (!registredProv) {
|
||||||
|
@ -92,10 +94,10 @@ public HardwareInfoCompareResult compareHardwareInfo(HardwareReportRequest.Hardw
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void printHardwareInfo(LogHelper.Level logLevel, HardwareReportRequest.HardwareInfo info) {
|
protected void printHardwareInfo(HardwareReportRequest.HardwareInfo info) {
|
||||||
LogHelper.log(logLevel, String.format("[HardwareInfo] Processor: logical %d | physical %d | freq %d | bitness %d", info.logicalProcessors, info.physicalProcessors, info.processorMaxFreq, info.bitness), false);
|
logger.info("[HardwareInfo] Processor: logical {} | physical {} | freq {} | bitness {}", info.logicalProcessors, info.physicalProcessors, info.processorMaxFreq, info.bitness);
|
||||||
LogHelper.log(logLevel, String.format("[HardwareInfo] Memory max: %d | battery %s", info.totalMemory, info.battery ? "true" : "false"), false);
|
logger.info("[HardwareInfo] Memory max: {} | battery {}", info.totalMemory, info.battery ? "true" : "false");
|
||||||
LogHelper.log(logLevel, String.format("[HardwareInfo] HWDiskID %s | baseboardSerialNumber %s | displayId hash: %s", info.hwDiskId, info.baseboardSerialNumber, SecurityHelper.toHex(SecurityHelper.digest(SecurityHelper.DigestAlgorithm.MD5, info.displayId))), false);
|
logger.info("[HardwareInfo] HWDiskID {} | baseboardSerialNumber {} | displayId hash: {}", info.hwDiskId, info.baseboardSerialNumber, SecurityHelper.toHex(SecurityHelper.digest(SecurityHelper.DigestAlgorithm.MD5, info.displayId)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void init(LaunchServer server) {
|
public void init(LaunchServer server) {
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
package pro.gravit.launchserver.auth.protect.hwid;
|
package pro.gravit.launchserver.auth.protect.hwid;
|
||||||
|
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
import pro.gravit.launcher.request.secure.HardwareReportRequest;
|
import pro.gravit.launcher.request.secure.HardwareReportRequest;
|
||||||
import pro.gravit.launchserver.Reconfigurable;
|
import pro.gravit.launchserver.Reconfigurable;
|
||||||
import pro.gravit.launchserver.socket.Client;
|
import pro.gravit.launchserver.socket.Client;
|
||||||
import pro.gravit.utils.command.Command;
|
import pro.gravit.utils.command.Command;
|
||||||
import pro.gravit.utils.command.SubCommand;
|
import pro.gravit.utils.command.SubCommand;
|
||||||
import pro.gravit.utils.helper.LogHelper;
|
|
||||||
import pro.gravit.utils.helper.SecurityHelper;
|
import pro.gravit.utils.helper.SecurityHelper;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
@ -17,7 +18,8 @@
|
||||||
public class MemoryHWIDProvider extends HWIDProvider implements Reconfigurable {
|
public class MemoryHWIDProvider extends HWIDProvider implements Reconfigurable {
|
||||||
public double warningSpoofingLevel = -1.0;
|
public double warningSpoofingLevel = -1.0;
|
||||||
public double criticalCompareLevel = 1.0;
|
public double criticalCompareLevel = 1.0;
|
||||||
public Set<MemoryHWIDEntity> db = ConcurrentHashMap.newKeySet();
|
public transient Set<MemoryHWIDEntity> db = ConcurrentHashMap.newKeySet();
|
||||||
|
private transient final Logger logger = LogManager.getLogger();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Command> getCommands() {
|
public Map<String, Command> getCommands() {
|
||||||
|
@ -26,9 +28,9 @@ public Map<String, Command> getCommands() {
|
||||||
@Override
|
@Override
|
||||||
public void invoke(String... args) {
|
public void invoke(String... args) {
|
||||||
for (MemoryHWIDEntity e : db) {
|
for (MemoryHWIDEntity e : db) {
|
||||||
printHardwareInfo(LogHelper.Level.INFO, e.hardware);
|
printHardwareInfo(e.hardware);
|
||||||
LogHelper.info("ID %d banned %s", e.id, e.banned ? "true" : "false");
|
logger.info("ID {} banned {}", e.id, e.banned ? "true" : "false");
|
||||||
LogHelper.info("PublicKey Hash: %s", SecurityHelper.toHex(SecurityHelper.digest(SecurityHelper.DigestAlgorithm.SHA1, e.publicKey)));
|
logger.info("PublicKey Hash: {}", SecurityHelper.toHex(SecurityHelper.digest(SecurityHelper.DigestAlgorithm.SHA1, e.publicKey)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -40,7 +42,7 @@ public void invoke(String... args) throws Exception {
|
||||||
for (MemoryHWIDEntity e : db) {
|
for (MemoryHWIDEntity e : db) {
|
||||||
if (e.id == id) {
|
if (e.id == id) {
|
||||||
e.banned = true;
|
e.banned = true;
|
||||||
LogHelper.info("HardwareID %d banned", e.id);
|
logger.info("HardwareID {} banned", e.id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -70,11 +72,11 @@ public boolean addPublicKeyToHardwareInfo(HardwareReportRequest.HardwareInfo har
|
||||||
for (MemoryHWIDEntity e : db) {
|
for (MemoryHWIDEntity e : db) {
|
||||||
HardwareInfoCompareResult result = compareHardwareInfo(e.hardware, hardwareInfo);
|
HardwareInfoCompareResult result = compareHardwareInfo(e.hardware, hardwareInfo);
|
||||||
if (warningSpoofingLevel > 0 && result.firstSpoofingLevel > warningSpoofingLevel && !isAlreadyWarning) {
|
if (warningSpoofingLevel > 0 && result.firstSpoofingLevel > warningSpoofingLevel && !isAlreadyWarning) {
|
||||||
LogHelper.warning("HardwareInfo spoofing level too high: %f", result.firstSpoofingLevel);
|
logger.warn("HardwareInfo spoofing level too high: {}", result.firstSpoofingLevel);
|
||||||
isAlreadyWarning = true;
|
isAlreadyWarning = true;
|
||||||
}
|
}
|
||||||
if (result.compareLevel > criticalCompareLevel) {
|
if (result.compareLevel > criticalCompareLevel) {
|
||||||
LogHelper.debug("HardwareInfo publicKey change: compareLevel %f", result.compareLevel);
|
logger.debug("HardwareInfo publicKey change: compareLevel {}", result.compareLevel);
|
||||||
if (e.banned) throw new HWIDException("You HWID banned");
|
if (e.banned) throw new HWIDException("You HWID banned");
|
||||||
e.publicKey = publicKey;
|
e.publicKey = publicKey;
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
package pro.gravit.launchserver.auth.protect.hwid;
|
package pro.gravit.launchserver.auth.protect.hwid;
|
||||||
|
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
import pro.gravit.launcher.request.secure.HardwareReportRequest;
|
import pro.gravit.launcher.request.secure.HardwareReportRequest;
|
||||||
import pro.gravit.launchserver.LaunchServer;
|
import pro.gravit.launchserver.LaunchServer;
|
||||||
import pro.gravit.launchserver.auth.MySQLSourceConfig;
|
import pro.gravit.launchserver.auth.MySQLSourceConfig;
|
||||||
import pro.gravit.launchserver.socket.Client;
|
import pro.gravit.launchserver.socket.Client;
|
||||||
import pro.gravit.utils.helper.IOHelper;
|
import pro.gravit.utils.helper.IOHelper;
|
||||||
import pro.gravit.utils.helper.LogHelper;
|
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -28,6 +29,8 @@ public class MysqlHWIDProvider extends HWIDProvider {
|
||||||
private String sqlCreateHWIDLog;
|
private String sqlCreateHWIDLog;
|
||||||
private String sqlUpdateHardware;
|
private String sqlUpdateHardware;
|
||||||
private String sqlUpdateUsers;
|
private String sqlUpdateUsers;
|
||||||
|
|
||||||
|
private transient final Logger logger = LogManager.getLogger();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void init(LaunchServer server) {
|
public void init(LaunchServer server) {
|
||||||
|
@ -39,7 +42,7 @@ public void init(LaunchServer server) {
|
||||||
if (tableUsers != null && usersHWIDColumn != null && usersNameColumn != null) {
|
if (tableUsers != null && usersHWIDColumn != null && usersNameColumn != null) {
|
||||||
sqlUpdateUsers = String.format("UPDATE %s SET `%s` = ? WHERE `%s` = ?", tableUsers, usersHWIDColumn, usersNameColumn);
|
sqlUpdateUsers = String.format("UPDATE %s SET `%s` = ? WHERE `%s` = ?", tableUsers, usersHWIDColumn, usersNameColumn);
|
||||||
} else {
|
} else {
|
||||||
LogHelper.warning("[MysqlHWIDProvider] Link to users table not configured");
|
logger.warn("[MysqlHWIDProvider] Link to users table not configured");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,7 +64,7 @@ public HardwareReportRequest.HardwareInfo findHardwareInfoByPublicKey(byte[] pub
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
} catch (SQLException | IOException throwables) {
|
} catch (SQLException | IOException throwables) {
|
||||||
LogHelper.error(throwables);
|
logger.error(throwables);
|
||||||
throw new HWIDException("SQL error. Please try again later");
|
throw new HWIDException("SQL error. Please try again later");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -103,7 +106,7 @@ public void createHardwareInfo(HardwareReportRequest.HardwareInfo hardwareInfo,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (SQLException throwables) {
|
} catch (SQLException throwables) {
|
||||||
LogHelper.error(throwables);
|
logger.error(throwables);
|
||||||
throw new HWIDException("SQL error. Please try again later");
|
throw new HWIDException("SQL error. Please try again later");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -129,7 +132,7 @@ public boolean addPublicKeyToHardwareInfo(HardwareReportRequest.HardwareInfo har
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (SQLException | IOException throwables) {
|
} catch (SQLException | IOException throwables) {
|
||||||
LogHelper.error(throwables);
|
logger.error(throwables);
|
||||||
throw new HWIDException("SQL error. Please try again later");
|
throw new HWIDException("SQL error. Please try again later");
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
import pro.gravit.launchserver.auth.AuthException;
|
import pro.gravit.launchserver.auth.AuthException;
|
||||||
import pro.gravit.launchserver.auth.MySQLSourceConfig;
|
import pro.gravit.launchserver.auth.MySQLSourceConfig;
|
||||||
import pro.gravit.utils.helper.CommonHelper;
|
import pro.gravit.utils.helper.CommonHelper;
|
||||||
import pro.gravit.utils.helper.LogHelper;
|
|
||||||
import pro.gravit.utils.helper.SecurityHelper;
|
import pro.gravit.utils.helper.SecurityHelper;
|
||||||
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
|
@ -25,9 +24,9 @@ public final class MySQLAuthProvider extends AuthProvider {
|
||||||
@Override
|
@Override
|
||||||
public void init(LaunchServer srv) {
|
public void init(LaunchServer srv) {
|
||||||
super.init(srv);
|
super.init(srv);
|
||||||
if (query == null) LogHelper.error("[Verify][AuthProvider] query cannot be null");
|
if (query == null) throw new RuntimeException("[Verify][AuthProvider] query cannot be null");
|
||||||
if (message == null) LogHelper.error("[Verify][AuthProvider] message cannot be null");
|
if (message == null) throw new RuntimeException("[Verify][AuthProvider] message cannot be null");
|
||||||
if (mySQLHolder == null) LogHelper.error("[Verify][AuthProvider] mySQLHolder cannot be null");
|
if (mySQLHolder == null) throw new RuntimeException("[Verify][AuthProvider] mySQLHolder cannot be null");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package pro.gravit.launchserver.auth.provider;
|
package pro.gravit.launchserver.auth.provider;
|
||||||
|
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
import pro.gravit.launcher.ClientPermissions;
|
import pro.gravit.launcher.ClientPermissions;
|
||||||
import pro.gravit.launcher.request.auth.AuthRequest;
|
import pro.gravit.launcher.request.auth.AuthRequest;
|
||||||
import pro.gravit.launchserver.Reconfigurable;
|
import pro.gravit.launchserver.Reconfigurable;
|
||||||
|
@ -17,6 +19,8 @@ public final class RejectAuthProvider extends AuthProvider implements Reconfigur
|
||||||
public String message;
|
public String message;
|
||||||
public ArrayList<String> whitelist = new ArrayList<>();
|
public ArrayList<String> whitelist = new ArrayList<>();
|
||||||
|
|
||||||
|
private transient final Logger logger = LogManager.getLogger();
|
||||||
|
|
||||||
public RejectAuthProvider() {
|
public RejectAuthProvider() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,7 +53,7 @@ public Map<String, Command> getCommands() {
|
||||||
public void invoke(String... args) throws Exception {
|
public void invoke(String... args) throws Exception {
|
||||||
verifyArgs(args, 1);
|
verifyArgs(args, 1);
|
||||||
message = args[0];
|
message = args[0];
|
||||||
LogHelper.info("New reject message: %s", message);
|
logger.info("New reject message: {}", message);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
commands.put("whitelist.add", new SubCommand() {
|
commands.put("whitelist.add", new SubCommand() {
|
||||||
|
@ -57,7 +61,7 @@ public void invoke(String... args) throws Exception {
|
||||||
public void invoke(String... args) throws Exception {
|
public void invoke(String... args) throws Exception {
|
||||||
verifyArgs(args, 1);
|
verifyArgs(args, 1);
|
||||||
whitelist.add(args[0]);
|
whitelist.add(args[0]);
|
||||||
LogHelper.info("%s added to whitelist", args[0]);
|
logger.info("{} added to whitelist", args[0]);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return commands;
|
return commands;
|
||||||
|
|
|
@ -33,8 +33,8 @@ public final class RequestAuthProvider extends AuthProvider {
|
||||||
@Override
|
@Override
|
||||||
public void init(LaunchServer srv) {
|
public void init(LaunchServer srv) {
|
||||||
super.init(srv);
|
super.init(srv);
|
||||||
if (url == null) LogHelper.error("[Verify][AuthProvider] url cannot be null");
|
if (url == null) throw new RuntimeException("[Verify][AuthProvider] url cannot be null");
|
||||||
if (response == null) LogHelper.error("[Verify][AuthProvider] response cannot be null");
|
if (response == null) throw new RuntimeException("[Verify][AuthProvider] response cannot be null");
|
||||||
pattern = Pattern.compile(response);
|
pattern = Pattern.compile(response);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -55,7 +55,6 @@ public Path process(Path inputFile) throws IOException {
|
||||||
|
|
||||||
private void attach(ZipOutputStream output, Path inputFile, List<Path> lst) throws IOException {
|
private void attach(ZipOutputStream output, Path inputFile, List<Path> lst) throws IOException {
|
||||||
for (Path p : lst) {
|
for (Path p : lst) {
|
||||||
LogHelper.debug("Attaching: " + p);
|
|
||||||
AdditionalFixesApplyTask.apply(inputFile, p, output, srv, (e) -> exclusions.stream().anyMatch(e.getName()::startsWith), false);
|
AdditionalFixesApplyTask.apply(inputFile, p, output, srv, (e) -> exclusions.stream().anyMatch(e.getName()::startsWith), false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package pro.gravit.launchserver.binary.tasks;
|
package pro.gravit.launchserver.binary.tasks;
|
||||||
|
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.bouncycastle.asn1.x500.X500Name;
|
import org.bouncycastle.asn1.x500.X500Name;
|
||||||
import org.bouncycastle.asn1.x500.X500NameBuilder;
|
import org.bouncycastle.asn1.x500.X500NameBuilder;
|
||||||
import org.bouncycastle.asn1.x500.style.BCStyle;
|
import org.bouncycastle.asn1.x500.style.BCStyle;
|
||||||
|
@ -17,7 +19,6 @@
|
||||||
import org.bouncycastle.operator.jcajce.JcaContentSignerBuilder;
|
import org.bouncycastle.operator.jcajce.JcaContentSignerBuilder;
|
||||||
import pro.gravit.launchserver.LaunchServer;
|
import pro.gravit.launchserver.LaunchServer;
|
||||||
import pro.gravit.launchserver.helper.SignHelper;
|
import pro.gravit.launchserver.helper.SignHelper;
|
||||||
import pro.gravit.utils.helper.LogHelper;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
|
@ -36,6 +37,8 @@ public class CertificateAutogenTask implements LauncherBuildTask {
|
||||||
public X509Certificate certificate;
|
public X509Certificate certificate;
|
||||||
public X509CertificateHolder bcCertificate;
|
public X509CertificateHolder bcCertificate;
|
||||||
public CMSSignedDataGenerator signedDataGenerator;
|
public CMSSignedDataGenerator signedDataGenerator;
|
||||||
|
|
||||||
|
private transient final Logger logger = LogManager.getLogger();
|
||||||
|
|
||||||
public CertificateAutogenTask(LaunchServer server) {
|
public CertificateAutogenTask(LaunchServer server) {
|
||||||
this.server = server;
|
this.server = server;
|
||||||
|
@ -50,9 +53,9 @@ public String getName() {
|
||||||
public Path process(Path inputFile) throws IOException {
|
public Path process(Path inputFile) throws IOException {
|
||||||
if (signedDataGenerator != null) return inputFile;
|
if (signedDataGenerator != null) return inputFile;
|
||||||
try {
|
try {
|
||||||
LogHelper.warning("You are using an auto-generated certificate (sign.enabled false). It is not good");
|
logger.warn("You are using an auto-generated certificate (sign.enabled false). It is not good");
|
||||||
LogHelper.warning("It is highly recommended that you use the correct certificate (sign.enabled true)");
|
logger.warn("It is highly recommended that you use the correct certificate (sign.enabled true)");
|
||||||
LogHelper.warning("You can use GenerateCertificateModule or your own certificate.");
|
logger.warn("You can use GenerateCertificateModule or your own certificate.");
|
||||||
X500NameBuilder subject = new X500NameBuilder();
|
X500NameBuilder subject = new X500NameBuilder();
|
||||||
subject.addRDN(BCStyle.CN, server.config.projectName.concat(" Autogenerated"));
|
subject.addRDN(BCStyle.CN, server.config.projectName.concat(" Autogenerated"));
|
||||||
subject.addRDN(BCStyle.O, server.config.projectName);
|
subject.addRDN(BCStyle.O, server.config.projectName);
|
||||||
|
@ -63,11 +66,11 @@ public Path process(Path inputFile) throws IOException {
|
||||||
Date.from(startDate.atZone(ZoneId.systemDefault()).toInstant()),
|
Date.from(startDate.atZone(ZoneId.systemDefault()).toInstant()),
|
||||||
Date.from(startDate.plusDays(3650).atZone(ZoneId.systemDefault()).toInstant()),
|
Date.from(startDate.plusDays(3650).atZone(ZoneId.systemDefault()).toInstant()),
|
||||||
new X500Name("CN=ca"),
|
new X500Name("CN=ca"),
|
||||||
SubjectPublicKeyInfo.getInstance(server.publicKey.getEncoded()));
|
SubjectPublicKeyInfo.getInstance(server.keyAgreementManager.ecdsaPublicKey.getEncoded()));
|
||||||
builder.addExtension(Extension.extendedKeyUsage, false, new ExtendedKeyUsage(KeyPurposeId.id_kp_codeSigning));
|
builder.addExtension(Extension.extendedKeyUsage, false, new ExtendedKeyUsage(KeyPurposeId.id_kp_codeSigning));
|
||||||
//builder.addExtension(Extension.keyUsage, false, new KeyUsage(1));
|
//builder.addExtension(Extension.keyUsage, false, new KeyUsage(1));
|
||||||
JcaContentSignerBuilder csBuilder = new JcaContentSignerBuilder("SHA256WITHECDSA");
|
JcaContentSignerBuilder csBuilder = new JcaContentSignerBuilder("SHA256WITHECDSA");
|
||||||
ContentSigner signer = csBuilder.build(server.privateKey);
|
ContentSigner signer = csBuilder.build(server.keyAgreementManager.ecdsaPrivateKey);
|
||||||
bcCertificate = builder.build(signer);
|
bcCertificate = builder.build(signer);
|
||||||
certificate = new JcaX509CertificateConverter().setProvider("BC")
|
certificate = new JcaX509CertificateConverter().setProvider("BC")
|
||||||
.getCertificate(bcCertificate);
|
.getCertificate(bcCertificate);
|
||||||
|
@ -75,7 +78,7 @@ public Path process(Path inputFile) throws IOException {
|
||||||
chain.add(certificate);
|
chain.add(certificate);
|
||||||
signedDataGenerator = SignHelper.createSignedDataGenerator(server.privateKey, certificate, chain, "SHA256WITHECDSA");
|
signedDataGenerator = SignHelper.createSignedDataGenerator(server.privateKey, certificate, chain, "SHA256WITHECDSA");
|
||||||
} catch (OperatorCreationException | CMSException | CertificateException e) {
|
} catch (OperatorCreationException | CMSException | CertificateException e) {
|
||||||
LogHelper.error(e);
|
logger.error(e);
|
||||||
}
|
}
|
||||||
return inputFile;
|
return inputFile;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package pro.gravit.launchserver.binary.tasks;
|
package pro.gravit.launchserver.binary.tasks;
|
||||||
|
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.objectweb.asm.ClassReader;
|
import org.objectweb.asm.ClassReader;
|
||||||
import org.objectweb.asm.ClassWriter;
|
import org.objectweb.asm.ClassWriter;
|
||||||
import org.objectweb.asm.Type;
|
import org.objectweb.asm.Type;
|
||||||
|
@ -34,6 +36,7 @@ public class MainBuildTask implements LauncherBuildTask {
|
||||||
public final IOHookSet<BuildContext> postBuildHook = new IOHookSet<>();
|
public final IOHookSet<BuildContext> postBuildHook = new IOHookSet<>();
|
||||||
public final Map<String, Object> properties = new HashMap<>();
|
public final Map<String, Object> properties = new HashMap<>();
|
||||||
private final LaunchServer server;
|
private final LaunchServer server;
|
||||||
|
private transient final Logger logger = LogManager.getLogger();
|
||||||
|
|
||||||
public MainBuildTask(LaunchServer srv) {
|
public MainBuildTask(LaunchServer srv) {
|
||||||
server = srv;
|
server = srv;
|
||||||
|
@ -58,13 +61,9 @@ public Path process(Path inputJar) throws IOException {
|
||||||
properties.put("launcher.modules", context.clientModules.stream().map(e -> Type.getObjectType(e.replace('.', '/'))).collect(Collectors.toList()));
|
properties.put("launcher.modules", context.clientModules.stream().map(e -> Type.getObjectType(e.replace('.', '/'))).collect(Collectors.toList()));
|
||||||
postInitProps();
|
postInitProps();
|
||||||
reader.getCp().add(new JarFile(inputJar.toFile()));
|
reader.getCp().add(new JarFile(inputJar.toFile()));
|
||||||
server.launcherBinary.coreLibs.forEach(e -> {
|
for(Path e : server.launcherBinary.coreLibs) {
|
||||||
try {
|
reader.getCp().add(new JarFile(e.toFile()));
|
||||||
reader.getCp().add(new JarFile(e.toFile()));
|
};
|
||||||
} catch (IOException e1) {
|
|
||||||
LogHelper.error(e1);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
context.pushJarFile(inputJar, (e) -> blacklist.contains(e.getName()), (e) -> true);
|
context.pushJarFile(inputJar, (e) -> blacklist.contains(e.getName()), (e) -> true);
|
||||||
|
|
||||||
// map for guard
|
// map for guard
|
||||||
|
@ -86,7 +85,7 @@ protected void postInitProps() {
|
||||||
try {
|
try {
|
||||||
return e.getEncoded();
|
return e.getEncoded();
|
||||||
} catch (CertificateEncodingException e2) {
|
} catch (CertificateEncodingException e2) {
|
||||||
LogHelper.error(e2);
|
logger.error(e2);
|
||||||
return new byte[0];
|
return new byte[0];
|
||||||
}
|
}
|
||||||
}).collect(Collectors.toList());
|
}).collect(Collectors.toList());
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
package pro.gravit.launchserver.binary.tasks;
|
package pro.gravit.launchserver.binary.tasks;
|
||||||
|
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
import pro.gravit.launchserver.LaunchServer;
|
import pro.gravit.launchserver.LaunchServer;
|
||||||
import pro.gravit.utils.helper.IOHelper;
|
import pro.gravit.utils.helper.IOHelper;
|
||||||
import pro.gravit.utils.helper.LogHelper;
|
|
||||||
import pro.gravit.utils.helper.UnpackHelper;
|
import pro.gravit.utils.helper.UnpackHelper;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -16,6 +17,7 @@
|
||||||
public class PrepareBuildTask implements LauncherBuildTask {
|
public class PrepareBuildTask implements LauncherBuildTask {
|
||||||
private final LaunchServer server;
|
private final LaunchServer server;
|
||||||
private final Path result;
|
private final Path result;
|
||||||
|
private transient final Logger logger = LogManager.getLogger();
|
||||||
|
|
||||||
public PrepareBuildTask(LaunchServer server) {
|
public PrepareBuildTask(LaunchServer server) {
|
||||||
this.server = server;
|
this.server = server;
|
||||||
|
@ -44,7 +46,7 @@ public boolean allowDelete() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void tryUnpack() throws IOException {
|
public void tryUnpack() throws IOException {
|
||||||
LogHelper.info("Unpacking launcher native guard list and runtime");
|
logger.info("Unpacking launcher native guard list and runtime");
|
||||||
UnpackHelper.unpackZipNoCheck("guard.zip", server.launcherBinary.guardDir);
|
UnpackHelper.unpackZipNoCheck("guard.zip", server.launcherBinary.guardDir);
|
||||||
UnpackHelper.unpackZipNoCheck("runtime.zip", server.launcherBinary.runtimeDir);
|
UnpackHelper.unpackZipNoCheck("runtime.zip", server.launcherBinary.runtimeDir);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package pro.gravit.launchserver.binary.tasks;
|
package pro.gravit.launchserver.binary.tasks;
|
||||||
|
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.bouncycastle.cms.CMSException;
|
import org.bouncycastle.cms.CMSException;
|
||||||
import org.bouncycastle.cms.CMSSignedDataGenerator;
|
import org.bouncycastle.cms.CMSSignedDataGenerator;
|
||||||
import org.bouncycastle.operator.OperatorCreationException;
|
import org.bouncycastle.operator.OperatorCreationException;
|
||||||
|
@ -8,7 +10,6 @@
|
||||||
import pro.gravit.launchserver.config.LaunchServerConfig;
|
import pro.gravit.launchserver.config.LaunchServerConfig;
|
||||||
import pro.gravit.launchserver.helper.SignHelper;
|
import pro.gravit.launchserver.helper.SignHelper;
|
||||||
import pro.gravit.utils.helper.IOHelper;
|
import pro.gravit.utils.helper.IOHelper;
|
||||||
import pro.gravit.utils.helper.LogHelper;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -27,6 +28,7 @@ public class SignJarTask implements LauncherBuildTask {
|
||||||
|
|
||||||
private final LaunchServerConfig.JarSignerConf config;
|
private final LaunchServerConfig.JarSignerConf config;
|
||||||
private final LaunchServer srv;
|
private final LaunchServer srv;
|
||||||
|
private transient static final Logger logger = LogManager.getLogger();
|
||||||
|
|
||||||
public SignJarTask(LaunchServerConfig.JarSignerConf config, LaunchServer srv) {
|
public SignJarTask(LaunchServerConfig.JarSignerConf config, LaunchServer srv) {
|
||||||
this.config = config;
|
this.config = config;
|
||||||
|
@ -39,7 +41,7 @@ public static CMSSignedDataGenerator gen(LaunchServerConfig.JarSignerConf config
|
||||||
config.keyAlias, config.signAlgo, config.keyPass);
|
config.keyAlias, config.signAlgo, config.keyPass);
|
||||||
} catch (CertificateEncodingException | UnrecoverableKeyException | KeyStoreException
|
} catch (CertificateEncodingException | UnrecoverableKeyException | KeyStoreException
|
||||||
| OperatorCreationException | NoSuchAlgorithmException | CMSException e) {
|
| OperatorCreationException | NoSuchAlgorithmException | CMSException e) {
|
||||||
LogHelper.error(e);
|
logger.error(e);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,11 +3,12 @@
|
||||||
import net.sf.launch4j.Builder;
|
import net.sf.launch4j.Builder;
|
||||||
import net.sf.launch4j.Log;
|
import net.sf.launch4j.Log;
|
||||||
import net.sf.launch4j.config.*;
|
import net.sf.launch4j.config.*;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
import pro.gravit.launchserver.LaunchServer;
|
import pro.gravit.launchserver.LaunchServer;
|
||||||
import pro.gravit.launchserver.binary.tasks.LauncherBuildTask;
|
import pro.gravit.launchserver.binary.tasks.LauncherBuildTask;
|
||||||
import pro.gravit.utils.Version;
|
import pro.gravit.utils.Version;
|
||||||
import pro.gravit.utils.helper.IOHelper;
|
import pro.gravit.utils.helper.IOHelper;
|
||||||
import pro.gravit.utils.helper.LogHelper;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
|
@ -18,6 +19,7 @@ public class Launch4JTask implements LauncherBuildTask, BuildExeMainTask {
|
||||||
private static final int BUILD = Version.getVersion().build;
|
private static final int BUILD = Version.getVersion().build;
|
||||||
private final Path faviconFile;
|
private final Path faviconFile;
|
||||||
private final LaunchServer server;
|
private final LaunchServer server;
|
||||||
|
private transient final Logger logger = LogManager.getLogger();
|
||||||
|
|
||||||
public Launch4JTask(LaunchServer launchServer) {
|
public Launch4JTask(LaunchServer launchServer) {
|
||||||
this.server = launchServer;
|
this.server = launchServer;
|
||||||
|
@ -35,7 +37,7 @@ public String getName() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Path process(Path inputFile) throws IOException {
|
public Path process(Path inputFile) throws IOException {
|
||||||
LogHelper.info("Building launcher EXE binary file (Using Launch4J)");
|
logger.info("Building launcher EXE binary file (Using Launch4J)");
|
||||||
Path output = setConfig();
|
Path output = setConfig();
|
||||||
|
|
||||||
// Set favicon path
|
// Set favicon path
|
||||||
|
@ -44,7 +46,7 @@ public Path process(Path inputFile) throws IOException {
|
||||||
config.setIcon(faviconFile.toFile());
|
config.setIcon(faviconFile.toFile());
|
||||||
else {
|
else {
|
||||||
config.setIcon(null);
|
config.setIcon(null);
|
||||||
LogHelper.warning("Missing favicon.ico file");
|
logger.warn("Missing favicon.ico file");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start building
|
// Start building
|
||||||
|
@ -114,10 +116,11 @@ private Path setConfig() {
|
||||||
|
|
||||||
private final static class Launch4JLog extends Log {
|
private final static class Launch4JLog extends Log {
|
||||||
private static final Launch4JLog INSTANCE = new Launch4JLog();
|
private static final Launch4JLog INSTANCE = new Launch4JLog();
|
||||||
|
private static final Logger logger = LogManager.getLogger();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void append(String s) {
|
public void append(String s) {
|
||||||
LogHelper.subInfo(s);
|
logger.info(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
import io.netty.handler.codec.http.HttpRequest;
|
import io.netty.handler.codec.http.HttpRequest;
|
||||||
import io.netty.util.ReferenceCounted;
|
import io.netty.util.ReferenceCounted;
|
||||||
import pro.gravit.launchserver.socket.NettyConnectContext;
|
import pro.gravit.launchserver.socket.NettyConnectContext;
|
||||||
import pro.gravit.utils.helper.LogHelper;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -36,11 +35,8 @@ protected void decode(ChannelHandlerContext ctx, HttpRequest msg, List<Object> o
|
||||||
realIP = headers.get("X-Real-IP");
|
realIP = headers.get("X-Real-IP");
|
||||||
}
|
}
|
||||||
if (realIP != null) {
|
if (realIP != null) {
|
||||||
if (LogHelper.isDevEnabled()) {
|
|
||||||
LogHelper.dev("Real IP address %s", realIP);
|
|
||||||
}
|
|
||||||
context.ip = realIP;
|
context.ip = realIP;
|
||||||
} else LogHelper.error("IpForwarding error. Headers not found");
|
}
|
||||||
out.add(msg);
|
out.add(msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,6 @@
|
||||||
import pro.gravit.launchserver.auth.texture.TextureProvider;
|
import pro.gravit.launchserver.auth.texture.TextureProvider;
|
||||||
import pro.gravit.launchserver.socket.Client;
|
import pro.gravit.launchserver.socket.Client;
|
||||||
import pro.gravit.launchserver.socket.response.SimpleResponse;
|
import pro.gravit.launchserver.socket.response.SimpleResponse;
|
||||||
import pro.gravit.utils.helper.LogHelper;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
@ -23,7 +22,6 @@ public static PlayerProfile getProfile(UUID uuid, String username, String client
|
||||||
try {
|
try {
|
||||||
skin = textureProvider.getSkinTexture(uuid, username, client);
|
skin = textureProvider.getSkinTexture(uuid, username, client);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
LogHelper.error(new IOException(String.format("Can't get skin texture: '%s'", username), e));
|
|
||||||
skin = null;
|
skin = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,7 +30,6 @@ public static PlayerProfile getProfile(UUID uuid, String username, String client
|
||||||
try {
|
try {
|
||||||
cloak = textureProvider.getCloakTexture(uuid, username, client);
|
cloak = textureProvider.getCloakTexture(uuid, username, client);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
LogHelper.error(new IOException(String.format("Can't get cloak texture: '%s'", username), e));
|
|
||||||
cloak = null;
|
cloak = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue