Skip to content

Commit

Permalink
Update mps, fix ssl problems and use v3.mps.dynamx.fr for mps backend
Browse files Browse the repository at this point in the history
  • Loading branch information
AymericBdy committed Jul 5, 2024
1 parent d251e09 commit f920648
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 9 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ dependencies {

implementation 'com.github.stephengold:Libbulletjme:' + libbulletjme_version
implementation "fr.aym.acsguis:ACsGuis:1.2.12"
implementation ":ModProtectionLib:1.4.1"
implementation ":ModProtectionLib:1.4.2"
implementation('org.spongepowered:mixin:0.8.3') {
exclude module: 'guava'
exclude module: 'commons-io'
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ minecraft_version=1.12.2
version_suffix=SYNC
version_major=4
version_minor=1
version_patch=0-dev26
version_patch=0-dev27
libbulletjme_version=18.1.0

mavenArtifactId=DynamX
Expand Down
Binary file removed libs/ModProtectionLib-1.4.1.jar
Binary file not shown.
Binary file added libs/ModProtectionLib-1.4.2.jar
Binary file not shown.
16 changes: 11 additions & 5 deletions src/main/java/fr/dynamx/utils/DynamXConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import net.minecraftforge.fml.common.versioning.ArtifactVersion;
import net.minecraftforge.fml.common.versioning.DefaultArtifactVersion;

import java.util.function.Function;

public class DynamXConstants
{
public static final String NAME = "DynamX";
Expand All @@ -11,11 +13,11 @@ public class DynamXConstants
public static final String VERSION_TYPE = "Beta";
public static final String RES_DIR_NAME = "DynamX";

public static final String ACS_GUIS_BASE_URL = "https://mps.dynamx.fr/files/4.0.0/ACsGuis/ACsGuis-%s-all.jar";//"https://maven.dynamx.fr/artifactory/ACsGuisRepo/fr/aym/acsguis/ACsGuis/%1$s/ACsGuis-%1$s.jar";
public static final String DEFAULT_ACSGUIS_VERSION = "1.2.12";
public static final String ACS_GUIS_BASE_URL = "https://v3.mps.dynamx.fr/files/4.0.0/ACsGuis/ACsGuis-%s-all.jar";//"https://maven.dynamx.fr/artifactory/ACsGuisRepo/fr/aym/acsguis/ACsGuis/%1$s/ACsGuis-%1$s.jar";
public static final String DEFAULT_ACSGUIS_VERSION = "1.2.13";
public static final String ACSLIBS_REQUIRED_VERSION = "[1.2.12,)";

public static final String LIBBULLET_BASE_URL = "https://mps.dynamx.fr/files/4.0.0/LibBullet/";
public static final String LIBBULLET_BASE_URL = "https://v3.mps.dynamx.fr/files/4.0.0/LibBullet/";

public static final String LIBBULLET_VERSION = "18.1.0";
/** .dc file version, only change when an update of libbullet breaks the .dc files, to regenerate them */
Expand All @@ -26,13 +28,17 @@ public class DynamXConstants
public static final ArtifactVersion PACK_LOADER_VERSION = new DefaultArtifactVersion("1.1.0");

/**
* FIXME NOTE
* FIXME NOTE <br>
* We keep the lets-encrypt-r3.der certificate for the backup mps2.dynamx.fr domain, which is valid until September 2024 <br>
* It will be then replaced by a certificate signed by the DynamX Root CA
* It will be then replaced by a certificate signed by the DynamX Root CA <br>
* <br>
* Also, for compatibility reasons, the main mps url is still mps.dynamx.fr, but mps dynamically rewrites it to v3.mps.dynamx.fr which has a valid DynamXRootCA certificate <br>
* This rewrite will stay "hidden" and the new packs still need to be ciphered using the mps.dynamx.fr url
*/
public static final String DYNAMX_CERT = "certs/DynamXRootCA.crt", DYNAMX_AUX_CERT = "certs/lets-encrypt-r3.der";

public static final String MPS_URL = "https://mps.dynamx.fr/legacy/", OLD_MPS_URL = "https://dynamx.fr/mps/", MPS_AUX_URL = "https://mps2.dynamx.fr/legacy/", MPS_KEY = "VGZQNFY5UEJ1YmVLTlpwWC1BQ1JFLTQ=", MPS_STARTER = null;
public static final Function<String, String> MPS_URL_PATCHER = url -> url.replace("https://mps.dynamx.fr/", "https://v3.mps.dynamx.fr/");

public static final String STATS_URL = "https://dynamx.fr/statsbot/statsbotrcv.php", STATS_PRODUCT = "DNX_"+VERSION+"_BETA", STATS_TOKEN = "ZG54OnN0YWJkOTg=";

Expand Down
37 changes: 35 additions & 2 deletions src/main/java/fr/dynamx/utils/DynamXMpsConfig.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,45 @@
package fr.dynamx.utils;

import fr.aym.acslib.api.services.mps.ModProtectionConfig;
import fr.aym.acslib.api.services.mps.ModProtectionContainer;
import fr.aym.mps.core.BasicMpsConfig;
import fr.aym.mps.utils.ProtectionException;
import fr.aym.mps.utils.MpsUrlFactory;

import javax.annotation.Nullable;
import java.net.MalformedURLException;
import java.net.URL;

import static fr.dynamx.utils.DynamXConstants.*;

public class DynamXMpsConfig extends BasicMpsConfig {
public DynamXMpsConfig() {
super(VERSION, MPS_KEY, null, MPS_URL, new String[]{MPS_AUX_URL}, new String[0], MPS_STARTER);
super(VERSION, MPS_KEY, null, new DynamXMpsUrlFactory(MPS_URL, new String[]{MPS_AUX_URL}), new String[0], MPS_STARTER);
}

public static class DynamXMpsUrlFactory extends MpsUrlFactory.DefaultUrlFactory {
public DynamXMpsUrlFactory(String mainUrl, String[] auxUrls) {
super(mainUrl, auxUrls);
}

public String getPatchedMainUrl() {
return MPS_URL_PATCHER.apply(this.getMainUrl());
}

@Override
public URL getHomeUrl(ModProtectionConfig config, int attempt) throws MalformedURLException {
String mpsURL = attempt > -1 ? getAuxUrls()[attempt] : getPatchedMainUrl();
return new URL(mpsURL + config.getMpsVersion() + "/home.php?access_key=" + config.getMpsAccessKey());
}

@Override
public URL getResourceUrl(ModProtectionConfig config, int attempt, String encodedModVersion, String resource, @Nullable ModProtectionContainer.CustomRepoParams params) throws MalformedURLException {
if (params != null) {
if (attempt == -1)
return new URL(MPS_URL_PATCHER.apply(params.getDomain()) + resource);
return new URL(params.getDomain().replace(getMainUrl(), getAuxUrls()[attempt]) + resource); //apply aux url
}
String mpsURL = (attempt > -1 ? getAuxUrls()[attempt] : getPatchedMainUrl());
return new URL(mpsURL + config.getMpsVersion() + "/router.php?mod_version=" + encodedModVersion + "&target=" + resource);
}
}
}

0 comments on commit f920648

Please sign in to comment.