(trunk) #3060 "Local Peer Discovery" -- in the code, rename LDS as LPD for Local Peer Discovery

This commit is contained in:
Charles Kerr 2010-05-08 08:42:45 +00:00
parent 0051b8a110
commit 2b9ab542cb
22 changed files with 202 additions and 205 deletions

View File

@ -104,8 +104,8 @@
A21F15AD11729A9F00CF5A9C /* AddMagnetWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = A21F1538117299F100CF5A9C /* AddMagnetWindow.xib */; };
A21FBBAB0EDA78C300BC3C51 /* bandwidth.h in Headers */ = {isa = PBXBuildFile; fileRef = A21FBBA90EDA78C300BC3C51 /* bandwidth.h */; };
A21FBBAC0EDA78C300BC3C51 /* bandwidth.c in Sources */ = {isa = PBXBuildFile; fileRef = A21FBBAA0EDA78C300BC3C51 /* bandwidth.c */; };
A220EC5B118C8A060022B4BE /* tr-lds.c in Sources */ = {isa = PBXBuildFile; fileRef = A220EC59118C8A060022B4BE /* tr-lds.c */; };
A220EC5C118C8A060022B4BE /* tr-lds.h in Headers */ = {isa = PBXBuildFile; fileRef = A220EC5A118C8A060022B4BE /* tr-lds.h */; };
A220EC5B118C8A060022B4BE /* tr-lpd.c in Sources */ = {isa = PBXBuildFile; fileRef = A220EC59118C8A060022B4BE /* tr-lpd.c */; };
A220EC5C118C8A060022B4BE /* tr-lpd.h in Headers */ = {isa = PBXBuildFile; fileRef = A220EC5A118C8A060022B4BE /* tr-lpd.h */; };
A22180980D148A71007D09ED /* GroupsPrefsController.m in Sources */ = {isa = PBXBuildFile; fileRef = A22180970D148A71007D09ED /* GroupsPrefsController.m */; };
A221DCC8104B3660008A642D /* Quartz.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A221DCC7104B3660008A642D /* Quartz.framework */; };
A222E9870E6B21D9009FB003 /* BlocklistDownloaderViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = A222E9860E6B21D9009FB003 /* BlocklistDownloaderViewController.m */; };
@ -546,8 +546,8 @@
A21F15AB11729A8B00CF5A9C /* AddMagnetWindowController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AddMagnetWindowController.h; path = macosx/AddMagnetWindowController.h; sourceTree = "<group>"; };
A21FBBA90EDA78C300BC3C51 /* bandwidth.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = bandwidth.h; path = libtransmission/bandwidth.h; sourceTree = "<group>"; };
A21FBBAA0EDA78C300BC3C51 /* bandwidth.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = bandwidth.c; path = libtransmission/bandwidth.c; sourceTree = "<group>"; };
A220EC59118C8A060022B4BE /* tr-lds.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = "tr-lds.c"; path = "libtransmission/tr-lds.c"; sourceTree = "<group>"; };
A220EC5A118C8A060022B4BE /* tr-lds.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "tr-lds.h"; path = "libtransmission/tr-lds.h"; sourceTree = "<group>"; };
A220EC59118C8A060022B4BE /* tr-lpd.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = "tr-lpd.c"; path = "libtransmission/tr-lpd.c"; sourceTree = "<group>"; };
A220EC5A118C8A060022B4BE /* tr-lpd.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "tr-lpd.h"; path = "libtransmission/tr-lpd.h"; sourceTree = "<group>"; };
A22180960D148A71007D09ED /* GroupsPrefsController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GroupsPrefsController.h; path = macosx/GroupsPrefsController.h; sourceTree = "<group>"; };
A22180970D148A71007D09ED /* GroupsPrefsController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = GroupsPrefsController.m; path = macosx/GroupsPrefsController.m; sourceTree = "<group>"; };
A221DCC7104B3660008A642D /* Quartz.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Quartz.framework; path = /System/Library/Frameworks/Quartz.framework; sourceTree = "<absolute>"; };
@ -1212,8 +1212,8 @@
0A6169A60FE5C9A200C66CE6 /* bitfield.h */,
A22CFCA60FC24ED80009BD3E /* tr-dht.c */,
A22CFCA70FC24ED80009BD3E /* tr-dht.h */,
A220EC59118C8A060022B4BE /* tr-lds.c */,
A220EC5A118C8A060022B4BE /* tr-lds.h */,
A220EC59118C8A060022B4BE /* tr-lpd.c */,
A220EC5A118C8A060022B4BE /* tr-lpd.h */,
A2AAB65B0DE0CF6200E04DDA /* rpcimpl.c */,
A2AAB6590DE0CF6200E04DDA /* rpcimpl.h */,
A2AAB6580DE0CF6200E04DDA /* rpc-server.c */,
@ -1569,7 +1569,7 @@
4D80185A10BBC0B0008A4AF2 /* magnet.h in Headers */,
A209EE5D1144B51E002B02D1 /* history.h in Headers */,
A247A443114C701800547DFC /* InfoViewController.h in Headers */,
A220EC5C118C8A060022B4BE /* tr-lds.h in Headers */,
A220EC5C118C8A060022B4BE /* tr-lpd.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -2040,7 +2040,7 @@
4D8017EA10BBC073008A4AF2 /* torrent-magnet.c in Sources */,
4D80185910BBC0B0008A4AF2 /* magnet.c in Sources */,
A209EE5C1144B51E002B02D1 /* history.c in Sources */,
A220EC5B118C8A060022B4BE /* tr-lds.c in Sources */,
A220EC5B118C8A060022B4BE /* tr-lpd.c in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};

View File

@ -85,8 +85,8 @@ static const struct tr_option options[] =
{ 800, "paused", "Pause all torrents on startup", NULL, 0, NULL },
{ 'o', "dht", "Enable distributed hash tables (DHT)", "o", 0, NULL },
{ 'O', "no-dht", "Disable distributed hash tables (DHT)", "O", 0, NULL },
{ 'z', "lds", "Enable local peer discovery (LDS)", "z", 0, NULL },
{ 'Z', "no-lds", "Disable local peer discovery (LDS)", "Z", 0, NULL },
{ 'z', "lds", "Enable local peer discovery (LPD)", "z", 0, NULL },
{ 'Z', "no-lds", "Disable local peer discovery (LPD)", "Z", 0, NULL },
{ 'P', "peerport", "Port for incoming peers (Default: " TR_DEFAULT_PEER_PORT_STR ")", "P", 1, "<port>" },
{ 'm', "portmap", "Enable portmapping via NAT-PMP or UPnP", "m", 0, NULL },
{ 'M', "no-portmap", "Disable portmapping", "M", 0, NULL },
@ -408,9 +408,9 @@ main( int argc, char ** argv )
case 954:
tr_bencDictAddBool( &settings, TR_PREFS_KEY_RATIO_ENABLED, FALSE );
break;
case 'z': tr_bencDictAddBool( &settings, TR_PREFS_KEY_LDS_ENABLED, TRUE );
case 'z': tr_bencDictAddBool( &settings, TR_PREFS_KEY_LPD_ENABLED, TRUE );
break;
case 'Z': tr_bencDictAddBool( &settings, TR_PREFS_KEY_LDS_ENABLED, FALSE );
case 'Z': tr_bencDictAddBool( &settings, TR_PREFS_KEY_LPD_ENABLED, FALSE );
break;
default: showUsage( );
break;

View File

@ -255,8 +255,8 @@ static tr_option opts[] =
{ 'w', "download-dir", "When adding a new torrent, set its download folder. Otherwise, set the default download folder", "w", 1, "<path>" },
{ 'x', "pex", "Enable peer exchange (PEX)", "x", 0, NULL },
{ 'X', "no-pex", "Disable peer exchange (PEX)", "X", 0, NULL },
{ 'z', "lds", "Enable local peer discovery (LDS)", "z", 0, NULL },
{ 'Z', "no-lds", "Disable local peer discovery (LDS)", "Z", 0, NULL },
{ 'z', "lds", "Enable local peer discovery (LPD)", "z", 0, NULL },
{ 'Z', "no-lds", "Disable local peer discovery (LPD)", "Z", 0, NULL },
{ 940, "peer-info", "List the current torrent(s)' peers", "pi", 0, NULL },
{ 0, NULL, NULL, NULL, 0, NULL }
};
@ -1343,7 +1343,7 @@ printSession( tr_benc * top )
printf( " Portforwarding enabled: %s\n", ( boolVal ? "Yes" : "No" ) );
if( tr_bencDictFindBool( args, TR_PREFS_KEY_DHT_ENABLED, &boolVal ) )
printf( " Distributed hash table enabled: %s\n", ( boolVal ? "Yes" : "No" ) );
if( tr_bencDictFindBool( args, TR_PREFS_KEY_LDS_ENABLED, &boolVal ) )
if( tr_bencDictFindBool( args, TR_PREFS_KEY_LPD_ENABLED, &boolVal ) )
printf( " Local peer discovery enabled: %s\n", ( boolVal ? "Yes" : "No" ) );
if( tr_bencDictFindBool( args, TR_PREFS_KEY_PEX_ENABLED, &boolVal ) )
printf( " Peer exchange allowed: %s\n", ( boolVal ? "Yes" : "No" ) );
@ -1823,9 +1823,9 @@ processArgs( const char * host, int port, int argc, const char ** argv )
break;
case 'X': tr_bencDictAddBool( args, TR_PREFS_KEY_PEX_ENABLED, FALSE );
break;
case 'z': tr_bencDictAddBool( args, TR_PREFS_KEY_LDS_ENABLED, TRUE );
case 'z': tr_bencDictAddBool( args, TR_PREFS_KEY_LPD_ENABLED, TRUE );
break;
case 'Z': tr_bencDictAddBool( args, TR_PREFS_KEY_LDS_ENABLED, FALSE );
case 'Z': tr_bencDictAddBool( args, TR_PREFS_KEY_LPD_ENABLED, FALSE );
break;
case 953: tr_bencDictAddReal( args, "seedRatioLimit", atof(optarg) );
tr_bencDictAddBool( args, "seedRatioLimited", TRUE );

View File

@ -248,9 +248,9 @@ Enable peer exchange (PEX).
.It Fl X Fl -no-pex
Disable peer exchange (PEX).
.It Fl z Fl -lds
Enable local peer discovery (LDS).
Enable local peer discovery (LPD).
.It Fl Z Fl -no-lds
Disable local peer discovery (LDS).
Disable local peer discovery (LPD).
.It Fl pi Fl -peer-info
List the current torrent's connected peers.
In the `status' section of the list, the following shorthand is used:

View File

@ -405,7 +405,7 @@
"encryption" | string "required", "preferred", "tolerated"
"incomplete-dir" | string path for incomplete torrents, when enabled
"incomplete-dir-enabled" | boolean true means keep torrents in incomplete-dir until done
"lds-enabled" | boolean true means allow lds in public torrents
"lpd-enabled" | boolean true means allow Local Peer Discovery in public torrents
"peer-limit-global" | number maximum global number of peers
"peer-limit-per-torrent" | number maximum global number of peers
"pex-enabled" | boolean true means allow pex in public torrents

View File

@ -1221,9 +1221,9 @@ prefschanged( TrCore * core UNUSED,
{
tr_sessionSetDHTEnabled( tr, pref_flag_get( key ) );
}
else if( !strcmp( key, TR_PREFS_KEY_LDS_ENABLED ) )
else if( !strcmp( key, TR_PREFS_KEY_LPD_ENABLED ) )
{
tr_sessionSetLDSEnabled( tr, pref_flag_get( key ) );
tr_sessionSetLPDEnabled( tr, pref_flag_get( key ) );
}
else if( !strcmp( key, TR_PREFS_KEY_RPC_PORT ) )
{

View File

@ -554,9 +554,9 @@ privacyPage( GObject * core )
gtr_widget_set_tooltip_text( w, s );
hig_workarea_add_wide_control( t, &row, w );
s = _( "Use LDS to find local peers" );
w = new_check_button( s, TR_PREFS_KEY_LDS_ENABLED, core );
s = _( "LDS is a tool for finding peers on your local network." );
s = _( "Use Local Peer Discovery to find more peers" );
w = new_check_button( s, TR_PREFS_KEY_LPD_ENABLED, core );
s = _( "LPD is a tool for finding peers on your local network." );
gtr_widget_set_tooltip_text( w, s );
hig_workarea_add_wide_control( t, &row, w );

View File

@ -55,7 +55,7 @@ libtransmission_a_SOURCES = \
torrent-ctor.c \
torrent-magnet.c \
tr-dht.c \
tr-lds.c \
tr-lpd.c \
tr-getopt.c \
trevent.c \
upnp.c \
@ -108,7 +108,7 @@ noinst_HEADERS = \
tr-getopt.h \
transmission.h \
tr-dht.h \
tr-lds.h \
tr-lpd.h \
trevent.h \
upnp.h \
utils.h \

View File

@ -24,7 +24,7 @@
#include "publish.h"
#include "session.h"
#include "tr-dht.h"
#include "tr-lds.h"
#include "tr-lpd.h"
#include "torrent.h"
#include "utils.h"
#include "web.h"
@ -69,7 +69,7 @@ enum
UPKEEP_INTERVAL_SECS = 1,
/* this is an upper limit for the frequency of LDS announces */
LDS_HOUSEKEEPING_INTERVAL_SECS = 30
LPD_HOUSEKEEPING_INTERVAL_SECS = 30
};
@ -206,7 +206,7 @@ typedef struct tr_announcer
tr_session * session;
struct event * upkeepTimer;
int slotsAvailable;
time_t ldsHouseKeepingAt;
time_t lpdHouseKeepingAt;
}
tr_announcer;
@ -254,7 +254,7 @@ tr_announcerInit( tr_session * session )
tr_announcer * a;
const time_t relaxUntil =
calcRescheduleWithJitter( LDS_HOUSEKEEPING_INTERVAL_SECS / 3 );
calcRescheduleWithJitter( LPD_HOUSEKEEPING_INTERVAL_SECS / 3 );
assert( tr_isSession( session ) );
@ -263,7 +263,7 @@ tr_announcerInit( tr_session * session )
a->stops = TR_PTR_ARRAY_INIT;
a->session = session;
a->slotsAvailable = MAX_CONCURRENT_TASKS;
a->ldsHouseKeepingAt = relaxUntil;
a->lpdHouseKeepingAt = relaxUntil;
a->upkeepTimer = tr_new0( struct event, 1 );
evtimer_set( a->upkeepTimer, onUpkeepTimer, a );
tr_timerAdd( a->upkeepTimer, UPKEEP_INTERVAL_SECS, 0 );
@ -1907,13 +1907,13 @@ fprintf( stderr, "[%s] announce.c has %d requests ready to send (announce: %d, s
}
/* Local Peer Discovery */
if( announcer->ldsHouseKeepingAt <= now )
if( announcer->lpdHouseKeepingAt <= now )
{
tr_ldsAnnounceMore( now, LDS_HOUSEKEEPING_INTERVAL_SECS );
tr_lpdAnnounceMore( now, LPD_HOUSEKEEPING_INTERVAL_SECS );
/* reschedule more LDS announces for ( the future + jitter ) */
announcer->ldsHouseKeepingAt =
calcRescheduleWithJitter( LDS_HOUSEKEEPING_INTERVAL_SECS );
announcer->lpdHouseKeepingAt =
calcRescheduleWithJitter( LPD_HOUSEKEEPING_INTERVAL_SECS );
}
}

View File

@ -1508,7 +1508,7 @@ getDefaultShelfLife( uint8_t from )
case TR_PEER_FROM_DHT : return 60 * 60 * 3;
case TR_PEER_FROM_PEX : return 60 * 60 * 2;
case TR_PEER_FROM_RESUME : return 60 * 60;
case TR_PEER_FROM_LDS : return 10 * 60;
case TR_PEER_FROM_LPD : return 10 * 60;
default : return 60 * 60;
}
}

View File

@ -1214,8 +1214,8 @@ sessionSet( tr_session * session,
tr_sessionSetPexEnabled( session, boolVal );
if( tr_bencDictFindBool( args_in, TR_PREFS_KEY_DHT_ENABLED, &boolVal ) )
tr_sessionSetDHTEnabled( session, boolVal );
if( tr_bencDictFindBool( args_in, TR_PREFS_KEY_LDS_ENABLED, &boolVal ) )
tr_sessionSetLDSEnabled( session, boolVal );
if( tr_bencDictFindBool( args_in, TR_PREFS_KEY_LPD_ENABLED, &boolVal ) )
tr_sessionSetLPDEnabled( session, boolVal );
if( tr_bencDictFindBool( args_in, TR_PREFS_KEY_PEER_PORT_RANDOM_ON_START, &boolVal ) )
tr_sessionSetPeerPortRandomOnStart( session, boolVal );
if( tr_bencDictFindInt( args_in, TR_PREFS_KEY_PEER_PORT, &i ) )
@ -1328,7 +1328,7 @@ sessionGet( tr_session * s,
tr_bencDictAddBool( d, TR_PREFS_KEY_INCOMPLETE_DIR_ENABLED, tr_sessionIsIncompleteDirEnabled( s ) );
tr_bencDictAddBool( d, TR_PREFS_KEY_PEX_ENABLED, tr_sessionIsPexEnabled( s ) );
tr_bencDictAddBool( d, TR_PREFS_KEY_DHT_ENABLED, tr_sessionIsDHTEnabled( s ) );
tr_bencDictAddBool( d, TR_PREFS_KEY_LDS_ENABLED, tr_sessionIsLDSEnabled( s ) );
tr_bencDictAddBool( d, TR_PREFS_KEY_LPD_ENABLED, tr_sessionIsLPDEnabled( s ) );
tr_bencDictAddInt ( d, TR_PREFS_KEY_PEER_PORT, tr_sessionGetPeerPort( s ) );
tr_bencDictAddInt ( d, TR_PREFS_KEY_PEER_PORT_RANDOM_ON_START, tr_sessionGetPeerPortRandomOnStart( s ) );
tr_bencDictAddBool( d, TR_PREFS_KEY_PORT_FORWARDING, tr_sessionIsPortForwardingEnabled( s ) );

View File

@ -42,7 +42,7 @@
#include "stats.h"
#include "torrent.h"
#include "tr-dht.h"
#include "tr-lds.h"
#include "tr-lpd.h"
#include "trevent.h"
#include "utils.h"
#include "verify.h"
@ -245,7 +245,7 @@ tr_sessionGetDefaultSettings( const char * configDir UNUSED, tr_benc * d )
tr_bencDictReserve( d, 35 );
tr_bencDictAddBool( d, TR_PREFS_KEY_BLOCKLIST_ENABLED, FALSE );
tr_bencDictAddBool( d, TR_PREFS_KEY_DHT_ENABLED, TRUE );
tr_bencDictAddBool( d, TR_PREFS_KEY_LDS_ENABLED, FALSE );
tr_bencDictAddBool( d, TR_PREFS_KEY_LPD_ENABLED, FALSE );
tr_bencDictAddStr ( d, TR_PREFS_KEY_DOWNLOAD_DIR, tr_getDefaultDownloadDir( ) );
tr_bencDictAddInt ( d, TR_PREFS_KEY_DSPEED, 100 );
tr_bencDictAddBool( d, TR_PREFS_KEY_DSPEED_ENABLED, FALSE );
@ -308,7 +308,7 @@ tr_sessionGetSettings( tr_session * s, struct tr_benc * d )
tr_bencDictReserve( d, 30 );
tr_bencDictAddBool( d, TR_PREFS_KEY_BLOCKLIST_ENABLED, tr_blocklistIsEnabled( s ) );
tr_bencDictAddBool( d, TR_PREFS_KEY_DHT_ENABLED, s->isDHTEnabled );
tr_bencDictAddBool( d, TR_PREFS_KEY_LDS_ENABLED, s->isLDSEnabled );
tr_bencDictAddBool( d, TR_PREFS_KEY_LPD_ENABLED, s->isLPDEnabled );
tr_bencDictAddStr ( d, TR_PREFS_KEY_DOWNLOAD_DIR, s->downloadDir );
tr_bencDictAddInt ( d, TR_PREFS_KEY_DSPEED, tr_sessionGetSpeedLimit( s, TR_DOWN ) );
tr_bencDictAddBool( d, TR_PREFS_KEY_DSPEED_ENABLED, tr_sessionIsSpeedLimited( s, TR_DOWN ) );
@ -628,13 +628,10 @@ tr_sessionInitImpl( void * vdata )
tr_dhtInit( session, &session->public_ipv4->addr );
}
if( session->isLDSEnabled )
{
if( tr_ldsInit( session, &session->public_ipv4->addr ) )
tr_ninf( "LDS", "Local Peer Discovery active" );
}
else
tr_ndbg( "LDS", "Local Peer Discovery disabled" );
if( !session->isLPDEnabled )
tr_ndbg( "LPD", _( "Local Peer Discovery disabled" ) );
else if( tr_lpdInit( session, &session->public_ipv4->addr ) )
tr_ninf( "LPD", _( "Local Peer Discovery active" ) );
/* cleanup */
tr_bencFree( &settings );
@ -678,8 +675,8 @@ sessionSetImpl( void * vdata )
tr_sessionSetPexEnabled( session, boolVal );
if( tr_bencDictFindBool( settings, TR_PREFS_KEY_DHT_ENABLED, &boolVal ) )
tr_sessionSetDHTEnabled( session, boolVal );
if( tr_bencDictFindBool( settings, TR_PREFS_KEY_LDS_ENABLED, &boolVal ) )
tr_sessionSetLDSEnabled( session, boolVal );
if( tr_bencDictFindBool( settings, TR_PREFS_KEY_LPD_ENABLED, &boolVal ) )
tr_sessionSetLPDEnabled( session, boolVal );
if( tr_bencDictFindInt( settings, TR_PREFS_KEY_ENCRYPTION, &i ) )
tr_sessionSetEncryption( session, i );
if( tr_bencDictFindInt( settings, TR_PREFS_KEY_PEER_SOCKET_TOS, &i ) )
@ -1564,8 +1561,8 @@ sessionCloseImpl( void * vsession )
free_incoming_peer_port( session );
if( session->isLDSEnabled )
tr_ldsUninit( session );
if( session->isLPDEnabled )
tr_lpdUninit( session );
if( session->isDHTEnabled )
tr_dhtUninit( session );
@ -1802,26 +1799,26 @@ tr_sessionSetDHTEnabled( tr_session * session, tr_bool enabled )
}
void
tr_sessionSetLDSEnabled( tr_session * session,
tr_sessionSetLPDEnabled( tr_session * session,
tr_bool enabled )
{
assert( tr_isSession( session ) );
session->isLDSEnabled = ( enabled != 0 );
session->isLPDEnabled = ( enabled != 0 );
}
tr_bool
tr_sessionIsLDSEnabled( const tr_session * session )
tr_sessionIsLPDEnabled( const tr_session * session )
{
assert( tr_isSession( session ) );
return session->isLDSEnabled;
return session->isLPDEnabled;
}
tr_bool
tr_sessionAllowsLDS( const tr_session * session )
tr_sessionAllowsLPD( const tr_session * session )
{
return tr_sessionIsLDSEnabled( session );
return tr_sessionIsLPDEnabled( session );
}
/***

View File

@ -84,7 +84,7 @@ struct tr_session
tr_bool isPortRandom;
tr_bool isPexEnabled;
tr_bool isDHTEnabled;
tr_bool isLDSEnabled;
tr_bool isLPDEnabled;
tr_bool isBlocklistEnabled;
tr_bool isProxyEnabled;
tr_bool isProxyAuthEnabled;
@ -180,7 +180,7 @@ struct tr_session
tr_bool tr_sessionAllowsDHT( const tr_session * session );
tr_bool tr_sessionAllowsLDS( const tr_session * session );
tr_bool tr_sessionAllowsLPD( const tr_session * session );
const char * tr_sessionFindTorrentFile( const tr_session * session,
const char * hashString );

View File

@ -1400,7 +1400,7 @@ checkAndStartImpl( void * vtor )
tr_announcerTorrentStarted( tor );
tor->dhtAnnounceAt = now + tr_cryptoWeakRandInt( 20 );
tor->dhtAnnounce6At = now + tr_cryptoWeakRandInt( 20 );
tor->ldsAnnounceAt = now;
tor->lpdAnnounceAt = now;
tr_peerMgrStartTorrent( tor );
}

View File

@ -200,7 +200,7 @@ struct tr_torrent
tr_bool dhtAnnounceInProgress;
tr_bool dhtAnnounce6InProgress;
time_t ldsAnnounceAt;
time_t lpdAnnounceAt;
uint64_t downloadedCur;
uint64_t downloadedPrev;
@ -334,10 +334,10 @@ static inline tr_bool tr_torrentAllowsDHT( const tr_torrent * tor )
&& ( !tr_torrentIsPrivate( tor ) );
}
static inline tr_bool tr_torrentAllowsLDS( const tr_torrent * tor )
static inline tr_bool tr_torrentAllowsLPD( const tr_torrent * tor )
{
return ( tor != NULL )
&& ( tr_sessionAllowsLDS( tor->session ) )
&& ( tr_sessionAllowsLPD( tor->session ) )
&& ( !tr_torrentIsPrivate( tor ) );
}

View File

@ -44,53 +44,53 @@ THE SOFTWARE.
#include "peer-mgr.h" /* tr_peerMgrAddPex() */
#include "session.h"
#include "torrent.h" /* tr_torrentFindFromHash() */
#include "tr-lds.h"
#include "tr-lpd.h"
#include "utils.h"
#include "version.h"
/**
* @brief Local Peer Discovery
* @file tr-lds.c
* @file tr-lpd.c
*
* This module implements the Local Peer Discovery (LDS) protocol as supported by the
* uTorrent client application. A typical LDS datagram is 119 bytes long.
* This module implements the Local Peer Discovery (LPD) protocol as supported by the
* uTorrent client application. A typical LPD datagram is 119 bytes long.
*
* $Id$
*/
static void event_callback( int, short, void* );
static int lds_socket; /**<separate multicast receive socket */
static int lds_socket2; /**<and multicast send socket */
static struct event lds_event;
static tr_port lds_port;
static int lpd_socket; /**<separate multicast receive socket */
static int lpd_socket2; /**<and multicast send socket */
static struct event lpd_event;
static tr_port lpd_port;
static tr_torrent* lds_torStaticType UNUSED; /* just a helper for static type analysis */
static tr_torrent* lpd_torStaticType UNUSED; /* just a helper for static type analysis */
static tr_session* session;
enum { lds_maxDatagramLength = 200 }; /**<the size an LDS datagram must not exceed */
const char lds_mcastGroup[] = "239.192.152.143"; /**<LDS multicast group */
const int lds_mcastPort = 6771; /**<LDS source and destination UPD port */
static struct sockaddr_in lds_mcastAddr; /**<initialized from the above constants in tr_ldsInit */
enum { lpd_maxDatagramLength = 200 }; /**<the size an LPD datagram must not exceed */
const char lpd_mcastGroup[] = "239.192.152.143"; /**<LPD multicast group */
const int lpd_mcastPort = 6771; /**<LPD source and destination UPD port */
static struct sockaddr_in lpd_mcastAddr; /**<initialized from the above constants in tr_lpdInit */
/**
* @brief Protocol-related information carried by a Local Peer Discovery packet */
struct lds_protocolVersion
struct lpd_protocolVersion
{
int major, minor;
};
enum lds_enumTimeToLive {
lds_ttlSameSubnet = 1,
lds_ttlSameSite = 32,
lds_ttlSameRegion = 64,
lds_ttlSameContinent = 128,
lds_ttlUnrestricted = 255
enum lpd_enumTimeToLive {
lpd_ttlSameSubnet = 1,
lpd_ttlSameSite = 32,
lpd_ttlSameRegion = 64,
lpd_ttlSameContinent = 128,
lpd_ttlUnrestricted = 255
};
enum {
lds_announceInterval = 4 * 60, /**<4 min announce interval per torrent */
lds_announceScope = lds_ttlSameSubnet /**<the maximum scope for LDS datagrams */
lpd_announceInterval = 4 * 60, /**<4 min announce interval per torrent */
lpd_announceScope = lpd_ttlSameSubnet /**<the maximum scope for LPD datagrams */
};
@ -112,17 +112,17 @@ enum {
* @ingroup DoS
* @brief allow at most ten messages per second (interval average)
* @note this constraint is only enforced once per housekeeping interval */
enum { lds_announceCapFactor = 10 };
enum { lpd_announceCapFactor = 10 };
/**
* @ingroup DoS
* @brief number of unsolicited messages during the last HK interval
* @remark counts downwards */
static int lds_unsolicitedMsgCounter;
static int lpd_unsolicitedMsgCounter;
/**
* @def CRLF
* @brief a line-feed, as understood by the LDS protocol */
* @brief a line-feed, as understood by the LPD protocol */
#define CRLF "\r\n"
@ -144,9 +144,9 @@ static int lds_unsolicitedMsgCounter;
* If so, the return value points to the beginning of the parameter section (note:
* in this case the function returns a character sequence beginning with CRLF).
* If parameter is not NULL, the declared protocol version is returned as part of
* the lds_protocolVersion structure.
* the lpd_protocolVersion structure.
*/
static const char* lds_extractHeader( const char* s, struct lds_protocolVersion* const ver )
static const char* lpd_extractHeader( const char* s, struct lpd_protocolVersion* const ver )
{
int major = -1, minor = -1;
size_t len;
@ -155,7 +155,7 @@ static const char* lds_extractHeader( const char* s, struct lds_protocolVersion*
len = strlen( s );
/* something might be rotten with this chunk of data */
if( len == 0 || len > lds_maxDatagramLength )
if( len == 0 || len > lpd_maxDatagramLength )
return NULL;
/* now we can attempt to look up the BT-SEARCH header */
@ -198,7 +198,7 @@ static const char* lds_extractHeader( const char* s, struct lds_protocolVersion*
* - assemble search string "\r\nName: " and locate position
* - copy back value from end to next "\r\n"
*/
static int lds_extractParam( const char* const str, const char* const name, int n, char* const val )
static int lpd_extractParam( const char* const str, const char* const name, int n, char* const val )
{
/* configure maximum length of search string here */
enum { maxLength = 30 };
@ -244,7 +244,7 @@ static int lds_extractParam( const char* const str, const char* const name, int
/**
* @brief Configures additional capabilities for a socket */
static inline int lds_configureSocket( int sock, int add )
static inline int lpd_configureSocket( int sock, int add )
{
/* read-modify-write socket flags */
int flags = fcntl( sock, F_GETFL );
@ -264,10 +264,10 @@ static inline int lds_configureSocket( int sock, int add )
* For the most part, this means setting up an appropriately configured multicast socket
* and event-based message handling.
*
* @remark Since the LDS service does not use another protocol family yet, this code is
* @remark Since the LPD service does not use another protocol family yet, this code is
* IPv4 only for the time being.
*/
int tr_ldsInit( tr_session* ss, tr_address* tr_addr UNUSED )
int tr_lpdInit( tr_session* ss, tr_address* tr_addr UNUSED )
{
struct ip_mreq mcastReq;
const int opt_on = 1, opt_off = 0;
@ -275,95 +275,95 @@ int tr_ldsInit( tr_session* ss, tr_address* tr_addr UNUSED )
if( session ) /* already initialized */
return -1;
assert( lds_announceInterval > 0 );
assert( lds_announceScope > 0 );
assert( lpd_announceInterval > 0 );
assert( lpd_announceScope > 0 );
lds_port = tr_sessionGetPeerPort( ss );
if( lds_port <= 0 )
lpd_port = tr_sessionGetPeerPort( ss );
if( lpd_port <= 0 )
return -1;
tr_ndbg( "LDS", "Initialising Local Peer Discovery" );
tr_ndbg( "LPD", "Initialising Local Peer Discovery" );
/* setup datagram socket (receive) */
{
lds_socket = socket( PF_INET, SOCK_DGRAM, 0 );
if( lds_socket < 0 )
lpd_socket = socket( PF_INET, SOCK_DGRAM, 0 );
if( lpd_socket < 0 )
goto fail;
/* enable non-blocking operation */
if( lds_configureSocket( lds_socket, O_NONBLOCK ) < 0 )
if( lpd_configureSocket( lpd_socket, O_NONBLOCK ) < 0 )
goto fail;
if( setsockopt( lds_socket, SOL_SOCKET, SO_REUSEADDR,
if( setsockopt( lpd_socket, SOL_SOCKET, SO_REUSEADDR,
&opt_on, sizeof opt_on ) < 0 )
goto fail;
memset( &lds_mcastAddr, 0, sizeof lds_mcastAddr );
lds_mcastAddr.sin_family = AF_INET;
lds_mcastAddr.sin_port = htons( lds_mcastPort );
if( inet_pton( lds_mcastAddr.sin_family, lds_mcastGroup,
&lds_mcastAddr.sin_addr ) < 0 )
memset( &lpd_mcastAddr, 0, sizeof lpd_mcastAddr );
lpd_mcastAddr.sin_family = AF_INET;
lpd_mcastAddr.sin_port = htons( lpd_mcastPort );
if( inet_pton( lpd_mcastAddr.sin_family, lpd_mcastGroup,
&lpd_mcastAddr.sin_addr ) < 0 )
goto fail;
if( bind( lds_socket, (struct sockaddr*) &lds_mcastAddr,
sizeof lds_mcastAddr ) < 0 )
if( bind( lpd_socket, (struct sockaddr*) &lpd_mcastAddr,
sizeof lpd_mcastAddr ) < 0 )
goto fail;
/* we want to join that LDS multicast group */
/* we want to join that LPD multicast group */
memset( &mcastReq, 0, sizeof mcastReq );
mcastReq.imr_multiaddr = lds_mcastAddr.sin_addr;
mcastReq.imr_multiaddr = lpd_mcastAddr.sin_addr;
mcastReq.imr_interface.s_addr = htonl( INADDR_ANY );
if( setsockopt( lds_socket, IPPROTO_IP, IP_ADD_MEMBERSHIP,
if( setsockopt( lpd_socket, IPPROTO_IP, IP_ADD_MEMBERSHIP,
&mcastReq, sizeof mcastReq ) < 0 )
goto fail;
if( setsockopt( lds_socket, IPPROTO_IP, IP_MULTICAST_LOOP,
if( setsockopt( lpd_socket, IPPROTO_IP, IP_MULTICAST_LOOP,
&opt_off, sizeof opt_off ) < 0 )
goto fail;
}
/* setup datagram socket (send) */
{
const unsigned char scope = lds_announceScope;
const unsigned char scope = lpd_announceScope;
lds_socket2 = socket( PF_INET, SOCK_DGRAM, 0 );
if( lds_socket2 < 0 )
lpd_socket2 = socket( PF_INET, SOCK_DGRAM, 0 );
if( lpd_socket2 < 0 )
goto fail;
/* enable non-blocking operation */
if( lds_configureSocket( lds_socket2, O_NONBLOCK ) < 0 )
if( lpd_configureSocket( lpd_socket2, O_NONBLOCK ) < 0 )
goto fail;
/* configure outbound multicast TTL */
if( setsockopt( lds_socket2, IPPROTO_IP, IP_MULTICAST_TTL,
if( setsockopt( lpd_socket2, IPPROTO_IP, IP_MULTICAST_TTL,
&scope, sizeof scope ) < 0 )
goto fail;
if( setsockopt( lds_socket2, IPPROTO_IP, IP_MULTICAST_LOOP,
if( setsockopt( lpd_socket2, IPPROTO_IP, IP_MULTICAST_LOOP,
&opt_off, sizeof opt_off ) < 0 )
goto fail;
}
session = ss;
/* Note: lds_unsolicitedMsgCounter remains 0 until the first timeout event, thus
/* Note: lpd_unsolicitedMsgCounter remains 0 until the first timeout event, thus
* any announcement received during the initial interval will be discarded. */
event_set( &lds_event, lds_socket, EV_READ | EV_PERSIST, event_callback, NULL );
event_add( &lds_event, NULL );
event_set( &lpd_event, lpd_socket, EV_READ | EV_PERSIST, event_callback, NULL );
event_add( &lpd_event, NULL );
tr_ndbg( "LDS", "Local Peer Discovery initialised" );
tr_ndbg( "LPD", "Local Peer Discovery initialised" );
return 1;
fail:
{
const int save = errno;
close( lds_socket );
close( lds_socket2 );
lds_socket = lds_socket2 = -1;
close( lpd_socket );
close( lpd_socket2 );
lpd_socket = lpd_socket2 = -1;
session = NULL;
tr_ndbg( "LDS", "LDS initialisation failed (errno = %d)", save );
tr_ndbg( "LPD", "LPD initialisation failed (errno = %d)", save );
errno = save;
}
@ -371,24 +371,24 @@ int tr_ldsInit( tr_session* ss, tr_address* tr_addr UNUSED )
return -1;
}
void tr_ldsUninit( tr_session* ss )
void tr_lpdUninit( tr_session* ss )
{
if( session != ss )
return;
tr_ndbg( "LDS", "Uninitialising Local Peer Discovery" );
tr_ndbg( "LPD", "Uninitialising Local Peer Discovery" );
event_del( &lds_event );
event_del( &lpd_event );
/* just shut down, we won't remember any former nodes */
EVUTIL_CLOSESOCKET( lds_socket );
EVUTIL_CLOSESOCKET( lds_socket2 );
tr_ndbg( "LDS", "Done uninitialising Local Peer Discovery" );
EVUTIL_CLOSESOCKET( lpd_socket );
EVUTIL_CLOSESOCKET( lpd_socket2 );
tr_ndbg( "LPD", "Done uninitialising Local Peer Discovery" );
session = NULL;
}
tr_bool tr_ldsEnabled( const tr_session* ss )
tr_bool tr_lpdEnabled( const tr_session* ss )
{
return ss && ( ss == session );
}
@ -398,22 +398,22 @@ tr_bool tr_ldsEnabled( const tr_session* ss )
* @cond
* @brief Performs some (internal) software consistency checks at compile time.
* @remark Declared inline for the compiler not to allege us of feeding unused
* functions. In any other respect, lds_consistencyCheck is an orphaned function.
* functions. In any other respect, lpd_consistencyCheck is an orphaned function.
*/
static inline void lds_consistencyCheck( void )
static inline void lpd_consistencyCheck( void )
{
/* if the following check fails, the definition of a hash string has changed
* without our knowledge; revise string handling in functions tr_ldsSendAnnounce
* and tr_ldsConsiderAnnounce. However, the code is designed to function as long
* without our knowledge; revise string handling in functions tr_lpdSendAnnounce
* and tr_lpdConsiderAnnounce. However, the code is designed to function as long
* as interfaces to the rest of the lib remain compatible with char* strings. */
STATIC_ASSERT( sizeof(lds_torStaticType->info.hashString[0]) == sizeof(char) );
STATIC_ASSERT( sizeof(lpd_torStaticType->info.hashString[0]) == sizeof(char) );
}
/**
* @endcond */
/**
* @defgroup LdsProto LDS announcement processing
* @defgroup LdsProto LPD announcement processing
* @{
*/
@ -423,11 +423,11 @@ static inline void lds_consistencyCheck( void )
* @param[in] t Torrent to announce
* @return Returns TRUE on success
*
* Send a query for torrent t out to the LDS multicast group (or the LAN, for that
* Send a query for torrent t out to the LPD multicast group (or the LAN, for that
* matter). A listening client on the same network might react by adding us to his
* peer pool for torrent t.
*/
tr_bool tr_ldsSendAnnounce( const tr_torrent* t )
tr_bool tr_lpdSendAnnounce( const tr_torrent* t )
{
const char fmt[] =
"BT-SEARCH * HTTP/%u.%u" CRLF
@ -438,7 +438,7 @@ tr_bool tr_ldsSendAnnounce( const tr_torrent* t )
CRLF;
char hashString[lengthof( t->info.hashString )];
char query[lds_maxDatagramLength + 1] = { };
char query[lpd_maxDatagramLength + 1] = { };
if( t == NULL )
return FALSE;
@ -448,23 +448,23 @@ tr_bool tr_ldsSendAnnounce( const tr_torrent* t )
hashString[i] = toupper( t->info.hashString[i] );
/* prepare a zero-terminated announce message */
snprintf( query, lds_maxDatagramLength + 1, fmt, 1, 1,
lds_mcastGroup, lds_mcastPort, lds_port, hashString );
snprintf( query, lpd_maxDatagramLength + 1, fmt, 1, 1,
lpd_mcastGroup, lpd_mcastPort, lpd_port, hashString );
/* actually send the query out using [lds_socket2] */
/* actually send the query out using [lpd_socket2] */
{
const int len = strlen( query );
/* destination address info has already been set up in tr_ldsInit(),
/* destination address info has already been set up in tr_lpdInit(),
* so we refrain from preparing another sockaddr_in here */
int res = sendto( lds_socket2, query, len, 0,
(const struct sockaddr*) &lds_mcastAddr, sizeof lds_mcastAddr );
int res = sendto( lpd_socket2, query, len, 0,
(const struct sockaddr*) &lpd_mcastAddr, sizeof lpd_mcastAddr );
if( res != len )
return FALSE;
}
tr_tordbg( t, "LDS announce message away" );
tr_tordbg( t, "LPD announce message away" );
return TRUE;
}
@ -479,19 +479,19 @@ tr_bool tr_ldsSendAnnounce( const tr_torrent* t )
* was successfully added, -1 if not; a non-null return value indicates a side-effect to
* the peer in/out parameter.
*
* @note The port information gets added to the peer structure if tr_ldsConsiderAnnounce
* @note The port information gets added to the peer structure if tr_lpdConsiderAnnounce
* is able to extract the necessary information from the announce message. That is, if
* return != 0, the caller may retrieve the value from the passed structure.
*/
static int tr_ldsConsiderAnnounce( tr_pex* peer, const char* const msg )
static int tr_lpdConsiderAnnounce( tr_pex* peer, const char* const msg )
{
enum
{
maxValueLen = 25,
maxHashLen = lengthof(lds_torStaticType->info.hashString)
maxHashLen = lengthof(lpd_torStaticType->info.hashString)
};
struct lds_protocolVersion ver = { -1, -1 };
struct lpd_protocolVersion ver = { -1, -1 };
char value[maxValueLen] = { };
char hashString[maxHashLen] = { };
int res = 0, peerPort = 0;
@ -500,13 +500,13 @@ static int tr_ldsConsiderAnnounce( tr_pex* peer, const char* const msg )
{
tr_torrent* tor = NULL;
const char* params = lds_extractHeader( msg, &ver );
const char* params = lpd_extractHeader( msg, &ver );
if( params == NULL || ver.major != 1 ) /* allow messages of protocol v1 */
return 0;
/* save the effort to check Host, which seems to be optional anyway */
if( lds_extractParam( params, "Port", maxValueLen, value ) == 0 )
if( lpd_extractParam( params, "Port", maxValueLen, value ) == 0 )
return 0;
/* determine announced peer port, refuse if value too large */
@ -516,16 +516,16 @@ static int tr_ldsConsiderAnnounce( tr_pex* peer, const char* const msg )
peer->port = htons( peerPort );
res = -1; /* signal caller side-effect to peer->port via return != 0 */
if( lds_extractParam( params, "Infohash", maxHashLen, hashString ) == 0 )
if( lpd_extractParam( params, "Infohash", maxHashLen, hashString ) == 0 )
return res;
tor = tr_torrentFindFromHashString( session, hashString );
if( tr_isTorrent( tor ) && tr_torrentAllowsLDS( tor ) )
if( tr_isTorrent( tor ) && tr_torrentAllowsLPD( tor ) )
{
/* we found a suitable peer, add it to the torrent */
tr_peerMgrAddPex( tor, TR_PEER_FROM_LDS, peer, -1 );
tr_tordbg( tor, "Learned %d local peer from LDS (%s:%u)",
tr_peerMgrAddPex( tor, TR_PEER_FROM_LPD, peer, -1 );
tr_tordbg( tor, "Learned %d local peer from LPD (%s:%u)",
1, inet_ntoa( peer->addr.addr.addr4 ), peerPort );
/* periodic reconnectPulse() deals with the rest... */
@ -533,7 +533,7 @@ static int tr_ldsConsiderAnnounce( tr_pex* peer, const char* const msg )
return 1;
}
else
tr_ndbg( "LDS", "Cannot serve torrent #%s", hashString );
tr_ndbg( "LPD", "Cannot serve torrent #%s", hashString );
}
return res;
@ -543,12 +543,12 @@ static int tr_ldsConsiderAnnounce( tr_pex* peer, const char* const msg )
* @} */
/**
* @note Since it possible for tr_ldsAnnounceMore to get called from outside the LDS module,
* @note Since it possible for tr_lpdAnnounceMore to get called from outside the LPD module,
* the function needs to be informed of the externally employed housekeeping interval.
* Further, by setting interval to zero (or negative) the caller may actually disable LDS
* Further, by setting interval to zero (or negative) the caller may actually disable LPD
* announces on a per-interval basis.
*/
int tr_ldsAnnounceMore( const time_t now, const int interval )
int tr_lpdAnnounceMore( const time_t now, const int interval )
{
tr_torrent* tor = NULL;
int announcesSent = 0;
@ -557,21 +557,21 @@ int tr_ldsAnnounceMore( const time_t now, const int interval )
return -1;
while(( tor = tr_torrentNext( session, tor ) )
&& tr_sessionAllowsLDS( session ) )
&& tr_sessionAllowsLPD( session ) )
{
if( tr_isTorrent( tor ) )
{
if( !tr_torrentAllowsLDS( tor ) || (
if( !tr_torrentAllowsLPD( tor ) || (
( tr_torrentGetActivity( tor ) != TR_STATUS_DOWNLOAD ) &&
( tr_torrentGetActivity( tor ) != TR_STATUS_SEED ) ) )
continue;
if( tor->ldsAnnounceAt <= now )
if( tor->lpdAnnounceAt <= now )
{
if( tr_ldsSendAnnounce( tor ) )
if( tr_lpdSendAnnounce( tor ) )
announcesSent++;
tor->ldsAnnounceAt = now + lds_announceInterval;
tor->lpdAnnounceAt = now + lpd_announceInterval;
break; /* that's enough; for this interval */
}
}
@ -579,13 +579,13 @@ int tr_ldsAnnounceMore( const time_t now, const int interval )
/* perform housekeeping for the flood protection mechanism */
{
const int maxAnnounceCap = interval * lds_announceCapFactor;
const int maxAnnounceCap = interval * lpd_announceCapFactor;
if( lds_unsolicitedMsgCounter < 0 )
tr_ninf( "LDS", "Dropped %d announces in the last interval (max. %d "
"allowed)", -lds_unsolicitedMsgCounter, maxAnnounceCap );
if( lpd_unsolicitedMsgCounter < 0 )
tr_ninf( "LPD", "Dropped %d announces in the last interval (max. %d "
"allowed)", -lpd_unsolicitedMsgCounter, maxAnnounceCap );
lds_unsolicitedMsgCounter = maxAnnounceCap;
lpd_unsolicitedMsgCounter = maxAnnounceCap;
}
return announcesSent;
@ -593,14 +593,14 @@ int tr_ldsAnnounceMore( const time_t now, const int interval )
/**
* @brief Processing of timeout notifications and incoming data on the socket
* @note maximum rate of read events is limited according to @a lds_maxAnnounceCap
* @note maximum rate of read events is limited according to @a lpd_maxAnnounceCap
* @see DoS */
static void event_callback( int s UNUSED, short type, void* ignore UNUSED )
{
assert( tr_isSession( session ) );
/* do not allow announces to be processed if LDS is disabled */
if( !tr_sessionAllowsLDS( session ) )
/* do not allow announces to be processed if LPD is disabled */
if( !tr_sessionAllowsLPD( session ) )
return;
if( ( type & EV_READ ) != 0 )
@ -609,17 +609,17 @@ static void event_callback( int s UNUSED, short type, void* ignore UNUSED )
int addrLen = sizeof foreignAddr;
/* be paranoid enough about zero terminating the foreign string */
char foreignMsg[lds_maxDatagramLength + 1] = { };
char foreignMsg[lpd_maxDatagramLength + 1] = { };
/* process local announcement from foreign peer */
int res = recvfrom( lds_socket, foreignMsg, lds_maxDatagramLength,
int res = recvfrom( lpd_socket, foreignMsg, lpd_maxDatagramLength,
0, (struct sockaddr*) &foreignAddr, (socklen_t*) &addrLen );
/* besides, do we get flooded? then bail out! */
if( --lds_unsolicitedMsgCounter < 0 )
if( --lpd_unsolicitedMsgCounter < 0 )
return;
if( res > 0 && res <= lds_maxDatagramLength )
if( res > 0 && res <= lpd_maxDatagramLength )
{
struct tr_pex foreignPeer =
{
@ -628,11 +628,11 @@ static void event_callback( int s UNUSED, short type, void* ignore UNUSED )
};
foreignPeer.addr.addr.addr4 = foreignAddr.sin_addr;
if( tr_ldsConsiderAnnounce( &foreignPeer, foreignMsg ) != 0 )
if( tr_lpdConsiderAnnounce( &foreignPeer, foreignMsg ) != 0 )
return; /* OK so far, no log message */
}
tr_ndbg( "LDS", "Discarded invalid multicast message" );
tr_ndbg( "LPD", "Discarded invalid multicast message" );
}
}

View File

@ -20,19 +20,19 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#ifndef _TR_LDS_H
#define _TR_LDS_H
#ifndef _TR_LPD_H
#define _TR_LPD_H
/* $Id$ */
int tr_ldsInit( tr_session*, tr_address* );
void tr_ldsUninit( tr_session* );
int tr_lpdInit( tr_session*, tr_address* );
void tr_lpdUninit( tr_session* );
tr_bool tr_ldsEnabled( const tr_session* );
tr_bool tr_lpdEnabled( const tr_session* );
tr_bool tr_ldsSendAnnounce( const tr_torrent* );
tr_bool tr_lpdSendAnnounce( const tr_torrent* );
int tr_ldsAnnounceMore( const time_t, const int );
int tr_lpdAnnounceMore( const time_t, const int );
/**
* @defgroup Preproc Helper macros
@ -53,5 +53,5 @@ int tr_ldsAnnounceMore( const time_t, const int );
/**
* @} */
#endif /* _TR_LDS_H */
#endif /* _TR_LPD_H */

View File

@ -164,7 +164,7 @@ const char* tr_getDefaultDownloadDir( void );
#define TR_PREFS_KEY_BIND_ADDRESS_IPV6 "bind-address-ipv6"
#define TR_PREFS_KEY_BLOCKLIST_ENABLED "blocklist-enabled"
#define TR_PREFS_KEY_DHT_ENABLED "dht-enabled"
#define TR_PREFS_KEY_LDS_ENABLED "lds-enabled"
#define TR_PREFS_KEY_LPD_ENABLED "lpd-enabled"
#define TR_PREFS_KEY_DOWNLOAD_DIR "download-dir"
#define TR_PREFS_KEY_ENCRYPTION "encryption"
#define TR_PREFS_KEY_INCOMPLETE_DIR "incomplete-dir"
@ -592,9 +592,9 @@ tr_bool tr_sessionIsDHTEnabled( const tr_session * session );
void tr_sessionSetDHTEnabled( tr_session * session, tr_bool );
tr_bool tr_sessionIsLDSEnabled( const tr_session * session );
tr_bool tr_sessionIsLPDEnabled( const tr_session * session );
void tr_sessionSetLDSEnabled( tr_session * session, tr_bool enabled );
void tr_sessionSetLPDEnabled( tr_session * session, tr_bool enabled );
void tr_sessionSetLazyBitfieldEnabled( tr_session * session,
tr_bool enabled );
@ -1653,7 +1653,7 @@ tr_torrent_activity;
enum
{
TR_PEER_FROM_INCOMING = 0, /* connections made to the listening port */
TR_PEER_FROM_LDS, /* peers discovered by local announcements */
TR_PEER_FROM_LPD, /* peers discovered by local announcements */
TR_PEER_FROM_TRACKER, /* peers received from a tracker */
TR_PEER_FROM_DHT, /* peers learnt from the DHT */
TR_PEER_FROM_RESUME, /* peers read from the .resume file */

View File

@ -477,8 +477,8 @@ PrefsDialog :: createPrivacyTab( )
w->setToolTip( tr( "PEX is a tool for exchanging peer lists with the peers you're connected to." ) );
hig->addWideControl( w = checkBoxNew( tr( "Use &DHT to find more peers" ), Prefs::DHT_ENABLED ) );
w->setToolTip( tr( "DHT is a tool for finding peers without a tracker." ) );
hig->addWideControl( w = checkBoxNew( tr( "Use &LDS to find local peers" ), Prefs::LDS_ENABLED ) );
w->setToolTip( tr( "LDS is a tool for finding peers on your local network." ) );
hig->addWideControl( w = checkBoxNew( tr( "Use &Local Peer Discovery to find more peers" ), Prefs::LPD_ENABLED ) );
w->setToolTip( tr( "LPD is a tool for finding peers on your local network." ) );
hig->finish( );
updateBlocklistCheckBox( );

View File

@ -93,7 +93,7 @@ Prefs::PrefItem Prefs::myItems[] =
{ TRASH_ORIGINAL, TR_PREFS_KEY_TRASH_ORIGINAL, QVariant::Bool },
{ PEX_ENABLED, TR_PREFS_KEY_PEX_ENABLED, QVariant::Bool },
{ DHT_ENABLED, TR_PREFS_KEY_DHT_ENABLED, QVariant::Bool },
{ LDS_ENABLED, TR_PREFS_KEY_LDS_ENABLED, QVariant::Bool },
{ LPD_ENABLED, TR_PREFS_KEY_LPD_ENABLED, QVariant::Bool },
{ PORT_FORWARDING, TR_PREFS_KEY_PORT_FORWARDING, QVariant::Bool },
{ PROXY_AUTH_ENABLED, TR_PREFS_KEY_PROXY_AUTH_ENABLED, QVariant::Bool },
{ PREALLOCATION, TR_PREFS_KEY_PREALLOCATION, QVariant::Int },

View File

@ -97,7 +97,7 @@ class Prefs: public QObject
TRASH_ORIGINAL,
PEX_ENABLED,
DHT_ENABLED,
LDS_ENABLED,
LPD_ENABLED,
PORT_FORWARDING,
PROXY_AUTH_ENABLED,
PREALLOCATION,

View File

@ -141,7 +141,7 @@ Session :: updatePref( int key )
case Prefs :: DOWNLOAD_DIR:
case Prefs :: INCOMPLETE_DIR:
case Prefs :: INCOMPLETE_DIR_ENABLED:
case Prefs :: LDS_ENABLED:
case Prefs :: LPD_ENABLED:
case Prefs :: PEER_LIMIT_GLOBAL:
case Prefs :: PEER_LIMIT_TORRENT:
case Prefs :: USPEED_ENABLED: