[Zope-Checkins] CVS: Packages/Zope/Startup - handlers.py:1.6.2.11
Andreas Jung
andreas at andreas-jung.com
Wed Nov 24 03:36:55 EST 2004
Update of /cvs-repository/Packages/Zope/Startup
In directory cvs.zope.org:/tmp/cvs-serv5291/lib/python/Zope/Startup
Modified Files:
Tag: Zope-2_7-branch
handlers.py
Log Message:
- the 'trusted-proxy' directive in zope.conf now also accepts
hostnames instead of IP addresses only (patch by Dieter Maurer)
=== Packages/Zope/Startup/handlers.py 1.6.2.10 => 1.6.2.11 ===
--- Packages/Zope/Startup/handlers.py:1.6.2.10 Mon Jul 26 13:38:08 2004
+++ Packages/Zope/Startup/handlers.py Wed Nov 24 03:36:54 2004
@@ -166,7 +166,10 @@
# set up trusted proxies
if config.trusted_proxies:
import ZPublisher.HTTPRequest
- ZPublisher.HTTPRequest.trusted_proxies = tuple(config.trusted_proxies)
+ # DM 2004-11-24: added host name mapping (such that examples in conf file really have a chance to work
+ mapped = []
+ for name in config.trusted_proxies: mapped.extend(_name2Ips(name))
+ ZPublisher.HTTPRequest.trusted_proxies = tuple(mapped)
def handleConfig(config, multihandler):
handlers = {}
@@ -174,3 +177,13 @@
if not name.startswith('_'):
handlers[name] = value
return multihandler(handlers)
+
+# DM 2004-11-24: added
+def _name2Ips(host, isIp_=compile(r'(\d+\.){3}').match):
+ '''map a name *host* to the sequence of its ip addresses;
+ use *host* itself (as sequence) if it already is an ip address.
+ Thus, if only a specific interface on a host is trusted,
+ identify it by its ip (and not the host name).
+ '''
+ if isIp_(host): return [host]
+ return gethostbyaddr(host)[2]
More information about the Zope-Checkins
mailing list