mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-12-23 00:51:01 +03:00
Merge branch 'master' into v4.1.x
This commit is contained in:
commit
46ea7c8500
15 changed files with 98 additions and 33 deletions
|
@ -93,6 +93,8 @@ public static final class Config extends ConfigObject {
|
|||
|
||||
public final int authRateLimitMilis;
|
||||
|
||||
public final ListConfigEntry authLimitExclusions;
|
||||
|
||||
public final String authRejectString;
|
||||
|
||||
public final String projectName;
|
||||
|
@ -122,6 +124,7 @@ private Config(BlockConfigEntry block, Path coredir, LaunchServer server) {
|
|||
VerifyHelper.range(0, 1000000), "Illegal authRateLimit");
|
||||
authRateLimitMilis = VerifyHelper.verifyInt(block.getEntryValue("authRateLimitMilis", IntegerConfigEntry.class),
|
||||
VerifyHelper.range(10, 10000000), "Illegal authRateLimitMillis");
|
||||
authLimitExclusions = block.hasEntry("authLimitExclusions") ? block.getEntry("authLimitExclusions", ListConfigEntry.class) : null;
|
||||
bindAddress = block.hasEntry("bindAddress") ?
|
||||
block.getEntryValue("bindAddress", StringConfigEntry.class) : getAddress();
|
||||
authRejectString = block.hasEntry("authRejectString") ?
|
||||
|
@ -129,7 +132,6 @@ private Config(BlockConfigEntry block, Path coredir, LaunchServer server) {
|
|||
whitelistRejectString = block.hasEntry("whitelistRejectString") ?
|
||||
block.getEntryValue("whitelistRejectString", StringConfigEntry.class) : "Вас нет в белом списке";
|
||||
|
||||
|
||||
// Set handlers & providers
|
||||
authHandler = new AuthHandler[1];
|
||||
authHandler[0] = AuthHandler.newHandler(block.getEntryValue("authHandler", StringConfigEntry.class),
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
package ru.gravit.launchserver.auth;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import ru.gravit.launcher.NeedGarbageCollection;
|
||||
import ru.gravit.launcher.serialize.config.entry.StringConfigEntry;
|
||||
import ru.gravit.launchserver.LaunchServer;
|
||||
|
||||
public class AuthLimiter implements NeedGarbageCollection {
|
||||
|
@ -50,10 +53,13 @@ public String toString() {
|
|||
public final int rateLimit;
|
||||
public final int rateLimitMilis;
|
||||
|
||||
private HashMap<String, AuthEntry> map;
|
||||
private final HashMap<String, AuthEntry> map;
|
||||
private final List<String> excludeIps;
|
||||
|
||||
public AuthLimiter(LaunchServer srv) {
|
||||
map = new HashMap<>();
|
||||
excludeIps = new ArrayList<>();
|
||||
if (srv.config.authLimitExclusions != null) srv.config.authLimitExclusions.stream(StringConfigEntry.class).forEach(excludeIps::add);
|
||||
rateLimit = srv.config.authRateLimit;
|
||||
rateLimitMilis = srv.config.authRateLimitMilis;
|
||||
}
|
||||
|
@ -66,6 +72,7 @@ public void garbageCollection() {
|
|||
}
|
||||
|
||||
public boolean isLimit(String ip) {
|
||||
if (excludeIps.contains(ip)) return false;
|
||||
if (map.containsKey(ip)) {
|
||||
AuthEntry rate = map.get(ip);
|
||||
long currenttime = System.currentTimeMillis();
|
||||
|
|
|
@ -53,10 +53,8 @@ protected AuthHandler(BlockConfigEntry block) {
|
|||
super(block);
|
||||
}
|
||||
|
||||
|
||||
public abstract UUID auth(AuthProviderResult authResult) throws IOException;
|
||||
|
||||
|
||||
public abstract UUID checkServer(String username, String serverID) throws IOException;
|
||||
|
||||
@Override
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
public final class MySQLAuthProvider extends AuthProvider {
|
||||
private final MySQLSourceConfig mySQLHolder;
|
||||
private final String query;
|
||||
private final String message;
|
||||
private final String[] queryParams;
|
||||
private final boolean usePermission;
|
||||
|
||||
|
@ -31,6 +32,7 @@ public MySQLAuthProvider(BlockConfigEntry block, LaunchServer server) {
|
|||
query = VerifyHelper.verify(block.getEntryValue("query", StringConfigEntry.class),
|
||||
VerifyHelper.NOT_EMPTY, "MySQL query can't be empty");
|
||||
usePermission = block.hasEntry("usePermission") ? block.getEntryValue("usePermission", BooleanConfigEntry.class) : false;
|
||||
message = block.hasEntry("message") ? block.getEntryValue("message", StringConfigEntry.class) : "Incorrect username or password";
|
||||
queryParams = block.getEntry("queryParams", ListConfigEntry.class).
|
||||
stream(StringConfigEntry.class).toArray(String[]::new);
|
||||
}
|
||||
|
@ -46,7 +48,7 @@ public AuthProviderResult auth(String login, String password, String ip) throws
|
|||
// Execute SQL query
|
||||
s.setQueryTimeout(MySQLSourceConfig.TIMEOUT);
|
||||
try (ResultSet set = s.executeQuery()) {
|
||||
return set.next() ? new AuthProviderResult(set.getString(1), SecurityHelper.randomStringToken(), usePermission ? new ClientPermissions(set.getLong(2)) : new ClientPermissions()) : authError("Incorrect username or password");
|
||||
return set.next() ? new AuthProviderResult(set.getString(1), SecurityHelper.randomStringToken(), usePermission ? new ClientPermissions(set.getLong(2)) : new ClientPermissions()) : authError(message);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -276,19 +276,25 @@ function updateProfilesList(profiles) {
|
|||
profilesList = [];
|
||||
// Set profiles items
|
||||
serverList.getChildren().clear();
|
||||
var index = 0;
|
||||
profiles.forEach(function (profile, i, arr) {
|
||||
pingers[profile.object] = new ServerPinger(profile.object.getServerSocketAddress(), profile.object.getVersion());
|
||||
var serverBtn = new javafx.scene.control.ToggleButton(profile);
|
||||
(function () {
|
||||
profilesList[serverBtn] = profile;
|
||||
var hold = serverBtn;
|
||||
var hIndex = index;
|
||||
serverBtn.setOnAction(function (event) {
|
||||
serverHolder.set(hold);
|
||||
settings.profile = hIndex;
|
||||
});
|
||||
})();
|
||||
serverList.getChildren().add(serverBtn);
|
||||
index++;
|
||||
});
|
||||
serverHolder.set(serverList.getChildren().get(0));
|
||||
LogHelper.debug("Load selected %d profile",settings.profile);
|
||||
if(profiles.length > 0)
|
||||
serverHolder.set(serverList.getChildren().get(settings.profile));
|
||||
}
|
||||
|
||||
function pingServer(btn) {
|
||||
|
@ -417,4 +423,4 @@ launcher.loadScript("dialog/overlay/debug/debug.js");
|
|||
launcher.loadScript("dialog/overlay/processing/processing.js");
|
||||
launcher.loadScript("dialog/overlay/settings/settings.js");
|
||||
launcher.loadScript("dialog/overlay/options/options.js");
|
||||
launcher.loadScript("dialog/overlay/update/update.js");
|
||||
launcher.loadScript("dialog/overlay/update/update.js");
|
||||
|
|
|
@ -79,7 +79,7 @@ var options = {
|
|||
|
||||
initOverlay: function() {
|
||||
options.overlay = loadFXML("dialog/overlay/options/options.fxml");
|
||||
var holder = options.overlay.lookup("#holder");
|
||||
var holder = options.overlay.lookup("#holder");
|
||||
holder.lookup("#apply").setOnAction(function(event) overlay.hide(0, null));
|
||||
},
|
||||
update: function() {
|
||||
|
@ -188,8 +188,10 @@ var options = {
|
|||
modIDs.forEach(function(key, id) {
|
||||
if(modList[key] != null && modList[key].subTreeLevel != null) {
|
||||
if( modList[key].subTreeLevel > modInfo.subTreeLevel && modIDs.indexOf(key) > modIDs.indexOf(ImodFile) && enable == false && stop == false) {
|
||||
profile.unmarkOptional(key);
|
||||
LogHelper.debug("Unselected subMod %s", key);
|
||||
if(options.modExists(key)){
|
||||
profile.unmarkOptional(key);
|
||||
LogHelper.debug("Unselected subMod %s", key);
|
||||
}
|
||||
} else if(modIDs.indexOf(key) > modIDs.indexOf(ImodFile) && modList[key].subTreeLevel <= modInfo.subTreeLevel && stop == false) {
|
||||
//LogHelper.debug("STOP disable!! " + key);
|
||||
stop = true;
|
||||
|
@ -202,8 +204,10 @@ var options = {
|
|||
modIDs.forEach(function(key, id) {
|
||||
if(modList[key] != null && modList[key].onlyOneGroup != null) {
|
||||
if(modList[key].onlyOneGroup == modInfo.onlyOneGroup && modList[key].onlyOne == true && enable == true && key != ImodFile) {
|
||||
profile.unmarkOptional(key);
|
||||
LogHelper.debug("Unselected Mod (onlyOne toggle) %s", key);
|
||||
if(options.modExists(key)) {
|
||||
profile.unmarkOptional(key);
|
||||
LogHelper.debug("Unselected Mod (onlyOne toggle) %s", key);
|
||||
}
|
||||
options.treeToggle(false, key); //И все его подмодификации канут в Лету..
|
||||
}
|
||||
}
|
||||
|
@ -216,8 +220,10 @@ var options = {
|
|||
reverseModList.forEach(function(key, id) {
|
||||
if(modList[key] != null && modList[key].subTreeLevel != null) {
|
||||
if(modList[key].subTreeLevel == tsl && modIDs.indexOf(key) < modIDs.indexOf(ImodFile) && enable == true) {
|
||||
profile.markOptional(key);
|
||||
LogHelper.debug("Selected coreMod %s", key);
|
||||
if(options.modExists(key)) {
|
||||
profile.markOptional(key);
|
||||
LogHelper.debug("Selected coreMod %s", key);
|
||||
}
|
||||
options.treeToggle(true, key); //Для срабатывания onlyOne-модификаций.
|
||||
tsl--;
|
||||
}
|
||||
|
@ -227,6 +233,17 @@ var options = {
|
|||
|
||||
}
|
||||
}
|
||||
},
|
||||
modExists: function(key){
|
||||
var profile = profilesList[serverHolder.old].object;
|
||||
var list = profile.getOptional();
|
||||
var result = false;
|
||||
list.forEach(function(modFile) {
|
||||
if(modFile.string === key) {
|
||||
result = true;
|
||||
}
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
};
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
#holder {
|
||||
-fx-background-color: #fff;
|
||||
}
|
||||
#holder > #transferDialog {
|
||||
-fx-background-color: RGBA(0, 0, 0, 0.9);
|
||||
}
|
||||
/* Labels */
|
||||
#holder > #settingsTitle {
|
||||
-fx-font-size: 14pt;
|
||||
|
@ -37,14 +40,14 @@ #holder > #ramSlider:pressed > .thumb {
|
|||
}
|
||||
|
||||
/* Dir options */
|
||||
#holder > #deleteDir {
|
||||
#holder > #deleteDir, #cancelTransfer {
|
||||
-fx-background-color: #CE5757;
|
||||
-fx-text-fill: white;
|
||||
-fx-background-radius: 0;
|
||||
}
|
||||
|
||||
#holder > #deleteDir:hover,
|
||||
#holder > #deleteDir:focused {
|
||||
#holder > #deleteDir:hover,#cancelTransfer:hover,
|
||||
#holder > #deleteDir:focused,#cancelTransfer:focused {
|
||||
-fx-opacity: 0.8;
|
||||
}
|
||||
|
||||
|
@ -63,13 +66,13 @@ #holder > #changeDir:pressed {
|
|||
-fx-opacity: 0.8;
|
||||
}
|
||||
|
||||
#holder > #apply{
|
||||
#holder > #apply,#applyTransfer{
|
||||
-fx-background-color: #61B373;
|
||||
-fx-text-fill: #fff;
|
||||
-fx-background-radius: 0;
|
||||
}
|
||||
#holder > #apply:hover,
|
||||
#holder > #apply:focused{
|
||||
#holder > #apply:hover,#applyTransfer:hover,
|
||||
#holder > #apply:focused,#applyTransfer:focused{
|
||||
-fx-background-color: #74C085;
|
||||
}
|
||||
|
||||
|
|
|
@ -47,6 +47,17 @@
|
|||
|
||||
<Button fx:id="apply" defaultButton="true" layoutX="486.0" layoutY="335.0" prefHeight="23.0" prefWidth="100.0" text="Применить" />
|
||||
<Text layoutX="17.0" layoutY="19.0">Выделение памяти: </Text>
|
||||
<Pane fx:id="transferDialog" prefHeight="371.0" prefWidth="598.0">
|
||||
<children>
|
||||
<Text fill="WHITE" layoutX="99.0" layoutY="155.0" strokeType="OUTSIDE" strokeWidth="0.0" text="Перенести все данные в новую директорию?" wrappingWidth="400.13671875">
|
||||
<font>
|
||||
<Font size="19.0" />
|
||||
</font>
|
||||
</Text>
|
||||
<Button fx:id="applyTransfer" layoutX="130.0" layoutY="186.0" mnemonicParsing="false" prefHeight="25.0" prefWidth="124.0" text="Да, перенести!" />
|
||||
<Button fx:id="cancelTransfer" layoutX="344.0" layoutY="186.0" mnemonicParsing="false" prefHeight="25.0" prefWidth="124.0" text="Нет, не нужно." />
|
||||
</children>
|
||||
</Pane>
|
||||
|
||||
</children>
|
||||
</Pane>
|
||||
|
|
|
@ -37,7 +37,7 @@ var settingsClass = Java.extend(LauncherSettingsClass.static, {
|
|||
});
|
||||
var settingsOverlay = {
|
||||
/* ===================== OVERLAY ===================== */
|
||||
overlay: null, ramLabel: null, dirLabel: null,
|
||||
overlay: null, ramLabel: null, dirLabel: null, transferDialog: null,
|
||||
deleteDirPressedAgain: false, count: 0,
|
||||
|
||||
initOverlay: function() {
|
||||
|
@ -56,6 +56,10 @@ var settingsOverlay = {
|
|||
settingsOverlay.dirLabel.setOnAction(function(event)
|
||||
app.getHostServices().showDocument(settings.updatesDir.toUri()));
|
||||
settingsOverlay.updateDirLabel();
|
||||
|
||||
// Lokup transferDialog pane
|
||||
settingsOverlay.transferDialog = holder.lookup("#transferDialog");
|
||||
settingsOverlay.transferDialog.setVisible(false);
|
||||
|
||||
// Lookup change dir button
|
||||
holder.lookup("#changeDir").setOnAction(function(event) {
|
||||
|
@ -66,6 +70,7 @@ var settingsOverlay = {
|
|||
// Set new result
|
||||
var newDir = chooser.showDialog(stage);
|
||||
if (newDir !== null) {
|
||||
settingsOverlay.transferCatalogDialog();
|
||||
settings.updatesDir = newDir.toPath();
|
||||
settingsOverlay.updateDirLabel();
|
||||
}
|
||||
|
@ -132,6 +137,15 @@ var settingsOverlay = {
|
|||
holder.lookup("#apply").setOnAction(function(event) overlay.hide(0, null));
|
||||
},
|
||||
|
||||
transferCatalogDialog: function() {
|
||||
settingsOverlay.transferDialog.setVisible(true);
|
||||
settingsOverlay.transferDialog.lookup("#cancelTransfer").setOnAction(function(event) settingsOverlay.transferDialog.setVisible(false));
|
||||
settingsOverlay.transferDialog.lookup("#applyTransfer").setOnAction(function(event) {
|
||||
//Здесь могла быть ваша реклама, либо DirBridge.move();
|
||||
settingsOverlay.transferDialog.setVisible(false);
|
||||
});
|
||||
},
|
||||
|
||||
updateRAMLabel: function() {
|
||||
settingsOverlay.ramLabel.setText(settings.ram <= 0 ? "Автоматически" : settings.ram + " MiB");
|
||||
},
|
||||
|
|
|
@ -67,18 +67,24 @@ var EnvHelper = EnvHelperClass.static;
|
|||
var SecurityHelper = SecurityHelperClass.static;
|
||||
var DigestAlgorithm = DigestAlgorithmClass.static;
|
||||
var VerifyHelper = VerifyHelperClass.static;
|
||||
var CheckComboBox = CheckComboBoxClass.static;
|
||||
var CheckModel = CheckModelClass.static;
|
||||
var IndexedCheckModel = IndexedCheckModelClass.static;
|
||||
var CheckComboBoxSkin = CheckComboBoxSkinClass.static;
|
||||
var RingProgressIndicator = RingProgressIndicatorClass.static;
|
||||
var RingProgressIndicatorSkin = RingProgressIndicatorSkinClass.static;
|
||||
var LauncherSettings = LauncherSettingsClass.static;
|
||||
|
||||
// Helper JS class API imports
|
||||
var JSApplication = null;
|
||||
var CheckComboBox = null;
|
||||
var CheckModel = null;
|
||||
var IndexedCheckModel = null;
|
||||
var CheckComboBoxSkin = null;
|
||||
var RingProgressIndicator = null;
|
||||
var RingProgressIndicatorSkin = null;
|
||||
if (typeof JSApplicationClass !== 'undefined') {
|
||||
JSApplication = JSApplicationClass.static;
|
||||
CheckComboBox = CheckComboBoxClass.static;
|
||||
CheckModel = CheckModelClass.static;
|
||||
IndexedCheckModel = IndexedCheckModelClass.static;
|
||||
CheckComboBoxSkin = CheckComboBoxSkinClass.static;
|
||||
RingProgressIndicator = RingProgressIndicatorClass.static;
|
||||
RingProgressIndicatorSkin = RingProgressIndicatorSkinClass.static;
|
||||
}
|
||||
|
||||
// API wrapper
|
||||
|
|
|
@ -364,9 +364,9 @@ else if (isDownloadJava) {
|
|||
Collections.addAll(args, profile.object.getJvmArgs());
|
||||
Collections.addAll(args, "-Djava.library.path=".concat(params.clientDir.resolve(NATIVES_DIR).toString())); // Add Native Path
|
||||
Collections.addAll(args, "-javaagent:".concat(pathLauncher));
|
||||
//Collections.addAll(args, "-classpath", classPathString.toString());
|
||||
//if(wrapper)
|
||||
//Collections.addAll(args, "-Djava.class.path=".concat(classPathString.toString())); // Add Class Path
|
||||
Collections.addAll(args, "-classpath", pathLauncher);
|
||||
if(wrapper)
|
||||
Collections.addAll(args, "-Djava.class.path=".concat(pathLauncher)); // Add Class Path
|
||||
Collections.addAll(args, ClientLauncher.class.getName());
|
||||
|
||||
// Print commandline debug message
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
import javafx.scene.shape.Arc;
|
||||
import javafx.scene.shape.Circle;
|
||||
import javafx.util.Duration;
|
||||
import ru.gravit.launcher.LauncherAPI;
|
||||
|
||||
/**
|
||||
* Skin of the ring progress indicator where an arc grows and by the progress value up to 100% where the arc becomes a ring.
|
||||
|
|
|
@ -66,7 +66,7 @@ static int readBuildNumber() {
|
|||
private static final Pattern UUID_PATTERN = Pattern.compile("-", Pattern.LITERAL);
|
||||
public static int MAJOR = 4;
|
||||
public static int MINOR = 0;
|
||||
public static int PATCH = 7;
|
||||
public static int PATCH = 8;
|
||||
public static int BUILD = readBuildNumber();
|
||||
public static Version.Type RELEASE = Version.Type.STABLE;
|
||||
|
||||
|
|
2
modules
2
modules
|
@ -1 +1 @@
|
|||
Subproject commit dd97153ee53813078391aa07d1700f890e979e3f
|
||||
Subproject commit f4ff154d105248c5bcb3a4cb217b38eed01b3a27
|
Loading…
Reference in a new issue