diff options
author | Adam Tkac <atkac@redhat.com> | 2010-02-05 15:54:10 +0000 |
---|---|---|
committer | Adam Tkac <atkac@redhat.com> | 2010-02-05 15:54:10 +0000 |
commit | 93ff5dbd1ad8ad595c87fc127d62d4453fd35d9a (patch) | |
tree | 452fb1bcc1287c07d799e3167cdb0167a88de0c4 /unix | |
parent | be6b28efc0b45f711ba0997b0cdce3d2a06b4f63 (diff) | |
download | tigervnc-93ff5dbd1ad8ad595c87fc127d62d4453fd35d9a.tar.gz tigervnc-93ff5dbd1ad8ad595c87fc127d62d4453fd35d9a.zip |
[Development] Add new "-i" and "-interface" parameters to Xvnc. Now Xvnc is able
to listen on specific interface.
git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@3963 3789f03b-4d11-0410-bbf8-ca57d06f2519
Diffstat (limited to 'unix')
-rw-r--r-- | unix/vncviewer/vncviewer.cxx | 2 | ||||
-rw-r--r-- | unix/x0vncserver/x0vncserver.cxx | 2 | ||||
-rw-r--r-- | unix/xserver/hw/vnc/Xvnc.man | 4 | ||||
-rw-r--r-- | unix/xserver/hw/vnc/vncExtInit.cc | 13 | ||||
-rw-r--r-- | unix/xserver/hw/vnc/xvnc.cc | 22 |
5 files changed, 35 insertions, 8 deletions
diff --git a/unix/vncviewer/vncviewer.cxx b/unix/vncviewer/vncviewer.cxx index 5a4ee37d..9cbe295b 100644 --- a/unix/vncviewer/vncviewer.cxx +++ b/unix/vncviewer/vncviewer.cxx @@ -370,7 +370,7 @@ int main(int argc, char** argv) if (vncServerName && isdigit(vncServerName[0])) port = atoi(vncServerName); - TcpListener listener(port); + TcpListener listener(NULL, port); vlog.info("Listening on port %d\n",port); diff --git a/unix/x0vncserver/x0vncserver.cxx b/unix/x0vncserver/x0vncserver.cxx index ec2fd764..771f21c4 100644 --- a/unix/x0vncserver/x0vncserver.cxx +++ b/unix/x0vncserver/x0vncserver.cxx @@ -447,7 +447,7 @@ int main(int argc, char** argv) QueryConnHandler qcHandler(dpy, &server); server.setQueryConnectionHandler(&qcHandler); - TcpListener listener((int)rfbport); + TcpListener listener(NULL, (int)rfbport); vlog.info("Listening on port %d", (int)rfbport); const char *hostsData = hostsFile.getData(); diff --git a/unix/xserver/hw/vnc/Xvnc.man b/unix/xserver/hw/vnc/Xvnc.man index 865d408e..356925df 100644 --- a/unix/xserver/hw/vnc/Xvnc.man +++ b/unix/xserver/hw/vnc/Xvnc.man @@ -48,6 +48,10 @@ next three green, and the least significant three represent red), the default for depth 16 is RGB565 and for depth 24 is RGB888. .TP +.B \-interface \fIIP address\fP or \-i \fIIP address\fP +Listen on interface. By default Xvnc listens on all available interfaces. + +.TP .B \-cc 3 As an alternative to the default TrueColor visual, this allows you to run an Xvnc server with a PseudoColor visual (i.e. one which uses a color map or diff --git a/unix/xserver/hw/vnc/vncExtInit.cc b/unix/xserver/hw/vnc/vncExtInit.cc index 0364adc4..36948681 100644 --- a/unix/xserver/hw/vnc/vncExtInit.cc +++ b/unix/xserver/hw/vnc/vncExtInit.cc @@ -72,6 +72,7 @@ extern "C" { pointer args); extern char *display; + extern char *listenaddr; } using namespace rfb; @@ -223,22 +224,24 @@ void vncExtensionInit() if (network::TcpSocket::isSocket(vncInetdSock) && !network::TcpSocket::isConnected(vncInetdSock)) { - listener = new network::TcpListener(0, 0, vncInetdSock, true); + listener = new network::TcpListener(NULL, 0, 0, vncInetdSock, true); vlog.info("inetd wait"); } } else { int port = rfbport; if (port == 0) port = 5900 + atoi(display); port += 1000 * scr; - listener = new network::TcpListener(port, localhostOnly); - vlog.info("Listening for VNC connections on port %d",port); + listener = new network::TcpListener(listenaddr, port, localhostOnly); + vlog.info("Listening for VNC connections on %s interface(s), port %d", + listenaddr == NULL ? "all" : listenaddr, port); CharArray httpDirStr(httpDir.getData()); if (httpDirStr.buf[0]) { port = httpPort; if (port == 0) port = 5800 + atoi(display); port += 1000 * scr; - httpListener = new network::TcpListener(port, localhostOnly); - vlog.info("Listening for HTTP connections on port %d",port); + httpListener = new network::TcpListener(listenaddr, port, localhostOnly); + vlog.info("Listening for HTTP connections on %s interface(s), port %d", + listenaddr == NULL ? "all" : listenaddr, port); } } diff --git a/unix/xserver/hw/vnc/xvnc.cc b/unix/xserver/hw/vnc/xvnc.cc index 1fe3473c..62564d32 100644 --- a/unix/xserver/hw/vnc/xvnc.cc +++ b/unix/xserver/hw/vnc/xvnc.cc @@ -164,6 +164,8 @@ static bool displaySpecified = false; static bool wellKnownSocketsCreated = false; static char displayNumStr[16]; +char *listenaddr = NULL; + static void vfbInitializePixmapDepths(void) @@ -284,6 +286,7 @@ ddxUseMsg() ErrorF("-depth D set screen 0's depth\n"); ErrorF("-pixelformat fmt set pixel format (rgbNNN or bgrNNN)\n"); ErrorF("-inetd has been launched from inetd\n"); + ErrorF("-interface IP_address listen on specified interface\n"); ErrorF("\nVNC parameters:\n"); fprintf(stderr,"\n" @@ -306,7 +309,7 @@ static bool displayNumFree(int num) { try { - network::TcpListener l(6000+num); + network::TcpListener l(NULL, 6000+num); } catch (rdr::Exception& e) { return false; } @@ -544,6 +547,23 @@ ddxProcessArgument(int argc, char *argv[], int i) return 1; } + + if (strcmp(argv[i], "-interface") == 0 || + strcmp(argv[i], "-i") == 0) { + if (++i >= argc) { + UseMsg(); + return 2; + } + + if (listenaddr != NULL) /* Only first -interface is valid */ + return 2; + + listenaddr = strdup(argv[i]); + if (listenaddr == NULL) + FatalError("Not enough memory"); + + return 2; + } if (rfb::Configuration::setParam(argv[i])) return 1; |