Improve debug logging: log activated hooks & more clearly list conns

This commit is contained in:
Tim Perry
2023-10-18 18:33:37 +02:00
parent eaf6075303
commit ff1882f3d5
2 changed files with 14 additions and 4 deletions
+10 -1
View File
@@ -425,7 +425,16 @@ Java.perform(function () {
}`;
try {
targetMethod.implementation = replacement(targetMethod);
const newImplementation = replacement(targetMethod);
if (DEBUG_MODE) {
// Log each hooked method as it's called:
targetMethod.implementation = function () {
console.log(` => ${patchName}`);
return newImplementation.apply(this, arguments);
}
} else {
targetMethod.implementation = newImplementation;
}
if (DEBUG_MODE) console.log(`[+] ${patchName}`);
patchApplied = true;
+4 -3
View File
@@ -96,19 +96,20 @@ if (!connectFn) { // Should always be set, but just in case
addrPtr.add(4).writeByteArray(PROXY_HOST_IPv4_BYTES);
}
} else if (DEBUG_MODE) {
console.debug(`Ignoring ${sockType} connection`);
console.log(`Ignoring ${sockType} connection`);
this.ignored = true;
}
// N.b. we ignore all non-TCP connections: both UDP and Unix streams
},
onLeave: function (result) {
if (!DEBUG_MODE) return;
if (!DEBUG_MODE || this.ignored) return;
const fd = this.sockFd;
const sockType = Socket.type(fd);
const address = Socket.peerAddress(fd);
console.debug(
`Connected fd ${fd} of type ${sockType} to ${JSON.stringify(address)} (${result.toInt32()})`
`Connected ${sockType} fd ${fd} to ${JSON.stringify(address)} (${result.toInt32()})`
);
}
});