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
2019-11-12 11:09:47 -05:00

11 lines
363 B
Python

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