[PATCH virt-manager] sshtunnels: use ipaddr to check if address is loopback or unspecified

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



It supports IPv6 addresses written as "0::0", "0:0::0".

Signed-off-by: Giuseppe Scrivano <gscrivan@xxxxxxxxxx>
---
 virtManager/sshtunnels.py | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/virtManager/sshtunnels.py b/virtManager/sshtunnels.py
index 53274ea..53f43be 100644
--- a/virtManager/sshtunnels.py
+++ b/virtManager/sshtunnels.py
@@ -1,5 +1,5 @@
 #
-# Copyright (C) 2014 Red Hat, Inc.
+# Copyright (C) 2014, 2015 Red Hat, Inc.
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -23,6 +23,7 @@ import Queue
 import socket
 import signal
 import threading
+import ipaddr
 
 from .baseclass import vmmGObject
 
@@ -47,10 +48,10 @@ class ConnectionInfo(object):
             self._connhost = "127.0.0.1"
 
     def _is_listen_localhost(self, host=None):
-        return (host or self.gaddr) in ["127.0.0.1", "::1"]
+        return ipaddr.IPNetwork(host or self.gaddr).is_loopback
 
     def _is_listen_any(self):
-        return self.gaddr in ["0.0.0.0", "::"]
+        return ipaddr.IPNetwork(self.gaddr).is_unspecified
 
     def need_tunnel(self):
         if not self._is_listen_localhost():
-- 
2.1.0

_______________________________________________
virt-tools-list mailing list
virt-tools-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/virt-tools-list




[Index of Archives]     [Linux Virtualization]     [KVM Development]     [CentOS Virtualization]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]     [Video 4 Linux]

  Powered by Linux