mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-04 05:07:27 +02:00
Clean up port logic
This commit is contained in:
@@ -92,17 +92,30 @@ bool
|
|||||||
Servent::startListening( QHostAddress ha, bool upnp, int port )
|
Servent::startListening( QHostAddress ha, bool upnp, int port )
|
||||||
{
|
{
|
||||||
m_port = port;
|
m_port = port;
|
||||||
// try listening on one port higher as well, to aid debugging
|
int defPort = TomahawkSettings::instance()->defaultPort();
|
||||||
// and let you run 2 instances easily
|
// Listen on both the selected port and, if not the same, the default port -- the latter sometimes necessary for zeroconf
|
||||||
if( !listen( ha, m_port ) && !listen( ha, ++m_port ) )
|
// TODO: only listen on both when zeroconf sip is enabled
|
||||||
|
// TODO: use a real zeroconf system instead of a simple UDP broadcast?
|
||||||
|
if( !listen( ha, m_port ) )
|
||||||
{
|
{
|
||||||
qDebug() << "Failed to listen on port" << m_port;
|
bool defPortAlso = false;
|
||||||
qDebug() << "Error string is " << errorString();
|
if( m_port != defPort )
|
||||||
return false;
|
defPortAlso = listen( ha, defPort );
|
||||||
|
if( !defPortAlso )
|
||||||
|
{
|
||||||
|
qDebug() << "Failed to listen on both port " << m_port << " and port " << defPort;
|
||||||
|
qDebug() << "Error string is " << errorString();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
qDebug() << "Servent listening on port " << defPort << " servent thread:" << thread();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
qDebug() << "Servent listening on port" << m_port << " servent thread:" << thread();
|
bool defPortAlso = listen( ha, defPort );
|
||||||
|
qDebug() << "Servent listening on port " << m_port << " servent thread:" << thread();
|
||||||
|
if( defPortAlso )
|
||||||
|
qDebug() << "Servent also listening on port " << defPort << " servent thread:" << thread();
|
||||||
}
|
}
|
||||||
|
|
||||||
// --lanhack means to advertise your LAN IP over jabber as if it were externallyVisible
|
// --lanhack means to advertise your LAN IP over jabber as if it were externallyVisible
|
||||||
|
@@ -377,6 +377,12 @@ TomahawkSettings::setExternalHostname(const QString& externalHostname)
|
|||||||
setValue( "network/external-hostname", externalHostname );
|
setValue( "network/external-hostname", externalHostname );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
TomahawkSettings::defaultPort() const
|
||||||
|
{
|
||||||
|
return 50210;
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
TomahawkSettings::externalPort() const
|
TomahawkSettings::externalPort() const
|
||||||
{
|
{
|
||||||
|
@@ -95,6 +95,7 @@ public:
|
|||||||
QString externalHostname() const;
|
QString externalHostname() const;
|
||||||
void setExternalHostname( const QString& externalHostname );
|
void setExternalHostname( const QString& externalHostname );
|
||||||
|
|
||||||
|
int defaultPort() const;
|
||||||
int externalPort() const;
|
int externalPort() const;
|
||||||
void setExternalPort( int externalPort );
|
void setExternalPort( int externalPort );
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user