-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Custom Discord Backend URLs #187
Labels
rejected (not possible)
Not possible due to technical limiations
rejected (other)
This doesn't seem right
Comments
Sadly plugins load too late which makes it not possible. diff --git a/Injector/src/main/java/com/aliucord/injector/Injector.java b/Injector/src/main/java/com/aliucord/injector/Injector.java
index 035b56d..33c4f2e 100644
--- a/Injector/src/main/java/com/aliucord/injector/Injector.java
+++ b/Injector/src/main/java/com/aliucord/injector/Injector.java
@@ -13,6 +13,9 @@ import android.util.Log;
import android.widget.Toast;
import com.discord.app.AppActivity;
+import com.discord.gateway.rest.RestConfig;
+import com.discord.restapi.RequiredHeadersInterceptor;
+import com.discord.restapi.RestAPIBuilder;
import com.discord.stores.StoreClientVersion;
import com.discord.stores.StoreStream;
@@ -22,6 +25,7 @@ import org.json.JSONTokener;
import java.io.*;
import java.net.HttpURLConnection;
import java.net.URL;
+import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;
import dalvik.system.BaseDexClassLoader;
@@ -37,6 +41,9 @@ public final class Injector {
private static MethodHook.Unhook unhook;
+ private static final String host = "http://192.168.0.101:8000";
+ private static final String hostApi = host + "/api/";
+
public static void init() {
PineConfig.debug = new File(BASE_DIRECTORY, ".pine_debug").exists();
PineConfig.debuggable = new File(BASE_DIRECTORY, ".debuggable").exists();
@@ -54,6 +61,30 @@ public final class Injector {
unhook = null;
}
});
+
+ var buildConfig = com.discord.BuildConfig.class;
+ var hostField = buildConfig.getDeclaredField("HOST");
+ hostField.setAccessible(true);
+ hostField.set(null, host);
+ var hostApiField = buildConfig.getDeclaredField("HOST_API");
+ hostApiField.setAccessible(true);
+ hostApiField.set(null, hostApi);
+
+ var aField = c.a.d.m0.b.class.getDeclaredField("a");
+ aField.setAccessible(true);
+ aField.set(null, host);
+
+ Pine.hook(RestConfig.class.getDeclaredConstructor(String.class, RequiredHeadersInterceptor.HeadersProvider.class, List.class), new MethodHook() {
+ public void beforeCall(Pine.CallFrame callFrame) {
+ callFrame.args[0] = hostApi;
+ }
+ });
+
+ Pine.hook(RestAPIBuilder.class.getDeclaredConstructor(String.class, f0.p.class), new MethodHook() {
+ public void beforeCall(Pine.CallFrame callFrame) {
+ if (callFrame.args[0].equals("https://discord.com/api/")) callFrame.args[0] = hostApi;
+ }
+ });
} catch (Throwable th) {
Log.e(LOG_TAG, "Failed to initialize Aliucord", th);
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
rejected (not possible)
Not possible due to technical limiations
rejected (other)
This doesn't seem right
Discord Account
NurMarvin#1337
Plugin Description
Basically swaps out the URLs to Discord's backend, e.g. the REST API or Gateway to something else of your choice, like a self hosted Litecord instance or similar.
Go into more detail...
As already mentioned, this plugin should let you change the URLs to each individual Discord backend URL, e.g. the REST API, which is
https://discord.com/api
normally, or the gateway URL, whichwss://gateway.discord.gg
normally, to something of your choice via a config file. Changing it via inputs in the app would probably also be nice, but shouldn't be the only way, since changing it to something invalid could render the app useless and the inputs to change the URLs back inaccessible.Request Agreement
The text was updated successfully, but these errors were encountered: