Ejemplo n.º 1
0
def LOCALHOST(request):
    if not net.is_local_address(request.remote_ip):
        return False
    xff = request.headers.get('X-Forwarded-For', None)
    if not xff or net.is_local_address(xff):
        return True
    return False
Ejemplo n.º 2
0
def LOCALHOST(request):
    if not net.is_local_address(request.remote_ip):
        return False
    xff = request.headers.get('X-Forwarded-For', None)
    if not xff or net.is_local_address(xff):
        return True
    return False
Ejemplo n.º 3
0
 def _request(self, request):
     self.monitor.count('requests', 1)
     if net.is_local_address(request.remote_ip):
         self.monitor.count('localhost_requests', 1)
     if net.is_private_address(request.remote_ip):
         self.monitor.count('private_requests', 1)
     return NullTransform()
Ejemplo n.º 4
0
 def _request(self, request):
     self.monitor.count('requests', 1)
     if net.is_local_address(request.remote_ip):
         self.monitor.count('localhost_requests', 1)
     if net.is_private_address(request.remote_ip):
         self.monitor.count('private_requests', 1)
     return NullTransform()
Ejemplo n.º 5
0
 def test_is_local_address_works_with_python3(self, is_python2_mock):
     """Test is_local_address method works for python3."""
     is_python2_mock.return_value = False
     self.assertTrue(is_local_address(u'127.0.0.1'))
     self.assertTrue(is_local_address('127.0.0.1'))
     self.assertFalse(is_local_address('126.0.0.10'))
Ejemplo n.º 6
0
 def test_is_local_address_works_with_python3(self, is_python2_mock):
     """Test is_local_address method works for python3."""
     is_python2_mock.return_value = False
     self.assertTrue(is_local_address(u'127.0.0.1'))
     self.assertTrue(is_local_address('127.0.0.1'))
     self.assertFalse(is_local_address('126.0.0.10'))