[Twisted-Python] Best way to write a modularized proxy?
I am writing a modular multi-protocol proxy (initially for HTTP, and later HTTPS and possibly FTP as well) using Twisted. It will consist of a small core that handles initialization and loading of modules, a module for each protocol (which will consist of a part that accepts connections and a part that connects to the remote server), and several "filter" modules (which will be inserted in a "stack" between the two halves of the protocol module) for things like caching and filtering. Would there be a better way to structure it? Would the best way to handle the modules be to write a ServerFactory subclass that wraps the stack of modules? I understand the basic concepts behind Twisted, but am not totally familiar with the API, so I am not exactly sure what is the best way to do things.
Hi Andrew,
On Wed, 15 Aug 2007 05:13:16 -0500, Andrew Warkentin
I am writing a modular multi-protocol proxy (initially for HTTP, and later HTTPS and possibly FTP as well) using Twisted. It will consist of a small core that handles initialization and loading of modules, a module for each protocol (which will consist of a part that accepts connections and a part that connects to the remote server), and several "filter" modules (which will be inserted in a "stack" between the two halves of the protocol module) for things like caching and filtering. Would there be a better way to structure it?
Replace the word "module" with IService, and I think your design seems reasonable.
Would the best way to handle the modules be to write a ServerFactory subclass that wraps the stack of modules? I understand the basic concepts behind Twisted, but am not totally familiar with the API, so I am not exactly sure what is the best way to do things.
I'd write an IService implementation for each type of proxy I wanted to deploy, hang them all off of a MultiService, and go from there. Hope this helps, L. Daniel Burr
L. Daniel Burr wrote:
Would the best way to handle the modules be to write a ServerFactory subclass that wraps the stack of modules? I understand the basic concepts behind Twisted, but am not totally familiar with the API, so I am not exactly sure what is the best way to do things.
I'd write an IService implementation for each type of proxy I wanted to deploy, hang them all off of a MultiService, and go from there.
What would be the best way to tie together the filter objects within the service? I would like the filter modules to have a common interface and have common code for handling the stack of filters.
participants (2)
-
Andrew Warkentin
-
L. Daniel Burr