[Twisted-Python] TCP wrapper support for twisted servers - solution !
projects at reedflute.com
Tue Sep 21 12:00:27 EDT 2004
Eugene Coetzee wrote:
> Hi everyone,
> I was wondering if anybody knows about a Python wrapper for libwrap.
> I'm aware of libwrap function libraries for PHP and libwrap-ruby for
> Ruby - but could not google anything similar for Python.
> I want to control access to my twisted servers using hosts.allow/deny.
> I have read someting about "inetd setup" options planned for tap2deb
> (couldn't get any docs regarding inetd/tcp -wrapper support though).
> Alternatively, is there anything included in twisted that can be used
> get tcp wrapper support without having to run from inetd.
OK - I had the ich and I just *had to* scratch it. I have built a Python
wrapper (I'll call it PyTCPWrapper) to libwrap which is working very
much like Perl's
http://cpan.uwinnipeg.ca/htdocs/Authen-Libwrap/README.html. I will
release it on sourceforge under the GPL pretty soon.
Now - I want to use PyTCPWrapper inside twisted.protocol.http.Request to
control access to my http server possibly passing the result of
http.Request.getHost() to PyTCPWrapper.hosts_ctl().
*but* from http.py :
"""Get my originally requesting transport's host.
Don't rely on the 'transport' attribute, since Request objects
copied remotely. For information on this method's return value, see
If I "should not rely on transport" (I imagine this refers to IP
spoofing) - what is the most reliable way of getting the client's IP
address from inside an instance of http.Request ? I would also like to
drop the illegal connection as quickly as possible - much sooner than
Any advise thoughts ideas would be appreciated.
Web -> www.reedflute.com
More information about the Twisted-Python