Index: ChangeLog
===================================================================
--- ChangeLog	(revision 836)
+++ ChangeLog	(working copy)
@@ -1,3 +1,20 @@
+2008-05-04  Jorge Pereira  <jorge@jorgepereira.com.br>
+
+	* server/libvncserver/main.c: (rfbGetScreen):
+	* server/libvncserver/rfb/rfb.h:
+	* server/libvncserver/sockets.c: (rfbInitListenSock),
+	(rfbSetNetworkInterface), (ListenOnTCPPort):
+	* server/vino-prefs.c: (vino_prefs_network_interface_changed),
+	(vino_prefs_create_server), (vino_prefs_init):
+	* server/vino-server.c: (vino_server_init_from_screen),
+	(vino_server_finalize), (vino_server_set_property),
+	(vino_server_get_property), (vino_server_class_init),
+	(vino_server_get_network_interface),
+	(vino_server_set_network_interface):
+	* server/vino-server.h:
+	IPv6: support platforms which don't allow accepting IPv4
+	mapped IPv6 connections. Closes #403183, #488354, #403192
+
 ==================== 2.22.1 ======================
 
 2008-03-13  Jonh Wendell  <jwendell@gnome.org>
Index: server/vino-mdns.c
===================================================================
--- server/vino-mdns.c	(revision 836)
+++ server/vino-mdns.c	(working copy)
@@ -44,6 +44,8 @@
 static AvahiEntryGroup *mdns_entry_group = NULL;
 char                   *mdns_service_name = NULL; 
 
+void vino_mdns_restart (void);
+
 static const char *
 vino_mdns_get_service_name (void)
 {
Index: server/vino-server.c
===================================================================
--- server/vino-server.c	(revision 836)
+++ server/vino-server.c	(working copy)
@@ -75,7 +75,7 @@
   int               alternative_port;
 
   guint             on_hold : 1;
-  guint             local_only : 1;
+  char              *network_interface;
   guint             prompt_enabled : 1;
   guint             view_only : 1;
   guint             require_encryption : 1;
@@ -104,7 +104,7 @@
   PROP_ON_HOLD,
   PROP_PROMPT_ENABLED,
   PROP_VIEW_ONLY,
-  PROP_LOCAL_ONLY,
+  PROP_NETWORK_INTERFACE,
   PROP_USE_ALTERNATIVE_PORT,
   PROP_ALTERNATIVE_PORT,
   PROP_REQUIRE_ENCRYPTION,
@@ -540,7 +540,7 @@
   matches = NULL;
 
   result = gnome_keyring_find_network_password_sync (
-                NULL,           /* user     */
+        NULL,           /* user     */
 		NULL,           /* domain   */
 		"vino.local",   /* server   */
 		NULL,           /* object   */
@@ -846,11 +846,12 @@
    *   5900-6000
    */
   rfb_screen->rfbDeferUpdateTime = 0;
-  rfb_screen->localOnly          = server->priv->local_only;
   rfb_screen->autoPort           = TRUE;
   rfb_screen->rfbPort            = VINO_SERVER_DEFAULT_PORT;
   rfb_screen->rfbAlwaysShared    = TRUE;
 
+  strcpy(rfb_screen->networkInterface, VINO_SERVER_DEFAULT_NETWORK_INTERFACE);
+
   if (server->priv->use_alternative_port)
     {
       rfb_screen->autoPort = FALSE;
@@ -943,6 +944,10 @@
     g_free (server->priv->vnc_password);
   server->priv->vnc_password = NULL;
 
+  if(server->priv->network_interface)
+      g_free(server->priv->network_interface);
+  server->priv->network_interface = NULL;
+
   if (server->priv->prompt)
     g_object_unref (server->priv->prompt);
   server->priv->prompt = NULL;
@@ -992,8 +997,8 @@
     case PROP_VIEW_ONLY:
       vino_server_set_view_only (server, g_value_get_boolean (value));
       break;
-    case PROP_LOCAL_ONLY:
-      vino_server_set_local_only (server, g_value_get_boolean (value));
+    case PROP_NETWORK_INTERFACE:
+      vino_server_set_network_interface (server, g_value_get_string (value));
       break;
     case PROP_REQUIRE_ENCRYPTION:
       vino_server_set_require_encryption (server, g_value_get_boolean (value));
@@ -1041,8 +1046,8 @@
     case PROP_VIEW_ONLY:
       g_value_set_boolean (value, server->priv->view_only);
       break;
-    case PROP_LOCAL_ONLY:
-      g_value_set_boolean (value, server->priv->local_only);
+    case PROP_NETWORK_INTERFACE:
+      g_value_set_string (value, server->priv->network_interface);
       break;
     case PROP_REQUIRE_ENCRYPTION:
       g_value_set_boolean (value, server->priv->require_encryption);
@@ -1136,12 +1141,13 @@
                                                          G_PARAM_STATIC_NICK |
                                                          G_PARAM_STATIC_BLURB));
 
+
   g_object_class_install_property (gobject_class,
-				   PROP_LOCAL_ONLY,
-				   g_param_spec_boolean ("local-only",
-							 "Local Only",
-							 "Only allow local connections",
-							 FALSE,
+				   PROP_NETWORK_INTERFACE,
+				   g_param_spec_string ("network-interface",
+							 "Network Interface",
+							 "Network interface for accept connections",
+							 NULL,
                                                          G_PARAM_READWRITE   |
                                                          G_PARAM_CONSTRUCT   |
                                                          G_PARAM_STATIC_NAME |
@@ -1312,32 +1318,33 @@
     }
 }
 
-gboolean
-vino_server_get_local_only (VinoServer *server)
+G_CONST_RETURN char *
+vino_server_get_network_interface(VinoServer *server)
 {
-  g_return_val_if_fail (VINO_IS_SERVER (server), FALSE);
+    g_return_val_if_fail (VINO_IS_SERVER (server), NULL);
 
-  return server->priv->local_only;
+    return server->priv->network_interface;
 }
 
 void
-vino_server_set_local_only (VinoServer *server,
-                            gboolean    local_only)
+vino_server_set_network_interface (VinoServer *server,
+                                   const char *network_interface)
 {
   g_return_if_fail (VINO_IS_SERVER (server));
 
-  local_only = local_only != FALSE;
+  if(network_interface == NULL)
+      return;
 
-  if (server->priv->local_only != local_only)
+  if (server->priv->network_interface)
+      g_free(server->priv->network_interface);
+
+  if (server->priv->rfb_screen != NULL)
     {
-      server->priv->local_only = local_only;
+       server->priv->network_interface = g_strdup(network_interface);
+       rfbSetNetworkInterface(server->priv->rfb_screen, server->priv->network_interface);
+    }
 
-      if (server->priv->rfb_screen != NULL)
-        rfbSetLocalOnly (server->priv->rfb_screen,
-                         server->priv->local_only);
-
-      g_object_notify (G_OBJECT (server), "local-only");
-    }
+    g_object_notify (G_OBJECT (server), "network_interface");
 }
 
 gboolean
Index: server/libvncserver/sockets.c
===================================================================
--- server/libvncserver/sockets.c	(revision 836)
+++ server/libvncserver/sockets.c	(working copy)
@@ -64,12 +64,16 @@
 #include <netinet/tcp.h>
 #include <netdb.h>
 #include <arpa/inet.h>
+#include <ifaddrs.h>
+#include <net/if.h>
 #endif
 #ifdef HAVE_UNISTD_H
 #include <unistd.h>
 #endif
 #endif
 
+#include <sys/ioctl.h>
+
 #if defined(__linux__) && defined(NEED_TIMEVAL)
 struct timeval 
 {
@@ -93,6 +97,11 @@
                                    gone away - needed to stop us hanging */
 
 /*
+ * Listen TCP Port in network interface
+ * */
+static int ListenOnTCPPort(int port, const char *networkInterface);
+
+/*
  * rfbInitSockets sets up the TCP sockets to listen for RFB
  * connections.  It does nothing if called again.
  */
@@ -140,7 +149,7 @@
         rfbLog("Autoprobing TCP port \n");
 
         for (i = 5900; i < 6000; i++) {
-            if ((rfbScreen->rfbListenSock = ListenOnTCPPort(i, rfbScreen->localOnly)) >= 0) {
+            if ((rfbScreen->rfbListenSock = ListenOnTCPPort(i, rfbScreen->networkInterface)) >= 0) {
 		rfbScreen->rfbPort = i;
 		break;
 	    }
@@ -159,7 +168,7 @@
     else if(rfbScreen->rfbPort>0) {
       rfbLog("Listening for VNC connections on TCP port %d\n", rfbScreen->rfbPort);
 
-      if ((rfbScreen->rfbListenSock = ListenOnTCPPort(rfbScreen->rfbPort, rfbScreen->localOnly)) < 0) {
+      if ((rfbScreen->rfbListenSock = ListenOnTCPPort(rfbScreen->rfbPort, rfbScreen->networkInterface)) < 0) {
 	rfbLogPerror("ListenOnTCPPort");
 	return;
       }
@@ -210,33 +219,33 @@
     rfbInitListenSock(rfbScreen);
 }
 
-void
-rfbSetLocalOnly(rfbScreenInfoPtr rfbScreen, rfbBool localOnly)
+rfbBool
+rfbSetNetworkInterface(rfbScreenInfoPtr rfbScreen, const char *networkInterface)
 {
-    if (rfbScreen->localOnly == localOnly)
-        return;
+    if (networkInterface == NULL || *networkInterface == '\0' || !rfbScreen->socketInitDone)
+        return FALSE;
 
-    rfbScreen->localOnly = localOnly;
-
-    if (!rfbScreen->socketInitDone)
-	return;
-
-    if (rfbScreen->rfbListenSock > 0) {
+    if (rfbScreen->rfbListenSock > 0) 
+    {
         FD_CLR(rfbScreen->rfbListenSock, &(rfbScreen->allFds));
         close(rfbScreen->rfbListenSock);
         rfbScreen->rfbListenSock = -1;
     }
 
-    rfbLog("Re-binding socket to listen for %s VNC connections on TCP port %d\n",
-           rfbScreen->localOnly ? "local" : "all", rfbScreen->rfbPort);
+    strncpy(rfbScreen->networkInterface, networkInterface, sizeof(rfbScreen->networkInterface));
 
-    if ((rfbScreen->rfbListenSock = ListenOnTCPPort(rfbScreen->rfbPort, rfbScreen->localOnly)) < 0) {
-	rfbLogPerror("ListenOnTCPPort");
-	return;
+    rfbLog("Re-binding socket to listen for VNC connections on TCP port %d in (%s) interface\n",
+           rfbScreen->rfbPort, rfbScreen->networkInterface);
+
+    if ((rfbScreen->rfbListenSock = ListenOnTCPPort(rfbScreen->rfbPort, rfbScreen->networkInterface)) < 0) {
+	    rfbLogPerror("ListenOnTCPPort");
+        return FALSE;
     }
 
     FD_SET(rfbScreen->rfbListenSock, &(rfbScreen->allFds));
     rfbScreen->maxFd = max(rfbScreen->rfbListenSock, rfbScreen->maxFd);
+
+    return TRUE;
 }
 
 void
@@ -548,56 +557,152 @@
 }
 
 int
-ListenOnTCPPort(port, localOnly)
-    int port;
-    rfbBool localOnly;
+ListenOnTCPPort(int port, const char *networkInterface)
 {
     int sock = -1;
-    int one = 1;
+    int one  = 1;
+    socklen_t addrlen = 0;
+    rfbBool ifaceAll  = FALSE;
+    char buf_in[INET_ADDRSTRLEN];
+    char buf_in6[INET_ADDRSTRLEN];
+    char *buf = NULL;
+    struct ifreq ifreq;
+    struct sockaddr *addr;
     struct sockaddr_in addr_in;
-    struct sockaddr *addr;
-    socklen_t addrlen;
-
-#ifdef ENABLE_IPV6
     struct sockaddr_in6 addr_in6;
 
-    memset(&addr_in6, 0, sizeof(addr_in6));
-    addr_in6.sin6_family = AF_INET6;
-    addr_in6.sin6_port = htons(port);
-    addr_in6.sin6_addr = localOnly ? in6addr_loopback : in6addr_any;
+    if(!(port > 0x0000 && port < 0xFFFF)) /* it's a valid port? */
+    {
+        rfbLog("Invalid port: %d\n", port);
+        return -1;
+    }
 
-    addr = (struct sockaddr *)&addr_in6;
-    addrlen = sizeof(addr_in6);
+    if(networkInterface == NULL || !strcmp(networkInterface, "all")) /* bind in all interfaces? */
+    {
+        ifaceAll = TRUE;
+    }
+    else
+    {
+        int fd = socket(AF_INET, SOCK_STREAM, 0);
+        void *src;
+        int buflen;
 
-    sock = socket(AF_INET6, SOCK_STREAM, 0);
-#endif
+        if (fd < 0)
+        {
+            rfbLog("Problems in get interface, exiting!\n");
+            return -1;
+        }
 
-    if (sock < 0) {
-        if ((sock = socket(AF_INET, SOCK_STREAM, 0)) < 0)
+        /* Request network interface */
+        strncpy(ifreq.ifr_name, networkInterface, sizeof(ifreq.ifr_name));
+        if(ioctl(fd, SIOCGIFADDR, &ifreq) < 0)
+        {
+            rfbLog("The network interface (%s) not found! strerror='%s'\n", networkInterface, strerror(errno));
+            close(fd);
             return -1;
+        }
+        close(fd);
 
-        memset(&addr_in, 0, sizeof(addr_in));
-        addr_in.sin_family = AF_INET;
-        addr_in.sin_port = htons(port);
-        addr_in.sin_addr.s_addr = localOnly ? htonl(INADDR_LOOPBACK) : htonl(INADDR_ANY);
+        if(ifreq.ifr_addr.sa_family == AF_INET)
+        {
+            struct sockaddr_in *paddr_in = (struct sockaddr_in *)&ifreq.ifr_addr;
 
-        addr = (struct sockaddr *)&addr_in;
-        addrlen = sizeof(addr_in);
+            src    = &paddr_in->sin_addr;
+            buf    = buf_in;
+            buflen = sizeof (buf_in);
+        }
+        else
+        {
+            struct sockaddr_in6 *paddr_in6 = (struct sockaddr_in6 *)&ifreq.ifr_addr;
+
+            if (IN6_IS_ADDR_V4MAPPED (&paddr_in6->sin6_addr))
+                src = &paddr_in6->sin6_addr.s6_addr[12];
+            else
+                src = &paddr_in6->sin6_addr;
+
+            buf    = buf_in6;
+            buflen = sizeof (buf_in6);
+        }
+
+        if(inet_ntop(ifreq.ifr_addr.sa_family, src, buf, buflen) == NULL)
+        {
+            rfbLogPerror("inet_ntop");
+            return -1;
+        }
+
+        rfbLog("Network interface (%s) OK\n", (char *)ifreq.ifr_name);
+        addr = (struct sockaddr *)&(ifreq.ifr_addr);
     }
 
-    if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR,
-		   (char *)&one, sizeof(one)) < 0) {
-	close(sock);
-	return -1;
+    // first step, try make a ipv4 socket!
+    if ((sock = socket(AF_INET, SOCK_STREAM, 0)) < 0)
+    {
+        rfbLogPerror("socket");
+        return -1;
     }
-    if (bind(sock, addr, addrlen) < 0) {
-	close(sock);
-	return -1;
+
+    memset(&addr_in, 0, sizeof(addr_in));
+    addr_in.sin_family  = AF_INET;
+    addr_in.sin_port    = htons(port);
+
+    if(inet_pton(AF_INET, (ifaceAll) ? "0.0.0.0" : buf, &addr_in.sin_addr) < 0)
+    {
+       rfbLogPerror("inet_pton");
+       return -1;
     }
-    if (listen(sock, 5) < 0) {
-	close(sock);
-	return -1;
+
+    addr     = (struct sockaddr *)&addr_in;
+    addrlen  = sizeof(addr_in);
+
+    if (sock < 0)  // if fail ipv4 socket, try ipv6
+    {
+        if ((sock = socket(AF_INET6, SOCK_STREAM, 0)) < 0)
+        {
+            rfbLogPerror("socket");
+            return -1;
+        }
+
+        memset(&addr_in6, 0, sizeof(addr_in6));
+        addr_in6.sin6_family = AF_INET6;
+        addr_in6.sin6_port   = htons(port);
+
+        if(inet_pton(AF_INET6, (ifaceAll) ? "::" : buf, &addr_in6.sin6_addr) < 0)
+        {
+           rfbLogPerror("inet_pton");
+           return -1;
+        }
+
+        addr    = (struct sockaddr *)&addr_in6;
+        addrlen = sizeof(addr_in6);
     }
 
+    if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (char *)&one, sizeof(one)) < 0) 
+    {
+       rfbLogPerror("setsockopt");
+       close(sock);
+       return -1;
+    }
+            
+    if (bind(sock, addr, addrlen) < 0) 
+    {
+        rfbLogPerror("bind");
+        close(sock);
+        return -1;
+    }
+
+    if (listen(sock, 5) < 0) 
+    {
+        rfbLogPerror("listen");
+        close(sock);
+        return -1;
+    }
+
+    rfbLog("Listening in %s on vnc://%s:%d\n",  
+          networkInterface, 
+          (ifaceAll) ? (addr->sa_family == AF_INET ? "0.0.0.0" : "::") : buf,
+          port
+    );
+
     return sock;
 }
+
Index: server/libvncserver/main.c
===================================================================
--- server/libvncserver/main.c	(revision 836)
+++ server/libvncserver/main.c	(working copy)
@@ -311,7 +311,10 @@
      rfbErr("WARNING: Width (%d) is not a multiple of 4. VncViewer has problems with that.\n",width);
 
    rfbScreen->autoPort=FALSE;
-   rfbScreen->localOnly=FALSE;
+
+//   rfbScreen->netInterface.s4.s_addr = htonl(INADDR_ANY);
+  // rfbScreen->netInterface.s6        = in6addr_any;
+
    rfbScreen->rfbClientHead=0;
    rfbScreen->rfbPort=5900;
    rfbScreen->socketInitDone=FALSE;
Index: server/libvncserver/rfb/rfb.h
===================================================================
--- server/libvncserver/rfb/rfb.h	(revision 836)
+++ server/libvncserver/rfb/rfb.h	(working copy)
@@ -112,7 +112,7 @@
     char rfbThisHost[255];
 
     rfbBool autoPort;
-    rfbBool localOnly;
+    char networkInterface[64];
     int rfbPort;
     SOCKET rfbListenSock;
     int maxSock;
@@ -389,6 +389,7 @@
 extern void rfbInitSockets(rfbScreenInfoPtr rfbScreen);
 extern void rfbSetAutoPort(rfbScreenInfoPtr rfbScreen, rfbBool autoPort);
 extern void rfbSetPort(rfbScreenInfoPtr rfbScreen, int Port);
+extern rfbBool rfbSetNetworkInterface(rfbScreenInfoPtr rfbScreen, const char *networkInterface);
 extern void rfbSetLocalOnly(rfbScreenInfoPtr rfbScreen, rfbBool localOnly);
 extern void rfbCloseClient(rfbClientPtr cl);
 extern int ReadExact(rfbClientPtr cl, char *buf, int len);
@@ -396,7 +397,6 @@
 extern int WriteExact(rfbClientPtr cl, const char *buf, int len);
 extern void rfbProcessNewConnection(rfbScreenInfoPtr rfbScreen);
 extern void rfbCheckFds(rfbScreenInfoPtr rfbScreen,long usec);
-extern int ListenOnTCPPort(int port, rfbBool localOnly);
 
 /* rfbserver.c */
 
Index: server/vino-server.h
===================================================================
--- server/vino-server.h	(revision 836)
+++ server/vino-server.h	(working copy)
@@ -28,9 +28,10 @@
 
 G_BEGIN_DECLS
 
-#define VINO_SERVER_DEFAULT_PORT  5900
-#define VINO_SERVER_MIN_PORT      5000
-#define VINO_SERVER_MAX_PORT      50000
+#define VINO_SERVER_DEFAULT_NETWORK_INTERFACE "all"
+#define VINO_SERVER_DEFAULT_PORT              5900
+#define VINO_SERVER_MIN_PORT                  5000
+#define VINO_SERVER_MAX_PORT                  50000
 #define VINO_SERVER_VALID_PORT(p) ((p) > VINO_SERVER_MIN_PORT && (p) < VINO_SERVER_MAX_PORT)
 
 #define VINO_TYPE_SERVER         (vino_server_get_type ())
@@ -85,9 +86,9 @@
 void                 vino_server_set_alternative_port     (VinoServer     *server,
 							   int             alternative_port);
 int                  vino_server_get_port                 (VinoServer     *server);
-void                 vino_server_set_local_only           (VinoServer     *server,
-							   gboolean        local_only);
-gboolean             vino_server_get_local_only           (VinoServer     *server);
+void                 vino_server_set_network_interface    (VinoServer     *server,
+							   const char     *network_interface);
+G_CONST_RETURN char *vino_server_get_network_interface    (VinoServer     *server);
 void                 vino_server_set_require_encryption   (VinoServer     *server,
 							   gboolean        require_encryption);
 gboolean             vino_server_get_require_encryption   (VinoServer     *server);
Index: server/vino-prefs.c
===================================================================
--- server/vino-prefs.c	(revision 836)
+++ server/vino-prefs.c	(working copy)
@@ -34,7 +34,6 @@
 #define VINO_PREFS_ENABLED                VINO_PREFS_DIR "/enabled"
 #define VINO_PREFS_PROMPT_ENABLED         VINO_PREFS_DIR "/prompt_enabled"
 #define VINO_PREFS_VIEW_ONLY              VINO_PREFS_DIR "/view_only"
-#define VINO_PREFS_LOCAL_ONLY             VINO_PREFS_DIR "/local_only"
 #define VINO_PREFS_USE_ALTERNATIVE_PORT   VINO_PREFS_DIR "/use_alternative_port"
 #define VINO_PREFS_ALTERNATIVE_PORT       VINO_PREFS_DIR "/alternative_port"
 #define VINO_PREFS_REQUIRE_ENCRYPTION     VINO_PREFS_DIR "/require_encryption"
@@ -42,8 +41,10 @@
 #define VINO_PREFS_VNC_PASSWORD           VINO_PREFS_DIR "/vnc_password"
 #define VINO_PREFS_LOCK_SCREEN            VINO_PREFS_DIR "/lock_screen_on_disconnect"
 #define VINO_PREFS_ICON_VISIBILITY        VINO_PREFS_DIR "/icon_visibility"
+#define VINO_PREFS_NETWORK_INTERFACE      VINO_PREFS_DIR "/network_interface"
 
-#define VINO_N_LISTENERS 11
+#define VINO_N_LISTENERS                  11
+#define VINO_DEFAULT_NETWORK_INTERFACE    "all"
 
 static GConfClient *vino_client  = NULL;
 static GSList      *vino_servers = NULL;
@@ -52,10 +53,10 @@
 static gboolean        vino_enabled              = FALSE;
 static gboolean        vino_prompt_enabled       = FALSE;
 static gboolean        vino_view_only            = FALSE;
-static gboolean        vino_local_only           = FALSE;
 static gboolean        vino_require_encryption   = FALSE;
 static VinoAuthMethod  vino_auth_methods         = VINO_AUTH_VNC;
 static char           *vino_vnc_password         = NULL;
+static char           *vino_network_interface    = NULL;
 static gboolean        vino_use_alternative_port = FALSE;
 static int             vino_alternative_port     = VINO_SERVER_DEFAULT_PORT;
 static gboolean        vino_lock_screen          = FALSE;
@@ -139,30 +140,6 @@
 }
 
 static void
-vino_prefs_local_only_changed (GConfClient *client,
-			       guint	    cnxn_id,
-			       GConfEntry  *entry)
-{
-  gboolean  local_only;
-  GSList   *l;
-
-  if (!entry->value || entry->value->type != GCONF_VALUE_BOOL)
-    return;
-
-  local_only = gconf_value_get_bool (entry->value) != FALSE;
-
-  if (vino_local_only == local_only)
-    return;
-
-  vino_local_only = local_only;
-
-  dprintf (PREFS, "Local only changed: %s\n", vino_local_only ? "(true)" : "(false)");
-
-  for (l = vino_servers; l; l = l->next)
-    vino_server_set_local_only (l->data, local_only);
-}
-
-static void
 vino_prefs_require_encryption_changed (GConfClient *client,
 				       guint        cnxn_id,
 				       GConfEntry  *entry)
@@ -392,17 +369,47 @@
     }
 }
 
+static void
+vino_prefs_network_interface_changed (GConfClient *client,
+				 guint        cnxn_id,
+				 GConfEntry  *entry)
+{
+  const char *network_interface;
+  GSList     *l;
+
+  if (!entry->value || entry->value->type != GCONF_VALUE_STRING)
+    return;
+  
+  network_interface = gconf_value_get_string (entry->value);
+
+  if (!network_interface && !vino_network_interface)
+    return;
+
+  if (network_interface && vino_network_interface &&
+      !strcmp (network_interface, vino_network_interface))
+    return;
+
+  if (vino_network_interface)
+    g_free (vino_network_interface);
+
+  vino_network_interface = g_strdup (network_interface);
+
+  dprintf (PREFS, "Network Interface for bind() changed: %s\n",
+	   vino_network_interface ? vino_network_interface : "(null)");
+
+  for (l = vino_servers; l; l = l->next)
+    vino_server_set_network_interface (l->data, network_interface);
+}
+
 void
 vino_prefs_create_server (GdkScreen *screen)
 {
   VinoServer     *server;
   VinoStatusIcon *icon;
 
-
   server = g_object_new (VINO_TYPE_SERVER,
 			 "prompt-enabled",       vino_prompt_enabled,
 			 "view-only",            vino_view_only,
-			 "local-only",           vino_local_only,
 			 "use-alternative-port", vino_use_alternative_port,
 			 "alternative-port",     vino_alternative_port,
 			 "auth-methods",         vino_auth_methods,
@@ -410,7 +417,8 @@
 			 "vnc-password",         vino_vnc_password,
 			 "on-hold",              !vino_enabled,
 			 "screen",               screen,
-                         "lock-screen",          vino_lock_screen,
+             "lock-screen",          vino_lock_screen,
+             "network-interface",    vino_network_interface,
 			 NULL);
 
   vino_servers = g_slist_prepend (vino_servers, server);
@@ -454,12 +462,13 @@
 					      NULL);
     }
   dprintf (PREFS, "View only: %s\n", vino_view_only ? "(true)" : "(false)");
-      
-  vino_local_only = gconf_client_get_bool (vino_client,
-					   VINO_PREFS_LOCAL_ONLY,
-					   NULL);
-  dprintf (PREFS, "Local only: %s\n", vino_local_only ? "(true)" : "(false)");
 
+  vino_network_interface = gconf_client_get_string(vino_client,
+                       VINO_PREFS_NETWORK_INTERFACE,
+                       NULL);
+  dprintf (PREFS, "Network Interface bind(): %s\n", 
+                vino_network_interface ? vino_network_interface : VINO_DEFAULT_NETWORK_INTERFACE);
+
   vino_use_alternative_port = gconf_client_get_bool (vino_client,
                                                      VINO_PREFS_USE_ALTERNATIVE_PORT,
                                                      NULL);
@@ -535,8 +544,8 @@
 
   vino_listeners [i] =
     gconf_client_notify_add (vino_client,
-			     VINO_PREFS_LOCAL_ONLY,
-			     (GConfClientNotifyFunc) vino_prefs_local_only_changed,
+			     VINO_PREFS_NETWORK_INTERFACE,
+			     (GConfClientNotifyFunc) vino_prefs_network_interface_changed,
 			     NULL, NULL, NULL);
   i++;
 
