Ignore:
Timestamp:
Dec 15, 2008, 12:17:08 AM (12 years ago)
Author:
charles
Message:

(trunk libT) add ipv6 support by jhujhiti. I think this is the largest user-contributed patch we've ever used... thanks jhujhiti :)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/resume.c

    r7249 r7397  
    3535#define KEY_PAUSED          "paused"
    3636#define KEY_PEERS           "peers"
     37#define KEY_PEERS6          "peers6"
    3738#define KEY_PRIORITY        "priority"
    3839#define KEY_PROGRESS        "progress"
     
    6263***/
    6364
    64 /* TODO: resume peers6 */
    6565static void
    6666savePeers( tr_benc *          dict,
    6767           const tr_torrent * tor )
    6868{
    69     tr_pex *  pex = NULL;
    70     const int count = tr_peerMgrGetPeers( tor->session->peerMgr,
    71                                           tor->info.hash, &pex );
     69    tr_pex * pex = NULL;
     70    int count = tr_peerMgrGetPeers( tor->session->peerMgr,
     71                                    tor->info.hash, &pex, TR_AF_INET );
    7272
    7373    if( count > 0 )
    7474        tr_bencDictAddRaw( dict, KEY_PEERS, pex, sizeof( tr_pex ) * count );
     75   
     76    count = tr_peerMgrGetPeers( tor->session->peerMgr, tor->info.hash, &pex,
     77                                TR_AF_INET6 );
     78    if( count > 0 )
     79        tr_bencDictAddRaw( dict, KEY_PEERS6, pex, sizeof( tr_pex ) * count );
     80   
    7581    tr_free( pex );
    7682}
     
    95101                              tor->info.hash, TR_PEER_FROM_CACHE, &pex );
    96102        }
    97         tr_tordbg( tor, "Loaded %d peers from resume file", count );
     103        tr_tordbg( tor, "Loaded %d IPv4 peers from resume file", count );
     104        ret = TR_FR_PEERS;
     105    }
     106   
     107    if( tr_bencDictFindRaw( dict, KEY_PEERS6, &str, &len ) )
     108    {
     109        int       i;
     110        const int count = len / sizeof( tr_pex );
     111        for( i = 0; i < count; ++i )
     112        {
     113            tr_pex pex;
     114            memcpy( &pex, str + ( i * sizeof( tr_pex ) ), sizeof( tr_pex ) );
     115            tr_peerMgrAddPex( tor->session->peerMgr,
     116                              tor->info.hash, TR_PEER_FROM_CACHE, &pex );
     117        }
     118        tr_tordbg( tor, "Loaded %d IPv6 peers from resume file", count );
    98119        ret = TR_FR_PEERS;
    99120    }
Note: See TracChangeset for help on using the changeset viewer.