1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-09 07:36:48 +02:00

* Re-introduce the asserts in Servent. They must not happen.

This commit is contained in:
Christian Muehlhaeuser
2013-01-27 17:58:15 +01:00
parent 835e64fe55
commit 168c4f7ab7
2 changed files with 72 additions and 80 deletions

View File

@@ -70,23 +70,22 @@ Servent::Servent( QObject* parent )
s_instance = this;
m_lanHack = qApp->arguments().contains( "--lanhack" );
m_noAuth = qApp->arguments().contains( "--noauth" );
setProxy( QNetworkProxy::NoProxy );
{
boost::function<QSharedPointer<QIODevice>(result_ptr)> fac =
boost::bind( &Servent::localFileIODeviceFactory, this, _1 );
boost::function<QSharedPointer<QIODevice>(result_ptr)> fac = boost::bind( &Servent::localFileIODeviceFactory, this, _1 );
this->registerIODeviceFactory( "file", fac );
}
{
boost::function<QSharedPointer<QIODevice>(result_ptr)> fac =
boost::bind( &Servent::remoteIODeviceFactory, this, _1 );
boost::function<QSharedPointer<QIODevice>(result_ptr)> fac = boost::bind( &Servent::remoteIODeviceFactory, this, _1 );
this->registerIODeviceFactory( "servent", fac );
}
{
boost::function<QSharedPointer<QIODevice>(result_ptr)> fac =
boost::bind( &Servent::httpIODeviceFactory, this, _1 );
boost::function<QSharedPointer<QIODevice>(result_ptr)> fac = boost::bind( &Servent::httpIODeviceFactory, this, _1 );
this->registerIODeviceFactory( "http", fac );
}
}
@@ -254,6 +253,7 @@ Servent::registerOffer( const QString& key, Connection* conn )
void
Servent::registerControlConnection( ControlConnection* conn )
{
Q_ASSERT( conn );
m_controlconnections.append( conn );
}
@@ -261,13 +261,9 @@ Servent::registerControlConnection( ControlConnection* conn )
void
Servent::unregisterControlConnection( ControlConnection* conn )
{
QList<ControlConnection*> n;
foreach( ControlConnection* c, m_controlconnections )
if( c!=conn )
n.append( c );
Q_ASSERT( conn );
m_connectedNodes.removeAll( conn->id() );
m_controlconnections = n;
m_controlconnections.removeAll( conn );
}
@@ -508,11 +504,9 @@ Servent::readyRead()
peerInfoDebug( currentPeerInfo );
}
foreach ( ControlConnection* keepConnection, m_controlconnections )
{
if( !keepConnection )
continue;
Q_ASSERT( keepConnection );
if ( keepConnection->id() == nodeid )
{
@@ -713,7 +707,6 @@ Servent::connectToPeer( const peerinfo_ptr& peerInfo )
{
conn = c;
foreach ( const peerinfo_ptr& currentPeerInfo, c->peerInfos() )
{
peerInfoDebug( currentPeerInfo ) << "Same object: " << ( peerInfo == currentPeerInfo ) << ( peerInfo.data() == currentPeerInfo.data() ) << ( peerInfo->debugName() == currentPeerInfo->debugName() );
@@ -845,18 +838,17 @@ Servent::reverseOfferRequest( ControlConnection* orig_conn, const QString& their
Connection*
Servent::claimOffer( ControlConnection* cc, const QString &nodeid, const QString &key, const QHostAddress peer )
{
bool noauth = qApp->arguments().contains( "--noauth" );
// magic key for stream connections:
if ( key.startsWith( "FILE_REQUEST_KEY:" ) )
{
// check if the source IP matches an existing, authenticated connection
if ( !noauth && peer != QHostAddress::Any && !isIPWhitelisted( peer ) )
if ( !m_noAuth && peer != QHostAddress::Any && !isIPWhitelisted( peer ) )
{
bool authed = false;
foreach ( ControlConnection* cc, m_controlconnections )
{
if( !cc->socket().isNull() && cc->socket()->peerAddress() == peer )
tDebug() << Q_FUNC_INFO << "Probing:" << cc->name();
if ( cc->socket() && cc->socket()->peerAddress() == peer )
{
authed = true;
break;
@@ -932,7 +924,7 @@ Servent::claimOffer( ControlConnection* cc, const QString &nodeid, const QString
return conn.data()->clone();
}
}
else if ( noauth )
else if ( m_noAuth )
{
Connection* conn;
conn = new ControlConnection( this );
@@ -1040,8 +1032,7 @@ Servent::connectedToSession( const QString& session )
{
foreach ( ControlConnection* cc, m_controlconnections )
{
if( !cc )
continue;
Q_ASSERT( cc );
if ( cc->id() == session )
return true;

View File

@@ -177,6 +177,7 @@ private:
QString m_externalHostname;
bool m_ready;
bool m_lanHack;
bool m_noAuth;
// currently active file transfers:
QList< StreamConnection* > m_scsessions;