steal some blocklist/encryption options from remote & reuse them in cli

This commit is contained in:
Charles Kerr 2008-07-08 18:12:36 +00:00
parent 9fb3bf6412
commit 688b9f860a
2 changed files with 64 additions and 46 deletions

View File

@ -24,28 +24,20 @@
.Bk -words .Bk -words
.Fl h .Fl h
.Nm .Nm
.Op Fl v Ar level
.Fl i .Fl i
.Ar torrent-file .Ar torrent-file
.Nm .Nm
.Op Fl v Ar level
.Fl s .Fl s
.Ar torrent-file .Ar torrent-file
.Nm .Nm
.Op Fl v Ar level .Fl n Ar sourcefile
.Op Fl p Ar port
.Op Fl d Ar number
.Op Fl u Ar number
.Op Fl f Ar script
.Op Fl n
.Ar torrent-file
.Op Ar output-dir
.Nm
.Fl n Ar path
.Op Fl a Ar url .Op Fl a Ar url
.Op Fl c Ar comment .Op Fl c Ar comment
.Op Fl r .Op Fl r
.Ar output-file .Ar new-torrent-file
.Nm
.Op options
.Ar torrent-file
.Ek .Ek
.Sh DESCRIPTION .Sh DESCRIPTION
The The
@ -59,6 +51,13 @@ The options are as follows:
.It Fl a, Fl -announce Ar announce-url .It Fl a, Fl -announce Ar announce-url
When creating a new torrent, set its announce URL When creating a new torrent, set its announce URL
.It Fl b Fl -blocklist
Enable peer blocklists. Transmission understands the bluetack blocklist file format.
New blocklists can be added by copying them into the config-dir's "blocklists" subdirectory.
.It Fl B Fl -no-blocklist
Disble blocklists.
.It Fl c, Fl -comment Ar comment-text .It Fl c, Fl -comment Ar comment-text
When creating a new torrent, set its comment field When creating a new torrent, set its comment field
@ -68,6 +67,13 @@ Set the maximum download speed in KB/s
.It Fl D, -no-downlimit .It Fl D, -no-downlimit
Don't limit the download speed Don't limit the download speed
.It Fl e Fl -encryption Ar required
Require all peer connections to be encrypted.
.It Fl e Fl -encryption Ar preferred
Prefer encrypted peer connections.
.It Fl e Fl -encryption Ar tolerated
Prefer unencrypted peer connections.
.It Fl f, -finish Ar script .It Fl f, -finish Ar script
Set a script to run when the torrent finishes Set a script to run when the torrent finishes
@ -86,7 +92,7 @@ Enable portmapping via NAT-PMP or UPnP
.It Fl M, Fl -no-portmap .It Fl M, Fl -no-portmap
Disable portmapping Disable portmapping
.It Fl n, Fl -new Ar path .It Fl n, Fl -new Ar sourcefile
Create torrent from the specified file or directory Create torrent from the specified file or directory
.It Fl p, -port Ar port .It Fl p, -port Ar port
@ -113,8 +119,6 @@ Verify the torrent's downloaded data.
.It Fl w, Fl -download-dir Ar directory .It Fl w, Fl -download-dir Ar directory
Where to save downloaded data. Where to save downloaded data.
ccc
.Sh SIGNALS .Sh SIGNALS
In addition to these options, sending In addition to these options, sending
.Nm .Nm

View File

@ -38,18 +38,20 @@
#define MY_NAME "transmission-cli" #define MY_NAME "transmission-cli"
static int showInfo = 0; static int showInfo = 0;
static int showScrape = 0; static int showScrape = 0;
static int isPrivate = 0; static int isPrivate = 0;
static int verboseLevel = 0; static int verboseLevel = 0;
static int peerPort = TR_DEFAULT_PORT; static int encryptionMode = TR_ENCRYPTION_PREFERRED;
static int peerSocketTOS = TR_DEFAULT_PEER_SOCKET_TOS; static int peerPort = TR_DEFAULT_PORT;
static int uploadLimit = 20; static int peerSocketTOS = TR_DEFAULT_PEER_SOCKET_TOS;
static int downloadLimit = -1; static int blocklistEnabled = TR_DEFAULT_BLOCKLIST_ENABLED;
static int natTraversal = 0; static int uploadLimit = 20;
static int verify = 0; static int downloadLimit = -1;
static sig_atomic_t gotsig = 0; static int natTraversal = TR_DEFAULT_PORT_FORWARDING_ENABLED;
static sig_atomic_t manualUpdate = 0; static int verify = 0;
static sig_atomic_t gotsig = 0;
static sig_atomic_t manualUpdate = 0;
static const char * torrentPath = NULL; static const char * torrentPath = NULL;
static const char * downloadDir = NULL; static const char * downloadDir = NULL;
@ -187,7 +189,7 @@ main( int argc, char ** argv )
TR_DEFAULT_PEX_ENABLED, TR_DEFAULT_PEX_ENABLED,
natTraversal, /* nat enabled */ natTraversal, /* nat enabled */
peerPort, peerPort,
TR_ENCRYPTION_PREFERRED, encryptionMode,
uploadLimit >= 0, uploadLimit >= 0,
uploadLimit, uploadLimit,
downloadLimit >= 0, downloadLimit >= 0,
@ -195,7 +197,7 @@ main( int argc, char ** argv )
TR_DEFAULT_GLOBAL_PEER_LIMIT, TR_DEFAULT_GLOBAL_PEER_LIMIT,
verboseLevel + 1, /* messageLevel */ verboseLevel + 1, /* messageLevel */
0, /* is message queueing enabled? */ 0, /* is message queueing enabled? */
TR_DEFAULT_BLOCKLIST_ENABLED, blocklistEnabled,
peerSocketTOS, peerSocketTOS,
TR_DEFAULT_RPC_ENABLED, TR_DEFAULT_RPC_ENABLED,
TR_DEFAULT_RPC_PORT, TR_DEFAULT_RPC_PORT,
@ -439,24 +441,27 @@ getUsage( void )
} }
const struct tr_option options[] = { const struct tr_option options[] = {
{ 'a', "announce", "When creating a new torrent, set its announce URL", "a", 1, "<url>" }, { 'a', "announce", "When creating a new torrent, set its announce URL", "a", 1, "<url>" },
{ 'c', "comment", "When creating a new torrent, set its comment field", "c", 1, "<comment>" }, { 'b', "blocklist", "Enable peer blocklists", "b", 0, NULL },
{ 'd', "downlimit", "Set the maxiumum download speed in KB/s", "d", 1, "<number>" }, { 'B', "no-blocklist", "Disable peer blocklists", "B", 0, NULL },
{ 'D', "no-downlimit", "Don't limit the download speed", "D", 0, NULL }, { 'c', "comment", "When creating a new torrent, set its comment field", "c", 1, "<comment>" },
{ 'f', "finish", "Set a script to run when the torrent finishes", "f", 1, "<script>" }, { 'd', "downlimit", "Set the maxiumum download speed in KB/s", "d", 1, "<number>" },
{ 'g', "config-dir", "Where to look for configuration files", "g", 1, "<path>" }, { 'D', "no-downlimit", "Don't limit the download speed", "D", 0, NULL },
{ 'i', "info", "Show torrent details and exit", "i", 0, NULL }, { 'e', "encryption", "Set encryption mode [required, preferred, tolerated]", "e", 1, "<mode>" },
{ 'm', "portmap", "Enable portmapping via NAT-PMP or UPnP", "m", 0, NULL }, { 'f', "finish", "Set a script to run when the torrent finishes", "f", 1, "<script>" },
{ 'M', "no-portmap", "Disable portmapping", "M", 0, NULL }, { 'g', "config-dir", "Where to look for configuration files", "g", 1, "<path>" },
{ 'n', "new", "Create a new torrent from a file or directory", "n", 1, "<path>" }, { 'i', "info", "Show torrent details and exit", "i", 0, NULL },
{ 'm', "portmap", "Enable portmapping via NAT-PMP or UPnP", "m", 0, NULL },
{ 'M', "no-portmap", "Disable portmapping", "M", 0, NULL },
{ 'n', "new", "Create a new torrent from a file or directory", "n", 1, "<path>" },
{ 'p', "port", "Port to listen for incoming peers (Default: "TR_DEFAULT_PORT_STR")", "p", 1, "<port>" }, { 'p', "port", "Port to listen for incoming peers (Default: "TR_DEFAULT_PORT_STR")", "p", 1, "<port>" },
{ 'r', "private", "When creating a new torrent, set its 'private' flag", "r", 0, NULL }, { 'r', "private", "When creating a new torrent, set its 'private' flag", "r", 0, NULL },
{ 's', "scrape", "Scrape the torrent and exit", "s", 0, NULL }, { 's', "scrape", "Scrape the torrent and exit", "s", 0, NULL },
{ 't', "tos", "Peer socket TOS (0 to 255, default="TR_DEFAULT_PEER_SOCKET_TOS_STR")", "t", 1, "<number>"}, { 't', "tos", "Peer socket TOS (0 to 255, default="TR_DEFAULT_PEER_SOCKET_TOS_STR")", "t", 1, "<number>"},
{ 'u', "uplimit", "Set the maxiumum upload speed in KB/s", "u", 1, "<number>" }, { 'u', "uplimit", "Set the maxiumum upload speed in KB/s", "u", 1, "<number>" },
{ 'U', "no-uplimit", "Don't limit the upload speed", "U", 0, NULL }, { 'U', "no-uplimit", "Don't limit the upload speed", "U", 0, NULL },
{ 'v', "verify", "Verify the specified torrent", "v", 0, NULL }, { 'v', "verify", "Verify the specified torrent", "v", 0, NULL },
{ 'w', "download-dir", "Where to save downloaded data", "w", 1, "<path>" }, { 'w', "download-dir", "Where to save downloaded data", "w", 1, "<path>" },
{ 0, NULL, NULL, NULL, 0, NULL } { 0, NULL, NULL, NULL, 0, NULL }
}; };
@ -490,9 +495,18 @@ parseCommandLine( int argc, const char ** argv )
switch( c ) switch( c )
{ {
case 'a': announce = optarg; break; case 'a': announce = optarg; break;
case 'b': blocklistEnabled = 1; break;
case 'B': blocklistEnabled = 0; break;
case 'c': comment = optarg; break; case 'c': comment = optarg; break;
case 'd': downloadLimit = numarg( optarg ); break; case 'd': downloadLimit = numarg( optarg ); break;
case 'D': downloadLimit = -1; break; case 'D': downloadLimit = -1; break;
case 'e': if( !strcmp( optarg, "required" ) )
encryptionMode = TR_ENCRYPTION_REQUIRED;
else if( !strcmp( optarg, "tolerated" ) )
encryptionMode = TR_PLAINTEXT_PREFERRED;
else
encryptionMode = TR_ENCRYPTION_PREFERRED;
break;
case 'f': finishCall = optarg; break; case 'f': finishCall = optarg; break;
case 'g': configdir = optarg; break; case 'g': configdir = optarg; break;
case 'i': showInfo = 1; break; case 'i': showInfo = 1; break;