Skip to content
This repository has been archived by the owner on Dec 26, 2017. It is now read-only.

Commit

Permalink
Merge pull request #13 from fehnomenal/master
Browse files Browse the repository at this point in the history
Only rewrite pogo urls
  • Loading branch information
rastapasta authored Aug 24, 2016
2 parents e536c55 + b89bf78 commit 065268e
Showing 1 changed file with 13 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
package de.rastapasta.android.xposed.pokemongo;

import de.robv.android.xposed.XC_MethodHook;
import de.robv.android.xposed.XSharedPreferences;
import de.robv.android.xposed.XposedBridge;

public class DoSyncRequestHook extends XC_MethodHook {

private static final String DEFAULT_URL = "pgorelease.nianticlabs.com";

@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
/** arg[0] = object long
Expand All @@ -15,23 +19,22 @@ protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
arg[6] = bytebuffer body offset int
arg[7] = bytebuffer body size int **/

XposedBridge.log("Intercepted request to "+(String)param.args[2]);

XSharedPreferences pref = new XSharedPreferences(DoSyncRequestHook.class.getPackage().getName(), "preferences");
pref.makeWorldReadable();
pref.reload();

String request = ((String)param.args[2]).substring(34);
XposedBridge.log("URL part: "+request);

if (pref.getBoolean("enable_endpoint", false)) {
String endpoint = pref.getString("endpoint", "pgorelease.nianticlabs.com");
String url = pref.getBoolean("enable_ssl", false) ? "https://" : "http://";
final String url = (String) param.args[2];
final String[] parts = url.split(DEFAULT_URL);
if (parts.length == 2) {
XposedBridge.log("Intercepted request to " + url);

url += endpoint + request;
XposedBridge.log("Rewriting URL to "+url);
final String scheme = pref.getBoolean("enable_ssl", false) ? "https://" : "http://";
final String endpoint = pref.getString("endpoint", DEFAULT_URL);
param.args[2] = scheme + endpoint + parts[1];

param.args[2] = url;
XposedBridge.log("Rewriting URL to " + param.args[2]);
}
}
}
}

0 comments on commit 065268e

Please sign in to comment.