Serious refactoring of TUN/TAP and tunnel code. Linux udp/gre tunnels not yet functional
[nepi.git] / src / nepi / util / sshfuncs.py
index 508d462..8c83823 100644 (file)
@@ -81,14 +81,11 @@ def resolve_hostname(host):
     ip = None
 
     if host in ["localhost", "127.0.0.1", "::1"]:
-        try:
-           ip = socket.gethostbyname(socket.gethostname())
-        except socket.gaierror, e: #[Errno -5] No address associated with hostname
-            p = subprocess.Popen("ip -o addr list", shell=True,
-                    stdout=subprocess.PIPE, stderr=subprocess.PIPE)
-            stdout, stderr = p.communicate()
-            m = _re_inet.findall(stdout)
-            ip = m[0][1].split("/")[0]
+        p = subprocess.Popen("ip -o addr list", shell=True,
+                stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+        stdout, stderr = p.communicate()
+        m = _re_inet.findall(stdout)
+        ip = m[0][1].split("/")[0]
     else:
         ip = socket.gethostbyname(host)