Every packet fed into Dshell goes through this function. Its goal is to pass each packet down the chain of selected plugins. Each plugin decides whether the packet(s) will proceed to the next plugin, i.e. act as a filter.
(plugin_index: int, packet: Packet)
| 60 | |
| 61 | |
| 62 | def feed_plugin_chain(plugin_index: int, packet: Packet): |
| 63 | """ |
| 64 | Every packet fed into Dshell goes through this function. |
| 65 | Its goal is to pass each packet down the chain of selected plugins. |
| 66 | Each plugin decides whether the packet(s) will proceed to the next |
| 67 | plugin, i.e. act as a filter. |
| 68 | """ |
| 69 | if plugin_index >= len(plugin_chain): |
| 70 | # We are at the end of the chain. |
| 71 | return |
| 72 | |
| 73 | current_plugin = plugin_chain[plugin_index] |
| 74 | |
| 75 | # Pass packet into plugin for processing. |
| 76 | current_plugin.consume_packet(packet) |
| 77 | |
| 78 | # Process produced packets. |
| 79 | for _packet in current_plugin.produce_packets(): |
| 80 | feed_plugin_chain(plugin_index + 1, _packet) |
| 81 | |
| 82 | |
| 83 | def clean_plugin_chain(plugin_index): |
no test coverage detected