Browse Source

More graceful handling of disabled listeners

Don't assume a lack of TCP listeners means the server will be
unreachable. There might be other methods of access, so let the higher
levels do that sanity check instead.
pull/1672/head
Pierre Ossman 8 months ago
parent
commit
963f11e313

+ 0
- 4
common/network/TcpSocket.cxx View File

@@ -496,10 +496,6 @@ void network::createTcpListeners(std::list<SocketListener*> *listeners,
}
}

if (new_listeners.empty ())
throw SocketException("createTcpListeners: no addresses available",
EADDRNOTAVAIL);

listeners->splice (listeners->end(), new_listeners);
}


+ 16
- 5
unix/x0vncserver/x0vncserver.cxx View File

@@ -306,16 +306,22 @@ int main(int argc, char** argv)
}

if ((int)rfbport != -1) {
std::list<network::SocketListener*> tcp_listeners;
const char *addr = interface;

if (strcasecmp(addr, "all") == 0)
addr = 0;
if (localhostOnly)
createLocalTcpListeners(&listeners, (int)rfbport);
createLocalTcpListeners(&tcp_listeners, (int)rfbport);
else
createTcpListeners(&listeners, addr, (int)rfbport);
vlog.info("Listening for VNC connections on %s interface(s), port %d",
localhostOnly ? "local" : (const char*)interface,
(int)rfbport);
createTcpListeners(&tcp_listeners, addr, (int)rfbport);

if (!tcp_listeners.empty()) {
listeners.splice (listeners.end(), tcp_listeners);
vlog.info("Listening for VNC connections on %s interface(s), port %d",
localhostOnly ? "local" : (const char*)interface,
(int)rfbport);
}

FileTcpFilter fileTcpFilter(hostsFile);
if (strlen(hostsFile) != 0)
@@ -325,6 +331,11 @@ int main(int argc, char** argv)
(*i)->setFilter(&fileTcpFilter);
}

if (listeners.empty()) {
vlog.error("No path or port configured for incoming connections");
return -1;
}

PollingScheduler sched((int)pollingCycle, (int)maxProcessorUsage);

while (!caughtSignal) {

+ 12
- 5
unix/xserver/hw/vnc/vncExtInit.cc View File

@@ -229,6 +229,7 @@ void vncExtensionInit(void)
}

if (!inetd && rfbport != -1) {
std::list<network::SocketListener*> tcp_listeners;
const char *addr = interface;
int port = rfbport;
if (port == 0) port = 5900 + atoi(vncGetDisplay());
@@ -236,15 +237,21 @@ void vncExtensionInit(void)
if (strcasecmp(addr, "all") == 0)
addr = 0;
if (localhostOnly)
network::createLocalTcpListeners(&listeners, port);
network::createLocalTcpListeners(&tcp_listeners, port);
else
network::createTcpListeners(&listeners, addr, port);
network::createTcpListeners(&tcp_listeners, addr, port);

vlog.info("Listening for VNC connections on %s interface(s), port %d",
localhostOnly ? "local" : (const char*)interface,
port);
if (!tcp_listeners.empty()) {
listeners.splice (listeners.end(), tcp_listeners);
vlog.info("Listening for VNC connections on %s interface(s), port %d",
localhostOnly ? "local" : (const char*)interface,
port);
}
}

if (!inetd && listeners.empty())
throw rdr::Exception("No path or port configured for incoming connections");

PixelFormat pf = vncGetPixelFormat(scr);

vncSetGlueContext(scr);

+ 2
- 0
vncviewer/vncviewer.cxx View File

@@ -756,6 +756,8 @@ int main(int argc, char** argv)
port = atoi(vncServerName);

createTcpListeners(&listeners, 0, port);
if (listeners.empty())
throw Exception(_("Unable to listen for incoming connections"));

vlog.info(_("Listening on port %d"), port);


Loading…
Cancel
Save