mirror of https://github.com/aria2/aria2
2008-09-02 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Added _incoming member to Peer class and made it true if the peer initiated connection. Don't add those peer to UTPex message. If extended handshake is received, assign _incoming to false. * src/DefaultBtInteractive.cc * src/HandshakeExtensionMessage.cc * src/Peer.cc * src/Peer.h * src/PeerListenCommand.ccpull/1/head
parent
d4215a82b7
commit
46f0e018d4
11
ChangeLog
11
ChangeLog
|
@ -1,3 +1,14 @@
|
||||||
|
2008-09-02 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
|
||||||
|
|
||||||
|
Added _incoming member to Peer class and made it true if the peer
|
||||||
|
initiated connection. Don't add those peer to UTPex message.
|
||||||
|
If extended handshake is received, assign _incoming to false.
|
||||||
|
* src/DefaultBtInteractive.cc
|
||||||
|
* src/HandshakeExtensionMessage.cc
|
||||||
|
* src/Peer.cc
|
||||||
|
* src/Peer.h
|
||||||
|
* src/PeerListenCommand.cc
|
||||||
|
|
||||||
2008-09-02 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
|
2008-09-02 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
|
||||||
|
|
||||||
Made files whose name ends with ".gz", ".tgz" not inflated by Content
|
Made files whose name ends with ".gz", ".tgz" not inflated by Content
|
||||||
|
|
|
@ -402,7 +402,7 @@ void DefaultBtInteractive::addPeerExchangeMessage()
|
||||||
for(Peers::const_iterator i = peers.begin();
|
for(Peers::const_iterator i = peers.begin();
|
||||||
i != peers.end() && max; ++i) {
|
i != peers.end() && max; ++i) {
|
||||||
const PeerHandle& cpeer = *i;
|
const PeerHandle& cpeer = *i;
|
||||||
if(peer->ipaddr != cpeer->ipaddr &&
|
if(peer->ipaddr != cpeer->ipaddr && !cpeer->isIncomingPeer() &&
|
||||||
!cpeer->getFirstContactTime().elapsed(interval)) {
|
!cpeer->getFirstContactTime().elapsed(interval)) {
|
||||||
m->addFreshPeer(cpeer);
|
m->addFreshPeer(cpeer);
|
||||||
--max;
|
--max;
|
||||||
|
|
|
@ -102,6 +102,7 @@ void HandshakeExtensionMessage::doReceivedAction()
|
||||||
{
|
{
|
||||||
if(_tcpPort > 0) {
|
if(_tcpPort > 0) {
|
||||||
_peer->port = _tcpPort;
|
_peer->port = _tcpPort;
|
||||||
|
_peer->setIncomingPeer(false);
|
||||||
}
|
}
|
||||||
for(std::map<std::string, uint8_t>::const_iterator itr = _extensions.begin();
|
for(std::map<std::string, uint8_t>::const_iterator itr = _extensions.begin();
|
||||||
itr != _extensions.end(); ++itr) {
|
itr != _extensions.end(); ++itr) {
|
||||||
|
|
15
src/Peer.cc
15
src/Peer.cc
|
@ -45,12 +45,13 @@ namespace aria2 {
|
||||||
|
|
||||||
#define BAD_CONDITION_INTERVAL 10
|
#define BAD_CONDITION_INTERVAL 10
|
||||||
|
|
||||||
Peer::Peer(std::string ipaddr, uint16_t port):
|
Peer::Peer(std::string ipaddr, uint16_t port, bool incoming):
|
||||||
ipaddr(ipaddr),
|
ipaddr(ipaddr),
|
||||||
port(port),
|
port(port),
|
||||||
_badConditionStartTime(0),
|
_badConditionStartTime(0),
|
||||||
_seeder(false),
|
_seeder(false),
|
||||||
_res(0)
|
_res(0),
|
||||||
|
_incoming(incoming)
|
||||||
{
|
{
|
||||||
resetStatus();
|
resetStatus();
|
||||||
std::string idSeed = ipaddr+":"+Util::uitos(port);
|
std::string idSeed = ipaddr+":"+Util::uitos(port);
|
||||||
|
@ -460,4 +461,14 @@ uint64_t Peer::getCompletedLength() const
|
||||||
return _res->getCompletedLength();
|
return _res->getCompletedLength();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Peer::isIncomingPeer() const
|
||||||
|
{
|
||||||
|
return _incoming;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Peer::setIncomingPeer(bool incoming)
|
||||||
|
{
|
||||||
|
_incoming = incoming;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace aria2
|
} // namespace aria2
|
||||||
|
|
|
@ -69,12 +69,15 @@ private:
|
||||||
|
|
||||||
PeerSessionResource* _res;
|
PeerSessionResource* _res;
|
||||||
|
|
||||||
|
// If true, port is assumed not to be a listening port.
|
||||||
|
bool _incoming;
|
||||||
|
|
||||||
// Before calling updateSeeder(), make sure that
|
// Before calling updateSeeder(), make sure that
|
||||||
// allocateSessionResource() is called and _res is created.
|
// allocateSessionResource() is called and _res is created.
|
||||||
// Otherwise assertion fails.
|
// Otherwise assertion fails.
|
||||||
void updateSeeder();
|
void updateSeeder();
|
||||||
public:
|
public:
|
||||||
Peer(std::string ipaddr, uint16_t port);
|
Peer(std::string ipaddr, uint16_t port, bool incoming = false);
|
||||||
|
|
||||||
~Peer();
|
~Peer();
|
||||||
|
|
||||||
|
@ -237,6 +240,10 @@ public:
|
||||||
const Time& getLastAmUnchoking() const;
|
const Time& getLastAmUnchoking() const;
|
||||||
|
|
||||||
uint64_t getCompletedLength() const;
|
uint64_t getCompletedLength() const;
|
||||||
|
|
||||||
|
bool isIncomingPeer() const;
|
||||||
|
|
||||||
|
void setIncomingPeer(bool incoming);
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef SharedHandle<Peer> PeerHandle;
|
typedef SharedHandle<Peer> PeerHandle;
|
||||||
|
|
|
@ -101,7 +101,7 @@ bool PeerListenCommand::execute() {
|
||||||
// here.
|
// here.
|
||||||
peerSocket->setBlockingMode();
|
peerSocket->setBlockingMode();
|
||||||
|
|
||||||
PeerHandle peer(new Peer(peerInfo.first, 0));
|
PeerHandle peer(new Peer(peerInfo.first, peerInfo.second, true));
|
||||||
int32_t cuid = CUIDCounterSingletonHolder::instance()->newID();
|
int32_t cuid = CUIDCounterSingletonHolder::instance()->newID();
|
||||||
Command* command =
|
Command* command =
|
||||||
new ReceiverMSEHandshakeCommand(cuid, peer, e, peerSocket);
|
new ReceiverMSEHandshakeCommand(cuid, peer, e, peerSocket);
|
||||||
|
|
Loading…
Reference in New Issue