marionette-tg / marionette

the programmable network proxy
Apache License 2.0
112 stars 18 forks source link

Refactor operation of channels/connections #18

Open coulls opened 9 years ago

coulls commented 9 years ago

Currently, every model is associated with one channel regardless of if it handles any direct communications or not. For instance, a hierarchical composition of models will have an active port for even the higher-level model that just spawns/orchestrates lower-level models.

Furthermore, these channels operate such that they automatically open a connection (or start listening) at the start state of the model and it remains open until the model stop operation -- there are many cases where we might want finer-grained control over the start and stop. As an example, in the FTP format, we only want the spawned PASV connections to be listening on the ephemeral port when communicating with the client, while in the amzn_sess format we want to continue listening on the port even if there are zero active HTTP models running.

Closing the listening ports after execution works for FTP but not for the amzn_sess case, while keeping the ports open indefinitely works for amzn_sess but causes exhaustion of file descriptors in the FTP case. We want a more subtle approach that can work well for both of these potential scenarios.

Tasks for this refactor include: