-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
68,111 additions
and
16 deletions.
There are no files selected for viewing
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
43 changes: 43 additions & 0 deletions
43
fmlloader/src/main/java/org/magmafoundation/magma/deobf/DeobfRewritePolicy.java
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 |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package org.magmafoundation.magma.deobf; | ||
|
||
import org.apache.logging.log4j.core.Core; | ||
import org.apache.logging.log4j.core.LogEvent; | ||
import org.apache.logging.log4j.core.appender.rewrite.RewritePolicy; | ||
import org.apache.logging.log4j.core.config.plugins.Plugin; | ||
import org.apache.logging.log4j.core.config.plugins.PluginFactory; | ||
import org.apache.logging.log4j.core.impl.Log4jLogEvent; | ||
|
||
@Plugin(name = "DeobfRewritePolicy", category = Core.CATEGORY_NAME, elementType = "rewritePolicy", printObject = true) | ||
public class DeobfRewritePolicy implements RewritePolicy { | ||
|
||
private static final IStackTraceDeobfuscator noop = new IStackTraceDeobfuscator() { | ||
public void deobf(Throwable throwable) {} | ||
public StackTraceElement[] deobf(StackTraceElement[] stackTrace) { return stackTrace; } | ||
}; | ||
|
||
private static IStackTraceDeobfuscator deobfuscator; | ||
|
||
public static void setDeobfuscator(IStackTraceDeobfuscator deobfuscator) { | ||
DeobfRewritePolicy.deobfuscator = deobfuscator; | ||
} | ||
|
||
public static IStackTraceDeobfuscator getDeobfuscator() { | ||
return deobfuscator != null ? deobfuscator : noop; | ||
} | ||
|
||
private DeobfRewritePolicy() {} | ||
|
||
public LogEvent rewrite(LogEvent source) { | ||
Throwable throwable = source.getThrown(); | ||
if (throwable != null) { | ||
getDeobfuscator().deobf(throwable); | ||
return new Log4jLogEvent.Builder(source).setThrownProxy(null).build(); | ||
} | ||
return source; | ||
} | ||
|
||
@PluginFactory | ||
public static DeobfRewritePolicy createPolicy() { | ||
return new DeobfRewritePolicy(); | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
fmlloader/src/main/java/org/magmafoundation/magma/deobf/IStackTraceDeobfuscator.java
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package org.magmafoundation.magma.deobf; | ||
|
||
public interface IStackTraceDeobfuscator { | ||
|
||
void deobf(Throwable throwable); | ||
StackTraceElement[] deobf(StackTraceElement[] stackTrace); | ||
} |
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
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
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
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
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
Oops, something went wrong.