

def get_remote_address(request):
    """
    :param: request: request object of sanic
    :return: the ip address of given request (or 127.0.0.1 if none found)
    """
    return request.ip[0] or '127.0.0.1'



def get_remote_address(request):
    """
    :param: request: request object of sanic
    :return: the ip address of given request (or 127.0.0.1 if none found)
    """
    return request.remote_addr or request.ip

Fix IP keyfunc for reverse proxies
Fix IP keyfunc for reverse proxies

  
  
  def get_remote_address(request):
      """
      :param: request: request object of sanic
      :return: the ip address of given request (or 127.0.0.1 if none found)
      """
-     return request.ip[0] or '127.0.0.1'
+     return request.remote_addr or request.ip
  
Fix IP keyfunc for reverse proxies
## Code Before:


def get_remote_address(request):
    """
    :param: request: request object of sanic
    :return: the ip address of given request (or 127.0.0.1 if none found)
    """
    return request.ip[0] or '127.0.0.1'

## Instruction:
Fix IP keyfunc for reverse proxies
## Code After:


def get_remote_address(request):
    """
    :param: request: request object of sanic
    :return: the ip address of given request (or 127.0.0.1 if none found)
    """
    return request.remote_addr or request.ip
