Beispiel #1
0
 def test_get_ipv4_for_hostname(self):
     self.assertEqual(get_ipv4_for_hostname('localhost'), '127.0.0.1')
     self.assertEqual(get_ipv4_for_hostname('localhost.localdomain'),
                      '127.0.0.1')
     self.assertEqual(get_ipv4_for_hostname('127.0.0.1'), '127.0.0.1')
     self.assertEqual(get_ipv4_for_hostname('1.2.3.4'), '1.2.3.4')
     x = get_ipv4_for_hostname('foo.bar.doesnotexist')
     self.assertTrue(x is None)
     x = get_ipv4_for_hostname('www.google.com')
     self.assertTrue(x is not None)
     self.assertTrue(len(x) >= 4)
     y = x.split('.')
     self.assertEqual(len(y), 4)
Beispiel #2
0
 def test_get_ipv4_for_hostname(self):
     self.assertEquals(get_ipv4_for_hostname('localhost'), '127.0.0.1')
     self.assertEquals(get_ipv4_for_hostname('localhost.localdomain'),
                       '127.0.0.1')
     self.assertEquals(get_ipv4_for_hostname('127.0.0.1'), '127.0.0.1')
     self.assertEquals(get_ipv4_for_hostname('1.2.3.4'), '1.2.3.4')
     x = get_ipv4_for_hostname('foo.bar.doesnotexist')
     self.assertTrue(x is None)
     x = get_ipv4_for_hostname('www.google.com')
     self.assertTrue(x is not None)
     self.assertTrue(len(x) >= 4)
     y = x.split('.')
     self.assertEquals(len(y), 4)
Beispiel #3
0
def get_ip_var(opt, val):
    # Si c'est "null" ou si c'est une socket Unix
    if(val.lower() == "null" or val.startswith("/")):
        return val
    else:
        return get_ipv4_for_hostname(str(val))
Beispiel #4
0
def _resolve(val):
    if val.lower() == "null" or val.startswith("/"):
        # If it's "null" or linux socket
        return val
    return get_ipv4_for_hostname(str(val))
Beispiel #5
0
def get_ip_var(opt, val):
    # Si c'est "null" ou si c'est une socket Unix
    if (val.lower() == "null" or val.startswith("/")):
        return val
    else:
        return get_ipv4_for_hostname(str(val))