Verify source IP is in the allowed list.
(self)
| 68 | self.set_body_reader() |
| 69 | |
| 70 | def _check_allowed_ip(self): |
| 71 | """Verify source IP is in the allowed list.""" |
| 72 | allow_ips = getattr(self.cfg, 'uwsgi_allow_ips', ['127.0.0.1', '::1']) |
| 73 | |
| 74 | # UNIX sockets don't have IP addresses |
| 75 | if not isinstance(self.peer_addr, tuple): |
| 76 | return |
| 77 | |
| 78 | # Wildcard allows all |
| 79 | if '*' in allow_ips: |
| 80 | return |
| 81 | |
| 82 | if self.peer_addr[0] not in allow_ips: |
| 83 | raise ForbiddenUWSGIRequest(self.peer_addr[0]) |
| 84 | |
| 85 | def force_close(self): |
| 86 | """Force the connection to close after this request.""" |
no test coverage detected