@@ -246,14 +246,21 @@ def certificate(self):
246246
247247 @property
248248 def allow_from (self ):
249- allow_from = {}
249+ try :
250+ return self ._create_network_map (self .config .get ('proxy' , 'allow_from' ))
251+ except (ConfigParser .NoSectionError , ConfigParser .NoOptionError ):
252+ return {}
250253
254+ @property
255+ def trusted_proxies (self ):
251256 try :
252- value = self .config .get ('proxy' , 'allow_from' )
257+ return self ._create_network_map ( self . config .get ('proxy' , 'trusted_proxies' ) )
253258 except (ConfigParser .NoSectionError , ConfigParser .NoOptionError ):
254- return allow_from
259+ return {}
255260
256- for host_and_port in value .split (',' ):
261+ def _create_network_map (self , hosts ):
262+ network_map = {}
263+ for host_and_port in hosts .split (',' ):
257264 try :
258265 host , port = host_and_port .split (':' )
259266 except ValueError :
@@ -268,18 +275,18 @@ def allow_from(self):
268275 self .log .warning ('Failed to resolve hostname "%s". An error occurred: %s' , host , error )
269276 else :
270277 for ip in ip_list :
271- if ip not in allow_from :
278+ if ip not in network_map :
272279 if port :
273- allow_from [ip ] = [port ]
280+ network_map [ip ] = [port ]
274281 else :
275- allow_from [ip ] = None
276- elif allow_from [ip ] is not None :
282+ network_map [ip ] = None
283+ elif network_map [ip ] is not None :
277284 if port :
278- allow_from [ip ].append (port )
285+ network_map [ip ].append (port )
279286 else :
280- allow_from [ip ] = None
287+ network_map [ip ] = None
281288
282- return allow_from
289+ return network_map
283290
284291 @property
285292 @propertycache
0 commit comments