Changeset 8433
- Timestamp:
- May 19, 2009, 6:38:26 PM (13 years ago)
- Location:
- trunk
- Files:
-
- 11 added
- 19 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/AUTHORS
r8270 r8433 8 8 Project Contributors 9 9 Tomas Carnecky (Profiling, patches, and detection of sneaky bugs) 10 Juliusz Chroboczek (DHT) 10 11 John Clay (Website maintenance and troubleshooting) 11 12 Rashid Eissing (Mac OS X Transfers preferences icon) -
trunk/cli/Makefile.am
r8152 r8433 21 21 $(top_builddir)/third-party/libnatpmp/libnatpmp.a \ 22 22 $(top_builddir)/third-party/miniupnp/libminiupnp.a \ 23 $(top_builddir)/third-party/dht/libdht.a \ 23 24 $(INTLLIBS) \ 24 25 $(LIBCURL_LIBS) \ -
trunk/configure.ac
r8429 r8433 264 264 if test "x$enable_nls" = "xyes" ; then 265 265 use_nls=yes 266 IT_PROG_INTLTOOL([0. 40.0],[no-xml])266 IT_PROG_INTLTOOL([0.35],[no-xml]) 267 267 AC_CHECK_HEADERS([libintl.h]) 268 268 GETTEXT_PACKAGE=transmission … … 356 356 third-party/miniupnp/Makefile 357 357 third-party/libnatpmp/Makefile 358 third-party/dht/Makefile 358 359 macosx/Makefile 359 360 gtk/Makefile -
trunk/daemon/Makefile.am
r8152 r8433 23 23 $(top_builddir)/third-party/libnatpmp/libnatpmp.a \ 24 24 $(top_builddir)/third-party/libevent/libevent.la \ 25 $(top_builddir)/third-party/dht/libdht.a \ 25 26 $(INTLLIBS) \ 26 27 $(LIBCURL_LIBS) \ -
trunk/gtk/Makefile.am
r8389 r8433 104 104 $(top_builddir)/third-party/miniupnp/libminiupnp.a \ 105 105 $(top_builddir)/third-party/libnatpmp/libnatpmp.a \ 106 $(top_builddir)/third-party/dht/libdht.a \ 106 107 $(GTK_LIBS) \ 107 108 $(GIO_LIBS) \ -
trunk/gtk/details.c
r8432 r8433 942 942 str = mixed; 943 943 else if( baseline ) 944 str = _( "Private to this tracker -- PEX disabled" );944 str = _( "Private to this tracker -- DHT and PEX disabled" ); 945 945 else 946 946 str = _( "Public torrent" ); … … 1504 1504 case 'E': s = _( "Encrypted connection" ); break; 1505 1505 case 'X': s = _( "Peer was discovered through Peer Exchange (PEX)" ); break; 1506 case 'H': s = _( "Peer was discovered through DHT" ); break; 1506 1507 case 'I': s = _( "Peer is an incoming connection" ); break; 1507 1508 } -
trunk/libtransmission/Makefile.am
r8152 r8433 50 50 tr-getopt.c \ 51 51 tracker.c \ 52 tr-dht.c \ 52 53 trevent.c \ 53 54 upnp.c \ … … 97 98 tr-getopt.h \ 98 99 transmission.h \ 100 tr-dht.h \ 99 101 trevent.h \ 100 102 upnp.h \ … … 125 127 $(top_builddir)/third-party/libnatpmp/libnatpmp.a \ 126 128 $(top_builddir)/third-party/libevent/libevent.la \ 129 $(top_builddir)/third-party/dht/libdht.a \ 127 130 $(INTLLIBS) \ 128 131 $(LIBCURL_LIBS) \ -
trunk/libtransmission/handshake.c
r7883 r8433 29 29 #include "peer-mgr.h" 30 30 #include "torrent.h" 31 #include "tr-dht.h" 31 32 #include "trevent.h" 32 33 #include "utils.h" … … 36 37 /* fast extensions */ 37 38 #define ENABLE_FAST * / 39 /* DHT */ 40 #define ENABLE_DHT * / 38 41 39 42 /*** … … 81 84 #define HANDSHAKE_HAS_FASTEXT( bits ) ( 0 ) 82 85 #define HANDSHAKE_SET_FASTEXT( bits ) ( (void)0 ) 86 #endif 87 88 #ifdef ENABLE_DHT 89 #define HANDSHAKE_HAS_DHT( bits ) ( ( ( bits )[7] & 0x01 ) ? 1 : 0 ) 90 #define HANDSHAKE_SET_DHT( bits ) ( ( bits )[7] |= 0x01 ) 91 #else 92 #define HANDSHAKE_HAS_DHT( bits ) ( 0 ) 93 #define HANDSHAKE_SET_DHT( bits ) ( (void)0 ) 83 94 #endif 84 95 … … 220 231 HANDSHAKE_SET_FASTEXT( walk ); 221 232 233 /* Note that this doesn't depend on whether the torrent is private. We 234 don't accept DHT peers for a private torrent, but we participate in 235 the DHT regardless. */ 236 if(tr_dhtEnabled(handshake->session)) 237 HANDSHAKE_SET_DHT( walk ); 238 222 239 walk += HANDSHAKE_FLAGS_LEN; 223 240 memcpy( walk, torrentHash, SHA_DIGEST_LENGTH ); … … 303 320 304 321 tr_peerIoEnableFEXT( handshake->io, HANDSHAKE_HAS_FASTEXT( reserved ) ); 322 323 /* This doesn't depend on whether the torrent is private. */ 324 if( tor->session->isDHTEnabled ) 325 tr_peerIoEnableDHT( handshake->io, HANDSHAKE_HAS_DHT( reserved ) ); 305 326 306 327 return HANDSHAKE_OK; -
trunk/libtransmission/peer-io.c
r8265 r8433 618 618 } 619 619 620 void 621 tr_peerIoEnableDHT( tr_peerIo * io, tr_bool flag ) 622 { 623 assert( tr_isPeerIo( io ) ); 624 assert( tr_isBool( flag ) ); 625 626 dbgmsg( io, "setting DHT support flag to %d", (flag!=0) ); 627 io->dhtSupported = flag; 628 } 629 620 630 /** 621 631 *** -
trunk/libtransmission/peer-io.h
r8265 r8433 64 64 tr_bool extendedProtocolSupported; 65 65 tr_bool fastExtensionSupported; 66 tr_bool dhtSupported; 66 67 67 68 /* we create the socket in a nonblocking way, so this flag is initially … … 158 159 159 160 return io->fastExtensionSupported; 161 } 162 163 void tr_peerIoEnableDHT( tr_peerIo * io, tr_bool flag ); 164 165 static TR_INLINE tr_bool tr_peerIoSupportsDHT( const tr_peerIo * io ) 166 { 167 assert( tr_isPeerIo( io ) ); 168 169 return io->dhtSupported; 160 170 } 161 171 -
trunk/libtransmission/peer-mgr.c
r8406 r8433 1874 1874 if( !stat->peerIsChoked && !stat->peerIsInterested ) *pch++ = '?'; 1875 1875 if( stat->isEncrypted ) *pch++ = 'E'; 1876 if( stat->from == TR_PEER_FROM_DHT ) *pch++ = 'H'; 1876 1877 if( stat->from == TR_PEER_FROM_PEX ) *pch++ = 'X'; 1877 1878 if( stat->isIncoming ) *pch++ = 'I'; … … 2164 2165 return a->time < b->time ? -1 : 1; 2165 2166 2166 /* all other things being equal, prefer peers whose2167 * information comes from a more reliable source*/2167 /* In order to avoid fragmenting the swarm, peers from trackers and 2168 * from the DHT should be preferred to peers from PEX. */ 2168 2169 if( a->from != b->from ) 2169 2170 return a->from < b->from ? -1 : 1; -
trunk/libtransmission/peer-msgs.c
r8415 r8433 37 37 #include "stats.h" 38 38 #include "torrent.h" 39 #include "tr-dht.h" 39 40 #include "trevent.h" 40 41 #include "utils.h" … … 305 306 dbgOutMessageLen( msgs ); 306 307 pokeBatchPeriod( msgs, IMMEDIATE_PRIORITY_INTERVAL_SECS ); 308 } 309 310 static void 311 protocolSendPort(tr_peermsgs *msgs, uint16_t port) 312 { 313 tr_peerIo * io = msgs->peer->io; 314 struct evbuffer * out = msgs->outMessages; 315 316 dbgmsg( msgs, "sending Port %u", port); 317 tr_peerIoWriteUint32( io, out, 3 ); 318 tr_peerIoWriteUint8 ( io, out, BT_PORT ); 319 tr_peerIoWriteUint16( io, out, port); 307 320 } 308 321 … … 2124 2137 sendLtepHandshake( m ); 2125 2138 2139 if(tr_peerIoSupportsDHT(peer->io)) 2140 protocolSendPort(m, tr_dhtPort(torrent->session)); 2141 2126 2142 tellPeerWhatWeHave( m ); 2127 2143 -
trunk/libtransmission/session.c
r8398 r8433 46 46 #include "verify.h" 47 47 #include "web.h" 48 #include "tr-dht.h" 48 49 49 50 #define dbgmsg( ... ) \ … … 622 623 assert( found ); 623 624 session->isPexEnabled = boolVal; 625 /* This really ought to be a separate preference. */ 626 session->isDHTEnabled = boolVal; 624 627 625 628 found = tr_bencDictFindInt( &settings, TR_PREFS_KEY_ENCRYPTION, &i ); … … 831 834 session->isWaiting = FALSE; 832 835 dbgmsg( "returning session %p; session->tracker is %p", session, session->tracker ); 836 837 if( session->isDHTEnabled ) 838 tr_dhtInit(session); 833 839 } 834 840 … … 1393 1399 1394 1400 static void 1395 tr_closeAllConnections( void * vsession )1401 sessionCloseImpl( void * vsession ) 1396 1402 { 1397 1403 tr_session * session = vsession; … … 1403 1409 1404 1410 free_incoming_peer_port( session ); 1411 1412 if( session->isDHTEnabled ) 1413 tr_dhtUninit( session ); 1405 1414 1406 1415 evtimer_del( session->altTimer ); … … 1456 1465 1457 1466 /* close the session */ 1458 tr_runInEventThread( session, tr_closeAllConnections, session );1467 tr_runInEventThread( session, sessionCloseImpl, session ); 1459 1468 while( !session->isClosed && !deadlineReached( deadline ) ) 1460 1469 { … … 1578 1587 1579 1588 return session->isPexEnabled; 1589 } 1590 1591 tr_bool 1592 tr_sessionIsDHTEnabled( const tr_session * session ) 1593 { 1594 assert( tr_isSession( session ) ); 1595 1596 return session->isDHTEnabled; 1580 1597 } 1581 1598 -
trunk/libtransmission/session.h
r8398 r8433 62 62 tr_bool isPortRandom; 63 63 tr_bool isPexEnabled; 64 tr_bool isDHTEnabled; 64 65 tr_bool isBlocklistEnabled; 65 66 tr_bool isProxyEnabled; -
trunk/libtransmission/torrent.c
r8414 r8433 1272 1272 checkAndStartImpl( void * vtor ) 1273 1273 { 1274 time_t now; 1274 1275 tr_torrent * tor = vtor; 1275 1276 … … 1278 1279 tr_globalLock( tor->session ); 1279 1280 1281 now = time( NULL ); 1280 1282 tor->isRunning = TRUE; 1281 1283 tor->needsSeedRatioCheck = TRUE; … … 1284 1286 tor->completeness = tr_cpGetStatus( &tor->completion ); 1285 1287 tr_torrentSaveResume( tor ); 1286 tor->startDate = tor->anyDate = time( NULL );1288 tor->startDate = tor->anyDate = now; 1287 1289 tr_trackerStart( tor->tracker ); 1290 tor->dhtAnnounceAt = now + tr_cryptoWeakRandInt( 20 ); 1288 1291 tr_peerMgrStartTorrent( tor ); 1289 1292 -
trunk/libtransmission/torrent.h
r8389 r8433 176 176 struct tr_publisher_tag * trackerSubscription; 177 177 178 time_t dhtAnnounceAt; 179 tr_bool dhtAnnounceInProgress; 180 178 181 uint64_t downloadedCur; 179 182 uint64_t downloadedPrev; … … 289 292 } 290 293 294 static TR_INLINE tr_bool tr_torrentAllowsDHT( const tr_torrent * tor ) 295 { 296 return ( tor != NULL ) && tor->session->isDHTEnabled && !tr_torrentIsPrivate( tor ); 297 } 298 291 299 static TR_INLINE tr_bool tr_torrentIsPieceChecked( const tr_torrent * tor, tr_piece_index_t i ) 292 300 { -
trunk/libtransmission/tracker.c
r8394 r8433 27 27 #include "torrent.h" 28 28 #include "tracker.h" 29 #include "tr-dht.h" 29 30 #include "trevent.h" 30 31 #include "utils.h" … … 978 979 enqueueRequest( session, t, TR_REQ_REANNOUNCE ); 979 980 } 981 982 if( tor->dhtAnnounceAt <= now ) { 983 int rc = 1; 984 if( tr_torrentAllowsDHT(tor) ) 985 rc = tr_dhtAnnounce(tor, 1); 986 if(rc == 0) 987 /* The DHT is not ready yet. Try again soon. */ 988 tor->dhtAnnounceAt = now + 5 + tr_cryptoWeakRandInt( 5 ); 989 else 990 /* We should announce at least once every 30 minutes. */ 991 tor->dhtAnnounceAt = now + 25 * 60 + tr_cryptoWeakRandInt( 3 * 60 ); 992 } 980 993 } 981 994 -
trunk/libtransmission/transmission.h
r8389 r8433 531 531 tr_bool tr_sessionIsPexEnabled( const tr_session * session ); 532 532 533 tr_bool tr_sessionIsDHTEnabled( const tr_session * session ); 534 533 535 void tr_sessionSetLazyBitfieldEnabled( tr_session * session, 534 536 tr_bool enabled ); … … 1344 1346 TR_PEER_FROM_INCOMING = 0, /* connections made to the listening port */ 1345 1347 TR_PEER_FROM_TRACKER = 1, /* peers received from a tracker */ 1346 TR_PEER_FROM_CACHE = 2, /* peers read from the peer cache */ 1347 TR_PEER_FROM_PEX = 3, /* peers discovered via PEX */ 1348 TR_PEER_FROM_DHT = 2, /* peers learnt from the DHT */ 1349 TR_PEER_FROM_CACHE = 3, /* peers read from the peer cache */ 1350 TR_PEER_FROM_PEX = 4, /* peers discovered via PEX */ 1348 1351 TR_PEER_FROM__MAX 1349 1352 }; -
trunk/third-party/Makefile.am
r7974 r8433 2 2 libevent \ 3 3 libnatpmp \ 4 miniupnp 4 miniupnp \ 5 dht 5 6 6 7 EXTRA_DIST = \
Note: See TracChangeset
for help on using the changeset viewer.