Tor Cmd Interceptor
Intercept the currently executing EnqueuedJob and its associated TorCmd in order to apply EnqueuedJob.invokeOnCompletion handles, or modify the command's arguments.
If no modifications are needed for the TorCmd, the originating TorCmd should be returned.
NOTE: The following TorCmd cannot be replaced:
TorCmd.Onion.Add
TorCmd.Onion.Delete
e.g.
TorCmdInterceptor.intercept { job, cmd ->
job.invokeOnCompletion {
if (job.isError) return@invokeOnCompletion
// do something...
}
if (cmd.events.contains(TorEvent.NOTICE)) {
// Do not replace the command
cmd
} else {
// This is what will end up being executed
TorCmd.SetEvents(cmd.events + TorEvent.NOTICE)
}
} Content copied to clipboard