Changeset 2936


Ignore:
Timestamp:
Aug 28, 2007, 11:12:17 PM (15 years ago)
Author:
charles
Message:

not ready for use yet -- this is a periodic checkin so I don't lose my changes. Outgoing connections work for plaintext, encrypted, and encrypted connections that prefer plaintext. Incoming connections don't work yet. Handshakes aren't wired in to the rest of the peer code yet.

Location:
branches/encryption
Files:
6 added
2 deleted
15 edited

Legend:

Unmodified
Added
Removed
  • branches/encryption/libtransmission/Makefile.am

    r2829 r2936  
    1414    completion.c \
    1515    dirname.c \
     16    encryption.c \
    1617    fastresume.c \
    1718    fdlimit.c \
     19    handshake.c \
    1820    http.c \
    1921    inout.c \
     
    2527    net.c \
    2628    peer.c \
     29    peer-connection.c \
    2730    platform.c \
    2831    ptrarray.c \
    2932    publish.c \
    3033    ratecontrol.c \
    31     sha1.c \
    3234    shared.c \
    3335    strlcat.c \
     
    4951    clients.h \
    5052    completion.h \
     53    encryption.h \
    5154    fastresume.h \
    5255    fdlimit.h \
     56    handshake.h \
    5357    http.h \
    5458    inout.h \
     
    6771    peertree.h \
    6872    peerutils.h \
     73    peer-connection.h \
    6974    platform.h \
    7075    ptrarray.h \
    7176    publish.h \
    7277    ratecontrol.h \
    73     sha1.h \
    7478    shared.h \
    7579    timer.h \
  • branches/encryption/libtransmission/inout.c

    r2876 r2936  
    2121#include "transmission.h"
    2222#include "completion.h"
     23#include "encryption.h"
    2324#include "fdlimit.h"
    2425#include "inout.h"
    2526#include "net.h"
    2627#include "peer.h"
    27 #include "sha1.h"
    2828#include "utils.h"
    2929
     
    212212    buf = malloc( n );
    213213    ret = readOrWritePiece ( tor, TR_IO_READ, pieceIndex, 0, buf, n );
    214     if( !ret ) {
    215         SHA1( buf, n, setme );
    216     }
     214    if( !ret )
     215        tr_sha1( setme, buf, n, NULL );
    217216    free( buf );
    218217
  • branches/encryption/libtransmission/internal.h

    r2891 r2936  
    5656void tr_peerIdNew ( char* buf, int buflen );
    5757
    58 void tr_torrentResetTransferStats( tr_torrent_t * );
    59 
    60 int tr_torrentAddCompact( tr_torrent_t * tor, int from,
     58void tr_torrentResetTransferStats( tr_torrent * );
     59
     60int tr_torrentAddCompact( tr_torrent * tor, int from,
    6161                           const uint8_t * buf, int count );
    62 int tr_torrentAttachPeer( tr_torrent_t * tor, struct tr_peer_s * );
    63 
    64 void tr_torrentSetHasPiece( tr_torrent_t * tor, int pieceIndex, int has );
    65 
    66 void tr_torrentReaderLock    ( const tr_torrent_t * );
    67 void tr_torrentReaderUnlock  ( const tr_torrent_t * );
    68 void tr_torrentWriterLock    ( tr_torrent_t * );
    69 void tr_torrentWriterUnlock  ( tr_torrent_t * );
    70 
    71 void tr_torrentChangeMyPort  ( tr_torrent_t *, int port );
     62int tr_torrentAttachPeer( tr_torrent * tor, struct tr_peer_s * );
     63
     64void tr_torrentSetHasPiece( tr_torrent * tor, int pieceIndex, int has );
     65
     66void tr_torrentReaderLock    ( const tr_torrent * );
     67void tr_torrentReaderUnlock  ( const tr_torrent * );
     68void tr_torrentWriterLock    ( tr_torrent * );
     69void tr_torrentWriterUnlock  ( tr_torrent * );
     70
     71void tr_torrentChangeMyPort  ( tr_torrent *, int port );
     72
     73tr_torrent* tr_torrentFindFromObfuscatedHash( tr_handle *, const uint8_t* );
    7274
    7375/* get the index of this piece's first block */
     
    9092
    9193#define tr_block(a,b) _tr_block(tor,a,b)
    92 int _tr_block( const tr_torrent_t * tor, int index, int begin );
     94int _tr_block( const tr_torrent * tor, int index, int begin );
    9395
    9496
     
    106108#define TR_ID_LEN  20
    107109
    108 struct tr_torrent_s
     110struct tr_torrent
    109111{
    110112    tr_handle_t               * handle;
     
    120122    char                       errorString[128];
    121123    int                        hasChangedState;
     124
     125    uint8_t                    obfuscatedHash[SHA_DIGEST_LENGTH];
    122126
    123127    uint8_t                  * azId;
     
    172176    tr_stat_t                  stats[2];
    173177
    174     tr_torrent_t             * next;
     178    tr_torrent               * next;
    175179};
    176180
    177 struct tr_handle_s
     181struct tr_handle
    178182{
    179183    struct tr_event_handle_s * events;
    180184
    181185    int                        torrentCount;
    182     tr_torrent_t             * torrentList;
     186    tr_torrent               * torrentList;
    183187
    184188    char                     * tag;
  • branches/encryption/libtransmission/makemeta.c

    r2851 r2936  
    2222#include <dirent.h>
    2323
    24 #include "trcompat.h" /* for strlcpy */
     24#include "encryption.h" /* tr_sha1 */
     25#include "trcompat.h" /* strlcpy */
    2526#include "transmission.h"
    26 #include "internal.h" /* for tr_torrent_t */
     27#include "internal.h" /* tr_torrent_t */
    2728#include "bencode.h"
    2829#include "makemeta.h"
    2930#include "platform.h" /* threads, locks */
    3031#include "shared.h" /* shared lock */
    31 #include "sha1.h"
    3232#include "utils.h" /* buildpath */
    3333#include "version.h"
     
    232232        assert( bufptr-buf == (int)thisPieceSize );
    233233        assert( pieceRemain == 0 );
    234         SHA1( buf, thisPieceSize, walk );
     234        tr_sha1( buf, walk, thisPieceSize, NULL );
    235235        walk += SHA_DIGEST_LENGTH;
    236236
  • branches/encryption/libtransmission/metainfo.c

    r2857 r2936  
    3434#include "transmission.h"
    3535#include "bencode.h"
     36#include "encryption.h" /* tr_sha1 */
    3637#include "http.h" /* tr_httpParseUrl */
    3738#include "metainfo.h"
    3839#include "platform.h"
    39 #include "sha1.h"
    4040#include "utils.h"
    4141
     
    193193        return TR_EINVALID;
    194194    }
    195     SHA1( (uint8_t *) beInfo->begin,
    196           (long) beInfo->end - (long) beInfo->begin, inf->hash );
     195
     196    tr_sha1( inf->hash, beInfo->begin, beInfo->end - beInfo->begin, NULL );
     197
    197198    for( i = 0; i < SHA_DIGEST_LENGTH; i++ )
    198199    {
  • branches/encryption/libtransmission/peer.c

    r2891 r2936  
    296296}
    297297
    298 static const char* getPeerId( void )
     298const char* getPeerId( void )
    299299{
    300300    static char * peerId = NULL;
     
    798798}
    799799
    800 int tr_peerIsFrom( const tr_peer_t * peer )
     800int tr_peerGetFrom( const tr_peer_t * peer )
    801801{
    802802    return peer->from;
  • branches/encryption/libtransmission/peer.h

    r2573 r2936  
    3535const char *tr_peerClient          ( tr_peer_t * );
    3636void        tr_peerSetPrivate      ( tr_peer_t *, int );
    37 void        tr_peerSetTorrent      ( tr_peer_t *, struct tr_torrent_s * );
     37void        tr_peerSetTorrent      ( tr_peer_t *, struct tr_torrent * );
    3838void        tr_peerSentBlockToUs   ( tr_peer_t *, int byteCount );
    3939void        tr_peerGotBlockFromUs  ( tr_peer_t *, int byteCount );
     
    4343int         tr_peerPulse           ( tr_peer_t * );
    4444int         tr_peerIsConnected     ( const tr_peer_t * );
    45 int         tr_peerIsFrom          ( const tr_peer_t * );
     45int         tr_peerGetFrom         ( const tr_peer_t * );
    4646int         tr_peerTimesChoked     ( const tr_peer_t * );
    4747int         tr_peerIsChokingUs     ( const tr_peer_t * );
     
    6161void        tr_peerBlame           ( tr_peer_t *, int piece, int success );
    6262struct in_addr * tr_peerAddress    ( tr_peer_t * );
    63 int         tr_peerGetConnectable  ( const struct tr_torrent_s *, uint8_t ** );
     63int         tr_peerGetConnectable  ( const struct tr_torrent *, uint8_t ** );
    6464
    6565void        tr_swiftPulse          ( tr_handle_t * );
  • branches/encryption/libtransmission/shared.c

    r2805 r2936  
    2626#include <stdlib.h>
    2727#include <string.h>
     28#include <stdio.h>
    2829
    2930#include <sys/types.h>
     
    3132#include "transmission.h"
    3233#include "choking.h"
     34#include "handshake.h"
    3335#include "natpmp.h"
    3436#include "net.h"
    3537#include "peer.h"
     38#include "peer-connection.h"
    3639#include "platform.h"
    3740#include "shared.h"
     
    334337}
    335338
     339
     340static void
     341myHandshakeDoneCB( struct tr_peerConnection * c, int isConnected, void * unused UNUSED )
     342{
     343    if( isConnected )
     344        fprintf( stderr, "FIXME: add some way to push this connection to the tor\n" );
     345    else
     346        tr_peerConnectionFree( c );
     347}
     348
    336349/***********************************************************************
    337350 * AcceptPeers
     
    346359    for( ;; )
    347360    {
     361        tr_peerConnection * connection;
     362
    348363        if( s->bindSocket < 0 || s->peerCount >= MAX_PEER_COUNT )
    349364        {
     
    356371            break;
    357372        }
    358         s->peers[s->peerCount++] = tr_peerInit( &addr, 0, socket,
    359                                                 TR_PEER_FROM_INCOMING );
     373
     374        connection = tr_peerConnectionNewIncoming( s->h,
     375                                                   &addr,
     376                                                   socket );
     377
     378        tr_handshakeAdd( connection,
     379                         HANDSHAKE_ENCRYPTION_PREFERRED,
     380                         myHandshakeDoneCB,
     381                         NULL );
    360382    }
    361383}
  • branches/encryption/libtransmission/timer.h

    r2849 r2936  
    2626 * if user_data has resources that need to be freed.
    2727 */
    28 tr_timer_tag  tr_timerNew( struct tr_handle_s   * handle,
    29                            int                    timer_func( void * user_data ),
    30                            void                 * user_data,
    31                            void                   free_func( void * user_data ),
    32                            int                    timeout_milliseconds );
     28tr_timer_tag  tr_timerNew( struct tr_handle  * handle,
     29                           int                 timer_func( void * user_data ),
     30                           void              * user_data,
     31                           void                free_func( void * user_data ),
     32                           int                 timeout_milliseconds );
    3333
    3434/**
  • branches/encryption/libtransmission/torrent.c

    r2891 r2936  
    3232#include "transmission.h"
    3333#include "completion.h"
     34#include "encryption.h"
    3435#include "fastresume.h"
     36#include "handshake.h"
    3537#include "inout.h"
    3638#include "metainfo.h"
    3739#include "net.h" /* tr_netNtop */
    3840#include "peer.h"
     41#include "peer-connection.h"
    3942#include "platform.h"
    4043#include "ratecontrol.h"
     
    4548
    4649/***
     50****
     51***/
     52
     53tr_torrent*
     54tr_torrentFindFromObfuscatedHash( tr_handle      * handle,
     55                                  const uint8_t  * obfuscatedTorrentHash )
     56{
     57    tr_torrent * tor;
     58
     59    for( tor = handle->torrentList; tor; tor = tor->next )
     60        if( !memcmp( tor->obfuscatedHash, obfuscatedTorrentHash, SHA_DIGEST_LENGTH ) )
     61            return tor;
     62
     63    return NULL;
     64}
     65
     66/***
    4767****  LOCKS
    4868***/
    4969
    5070void
    51 tr_torrentReaderLock( const tr_torrent_t * tor )
     71tr_torrentReaderLock( const tr_torrent * tor )
    5272{
    5373    tr_rwReaderLock ( (tr_rwlock_t*)tor->lock );
     
    5575
    5676void
    57 tr_torrentReaderUnlock( const tr_torrent_t * tor )
     77tr_torrentReaderUnlock( const tr_torrent * tor )
    5878{
    5979    tr_rwReaderUnlock ( (tr_rwlock_t*)tor->lock );
     
    6181
    6282void
    63 tr_torrentWriterLock( tr_torrent_t * tor )
     83tr_torrentWriterLock( tr_torrent * tor )
    6484{
    6585    tr_rwWriterLock ( tor->lock );
     
    6787
    6888void
    69 tr_torrentWriterUnlock( tr_torrent_t * tor )
     89tr_torrentWriterUnlock( tr_torrent * tor )
    7090{
    7191    tr_rwWriterUnlock ( tor->lock );
     
    7797
    7898void
    79 tr_torrentSetSpeedMode( tr_torrent_t     * tor,
    80                         int                up_or_down,
    81                         tr_speedlimit_t    mode )
     99tr_torrentSetSpeedMode( tr_torrent     * tor,
     100                        int              up_or_down,
     101                        tr_speedlimit_t  mode )
    82102{
    83103    tr_speedlimit_t * limit = up_or_down==TR_UP
     
    88108
    89109tr_speedlimit_t
    90 tr_torrentGetSpeedMode( const tr_torrent_t * tor,
    91                         int                  up_or_down)
     110tr_torrentGetSpeedMode( const tr_torrent * tor,
     111                        int                up_or_down)
    92112{
    93113    return up_or_down==TR_UP ? tor->uploadLimitMode
     
    96116
    97117void
    98 tr_torrentSetSpeedLimit( tr_torrent_t   * tor,
    99                          int              up_or_down,
    100                          int              single_KiB_sec )
     118tr_torrentSetSpeedLimit( tr_torrent   * tor,
     119                         int            up_or_down,
     120                         int            single_KiB_sec )
    101121{
    102122    tr_ratecontrol_t * rc = up_or_down==TR_UP ? tor->upload : tor->download;
     
    105125
    106126int
    107 tr_torrentGetSpeedLimit( const tr_torrent_t  * tor,
    108                          int                   up_or_down )
     127tr_torrentGetSpeedLimit( const tr_torrent  * tor,
     128                         int                 up_or_down )
    109129{
    110130    tr_ratecontrol_t * rc = up_or_down==TR_UP ? tor->upload : tor->download;
     
    116136***/
    117137
    118 static void setRunState( tr_torrent_t *, run_status_t );
     138static void setRunState( tr_torrent *, run_status_t );
    119139
    120140static void
    121141onTrackerResponse( void * tracker UNUSED, void * vevent, void * user_data )
    122142{
    123     tr_torrent_t * tor = (tr_torrent_t *) user_data;
     143    tr_torrent * tor = (tr_torrent *) user_data;
    124144    tr_tracker_event_t * event = (tr_tracker_event_t *) vevent;
    125145
     
    182202
    183203static tr_priority_t
    184 calculatePiecePriority ( const tr_torrent_t * tor,
    185                          int                  piece )
     204calculatePiecePriority ( const tr_torrent * tor,
     205                         int                piece )
    186206{
    187207    int i;
     
    208228
    209229static void
    210 tr_torrentInitFilePieces( tr_torrent_t * tor )
     230tr_torrentInitFilePieces( tr_torrent * tor )
    211231{
    212232    int i;
     
    228248
    229249static void
    230 torrentRealInit( tr_handle_t   * h,
    231                  tr_torrent_t  * tor,
    232                  const char    * destination,
    233                  int             flags )
     250torrentRealInit( tr_handle_t * h,
     251                 tr_torrent  * tor,
     252                 const char  * destination,
     253                 int           flags )
    234254{
    235255    uint64_t loaded;
     
    304324    tor->download       = tr_rcInit();
    305325    tor->swarmspeed     = tr_rcInit();
     326
     327    tr_sha1( tor->obfuscatedHash, "req2", 4,
     328                                  info->hash, SHA_DIGEST_LENGTH,
     329                                  NULL );
    306330 
    307331    /* We have a new torrent */
     
    365389              const char          * name )
    366390{
    367     const tr_torrent_t * tor;
     391    const tr_torrent * tor;
    368392   
    369393    for( tor=h->torrentList; tor; tor=tor->next )
     
    379403            const uint8_t       * hash )
    380404{
    381     const tr_torrent_t * tor;
     405    const tr_torrent * tor;
    382406
    383407    for( tor=h->torrentList; tor; tor=tor->next )
     
    427451}
    428452 
    429 tr_torrent_t *
     453tr_torrent *
    430454tr_torrentInit( tr_handle_t   * h,
    431455                const char    * path,
     
    436460    int val;
    437461    int tmpError;
    438     tr_torrent_t * tor = NULL;
     462    tr_torrent * tor = NULL;
    439463
    440464    if( !error )
     
    443467    if(( val = tr_torrentParse( h, path, destination, NULL )))
    444468        *error = val;
    445     else if(!(( tor = tr_new0( tr_torrent_t, 1 ))))
     469    else if(!(( tor = tr_new0( tr_torrent, 1 ))))
    446470        *error = TR_EOTHER;
    447471    else {
     
    478502}
    479503
    480 tr_torrent_t *
     504tr_torrent *
    481505tr_torrentInitSaved( tr_handle_t    * h,
    482506                     const char     * hashStr,
     
    487511    int val;
    488512    int tmpError;
    489     tr_torrent_t * tor = NULL;
     513    tr_torrent * tor = NULL;
    490514
    491515    if( !error )
     
    494518    if(( val = tr_torrentParseHash( h, hashStr, destination, NULL )))
    495519        *error = val;
    496     else if(!(( tor = tr_new0( tr_torrent_t, 1 ))))
     520    else if(!(( tor = tr_new0( tr_torrent, 1 ))))
    497521        *error = TR_EOTHER;
    498522    else {
     
    530554}
    531555
    532 tr_torrent_t *
     556tr_torrent *
    533557tr_torrentInitData( tr_handle_t    * h,
    534558                    const uint8_t  * data,
     
    540564    int val;
    541565    int tmpError;
    542     tr_torrent_t * tor = NULL;
     566    tr_torrent * tor = NULL;
    543567
    544568    if( !error )
     
    547571    if(( val = tr_torrentParseData( h, data, size, destination, NULL )))
    548572        *error = val;
    549     else if(!(( tor = tr_new0( tr_torrent_t, 1 ))))
     573    else if(!(( tor = tr_new0( tr_torrent, 1 ))))
    550574        *error = TR_EOTHER;
    551575    else {
     
    558582
    559583const tr_info_t *
    560 tr_torrentInfo( const tr_torrent_t * tor )
     584tr_torrentInfo( const tr_torrent * tor )
    561585{
    562586    return &tor->info;
     
    568592
    569593#if 0
    570 int tr_torrentScrape( tr_torrent_t * tor, int * s, int * l, int * d )
     594int tr_torrentScrape( tr_torrent * tor, int * s, int * l, int * d )
    571595{
    572596    return tr_trackerScrape( tor, s, l, d );
     
    575599
    576600static void
    577 fastResumeSave( tr_torrent_t * tor )
     601fastResumeSave( tr_torrent * tor )
    578602{
    579603    tr_fastResumeSave( tor );
     
    582606
    583607void
    584 tr_torrentSetFolder( tr_torrent_t * tor, const char * path )
     608tr_torrentSetFolder( tr_torrent * tor, const char * path )
    585609{
    586610    tr_free( tor->destination );
     
    590614
    591615const char*
    592 tr_torrentGetFolder( const tr_torrent_t * tor )
     616tr_torrentGetFolder( const tr_torrent * tor )
    593617{
    594618    return tor->destination;
     
    596620
    597621void
    598 tr_torrentChangeMyPort( tr_torrent_t * tor, int port )
     622tr_torrentChangeMyPort( tr_torrent * tor, int port )
    599623{
    600624    tr_torrentWriterLock( tor );
     
    614638 **********************************************************************/
    615639
    616 void tr_torrentDisablePex( tr_torrent_t * tor, int disable )
     640void tr_torrentDisablePex( tr_torrent * tor, int disable )
    617641{
    618642    tr_torrentWriterLock( tor );
     
    632656}
    633657
    634 static int tr_didStateChangeTo ( tr_torrent_t * tor, int status )
     658static int tr_didStateChangeTo ( tr_torrent * tor, int status )
    635659{
    636660    int ret;
     
    644668}
    645669
    646 int tr_getIncomplete( tr_torrent_t * tor )
     670int tr_getIncomplete( tr_torrent * tor )
    647671{
    648672    return tr_didStateChangeTo( tor, TR_CP_INCOMPLETE );
    649673}
    650 int tr_getDone( tr_torrent_t * tor )
     674int tr_getDone( tr_torrent * tor )
    651675{
    652676    return tr_didStateChangeTo( tor, TR_CP_DONE );
    653677}
    654 int tr_getComplete( tr_torrent_t * tor )
     678int tr_getComplete( tr_torrent * tor )
    655679{
    656680    return tr_didStateChangeTo( tor, TR_CP_COMPLETE );
     
    658682
    659683void
    660 tr_manualUpdate( tr_torrent_t * tor )
     684tr_manualUpdate( tr_torrent * tor )
    661685{
    662686    if( tor->runStatus == TR_RUN_RUNNING )
     
    664688}
    665689int
    666 tr_torrentCanManualUpdate( const tr_torrent_t * tor )
     690tr_torrentCanManualUpdate( const tr_torrent * tor )
    667691{
    668692    return ( tor != NULL )
     
    672696
    673697const tr_stat_t *
    674 tr_torrentStat( tr_torrent_t * tor )
     698tr_torrentStat( tr_torrent * tor )
    675699{
    676700    tr_stat_t * s;
     
    704728        {
    705729            ++s->peersConnected;
    706             ++s->peersFrom[tr_peerIsFrom(peer)];
     730            ++s->peersFrom[tr_peerGetFrom(peer)];
    707731
    708732            if( tr_peerDownloadRate( peer ) > 0.01 )
     
    783807
    784808static uint64_t
    785 fileBytesCompleted ( const tr_torrent_t * tor, int fileIndex )
     809fileBytesCompleted ( const tr_torrent * tor, int fileIndex )
    786810{
    787811    const tr_file_t * file     =  &tor->info.files[fileIndex];
     
    826850
    827851tr_file_stat_t *
    828 tr_torrentFiles( const tr_torrent_t * tor, int * fileCount )
     852tr_torrentFiles( const tr_torrent * tor, int * fileCount )
    829853{
    830854    int i;
     
    870894
    871895tr_peer_stat_t *
    872 tr_torrentPeers( const tr_torrent_t * tor, int * peerCount )
     896tr_torrentPeers( const tr_torrent * tor, int * peerCount )
    873897{
    874898    tr_peer_stat_t * peers;
     
    897921            peers[i].client           =  tr_peerClient( peer );
    898922            peers[i].isConnected      =  tr_peerIsConnected( peer );
    899             peers[i].from             =  tr_peerIsFrom( peer );
     923            peers[i].from             =  tr_peerGetFrom( peer );
    900924            peers[i].progress         =  tr_peerProgress( peer );
    901925            peers[i].port             =  tr_peerPort( peer );
     
    919943}
    920944
    921 void tr_torrentAvailability( const tr_torrent_t * tor, int8_t * tab, int size )
     945void tr_torrentAvailability( const tr_torrent * tor, int8_t * tab, int size )
    922946{
    923947    int i, j, piece;
     
    950974}
    951975
    952 void tr_torrentAmountFinished( const tr_torrent_t * tor, float * tab, int size )
     976void tr_torrentAmountFinished( const tr_torrent * tor, float * tab, int size )
    953977{
    954978    int i;
     
    967991
    968992void
    969 tr_torrentResetTransferStats( tr_torrent_t * tor )
     993tr_torrentResetTransferStats( tr_torrent * tor )
    970994{
    971995    tr_torrentWriterLock( tor );
     
    9831007
    9841008void
    985 tr_torrentSetHasPiece( tr_torrent_t * tor, int pieceIndex, int has )
     1009tr_torrentSetHasPiece( tr_torrent * tor, int pieceIndex, int has )
    9861010{
    9871011    tr_torrentWriterLock( tor );
     
    9951019}
    9961020
    997 void tr_torrentRemoveSaved( tr_torrent_t * tor )
     1021void tr_torrentRemoveSaved( tr_torrent * tor )
    9981022{
    9991023    tr_metainfoRemoveSaved( tor->info.hashString, tor->handle->tag );
    10001024}
    10011025
    1002 void tr_torrentRecheck( tr_torrent_t * tor )
     1026void tr_torrentRecheck( tr_torrent * tor )
    10031027{
    10041028    if( !tor->uncheckedPieces )
     
    10081032
    10091033
    1010 int tr_torrentAttachPeer( tr_torrent_t * tor, tr_peer_t * peer )
     1034int tr_torrentAttachPeer( tr_torrent * tor, tr_peer_t * peer )
    10111035{
    10121036    int i;
     
    10411065}
    10421066
    1043 int tr_torrentAddCompact( tr_torrent_t * tor, int from,
    1044                            const uint8_t * buf, int count )
     1067static void
     1068tr_torrentAddPeerConnection( tr_torrent        * tor UNUSED,
     1069                             tr_peerConnection * connection UNUSED )
     1070{
     1071    assert( 0 && "FIXME" );
     1072}
     1073
     1074static void
     1075myHandshakeDoneCB( tr_peerConnection * c, int isConnected, void * userData UNUSED )
     1076{
     1077    if( isConnected )
     1078        tr_torrentAddPeerConnection( tr_peerConnectionGetTorrent(c), c );
     1079    else
     1080        tr_peerConnectionFree( c );
     1081}
     1082
     1083int tr_torrentAddCompact( tr_torrent * tor, int from UNUSED,
     1084                          const uint8_t * buf, int count )
    10451085{
    10461086    struct in_addr addr;
    10471087    tr_port_t port;
    10481088    int i, added;
    1049     tr_peer_t * peer;
    10501089
    10511090    added = 0;
     
    10541093        memcpy( &addr, buf, 4 ); buf += 4;
    10551094        memcpy( &port, buf, 2 ); buf += 2;
    1056         peer = tr_peerInit( &addr, port, -1, from );
    1057         added += tr_torrentAttachPeer( tor, peer );
     1095
     1096        tr_handshakeAdd (
     1097            tr_peerConnectionNewOutgoing( tor->handle, &addr, port, tor ),
     1098            HANDSHAKE_ENCRYPTION_PREFERRED,
     1099            myHandshakeDoneCB,
     1100            NULL );
     1101
     1102        //added += tr_torrentAttachPeer( tor, peer );
    10581103    }
    10591104
     
    10651110***/
    10661111
    1067 static void setRunState( tr_torrent_t * tor, run_status_t run )
     1112static void setRunState( tr_torrent * tor, run_status_t run )
    10681113{
    10691114    tr_torrentWriterLock( tor );
     
    10721117}
    10731118
    1074 void tr_torrentStart( tr_torrent_t * tor )
     1119void tr_torrentStart( tr_torrent * tor )
    10751120{
    10761121    setRunState( tor, TR_RUN_RUNNING );
     
    10791124}
    10801125
    1081 void tr_torrentStop( tr_torrent_t * tor )
     1126void tr_torrentStop( tr_torrent * tor )
    10821127{
    10831128    if((tor->runStatus != TR_RUN_STOPPING) && (tor->runStatus != TR_RUN_STOPPED) )
     
    10851130}
    10861131
    1087 void tr_torrentClose( tr_torrent_t * tor )
     1132void tr_torrentClose( tr_torrent * tor )
    10881133{
    10891134    tor->runStatusToSave = tor->runStatus;
     
    10941139
    10951140static void
    1096 tr_torrentFree( tr_torrent_t * tor )
    1097 {
    1098     tr_torrent_t * t;
     1141tr_torrentFree( tr_torrent * tor )
     1142{
     1143    tr_torrent * t;
    10991144    tr_handle_t * h = tor->handle;
    11001145    tr_info_t * inf = &tor->info;
     
    11371182
    11381183static void
    1139 recheckCpState( tr_torrent_t * tor )
     1184recheckCpState( tr_torrent * tor )
    11401185{
    11411186    cp_status_t cpStatus;
     
    11611206{
    11621207    static tr_lock_t * checkFilesLock = NULL;
    1163     tr_torrent_t * tor = _tor;
     1208    tr_torrent * tor = _tor;
    11641209
    11651210    /* create the check-files mutex */
     
    11711216    {
    11721217        /* sleep a little while */
    1173         tr_wait( tor->runStatus == TR_RUN_STOPPED ? 1600 : 600 );
     1218        tr_wait( tor->runStatus == TR_RUN_STOPPED ? 1600 : 100 );
    11741219
    11751220        if( tor->fastResumeDirty )
     
    13071352
    13081353void
    1309 tr_torrentSetFilePriority( tr_torrent_t   * tor,
    1310                            int              fileIndex,
    1311                            tr_priority_t    priority )
     1354tr_torrentSetFilePriority( tr_torrent   * tor,
     1355                           int            fileIndex,
     1356                           tr_priority_t  priority )
    13121357{
    13131358    int i;
     
    13351380
    13361381void
    1337 tr_torrentSetFilePriorities( tr_torrent_t        * tor,
    1338                              int                 * files,
    1339                              int                   fileCount,
    1340                              tr_priority_t         priority )
     1382tr_torrentSetFilePriorities( tr_torrent     * tor,
     1383                             int            * files,
     1384                             int              fileCount,
     1385                             tr_priority_t    priority )
    13411386{
    13421387    int i;
     
    13461391
    13471392tr_priority_t
    1348 tr_torrentGetFilePriority( const tr_torrent_t *  tor, int file )
     1393tr_torrentGetFilePriority( const tr_torrent *  tor, int file )
    13491394{
    13501395    tr_priority_t ret;
     
    13611406
    13621407tr_priority_t*
    1363 tr_torrentGetFilePriorities( const tr_torrent_t * tor )
     1408tr_torrentGetFilePriorities( const tr_torrent * tor )
    13641409{
    13651410    int i;
     
    13801425
    13811426int
    1382 tr_torrentGetFileDL( const tr_torrent_t * tor,
    1383                      int                  file )
     1427tr_torrentGetFileDL( const tr_torrent * tor,
     1428                     int                file )
    13841429{
    13851430    int doDownload;
     
    13941439
    13951440void
    1396 tr_torrentSetFileDL( tr_torrent_t  * tor,
    1397                      int             fileIndex,
    1398                      int             doDownload )
     1441tr_torrentSetFileDL( tr_torrent  * tor,
     1442                     int           fileIndex,
     1443                     int           doDownload )
    13991444{
    14001445    tr_file_t * file;
     
    14491494
    14501495void
    1451 tr_torrentSetFileDLs ( tr_torrent_t   * tor,
    1452                        int            * files,
    1453                        int              fileCount,
    1454                        int              doDownload )
     1496tr_torrentSetFileDLs ( tr_torrent  * tor,
     1497                       int         * files,
     1498                       int           fileCount,
     1499                       int           doDownload )
    14551500{
    14561501    int i;
     
    14631508***/
    14641509
    1465 int _tr_block( const tr_torrent_t * tor, int index, int begin )
     1510int _tr_block( const tr_torrent * tor, int index, int begin )
    14661511{
    14671512    const tr_info_t * inf = &tor->info;
  • branches/encryption/libtransmission/transmission.h

    r2891 r2936  
    102102 *   beos cli daemon gtk macosx
    103103 **********************************************************************/
    104 typedef struct tr_handle_s tr_handle_t;
     104typedef struct tr_handle tr_handle;
     105typedef struct tr_handle tr_handle_t;
    105106tr_handle_t * tr_init( const char * tag );
    106107
     
    180181 * Iterates on open torrents
    181182 **********************************************************************/
    182 typedef struct tr_torrent_s tr_torrent_t;
     183typedef struct tr_torrent tr_torrent;
     184typedef struct tr_torrent tr_torrent_t;
    183185typedef void (*tr_callback_t) ( tr_torrent_t *, void * );
    184186void tr_torrentIterate( tr_handle_t *, tr_callback_t, void * );
     
    318320                               int          * setme_error );
    319321
    320 typedef struct tr_info_s tr_info_t;
     322typedef struct tr_info tr_info;
     323typedef struct tr_info tr_info_t;
    321324
    322325/**
     
    506509
    507510/***********************************************************************
    508  * tr_info_s
     511 * tr_info
    509512 **********************************************************************/
    510513
     
    529532tr_piece_t;
    530533   
    531 struct tr_info_s
     534struct tr_info
    532535{
    533536    /* Path to torrent */
  • branches/encryption/libtransmission/trevent.c

    r2921 r2936  
    5353    struct event pipeEvent;
    5454}
    55 tr_event_handle_t;
     55tr_event_handle;
    5656
    5757#ifdef DEBUG
     
    120120            read( fd, &mode, sizeof(short) );
    121121            bufferevent_enable( bufev, mode );
    122             bufferevent_disable( bufev, ~mode );
     122            bufferevent_disable( bufev, mode==EV_READ ? EV_WRITE : EV_READ );
    123123            break;
    124124
     
    128128            read( fd, &buflen, sizeof(size_t) );
    129129            fprintf( stderr, "bufev is %p, buflen is %d, buf is %p\n", bufev, (int)buflen, buf );
     130            bufferevent_enable( bufev, EV_WRITE );
     131            bufferevent_disable( bufev, EV_READ );
    130132            bufferevent_write( bufev, buf, buflen );
    131133            tr_free( buf );
     
    157159libeventThreadFunc( void * veh )
    158160{
    159     tr_event_handle_t * eh = (tr_event_handle_t *) veh;
     161    tr_event_handle * eh = (tr_event_handle *) veh;
    160162    tr_dbg( "Starting libevent thread" );
    161163
     
    180182tr_eventInit( tr_handle_t * handle )
    181183{
    182     tr_event_handle_t * eh;
    183 
    184     eh = tr_new0( tr_event_handle_t, 1 );
     184    tr_event_handle * eh;
     185
     186    eh = tr_new0( tr_event_handle, 1 );
    185187    eh->lock = tr_lockNew( );
    186188    pipe( eh->fds );
     
    193195tr_eventClose( tr_handle_t * handle )
    194196{
    195     tr_event_handle_t * eh = handle->events;
     197    tr_event_handle * eh = handle->events;
    196198
    197199    event_base_loopexit( eh->base, NULL );
     
    282284
    283285void
    284 tr_setBufferEventMode( struct tr_handle_s * handle,
     286tr_setBufferEventMode( struct tr_handle  * handle,
    285287                       struct bufferevent * bufev,
    286288                       short                mode )
  • branches/encryption/libtransmission/trevent.h

    r2921 r2936  
    1818**/
    1919
    20 void tr_eventInit( struct tr_handle_s * tr_handle );
     20void tr_eventInit( struct tr_handle * tr_handle );
    2121
    22 void tr_eventClose( struct tr_handle_s * tr_handle );
     22void tr_eventClose( struct tr_handle * tr_handle );
    2323
    2424/**
     
    3131struct bufferevent;
    3232
    33 void  tr_event_add( struct tr_handle_s  * tr_handle,
    34                     struct event        * event,
    35                     struct timeval      * interval );
     33void  tr_event_add( struct tr_handle  * tr_handle,
     34                    struct event      * event,
     35                    struct timeval    * interval );
    3636
    37 void  tr_event_del( struct tr_handle_s  * tr_handle,
    38                     struct event        * event );
     37void  tr_event_del( struct tr_handle  * tr_handle,
     38                    struct event      * event );
    3939
    40 void tr_evhttp_make_request (struct tr_handle_s        * tr_handle,
     40void tr_evhttp_make_request (struct tr_handle          * tr_handle,
    4141                             struct evhttp_connection  * evcon,
    4242                             struct evhttp_request     * req,
     
    4444                             char                      * uri);
    4545
    46 void tr_bufferevent_write( struct tr_handle_s    * tr_handle,
    47                            struct bufferevent    * bufferEvent,
    48                            const void            * buf,
    49                            size_t                  buflen );
     46void tr_bufferevent_write( struct tr_handle    * tr_handle,
     47                           struct bufferevent  * bufferEvent,
     48                           const void          * buf,
     49                           size_t                buflen );
    5050
    51 void tr_setBufferEventMode( struct tr_handle_s * tr_handle,
     51void tr_setBufferEventMode( struct tr_handle  * tr_handle,
    5252                            struct bufferevent * bufferEvent,
    5353                            short                mode );
  • branches/encryption/mk/osx.mk

    r1075 r2936  
    1515#
    1616include mk/version.mk
    17 ifeq ($(VERSION_STRING),$(VERSION_MAJOR).$(VERSION_MINOR))
     17ifeq ($(STABLE_RELEASE),"yes")
    1818VERSION_PACKAGE = $(VERSION_STRING)
    1919else
  • branches/encryption/mk/version.sh

    r2861 r2936  
    33# $Id$
    44
    5 # constraint: strlen(MAJOR MINOR MAINT BETA) must be 4
    6 # convention: BETA: "Z" for a beta, "0" for a stable
    7 MAJOR="0"
    8 MINOR="8"
    9 MAINT="0"
    10 BETA="Z"
    11 STRING=0.80+
    12 
     5# these should be the only two lines you need to change
    136PEERID_PREFIX="-TR080Z-"
    147USERAGENT_PREFIX="0.80+"
     8
     9
    1510SVN_REVISION=`find ./ -name "*\.[ch]" -o -name "*\.cpp" -o -name "*\.po" | \
    1611              xargs grep "\$Id:" | \
    1712              grep -v third-party | \
    1813              cut -d"$Id:" -f3 | cut -d" " -f3 | sort -n | tail -n 1`
     14
     15if test "x${PEERID_PREFIX//Z/}" = "x$PEERID_PREFIX";
     16then
     17    STABLE_RELEASE=yes
     18else
     19    STABLE_RELEASE=no
     20fi
    1921 
    2022# Generate files to be included: only overwrite them if changed so make
     
    3133# Generate version.mk
    3234cat > mk/version.mk.new << EOF
    33 VERSION_MAJOR       = "$MAJOR"
    34 VERSION_MINOR       = "$MINOR"
    35 VERSION_MAINTENANCE = "$MAINT"
    3635VERSION_REVISION    = "$SVN_REVISION"
    37 VERSION_STRING      = "$STRING ($SVN_REVISION)"
     36VERSION_STRING      = "$USERAGENT_PREFIX ($SVN_REVISION)"
     37STABLE_RELEASE      = "$STABLE_RELEASE"
    3838EOF
    3939replace_if_differs mk/version.mk.new mk/version.mk
Note: See TracChangeset for help on using the changeset viewer.