Changeset 13933
- Timestamp:
- Feb 2, 2013, 1:42:50 PM (8 years ago)
- Location:
- trunk/libtransmission
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/libtransmission/announcer.c
r13901 r13933 906 906 static tr_announce_request * 907 907 announce_request_new (const tr_announcer * announcer, 908 const tr_torrent* tor,908 tr_torrent * tor, 909 909 const tr_tier * tier, 910 910 tr_announce_event event) … … 915 915 req->tracker_id_str = tr_strdup (tier->currentTracker->tracker_id_str); 916 916 memcpy (req->info_hash, tor->info.hash, SHA_DIGEST_LENGTH); 917 memcpy (req->peer_id, t or->peer_id, PEER_ID_LEN);917 memcpy (req->peer_id, tr_torrentGetPeerId(tor), PEER_ID_LEN); 918 918 req->up = tier->byteCounts[TR_ANN_UP]; 919 919 req->down = tier->byteCounts[TR_ANN_DOWN]; … … 1210 1210 fprintf (stderr, "ANNOUNCE: event %s isPartialSeed %d port %d key %d numwant %d" 1211 1211 " up %"PRIu64" down %"PRIu64" corrupt %"PRIu64" left %"PRIu64 1212 " url [%s] tracker_id_str [%s] peer_id [% 8.8s]\n",1212 " url [%s] tracker_id_str [%s] peer_id [%20.20s]\n", 1213 1213 tr_announce_event_get_string (request->event), 1214 1214 (int)request->partial_seed, … … 1241 1241 tr_announce_request * req; 1242 1242 struct announce_data * data; 1243 consttr_torrent * tor = tier->tor;1243 tr_torrent * tor = tier->tor; 1244 1244 const time_t now = tr_time (); 1245 1245 -
trunk/libtransmission/handshake.c
r13932 r13933 194 194 uint8_t * walk = buf; 195 195 const uint8_t * torrentHash = tr_cryptoGetTorrentHash (handshake->crypto); 196 consttr_torrent * tor = tr_torrentFindFromHash (handshake->session, torrentHash);197 const u int8_t * peer_id = tor->peer_id;196 tr_torrent * tor = tr_torrentFindFromHash (handshake->session, torrentHash); 197 const unsigned char * peer_id = tr_torrentGetPeerId (tor); 198 198 199 199 memcpy (walk, HANDSHAKE_NAME, HANDSHAKE_NAME_LEN); … … 236 236 uint8_t reserved[HANDSHAKE_FLAGS_LEN]; 237 237 uint8_t hash[SHA_DIGEST_LENGTH]; 238 const tr_torrent * tor; 239 const uint8_t * tor_peer_id; 238 tr_torrent * tor; 240 239 uint8_t peer_id[PEER_ID_LEN]; 241 240 … … 273 272 274 273 tor = tr_torrentFindFromHash (handshake->session, hash); 275 tor_peer_id = tor->peer_id; 276 if (!memcmp (peer_id, tor_peer_id, PEER_ID_LEN)) 274 if (!memcmp (peer_id, tr_torrentGetPeerId(tor), PEER_ID_LEN)) 277 275 { 278 276 dbgmsg (handshake, "streuth! we've connected to ourselves."); … … 704 702 /* if we've somehow connected to ourselves, don't keep the connection */ 705 703 tor = tr_torrentFindFromHash (handshake->session, tr_peerIoGetTorrentHash (handshake->io)); 706 connected_to_self = (tor != NULL) && !memcmp (peer_id, t or->peer_id, PEER_ID_LEN);704 connected_to_self = (tor != NULL) && !memcmp (peer_id, tr_torrentGetPeerId(tor), PEER_ID_LEN); 707 705 708 706 return tr_handshakeDone (handshake, !connected_to_self); -
trunk/libtransmission/quark.c
r13816 r13933 209 209 { "pausedTorrentCount", 18 }, 210 210 { "peer-congestion-algorithm", 25 }, 211 { "peer-id-ttl-hours", 17 }, 211 212 { "peer-limit", 10 }, 212 213 { "peer-limit-global", 17 }, -
trunk/libtransmission/quark.h
r13816 r13933 219 219 TR_KEY_pausedTorrentCount, 220 220 TR_KEY_peer_congestion_algorithm, 221 TR_KEY_peer_id_ttl_hours, 221 222 TR_KEY_peer_limit, 222 223 TR_KEY_peer_limit_global, -
trunk/libtransmission/session.c
r13932 r13933 309 309 assert (tr_variantIsDict (d)); 310 310 311 tr_variantDictReserve (d, 6 2);311 tr_variantDictReserve (d, 63); 312 312 tr_variantDictAddBool (d, TR_KEY_blocklist_enabled, false); 313 313 tr_variantDictAddStr (d, TR_KEY_blocklist_url, "http://www.example.com/blocklist"); … … 338 338 tr_variantDictAddInt (d, TR_KEY_preallocation, TR_PREALLOCATE_SPARSE); 339 339 tr_variantDictAddBool (d, TR_KEY_prefetch_enabled, DEFAULT_PREFETCH_ENABLED); 340 tr_variantDictAddInt (d, TR_KEY_peer_id_ttl_hours, 6); 340 341 tr_variantDictAddBool (d, TR_KEY_queue_stalled_enabled, true); 341 342 tr_variantDictAddInt (d, TR_KEY_queue_stalled_minutes, 30); … … 409 410 tr_variantDictAddInt (d, TR_KEY_preallocation, s->preallocationMode); 410 411 tr_variantDictAddInt (d, TR_KEY_prefetch_enabled, s->isPrefetchEnabled); 412 tr_variantDictAddInt (d, TR_KEY_peer_id_ttl_hours, s->peer_id_ttl_hours); 411 413 tr_variantDictAddBool (d, TR_KEY_queue_stalled_enabled, tr_sessionGetQueueStalledEnabled (s)); 412 414 tr_variantDictAddInt (d, TR_KEY_queue_stalled_minutes, tr_sessionGetQueueStalledMinutes (s)); … … 800 802 if (tr_variantDictFindBool (settings, TR_KEY_trash_original_torrent_files, &boolVal)) 801 803 tr_sessionSetDeleteSource (session, boolVal); 804 if (tr_variantDictFindInt (settings, TR_KEY_peer_id_ttl_hours, &i)) 805 session->peer_id_ttl_hours = i; 802 806 803 807 /* torrent queues */ -
trunk/libtransmission/session.h
r13932 r13933 119 119 bool scrapePausedTorrents; 120 120 121 uint8_t peer_id_ttl_hours; 122 121 123 tr_variant removedTorrents; 122 124 -
trunk/libtransmission/torrent.c
r13924 r13933 176 176 177 177 /*** 178 **** 179 ***/ 180 181 static void 182 tr_torrentUnsetPeerId (tr_torrent * tor) 183 { 184 /* triggers a rebuild next time tr_torrentGetPeerId() is called */ 185 *tor->peer_id = '\0'; 186 } 187 188 static int 189 peerIdTTL (const tr_torrent * tor) 190 { 191 int ttl; 192 193 if (!tor->peer_id_creation_time) 194 ttl = 0; 195 else 196 ttl = (int)difftime(tor->peer_id_creation_time+(tor->session->peer_id_ttl_hours*3600), tr_time()); 197 198 return ttl; 199 } 200 201 const unsigned char * 202 tr_torrentGetPeerId (tr_torrent * tor) 203 { 204 bool needs_new_peer_id = false; 205 206 if (!*tor->peer_id) 207 needs_new_peer_id = true; 208 209 if (!needs_new_peer_id) 210 if (!tr_torrentIsPrivate (tor)) 211 if (peerIdTTL (tor) <= 0) 212 needs_new_peer_id = true; 213 214 if (needs_new_peer_id) 215 { 216 tr_peerIdInit (tor->peer_id); 217 tor->peer_id_creation_time = tr_time (); 218 } 219 220 return tor->peer_id; 221 } 222 /*** 178 223 **** PER-TORRENT UL / DL SPEEDS 179 224 ***/ … … 821 866 tor->queuePosition = session->torrentCount; 822 867 823 tr_peerIdInit (tor->peer_id);824 825 868 tr_sha1 (tor->obfuscatedHash, "req2", 4, 826 869 tor->info.hash, SHA_DIGEST_LENGTH, … … 1661 1704 * change the peerid. It would help sometimes if a stopped event 1662 1705 * was missed to ensure that we didn't think someone was cheating. */ 1663 tr_ peerIdInit (tor->peer_id);1664 tor->isRunning = 1;1706 tr_torrentUnsetPeerId (tor); 1707 tor->isRunning = true; 1665 1708 tr_torrentSetDirty (tor); 1666 1709 tr_runInEventThread (tor->session, torrentStartImpl, tor); -
trunk/libtransmission/torrent.h
r13890 r13933 160 160 * and in the handshake are expected to match. 161 161 */ 162 uint8_t peer_id[PEER_ID_LEN+1]; 162 unsigned char peer_id[PEER_ID_LEN+1]; 163 164 time_t peer_id_creation_time; 163 165 164 166 /* Where the files will be when it's complete */ … … 436 438 bool tr_torrentIsStalled (const tr_torrent * tor); 437 439 440 const unsigned char * tr_torrentGetPeerId (tr_torrent * tor); 441 442 438 443 static inline bool 439 444 tr_torrentIsQueued (const tr_torrent * tor)
Note: See TracChangeset
for help on using the changeset viewer.