If we use a port<1024 for HTTP server, then just assign a 'dynamic'/random port

This commit is contained in:
craig.p.drummond
2013-03-11 19:53:25 +00:00
parent 4e816d374f
commit f18b02ce47
4 changed files with 8 additions and 5 deletions

View File

@@ -521,7 +521,7 @@ int Settings::stopFadeDuration()
#ifdef TAGLIB_FOUND
int Settings::httpPort()
{
return GET_INT("httpPort", 9001);
return GET_INT("httpPort", 1023);
}
QString Settings::httpAddress()

View File

@@ -23,18 +23,21 @@
#include "httpserversettings.h"
#include "settings.h"
#include "localize.h"
HttpServerSettings::HttpServerSettings(QWidget *p)
: QWidget(p)
{
setupUi(this);
httpPort->setSpecialValueText(i18n("Dynamic"));
}
void HttpServerSettings::load()
{
int port=Settings::self()->httpPort();
enableHttp->setChecked(Settings::self()->enableHttp());
alwaysUseHttp->setChecked(Settings::self()->alwaysUseHttp());
httpPort->setValue(Settings::self()->httpPort());
httpPort->setValue(port<1024 ? 1023 : port);
httpAddress->setText(Settings::self()->httpAddress());
}

View File

@@ -66,7 +66,7 @@
<item row="3" column="1">
<widget class="SpinBox" name="httpPort">
<property name="minimum">
<number>1</number>
<number>1023</number>
</property>
<property name="maximum">
<number>65535</number>
@@ -108,7 +108,7 @@
<widget class="QLabel" name="label_4">
<property name="text">
<string>&lt;i&gt;&lt;b&gt;NOTE:&lt;/b&gt; MPD usually only plays songs that are stored within its folders. If you have connected via a local socket, then MPD can also play files located on your filesystem. If you are using a non local socket (e.g. you have entered a hostname or IP address in the 'Host' field of the 'Connection' settings page), then Cantata contains a minimal HTTP server that can be used to serve files to MPD. This, however, will only work whilst Cantata is running. If you enable 'Always use server', then Cantata will always pass server URLs to MPD for files, even when you have connected via a local socket.&lt;br/&gt;&lt;br/&gt;
&lt;b&gt;NOTE:&lt;/b&gt; 'Address/interface' may contain either the IP address, or interface (e.g. eth0), that you wish to listen for connections on. Leave blank to use the local loopback address (127.0.0.1).&lt;/i&gt;&lt;/i&gt;</string>
&lt;b&gt;NOTE:&lt;/b&gt; 'Address/interface' may contain either the IP address, or interface (e.g. eth0), that you wish to listen for connections on. Leave blank to use the local loopback address (127.0.0.1).&lt;br/&gt;&lt;br/&gt;&lt;b&gt;NOTE:&lt;/b&gt; Leave port set to 'Dynamic' to have Cantata choose a random port number.&lt;/i&gt;</string>
</property>
<property name="wordWrap">
<bool>true</bool>

View File

@@ -186,7 +186,7 @@ HttpSocket::HttpSocket(const QString &addr, quint16 p)
}
}
}
listen(a.isNull() ? QHostAddress::LocalHost : a, p);
listen(a.isNull() ? QHostAddress::LocalHost : a, p<1024 ? 0 : p);
}
void HttpSocket::terminate()