Skip to content

Commit

Permalink
Clarify the search for a proxy
Browse files Browse the repository at this point in the history
  • Loading branch information
chrismeyersfsu committed Jun 18, 2024
1 parent bef9ef1 commit bc2d339
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions awx/main/utils/proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,24 @@


def is_proxy_in_headers(request: Request, proxy_list: list[str], headers: list[str]) -> bool:
"""
Determine if the request went through at least one proxy in the list.
Example:
request.environ = {
"HTTP_X_FOO": "8.8.8.8, 192.168.2.1",
"REMOTE_ADDR": "192.168.2.1",
"REMOTE_HOST": "foobar"
}
proxy_list = ["192.168.2.1"]
headers = ["HTTP_X_FOO", "REMOTE_ADDR", "REMOTE_HOST"]
The above would return True since 192.168.2.1 is a value for the header HTTP_X_FOO
request: The DRF/Django request. request.environ dict will be used for searching for proxies
proxy_list: A list of known and trusted proxies may be ip or hostnames
headers: A list of keys for which to consider values that may contain a proxy
"""

remote_hosts = set()

for header in headers:
Expand Down

0 comments on commit bc2d339

Please sign in to comment.