This repository has been archived on 2020-03-24. You can view files and clone it, but cannot push or open issues or pull requests.
quay/util/request.py

12 lines
363 B
Python
Raw Normal View History

2019-11-12 16:09:47 +00:00
import os
from flask import request
def get_request_ip():
""" Returns the IP address of the client making the current Flask request or None if none. """
remote_addr = request.remote_addr or None
if os.getenv('TEST', 'false').lower() == 'true':
remote_addr = request.headers.get('X-Override-Remote-Addr-For-Testing', remote_addr)
return remote_addr