feat: smart input pro v2.3.8
This commit is contained in:
parent
7ecf02ed13
commit
3d830cf711
2
activation.conf.example
Normal file
2
activation.conf.example
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
[SmartInputHookClass]
|
||||||
|
EQUAL,O00oOO0
|
2
pom.xml
2
pom.xml
@ -63,7 +63,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.ja-netfilter</groupId>
|
<groupId>com.ja-netfilter</groupId>
|
||||||
<artifactId>ja-netfilter</artifactId>
|
<artifactId>ja-netfilter</artifactId>
|
||||||
<version>2.0.1</version>
|
<version>2.1.1</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
@ -1,14 +1,27 @@
|
|||||||
package com.yelochick;
|
package com.yelochick;
|
||||||
|
|
||||||
|
import com.janetfilter.core.Environment;
|
||||||
import com.janetfilter.core.plugin.MyTransformer;
|
import com.janetfilter.core.plugin.MyTransformer;
|
||||||
|
import com.janetfilter.core.plugin.PluginConfig;
|
||||||
import com.janetfilter.core.plugin.PluginEntry;
|
import com.janetfilter.core.plugin.PluginEntry;
|
||||||
import com.yelochick.coolrequest.VipApiTransformer;
|
import com.yelochick.coolrequest.VipApiTransformer;
|
||||||
import com.yelochick.smartinput.OsLanguageManagerProxyTransformer;
|
import com.yelochick.smartinput.OsLanguageManagerProxyTransformer;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class ActivationPlugin implements PluginEntry {
|
public class ActivationPlugin implements PluginEntry {
|
||||||
|
|
||||||
|
private final List<MyTransformer> transformers = new ArrayList<>();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init(Environment environment, PluginConfig config) {
|
||||||
|
transformers.add(new VipApiTransformer());
|
||||||
|
transformers.add(new OsLanguageManagerProxyTransformer(config.getBySection("SmartInputHookClass")));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return "ACTIVATION";
|
return "ACTIVATION";
|
||||||
@ -21,9 +34,6 @@ public class ActivationPlugin implements PluginEntry {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<MyTransformer> getTransformers() {
|
public List<MyTransformer> getTransformers() {
|
||||||
return Arrays.asList(
|
return Collections.unmodifiableList(transformers);
|
||||||
new VipApiTransformer(),
|
|
||||||
new OsLanguageManagerProxyTransformer()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,15 @@
|
|||||||
package com.yelochick.smartinput;
|
package com.yelochick.smartinput;
|
||||||
|
|
||||||
import com.janetfilter.core.commons.DebugInfo;
|
import com.janetfilter.core.commons.DebugInfo;
|
||||||
|
import com.janetfilter.core.models.FilterRule;
|
||||||
import com.janetfilter.core.plugin.MyTransformer;
|
import com.janetfilter.core.plugin.MyTransformer;
|
||||||
import com.yelochick.SafeClassWriter;
|
import com.yelochick.SafeClassWriter;
|
||||||
import jdk.internal.org.objectweb.asm.ClassReader;
|
import jdk.internal.org.objectweb.asm.ClassReader;
|
||||||
import jdk.internal.org.objectweb.asm.ClassWriter;
|
import jdk.internal.org.objectweb.asm.ClassWriter;
|
||||||
import jdk.internal.org.objectweb.asm.tree.*;
|
import jdk.internal.org.objectweb.asm.tree.*;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import static jdk.internal.org.objectweb.asm.Opcodes.*;
|
import static jdk.internal.org.objectweb.asm.Opcodes.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -14,13 +17,23 @@ import static jdk.internal.org.objectweb.asm.Opcodes.*;
|
|||||||
*/
|
*/
|
||||||
public class OsLanguageManagerProxyTransformer implements MyTransformer {
|
public class OsLanguageManagerProxyTransformer implements MyTransformer {
|
||||||
|
|
||||||
|
private final List<FilterRule> rules;
|
||||||
|
|
||||||
|
public OsLanguageManagerProxyTransformer(List<FilterRule> rules) {
|
||||||
|
this.rules = rules;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getHookClassName() {
|
public String getHookClassName() {
|
||||||
return "O00oOO0";
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public byte[] transform(String className, byte[] classBytes, int order) throws Exception {
|
public byte[] transform(String className, byte[] classBytes, int order) throws Exception {
|
||||||
|
if (!classMatched(className)) {
|
||||||
|
return classBytes;
|
||||||
|
}
|
||||||
|
|
||||||
ClassReader reader = new ClassReader(classBytes);
|
ClassReader reader = new ClassReader(classBytes);
|
||||||
ClassNode node = new ClassNode(ASM5);
|
ClassNode node = new ClassNode(ASM5);
|
||||||
reader.accept(node, 0);
|
reader.accept(node, 0);
|
||||||
@ -39,4 +52,14 @@ public class OsLanguageManagerProxyTransformer implements MyTransformer {
|
|||||||
node.accept(writer);
|
node.accept(writer);
|
||||||
return writer.toByteArray();
|
return writer.toByteArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean classMatched(String className) {
|
||||||
|
for (FilterRule rule : rules) {
|
||||||
|
if (rule.test(className)) {
|
||||||
|
DebugInfo.output("Native wrapper: " + className + ", rule: " + rule);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user