05nelsonm / kmp-tor

Kotlin Multiplatform Library for embedding Tor into your applications
Apache License 2.0
33 stars 5 forks source link

Add `RuntimeEvent.NEWNYM` event #409

Closed 05nelsonm closed 3 months ago

05nelsonm commented 3 months ago

When signaling NEWNYM via tor's control connection, it only replies with 250 OK. The crux is that even though the reply is 250 OK (indicating that tor received the signal), tor can rate-limit the execution. When it does, it will dispatch a NOTICE event indicating so.

This NEWNYM listener will intercept all TorCmd.Signal.NewNym executions, and keep an eye out for the notice event.

TorCmdJob[name=SIGNAL{NEWNYM}, state=Executing]@709360670
TorCmdJob[name=SIGNAL{NEWNYM}, state=Success]@709360670
TorCmdJob[name=SIGNAL{NEWNYM}, state=Executing]@534367305
TorDaemon[fid=6E96…6985]@459232922 May 28 13:03:48.000 [notice] Rate limiting NEWNYM request: delaying by 10 second(s)
TorCmdJob[name=SIGNAL{NEWNYM}, state=Success]@534367305
TorCmdJob[name=SIGNAL{NEWNYM}, state=Executing]@1793230975
TorDaemon[fid=6E96…6985]@459232922 May 28 13:03:48.000 [notice] Rate limiting NEWNYM request: delaying by 10 second(s)
TorCmdJob[name=SIGNAL{NEWNYM}, state=Success]@1793230975
TorCmdJob[name=SIGNAL{NEWNYM}, state=Executing]@248387619
TorDaemon[fid=6E96…6985]@459232922 May 28 13:03:48.000 [notice] Rate limiting NEWNYM request: delaying by 10 second(s)
TorCmdJob[name=SIGNAL{NEWNYM}, state=Success]@248387619
TorDaemon[fid=6E96…6985]@459232922 May 28 13:03:48.000 [notice] Interrupt: exiting cleanly.
05nelsonm commented 3 months ago

Unsure if this should be a direct subclass of RuntimeEvent, or if there are other commands that would benefit from this intercept behavior.

Something like the TorCmd sealed class hierarchy (e.g. RuntimeEvent.CMD.SIGNAL.NEWNYM) but would be for only those TorCmd that tor replies 250 OK and then dispatches a NOTICE or something for.