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,37 +11688,38 @@ int SetPorts() ...@@ -11688,37 +11688,38 @@ int SetPorts()
// ing, causing a loop. // ing, causing a loop.
// //
useCupsSocket = 0;
if (cupsPort.enabled()) {
if (control -> ProxyMode == proxy_client) { if (control -> ProxyMode == proxy_client) {
// ChannelEndPoint::enabled() implements the logic described above,
// and takes the default port into consideration. If cups=1, and
// there is a default port, then enabled() will return true.
//
// Therefore, we must set the default port before calling this
// function.
cupsPort.setDefaultTCPPort(DEFAULT_NX_CUPS_PORT_OFFSET + proxyPort); cupsPort.setDefaultTCPPort(DEFAULT_NX_CUPS_PORT_OFFSET + proxyPort);
useCupsSocket = 1; useCupsSocket = cupsPort.enabled();
} } else {
else
cupsPort.setDefaultTCPPort(631); 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 (auxPort.enabled()) {
if (control -> ProxyMode == proxy_client) { if (control -> ProxyMode == proxy_client) {
auxPort.setDefaultTCPPort(DEFAULT_NX_AUX_PORT_OFFSET + proxyPort); auxPort.setDefaultTCPPort(DEFAULT_NX_AUX_PORT_OFFSET + proxyPort);
useAuxSocket = 1; useAuxSocket = auxPort.enabled();
} } else {
else {
auxPort.setDefaultTCPPort(1); auxPort.setDefaultTCPPort(1);
if (auxPort.getTCPPort() != 1) { if ( auxPort.getTCPPort() != 1 ) {
#ifdef WARNING
#ifdef WARNING
*logofs << "Loop: WARNING! Overriding auxiliary X11 " *logofs << "Loop: WARNING! Overriding auxiliary X11 "
<< "port with new value '" << 1 << "'.\n" << "port with new value '" << 1 << "'.\n"
<< logofs_flush; << logofs_flush;
#endif #endif
cerr << "Warning" << ": Overriding auxiliary X11 " cerr << "Warning" << ": Overriding auxiliary X11 "
<< "port with new value '" << 1 << "'.\n"; << "port with new value '" << 1 << "'.\n";
...@@ -11726,21 +11727,17 @@ int SetPorts() ...@@ -11726,21 +11727,17 @@ int SetPorts()
auxPort.setSpec("1"); auxPort.setSpec("1");
} }
} }
}
#ifdef TEST #ifdef TEST
*logofs << "Loop: aux port: " << auxPort << "\n" *logofs << "Loop: aux port: " << auxPort << "\n"
<< logofs_flush; << logofs_flush;
#endif #endif
useSmbSocket = 0;
if (smbPort.enabled()) {
if (control -> ProxyMode == proxy_client) { if (control -> ProxyMode == proxy_client) {
auxPort.setDefaultTCPPort(DEFAULT_NX_SMB_PORT_OFFSET + proxyPort); smbPort.setDefaultTCPPort(DEFAULT_NX_SMB_PORT_OFFSET + proxyPort);
useAuxSocket = 1; useSmbSocket = smbPort.enabled();
} } else {
else smbPort.setDefaultTCPPort(139);
auxPort.setDefaultTCPPort(139);
} }
...@@ -11749,17 +11746,16 @@ int SetPorts() ...@@ -11749,17 +11746,16 @@ int SetPorts()
<< logofs_flush; << logofs_flush;
#endif #endif
useMediaSocket = 0;
if (mediaPort.enabled()) {
if (control -> ProxyMode == proxy_client) { if (control -> ProxyMode == proxy_client) {
mediaPort.setDefaultTCPPort(DEFAULT_NX_MEDIA_PORT_OFFSET + proxyPort); mediaPort.setDefaultTCPPort(DEFAULT_NX_MEDIA_PORT_OFFSET + proxyPort);
useMediaSocket = 1; useMediaSocket = mediaPort.enabled();
} } else {
else if (mediaPort.getTCPPort() == 1) {
#ifdef PANIC if ( !mediaPort.enabled() ) {
#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 (httpPort.enabled()) {
if (control -> ProxyMode == proxy_client) { 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,12 +11815,10 @@ int SetPorts() ...@@ -11822,12 +11815,10 @@ int SetPorts()
#endif #endif
} }
useSlaveSocket = 0; if (control -> ProxyMode == proxy_client) {
if (slavePort.enabled()) {
useSlaveSocket = 1;
if (control -> ProxyMode == proxy_client)
slavePort.setDefaultTCPPort(DEFAULT_NX_SLAVE_PORT_CLIENT_OFFSET + proxyPort); slavePort.setDefaultTCPPort(DEFAULT_NX_SLAVE_PORT_CLIENT_OFFSET + proxyPort);
else useSlaveSocket = slavePort.enabled();
} else {
slavePort.setDefaultTCPPort(DEFAULT_NX_SLAVE_PORT_SERVER_OFFSET + proxyPort); slavePort.setDefaultTCPPort(DEFAULT_NX_SLAVE_PORT_SERVER_OFFSET + proxyPort);
} }
......
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