From 694a98034833ec07cbba8e2110a77c95e861b278 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Tue, 30 Dec 2008 18:18:34 +0000 Subject: [PATCH] (trunk daemon) #1618: patch from er13 to make transmission-daemon's encryption, port, and peer limit command-line arguments similar to transmission-remote's --- daemon/daemon.c | 24 ++++++++++++++++++++++++ daemon/transmission-daemon.1 | 25 +++++++++++++++++++++++++ libtransmission/session.c | 4 ++-- libtransmission/transmission.h | 2 ++ 4 files changed, 53 insertions(+), 2 deletions(-) diff --git a/daemon/daemon.c b/daemon/daemon.c index b2cfec391..9c446a7aa 100644 --- a/daemon/daemon.c +++ b/daemon/daemon.c @@ -65,6 +65,14 @@ static const struct tr_option options[] = { 'u', "username", "Set username for authentication", "u", 1, "" }, { 'v', "password", "Set password for authentication", "v", 1, "" }, { 'w', "download-dir", "Where to save downloaded data", "w", 1, "" }, + { 'P', "peerport", "Port for incoming peers (Default: " TR_DEFAULT_PEER_PORT_STR ")", "P", 1, "" }, + { 'm', "portmap", "Enable portmapping via NAT-PMP or UPnP", "m", 0, NULL }, + { 'M', "no-portmap", "Disable portmapping", "M", 0, NULL }, + { 'L', "peerlimit-global", "Maximum overall number of peers (Default: " TR_DEFAULT_PEER_LIMIT_GLOBAL_STR ")", "L", 1, "" }, + { 'l', "peerlimit-torrent", "Maximum number of peers per torrent (Default: " TR_DEFAULT_PEER_LIMIT_TORRENT_STR ")", "l", 1, "" }, + { 910, "encryption-required", "Encrypt all peer connections", "er", 0, NULL }, + { 911, "encryption-preferred", "Prefer encrypted peer connections", "ep", 0, NULL }, + { 912, "encryption-tolerated", "Prefer unencrypted peer connections", "et", 0, NULL }, { 0, NULL, NULL, NULL, 0, NULL } }; @@ -214,6 +222,22 @@ main( int argc, break; case 'w': tr_bencDictAddStr( &settings, TR_PREFS_KEY_DOWNLOAD_DIR, optarg ); break; + case 'P': tr_bencDictAddInt( &settings, TR_PREFS_KEY_PEER_PORT, atoi( optarg ) ); + break; + case 'm': tr_bencDictAddInt( &settings, TR_PREFS_KEY_PORT_FORWARDING, 1 ); + break; + case 'M': tr_bencDictAddInt( &settings, TR_PREFS_KEY_PORT_FORWARDING, 0 ); + break; + case 'L': tr_bencDictAddInt( &settings, TR_PREFS_KEY_PEER_LIMIT_GLOBAL, atoi( optarg ) ); + break; + case 'l': tr_bencDictAddInt( &settings, TR_PREFS_KEY_PEER_LIMIT_TORRENT, atoi( optarg ) ); + break; + case 910: tr_bencDictAddInt( &settings, TR_PREFS_KEY_ENCRYPTION, TR_ENCRYPTION_REQUIRED ); + break; + case 911: tr_bencDictAddInt( &settings, TR_PREFS_KEY_ENCRYPTION, TR_CLEAR_PREFERRED ); + break; + case 912: tr_bencDictAddInt( &settings, TR_PREFS_KEY_ENCRYPTION, TR_ENCRYPTION_PREFERRED ); + break; default: showUsage( ); break; } diff --git a/daemon/transmission-daemon.1 b/daemon/transmission-daemon.1 index e14c73aa4..8b57d6a72 100644 --- a/daemon/transmission-daemon.1 +++ b/daemon/transmission-daemon.1 @@ -18,6 +18,11 @@ .Op Fl t | T .Op Fl u Ar username .Op Fl v Ar password +.Op Fl P Ar port +.Op Fl m | M +.Op Fl l Ar limit +.Op Fl L Ar limit +.Op Fl er | ep | et .Op Fl w Ar download-dir .Ek @@ -49,12 +54,32 @@ Run in the foreground and print errors to stderr. .It Fl g Fl -config-dir Ar directory Where to look for .torrent and config files on startup. +.It Fl er Fl -encryption-required +Encrypt all peer connections. +.It Fl ep Fl -encryption-preferred +Prefer encrypted peer connections. +.It Fl et Fl -encryption-tolerated +Prefer unencrypted peer connections. + .It Fl h Fl -help Print command-line option descriptions. +.It Fl L Fl -peerlimit-global Ar limit +Overall peer limit. Useful on embedded systems where the default might be unsuitable. Default: 240 +.It Fl l Fl -peerlimit-torrent Ar limit +Peer limit per torrent. Useful on embedded systems where the default might be unsuitable. Default: 60 + +.It Fl m Fl -portmap +Enable portmapping via NAT-PMP or UPnP +.It Fl M Fl -no-portmap +Disable portmapping + .It Fl p Fl -port Ar port Port to open and listen for RPC requests on. Default: 9091 +.It Fl P, -peerport Ar port +Port to listen for incoming peers on. Default: 51413 + .It Fl t Fl -auth Require clients to authenticate themselves. This doesn't do much good unless diff --git a/libtransmission/session.c b/libtransmission/session.c index 8c18d2b54..c7442a3cd 100644 --- a/libtransmission/session.c +++ b/libtransmission/session.c @@ -221,8 +221,8 @@ tr_sessionGetDefaultSettings( tr_benc * d ) tr_bencDictAddInt( d, TR_PREFS_KEY_ENCRYPTION, TR_DEFAULT_ENCRYPTION ); tr_bencDictAddInt( d, TR_PREFS_KEY_LAZY_BITFIELD, TRUE ); tr_bencDictAddInt( d, TR_PREFS_KEY_MSGLEVEL, TR_MSG_INF ); - tr_bencDictAddInt( d, TR_PREFS_KEY_PEER_LIMIT_GLOBAL, 240 ); - tr_bencDictAddInt( d, TR_PREFS_KEY_PEER_LIMIT_TORRENT, 60 ); + tr_bencDictAddInt( d, TR_PREFS_KEY_PEER_LIMIT_GLOBAL, atoi( TR_DEFAULT_PEER_LIMIT_GLOBAL_STR ) ); + tr_bencDictAddInt( d, TR_PREFS_KEY_PEER_LIMIT_TORRENT, atoi( TR_DEFAULT_PEER_LIMIT_TORRENT_STR ) ); tr_bencDictAddInt( d, TR_PREFS_KEY_PEER_PORT, atoi( TR_DEFAULT_PEER_PORT_STR ) ); tr_bencDictAddInt( d, TR_PREFS_KEY_PEER_PORT_RANDOM_ENABLED, FALSE ); tr_bencDictAddInt( d, TR_PREFS_KEY_PEER_PORT_RANDOM_LOW, 1024 ); diff --git a/libtransmission/transmission.h b/libtransmission/transmission.h index 5eb0f5911..f2eb26e79 100644 --- a/libtransmission/transmission.h +++ b/libtransmission/transmission.h @@ -118,6 +118,8 @@ tr_encryption_mode; #define TR_DEFAULT_RPC_PORT_STR "9091" #define TR_DEFAULT_PEER_PORT_STR "51413" #define TR_DEFAULT_PEER_SOCKET_TOS_STR "8" +#define TR_DEFAULT_PEER_LIMIT_GLOBAL_STR "240" +#define TR_DEFAULT_PEER_LIMIT_TORRENT_STR "60" #define TR_PREFS_KEY_BLOCKLIST_ENABLED "blocklist-enabled" #define TR_PREFS_KEY_DOWNLOAD_DIR "download-dir" -- 2.40.0