Support listening on a particular interface
authorQuentin Smith <quentin@mit.edu>
Fri, 9 Jan 2009 16:50:54 +0000 (11:50 -0500)
committerQuentin Smith <quentin@mit.edu>
Fri, 9 Jan 2009 16:50:54 +0000 (11:50 -0500)
svn path=/trunk/scripts/vnc-client/; revision=1973

invirt-vnc-client

index 8a17f1d..ad5cce2 100755 (executable)
@@ -10,7 +10,8 @@ def usage():
     print """%s [-v] [-l [HOST:]PORT] {-a AUTHTOKEN|VMNAME}
  -l, --listen [HOST:]PORT  port (and optionally host) to listen on for
                            connections (default is 127.0.0.1 and a randomly
     print """%s [-v] [-l [HOST:]PORT] {-a AUTHTOKEN|VMNAME}
  -l, --listen [HOST:]PORT  port (and optionally host) to listen on for
                            connections (default is 127.0.0.1 and a randomly
-                           chosen port)
+                           chosen port). Use an empty HOST to listen on all
+                           interfaces (INSECURE!)
  -a, --authtoken AUTHTOKEN Authentication token for connecting to the VNC server
  VMNAME                    VM name to connect to (automatically fetches an
                            authentication token using remctl)
  -a, --authtoken AUTHTOKEN Authentication token for connecting to the VNC server
  VMNAME                    VM name to connect to (automatically fetches an
                            authentication token using remctl)
@@ -141,8 +142,9 @@ def main():
         elif o in ("-l", "--listen"):
             if ":" in a:
                 listen = a.split(":", 2)
         elif o in ("-l", "--listen"):
             if ":" in a:
                 listen = a.split(":", 2)
+                listen[1] = int(listen[1])
             else:
             else:
-                listen[1] = a
+                listen[1] = int(a)
         elif o in ("-a", "--authtoken"):
             authtoken = a
         else:
         elif o in ("-a", "--authtoken"):
             authtoken = a
         else:
@@ -190,9 +192,9 @@ def main():
     if listen[1] is None:
         listen[1] = 5900
         ready = False
     if listen[1] is None:
         listen[1] = 5900
         ready = False
-        while not ready:
+        while not ready and listen[1] < 6000:
             try:
             try:
-                reactor.listenTCP(listen[1], ProxyFactory(connect_host, connect_port, authtoken, machine))
+                reactor.listenTCP(listen[1], ProxyFactory(connect_host, connect_port, authtoken, machine), interface=listen[0])
                 ready = True
             except error.CannotListenError:
                 listen[1] += 1
                 ready = True
             except error.CannotListenError:
                 listen[1] += 1