-
Notifications
You must be signed in to change notification settings - Fork 230
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1、修复7.X、8.X版本运存消耗过大导致Node意外退出导致代理失效的虫子(强烈建议不是追求最新功能的童鞋使用6.X及以下版本,总觉得一…
…直在更新一些没用的功能还很消耗运存) 2、增加白名单模式,取消打勾后所有URL都走代理 3、增加同步锁,降低数据库频繁开关造成的错误
- Loading branch information
Showing
4 changed files
with
34 additions
and
22 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
package com.raincat.dolby_beta.hook; | ||
|
||
import android.app.Activity; | ||
import android.content.Context; | ||
import android.os.Bundle; | ||
|
||
|
@@ -20,14 +21,12 @@ | |
import de.robv.android.xposed.XC_MethodHook; | ||
|
||
import static de.robv.android.xposed.XposedBridge.hookAllConstructors; | ||
import static de.robv.android.xposed.XposedBridge.log; | ||
import static de.robv.android.xposed.XposedHelpers.findAndHookMethod; | ||
import static de.robv.android.xposed.XposedHelpers.findClass; | ||
|
||
/** | ||
* <pre> | ||
* author : RainCat | ||
* org : Shenzhen JingYu Network Technology Co., Ltd. | ||
* e-mail : [email protected] | ||
* time : 2021/03/10 | ||
* desc : 音乐代理hook | ||
|
@@ -41,6 +40,8 @@ public class UnblockMusicHook { | |
|
||
private static String dataPath; | ||
private static SSLSocketFactory socketFactory; | ||
private static Object objectProxy; | ||
private static Object objectSSLSocketFactory; | ||
|
||
private final String classMainActivity = "com.netease.cloudmusic.activity.MainActivity"; | ||
private String classRealCall; | ||
|
@@ -49,7 +50,6 @@ public class UnblockMusicHook { | |
private String fieldSSLSocketFactory; | ||
|
||
private final List<String> whiteUrlList = Arrays.asList( | ||
// Should be enough for most cases | ||
"song/enhance/player/url", "song/enhance/download/url"); | ||
|
||
public UnblockMusicHook(Context context, int versionCode, boolean isPlayProcess) { | ||
|
@@ -79,8 +79,6 @@ protected void beforeHookedMethod(MethodHookParam param) throws Throwable { | |
urlField.setAccessible(true); | ||
Field proxyField = client.getClass().getDeclaredField(fieldProxy); | ||
proxyField.setAccessible(true); | ||
Field sslSocketFactoryField = client.getClass().getDeclaredField(fieldSSLSocketFactory); | ||
sslSocketFactoryField.setAccessible(true); | ||
|
||
Object urlObj = urlField.get(request); | ||
|
||
|
@@ -90,17 +88,27 @@ protected void beforeHookedMethod(MethodHookParam param) throws Throwable { | |
if (ExtraDao.getInstance(context).getExtra("ScriptRunning").equals("1")) | ||
proxyField.set(client, proxy); | ||
else | ||
Tools.showToastOnLooper(context, "node未成功运行,请到模块内选择正确的脚本与Node路径!若已使用存储重定向等APP请保证网易云音乐也可访问到脚本路径!"); | ||
return; | ||
Tools.showToastOnLooper(context, "node未成功运行,请到模块内选择正确的脚本与Node路径,若已使用存储重定向等APP请保证网易云音乐也可访问到脚本路径!"); | ||
break; | ||
} | ||
} | ||
} else { | ||
if (ExtraDao.getInstance(context).getExtra("ScriptRunning").equals("0")) | ||
return; | ||
if (socketFactory == null) | ||
socketFactory = Tools.getSLLContext(dataPath + File.separator + "ca.crt").getSocketFactory(); | ||
proxyField.set(client, proxy); | ||
sslSocketFactoryField.set(client, socketFactory); | ||
Field sslSocketFactoryField = client.getClass().getDeclaredField(fieldSSLSocketFactory); | ||
sslSocketFactoryField.setAccessible(true); | ||
if (objectProxy == null) | ||
objectProxy = proxyField.get(client); | ||
if (objectSSLSocketFactory == null) | ||
objectSSLSocketFactory = sslSocketFactoryField.get(client); | ||
|
||
if (ExtraDao.getInstance(context).getExtra("ScriptRunning").equals("0")) { | ||
proxyField.set(client, objectProxy); | ||
sslSocketFactoryField.set(client, objectSSLSocketFactory); | ||
} else { | ||
if (socketFactory == null) | ||
socketFactory = Tools.getSLLContext(dataPath + File.separator + "ca.crt").getSocketFactory(); | ||
proxyField.set(client, proxy); | ||
sslSocketFactoryField.set(client, socketFactory); | ||
} | ||
} | ||
} | ||
} | ||
|
@@ -112,14 +120,14 @@ protected void beforeHookedMethod(MethodHookParam param) throws Throwable { | |
findAndHookMethod(classMainActivity, context.getClassLoader(), "onCreate", Bundle.class, new XC_MethodHook() { | ||
@Override | ||
protected void afterHookedMethod(MethodHookParam param) { | ||
ExtraDao.getInstance(context).saveExtra("ScriptRunning", "0"); | ||
initScript(context); | ||
final Context neteaseContext = (Context) param.thisObject; | ||
initScript(neteaseContext); | ||
} | ||
}); | ||
|
||
findAndHookMethod(classMainActivity, context.getClassLoader(), "onDestroy", new XC_MethodHook() { | ||
@Override | ||
protected void beforeHookedMethod(MethodHookParam param) { | ||
protected void afterHookedMethod(MethodHookParam param) { | ||
Command stop = new Command(0, STOP_PROXY); | ||
Tools.shell(context, stop); | ||
} | ||
|
@@ -165,16 +173,18 @@ private void startScrip(final Context c) { | |
@Override | ||
public void commandOutput(int id, String line) { | ||
if (line.contains("Error")) { | ||
ExtraDao.getInstance(context).saveExtra("ScriptRunning", "0"); | ||
Tools.showToastOnLooper(c, "运行失败,错误为:" + line); | ||
} else if (line.contains("HTTP Server running")) { | ||
ExtraDao.getInstance(context).saveExtra("ScriptRunning", "1"); | ||
Tools.showToastOnLooper(c, "UnblockNeteaseMusic运行成功"); | ||
} else if (line.contains("Killed")) { | ||
ExtraDao.getInstance(context).saveExtra("ScriptRunning", "0"); | ||
Tools.showToastOnLooper(c, "Node被Killed,可能手机运存已耗尽,正在尝试重启……"); | ||
startScrip(c); | ||
if (!((Activity) c).isFinishing()) { | ||
Tools.showToastOnLooper(c, "Node被Killed,可能手机运存已耗尽,正在尝试重启……"); | ||
startScrip(c); | ||
} | ||
} | ||
log("日志:" + line); | ||
} | ||
}; | ||
Tools.shell(c, start); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,6 @@ | |
/** | ||
* <pre> | ||
* author : RainCat | ||
* org : Shenzhen JingYu Network Technology Co., Ltd. | ||
* e-mail : [email protected] | ||
* time : 2021/03/13 | ||
* desc : 说明 | ||
|