Changeset 8460


Ignore:
Timestamp:
May 21, 2009, 12:15:54 AM (12 years ago)
Author:
charles
Message:

(trunk) add hooks for disabling/enabling DHT in gtk client, qt client, and transmission-remote

Location:
trunk
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/daemon/remote.c

    r8421 r8460  
    8282    { 'n', "auth",                 "Set authentication info", "n",  1, "<username:password>" },
    8383    { 'N', "netrc",                "Set authentication info from a .netrc file", "N",  1, "<filename>" },
     84    { 'o', "dht",                  "Enable distributed hash tables (DHT)", "o", 0, NULL },
     85    { 'O', "no-dht",               "Disable distributed hash tables (DHT)", "O", 0, NULL },
    8486    { 'p', "port",                 "Port for incoming peers (Default: " TR_DEFAULT_PEER_PORT_STR ")", "p", 1, "<port>" },
    8587    { 'P', "random-port",          "Random port for incomping peers", "P", 0, NULL },
     
    496498            }
    497499
     500            case 'o':
     501                tr_bencDictAddStr( &top, "method", "session-set" );
     502                tr_bencDictAddBool( args, TR_PREFS_KEY_DHT_ENABLED, TRUE );
     503                break;
     504
     505            case 'O':
     506                tr_bencDictAddStr( &top, "method", "session-set" );
     507                tr_bencDictAddBool( args, TR_PREFS_KEY_DHT_ENABLED, FALSE );
     508                break;
     509
    498510            case 'x':
    499511                tr_bencDictAddStr( &top, "method", "session-set" );
  • trunk/daemon/transmission-remote.1

    r8389 r8460  
    2828.Op Fl n Ar user:pass
    2929.Op Fl N Ar netrc
     30.Op Fl o | O
    3031.Op Fl p Ar port
    3132.Op Fl ph Ar files
     
    135136See netrc(5) for more information.
    136137
     138.It Fl o Fl -dht
     139Enable distributed hash table (DHT).
     140.It Fl O Fl -no-dht
     141Disable distribued hash table (DHT).
     142
    137143.It Fl p Fl -port Ar port
    138144Set the
  • trunk/doc/rpc-spec.txt

    r8431 r8460  
    375375   "blocklist-enabled"        | boolean    true means enabled
    376376   "blocklist-size"           | number     number of rules in the blocklist
     377   "dht-enabled"              | boolean    true means allow dht in public torrents
    377378   "encryption"               | string     "required", "preferred", "tolerated"
    378379   "download-dir"             | string     default path to download torrents
  • trunk/gtk/main.c

    r8420 r8460  
    10101010        tr_sessionSetPexEnabled( tr, pref_flag_get( key ) );
    10111011    }
     1012    else if( !strcmp( key, TR_PREFS_KEY_DHT_ENABLED ) )
     1013    {
     1014        tr_sessionSetDHTEnabled( tr, pref_flag_get( key ) );
     1015    }
    10121016    else if( !strcmp( key, TR_PREFS_KEY_RPC_PORT ) )
    10131017    {
  • trunk/gtk/relocate.c

    r8453 r8460  
    2626{
    2727    GtkDialog * dialog;
    28     tr_bool done;
     28    int done;
    2929};
    3030
  • trunk/gtk/tr-prefs.c

    r8395 r8460  
    539539    hig_workarea_add_row( t, &row, s, w, NULL );
    540540
    541     s = _( "Use peer e_xchange" );
     541    s = _( "Use peer e_xchange (PEX)" );
    542542    w = new_check_button( s, TR_PREFS_KEY_PEX_ENABLED, core );
     543    hig_workarea_add_wide_control( t, &row, w );
     544
     545    s = _( "Use _distributed hash table (DHT)" );
     546    w = new_check_button( s, TR_PREFS_KEY_DHT_ENABLED, core );
    543547    hig_workarea_add_wide_control( t, &row, w );
    544548
  • trunk/libtransmission/rpcimpl.c

    r8453 r8460  
    11371137    if( tr_bencDictFindBool( args_in, TR_PREFS_KEY_PEX_ENABLED, &boolVal ) )
    11381138        tr_sessionSetPexEnabled( session, boolVal );
     1139    if( tr_bencDictFindBool( args_in, TR_PREFS_KEY_DHT_ENABLED, &boolVal ) )
     1140        tr_sessionSetDHTEnabled( session, boolVal );
    11391141    if( tr_bencDictFindBool( args_in, TR_PREFS_KEY_PEER_PORT_RANDOM_ON_START, &boolVal ) )
    11401142        tr_sessionSetPeerPortRandomOnStart( session, boolVal );
     
    12391241    tr_bencDictAddInt ( d, TR_PREFS_KEY_PEER_LIMIT_TORRENT, tr_sessionGetPeerLimitPerTorrent( s ) );
    12401242    tr_bencDictAddBool( d, TR_PREFS_KEY_PEX_ENABLED, tr_sessionIsPexEnabled( s ) );
     1243    tr_bencDictAddBool( d, TR_PREFS_KEY_DHT_ENABLED, tr_sessionIsDHTEnabled( s ) );
    12411244    tr_bencDictAddInt ( d, TR_PREFS_KEY_PEER_PORT, tr_sessionGetPeerPort( s ) );
    12421245    tr_bencDictAddInt ( d, TR_PREFS_KEY_PEER_PORT_RANDOM_ON_START, tr_sessionGetPeerPortRandomOnStart( s ) );
  • trunk/libtransmission/session.c

    r8433 r8460  
    348348    tr_bencDictReserve( d, 35 );
    349349    tr_bencDictAddBool( d, TR_PREFS_KEY_BLOCKLIST_ENABLED,        FALSE );
     350    tr_bencDictAddBool( d, TR_PREFS_KEY_DHT_ENABLED,              TRUE );
    350351    tr_bencDictAddStr ( d, TR_PREFS_KEY_DOWNLOAD_DIR,             tr_getDefaultDownloadDir( ) );
    351352    tr_bencDictAddInt ( d, TR_PREFS_KEY_DSPEED,                   100 );
     
    404405    tr_bencDictReserve( d, 30 );
    405406    tr_bencDictAddBool( d, TR_PREFS_KEY_BLOCKLIST_ENABLED,        tr_blocklistIsEnabled( s ) );
     407    tr_bencDictAddBool( d, TR_PREFS_KEY_DHT_ENABLED,              s->isDHTEnabled );
    406408    tr_bencDictAddStr ( d, TR_PREFS_KEY_DOWNLOAD_DIR,             s->downloadDir );
    407409    tr_bencDictAddInt ( d, TR_PREFS_KEY_DSPEED,                   tr_sessionGetSpeedLimit( s, TR_DOWN ) );
     
    623625    assert( found );
    624626    session->isPexEnabled = boolVal;
    625     /* This really ought to be a separate preference. */
     627
     628    found = tr_bencDictFindBool( &settings, TR_PREFS_KEY_DHT_ENABLED, &boolVal );
     629    assert( found );
    626630    session->isDHTEnabled = boolVal;
    627631
     
    15951599
    15961600    return session->isDHTEnabled;
     1601}
     1602
     1603void
     1604tr_sessionSetDHTEnabled( tr_session * session, tr_bool enabled )
     1605{
     1606    assert( tr_isSession( session ) );
     1607
     1608    if( ( enabled!=0 ) != (session->isDHTEnabled!=0) )
     1609    {
     1610        if( session->isDHTEnabled )
     1611            tr_dhtUninit( session );
     1612
     1613        session->isDHTEnabled = enabled!=0;
     1614
     1615        if( session->isDHTEnabled )
     1616            tr_dhtInit( session );
     1617    }
    15971618}
    15981619
  • trunk/libtransmission/transmission.h

    r8453 r8460  
    180180#define TR_PREFS_KEY_BIND_ADDRESS_IPV6          "bind-address-ipv6"
    181181#define TR_PREFS_KEY_BLOCKLIST_ENABLED          "blocklist-enabled"
     182#define TR_PREFS_KEY_DHT_ENABLED                "dht-enabled"
    182183#define TR_PREFS_KEY_DOWNLOAD_DIR               "download-dir"
    183184#define TR_PREFS_KEY_ENCRYPTION                 "encryption"
     
    533534tr_bool            tr_sessionIsDHTEnabled( const tr_session * session );
    534535
     536void               tr_sessionSetDHTEnabled( tr_session * session, tr_bool );
     537
    535538void               tr_sessionSetLazyBitfieldEnabled( tr_session * session,
    536539                                                     tr_bool       enabled );
  • trunk/qt/prefs-dialog.cc

    r8374 r8460  
    472472    hig->addSectionTitle( tr( "Privacy" ) );
    473473    hig->addRow( tr( "&Encryption mode:" ), box );
    474     hig->addWideControl( checkBoxNew( tr( "Use peer e&xchange" ), Prefs::PEX_ENABLED ) );
     474    hig->addWideControl( checkBoxNew( tr( "Use peer e&xchange (PEX)" ), Prefs::PEX_ENABLED ) );
     475    hig->addWideControl( checkBoxNew( tr( "Use &distributed hash table (DHT)" ), Prefs::PEX_ENABLED ) );
    475476
    476477    hig->finish( );
  • trunk/qt/prefs.cc

    r8414 r8460  
    8888    { SOCKET_TOS, TR_PREFS_KEY_PEER_SOCKET_TOS, QVariant::Int },
    8989    { PEX_ENABLED, TR_PREFS_KEY_PEX_ENABLED, QVariant::Bool },
     90    { DHT_ENABLED, TR_PREFS_KEY_DHT_ENABLED, QVariant::Bool },
    9091    { PORT_FORWARDING, TR_PREFS_KEY_PORT_FORWARDING, QVariant::Bool },
    9192    { PROXY_AUTH_ENABLED, TR_PREFS_KEY_PROXY_AUTH_ENABLED, QVariant::Bool },
  • trunk/qt/prefs.h

    r8401 r8460  
    9292            SOCKET_TOS,
    9393            PEX_ENABLED,
     94            DHT_ENABLED,
    9495            PORT_FORWARDING,
    9596            PROXY_AUTH_ENABLED,
  • trunk/qt/session.cc

    r8414 r8460  
    121121        case Prefs :: BLOCKLIST_ENABLED:
    122122        case Prefs :: BLOCKLIST_DATE:
     123        case Prefs :: DHT_ENABLED:
    123124        case Prefs :: DOWNLOAD_DIR:
    124125        case Prefs :: PEER_LIMIT_GLOBAL:
Note: See TracChangeset for help on using the changeset viewer.