mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-04 13:17:34 +02:00
* Fixed issue where Servent would never emit ready when UPnP returns an invalid ip.
This commit is contained in:
@@ -139,23 +139,7 @@ Servent::startListening( QHostAddress ha, bool upnp, int port )
|
|||||||
switch ( mode )
|
switch ( mode )
|
||||||
{
|
{
|
||||||
case TomahawkSettings::Lan:
|
case TomahawkSettings::Lan:
|
||||||
foreach( QHostAddress ha, QNetworkInterface::allAddresses() )
|
setInternalAddress();
|
||||||
{
|
|
||||||
if( ha.toString() == "127.0.0.1" ) continue;
|
|
||||||
if( ha.toString().contains( ":" ) ) continue; //ipv6
|
|
||||||
|
|
||||||
if ( qApp->arguments().contains( "--lanhack" ) )
|
|
||||||
{
|
|
||||||
tLog() << "LANHACK: set external address to lan address" << ha.toString();
|
|
||||||
QMetaObject::invokeMethod( this, "setExternalAddress", Qt::QueuedConnection, Q_ARG( QHostAddress, ha ), Q_ARG( unsigned int, m_port ) );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
m_ready = true;
|
|
||||||
emit ready();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TomahawkSettings::Upnp:
|
case TomahawkSettings::Upnp:
|
||||||
@@ -189,6 +173,31 @@ Servent::createConnectionKey( const QString& name, const QString &nodeid, const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
Servent::setInternalAddress()
|
||||||
|
{
|
||||||
|
foreach ( QHostAddress ha, QNetworkInterface::allAddresses() )
|
||||||
|
{
|
||||||
|
if ( ha.toString() == "127.0.0.1" )
|
||||||
|
continue;
|
||||||
|
if ( ha.toString().contains( ":" ) )
|
||||||
|
continue; //ipv6
|
||||||
|
|
||||||
|
if ( qApp->arguments().contains( "--lanhack" ) )
|
||||||
|
{
|
||||||
|
tLog() << "LANHACK: set external address to lan address" << ha.toString();
|
||||||
|
setExternalAddress( ha, m_port );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_ready = true;
|
||||||
|
emit ready();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Servent::setExternalAddress( QHostAddress ha, unsigned int port )
|
Servent::setExternalAddress( QHostAddress ha, unsigned int port )
|
||||||
{
|
{
|
||||||
@@ -198,6 +207,7 @@ Servent::setExternalAddress( QHostAddress ha, unsigned int port )
|
|||||||
if ( ip.startsWith( "10." ) || ip.startsWith( "172.16." ) || ip.startsWith( "192.168." ) )
|
if ( ip.startsWith( "10." ) || ip.startsWith( "172.16." ) || ip.startsWith( "192.168." ) )
|
||||||
{
|
{
|
||||||
tDebug() << Q_FUNC_INFO << "Tried to set an invalid ip as external address!";
|
tDebug() << Q_FUNC_INFO << "Tried to set an invalid ip as external address!";
|
||||||
|
setInternalAddress();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -134,6 +134,7 @@ protected:
|
|||||||
void incomingConnection( int sd );
|
void incomingConnection( int sd );
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
void setInternalAddress();
|
||||||
void setExternalAddress( QHostAddress ha, unsigned int port );
|
void setExternalAddress( QHostAddress ha, unsigned int port );
|
||||||
|
|
||||||
void socketError( QAbstractSocket::SocketError );
|
void socketError( QAbstractSocket::SocketError );
|
||||||
|
Reference in New Issue
Block a user