=== modified file 'libktorrent/mse/streamsocket.cpp' --- libktorrent/mse/streamsocket.cpp 2006-10-28 09:51:11 +0000 +++ libktorrent/mse/streamsocket.cpp 2006-11-05 11:51:01 +0000 @@ -210,11 +210,16 @@ return sock->ok(); } - QString StreamSocket::getIPAddress() const + QString StreamSocket::getRemoteIPAddress() const { return sock->getPeerName().toString(); } + bt::Uint16 StreamSocket::getRemotePort() const + { + return sock->getPeerName().port(); + } + void StreamSocket::setRC4Encryptor(RC4Encryptor* e) { if (enc) === modified file 'libktorrent/mse/streamsocket.h' --- libktorrent/mse/streamsocket.h 2006-10-23 18:49:28 +0000 +++ libktorrent/mse/streamsocket.h 2006-11-05 11:51:01 +0000 @@ -102,7 +102,10 @@ bool connectTo(const QString & ip,Uint16 port); /// Get the IP address of the remote peer - QString getIPAddress() const; + QString getRemoteIPAddress() const; + + /// Get the port of the remote peer + bt::Uint16 getRemotePort() const; /** * Reinsert data, this is needed when we read to much during the crypto handshake. === modified file 'libktorrent/torrent/peer.cpp' --- libktorrent/torrent/peer.cpp 2006-10-21 11:26:24 +0000 +++ libktorrent/torrent/peer.cpp 2006-11-05 11:51:01 +0000 @@ -421,7 +421,7 @@ QString Peer::getIPAddresss() const { if (sock) - return sock->getIPAddress(); + return sock->getRemoteIPAddress(); else return QString::null; } @@ -461,6 +461,11 @@ pwriter->sendChoke(); uploader->clearAllRequests(); } + + void Peer::emitPortPacket() + { + gotPortPacket(sock->getRemoteIPAddress(),sock->getRemotePort()); + } } #include "peer.moc" === modified file 'libktorrent/torrent/peer.h' --- libktorrent/torrent/peer.h 2006-10-01 08:58:48 +0000 +++ libktorrent/torrent/peer.h 2006-11-05 11:51:01 +0000 @@ -203,7 +203,10 @@ /// Choke the peer void choke(); - + /** + * Emit the port packet signal. + */ + void emitPortPacket(); private slots: void dataWritten(int bytes); === modified file 'libktorrent/torrent/server.cpp' --- libktorrent/torrent/server.cpp 2006-09-10 15:39:24 +0000 +++ libktorrent/torrent/server.cpp 2006-11-05 11:51:01 +0000 @@ -107,7 +107,7 @@ else { IPBlocklist& ipfilter = IPBlocklist::instance(); - QString IP(s->getIPAddress()); + QString IP(s->getRemoteIPAddress()); if (ipfilter.isBlocked( IP )) { delete s; === modified file 'libktorrent/torrent/serverauthenticate.cpp' --- libktorrent/torrent/serverauthenticate.cpp 2006-09-23 08:34:33 +0000 +++ libktorrent/torrent/serverauthenticate.cpp 2006-11-05 11:51:01 +0000 @@ -45,7 +45,7 @@ void ServerAuthenticate::onFinish(bool succes) { - Out(SYS_CON|LOG_NOTICE) << "Authentication(S) to " << sock->getIPAddress() + Out(SYS_CON|LOG_NOTICE) << "Authentication(S) to " << sock->getRemoteIPAddress() << " : " << (succes ? "ok" : "failure") << endl; finished = true; @@ -63,7 +63,7 @@ Uint8* hs = handshake; IPBlocklist& ipfilter = IPBlocklist::instance(); - QString IP = sock->getIPAddress(); + QString IP = sock->getRemoteIPAddress(); if (ipfilter.isBlocked( IP )) { === modified file 'libktorrent/torrent/torrentcontrol.cpp' --- libktorrent/torrent/torrentcontrol.cpp 2006-11-04 11:15:30 +0000 +++ libktorrent/torrent/torrentcontrol.cpp 2006-11-05 11:51:01 +0000 @@ -727,8 +727,16 @@ if (!stats.completed) p->getPacketWriter().sendInterested(); - if (p->isDHTSupported() && !stats.priv_torrent) - p->getPacketWriter().sendPort(Globals::instance().getDHT().getPort()); + if (!stats.priv_torrent) + { + if (p->isDHTSupported()) + p->getPacketWriter().sendPort(Globals::instance().getDHT().getPort()); + else + // WORKAROUND so we can contact µTorrent's DHT + // They do not properly support the standard and do not turn on + // the DHT bit in the handshake, so we just ping each peer by default. + p->emitPortPacket(); + } if (tmon) tmon->peerAdded(p);