Commit 5f1eb0dc authored by Vadim Troshchinskiy's avatar Vadim Troshchinskiy

Fix nxagent argument parsing logic

This makes it so that slave=1 works again as it should. The changes introduced earlier resulted in the unintentional requirement to specify the actual port number, breaking backwards compatibility. Fixes: ArcticaProject/nx-libs#518
parent 3c95d604
...@@ -150,6 +150,7 @@ ChannelEndPoint::getSpec(char **socketUri) const { ...@@ -150,6 +150,7 @@ ChannelEndPoint::getSpec(char **socketUri) const {
void void
ChannelEndPoint::setDefaultTCPPort(long port) { ChannelEndPoint::setDefaultTCPPort(long port) {
defaultTCPPort_ = port; defaultTCPPort_ = port;
isTCP_ = getTCPHostAndPort();
} }
void void
...@@ -165,6 +166,8 @@ ChannelEndPoint::setDefaultUnixPath(char *path) { ...@@ -165,6 +166,8 @@ ChannelEndPoint::setDefaultUnixPath(char *path) {
defaultUnixPath_ = strdup(path); defaultUnixPath_ = strdup(path);
else else
defaultUnixPath_ = NULL; defaultUnixPath_ = NULL;
isUnix_ = getUnixPath();
} }
void void
......
...@@ -11688,43 +11688,43 @@ int SetPorts() ...@@ -11688,43 +11688,43 @@ int SetPorts()
// ing, causing a loop. // ing, causing a loop.
// //
useCupsSocket = 0; if (control -> ProxyMode == proxy_client) {
if (cupsPort.enabled()) { // ChannelEndPoint::enabled() implements the logic described above,
if (control -> ProxyMode == proxy_client) { // and takes the default port into consideration. If cups=1, and
cupsPort.setDefaultTCPPort(DEFAULT_NX_CUPS_PORT_OFFSET + proxyPort); // there is a default port, then enabled() will return true.
useCupsSocket = 1; //
} // Therefore, we must set the default port before calling this
else // function.
cupsPort.setDefaultTCPPort(631); cupsPort.setDefaultTCPPort(DEFAULT_NX_CUPS_PORT_OFFSET + proxyPort);
useCupsSocket = cupsPort.enabled();
} else {
cupsPort.setDefaultTCPPort(631);
} }
#ifdef TEST #ifdef TEST
*logofs << "Loop: cups port: " << cupsPort << "\n" *logofs << "Loop: cups port: " << cupsPort << "\n"
<< logofs_flush; << logofs_flush;
#endif #endif
useAuxSocket = 0; if (control -> ProxyMode == proxy_client) {
if (auxPort.enabled()) { auxPort.setDefaultTCPPort(DEFAULT_NX_AUX_PORT_OFFSET + proxyPort);
if (control -> ProxyMode == proxy_client) { useAuxSocket = auxPort.enabled();
auxPort.setDefaultTCPPort(DEFAULT_NX_AUX_PORT_OFFSET + proxyPort); } else {
useAuxSocket = 1; auxPort.setDefaultTCPPort(1);
}
else {
auxPort.setDefaultTCPPort(1);
if (auxPort.getTCPPort() != 1) {
#ifdef WARNING if ( auxPort.getTCPPort() != 1 ) {
*logofs << "Loop: WARNING! Overriding auxiliary X11 " #ifdef WARNING
<< "port with new value '" << 1 << "'.\n" *logofs << "Loop: WARNING! Overriding auxiliary X11 "
<< logofs_flush; << "port with new value '" << 1 << "'.\n"
#endif << logofs_flush;
#endif
cerr << "Warning" << ": Overriding auxiliary X11 " cerr << "Warning" << ": Overriding auxiliary X11 "
<< "port with new value '" << 1 << "'.\n"; << "port with new value '" << 1 << "'.\n";
auxPort.setSpec("1"); auxPort.setSpec("1");
}
} }
} }
...@@ -11733,14 +11733,11 @@ int SetPorts() ...@@ -11733,14 +11733,11 @@ int SetPorts()
<< logofs_flush; << logofs_flush;
#endif #endif
useSmbSocket = 0; if (control -> ProxyMode == proxy_client) {
if (smbPort.enabled()) { smbPort.setDefaultTCPPort(DEFAULT_NX_SMB_PORT_OFFSET + proxyPort);
if (control -> ProxyMode == proxy_client) { useSmbSocket = smbPort.enabled();
auxPort.setDefaultTCPPort(DEFAULT_NX_SMB_PORT_OFFSET + proxyPort); } else {
useAuxSocket = 1; smbPort.setDefaultTCPPort(139);
}
else
auxPort.setDefaultTCPPort(139);
} }
...@@ -11749,17 +11746,16 @@ int SetPorts() ...@@ -11749,17 +11746,16 @@ int SetPorts()
<< logofs_flush; << logofs_flush;
#endif #endif
useMediaSocket = 0; if (control -> ProxyMode == proxy_client) {
if (mediaPort.enabled()) { mediaPort.setDefaultTCPPort(DEFAULT_NX_MEDIA_PORT_OFFSET + proxyPort);
if (control -> ProxyMode == proxy_client) { useMediaSocket = mediaPort.enabled();
mediaPort.setDefaultTCPPort(DEFAULT_NX_MEDIA_PORT_OFFSET + proxyPort); } else {
useMediaSocket = 1;
} if ( !mediaPort.enabled() ) {
else if (mediaPort.getTCPPort() == 1) { #ifdef PANIC
#ifdef PANIC
*logofs << "Loop: PANIC! No port specified for multimedia connections.\n" *logofs << "Loop: PANIC! No port specified for multimedia connections.\n"
<< logofs_flush; << logofs_flush;
#endif #endif
cerr << "Error" << ": No port specified for multimedia connections.\n"; cerr << "Error" << ": No port specified for multimedia connections.\n";
...@@ -11772,13 +11768,10 @@ int SetPorts() ...@@ -11772,13 +11768,10 @@ int SetPorts()
<< "'.\n" << logofs_flush; << "'.\n" << logofs_flush;
#endif #endif
useHttpSocket = 0; if (control -> ProxyMode == proxy_client) {
if (httpPort.enabled()) {
if (control -> ProxyMode == proxy_client) {
httpPort.setDefaultTCPPort(DEFAULT_NX_HTTP_PORT_OFFSET + proxyPort); httpPort.setDefaultTCPPort(DEFAULT_NX_HTTP_PORT_OFFSET + proxyPort);
useHttpSocket = 1; useHttpSocket = httpPort.enabled();
} } else {
else
httpPort.setDefaultTCPPort(80); httpPort.setDefaultTCPPort(80);
} }
...@@ -11822,13 +11815,11 @@ int SetPorts() ...@@ -11822,13 +11815,11 @@ int SetPorts()
#endif #endif
} }
useSlaveSocket = 0; if (control -> ProxyMode == proxy_client) {
if (slavePort.enabled()) { slavePort.setDefaultTCPPort(DEFAULT_NX_SLAVE_PORT_CLIENT_OFFSET + proxyPort);
useSlaveSocket = 1; useSlaveSocket = slavePort.enabled();
if (control -> ProxyMode == proxy_client) } else {
slavePort.setDefaultTCPPort(DEFAULT_NX_SLAVE_PORT_CLIENT_OFFSET + proxyPort); slavePort.setDefaultTCPPort(DEFAULT_NX_SLAVE_PORT_SERVER_OFFSET + proxyPort);
else
slavePort.setDefaultTCPPort(DEFAULT_NX_SLAVE_PORT_SERVER_OFFSET + proxyPort);
} }
#ifdef TEST #ifdef TEST
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment