Changeset 12729


Ignore:
Timestamp:
Aug 24, 2011, 7:30:28 PM (10 years ago)
Author:
jordan
Message:

(trunk daemon) #3753 "support SSL in transmission-remote" -- added patch by reardon.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/daemon/remote.c

    r12726 r12729  
    264264    { 810, "authenv",                "Set authentication info from the TR_AUTH environment variable (user:pw)", "ne", 0, NULL },
    265265    { 'N', "netrc",                  "Set authentication info from a .netrc file", "N",  1, "<file>" },
     266    { 820, "ssl",                    "Use SSL when talking to daemon", NULL,  0, NULL },
    266267    { 'o', "dht",                    "Enable distributed hash tables (DHT)", "o", 0, NULL },
    267268    { 'O', "no-dht",                 "Disable distributed hash tables (DHT)", "O", 0, NULL },
     
    364365        case 810: /* authenv */
    365366        case 'N': /* netrc */
     367        case 820: /* UseSSL */
    366368        case 't': /* set current torrent */
    367369        case 'V': /* show version number */
     
    490492static char * netrc = NULL;
    491493static char * sessionId = NULL;
     494static bool UseSSL = false;
    492495
    493496static char*
     
    17321735    if( auth )
    17331736        curl_easy_setopt( curl, CURLOPT_USERPWD, auth );
     1737    if( UseSSL )
     1738        curl_easy_setopt( curl, CURLOPT_SSL_VERIFYPEER, 0 ); /* since most certs will be self-signed, do not verify against CA */               
    17341739    if( sessionId ) {
    17351740        char * h = tr_strdup_printf( "%s: %s", TR_RPC_SESSION_ID_HEADER, sessionId );
     
    17491754    struct evbuffer * buf = evbuffer_new( );
    17501755    char * json = tr_bencToStr( *benc, TR_FMT_JSON_LEAN, NULL );
     1756    char *rpcurl_http =  tr_strdup_printf( UseSSL? "https://%s" : "http://%s", rpcurl );
    17511757
    17521758    curl = tr_curl_easy_init( buf );
    1753     curl_easy_setopt( curl, CURLOPT_URL, rpcurl );
     1759    curl_easy_setopt( curl, CURLOPT_URL, rpcurl_http );
    17541760    curl_easy_setopt( curl, CURLOPT_POSTFIELDS, json );
    17551761    curl_easy_setopt( curl, CURLOPT_TIMEOUT, getTimeoutSecs( json ) );
     
    17601766    if(( res = curl_easy_perform( curl )))
    17611767    {
    1762         tr_nerr( MY_NAME, "(%s) %s", rpcurl, curl_easy_strerror( res ) );
     1768        tr_nerr( MY_NAME, "(%s) %s", rpcurl_http, curl_easy_strerror( res ) );
    17631769        status |= EXIT_FAILURE;
    17641770    }
     
    17881794
    17891795    /* cleanup */
     1796    tr_free( rpcurl_http );
    17901797    tr_free( json );
    17911798    evbuffer_free( buf );
     
    18851892                case 'N': /* netrc */
    18861893                    netrc = tr_strdup( optarg );
     1894                    break;
     1895
     1896                case 820: /* UseSSL */
     1897                    UseSSL = true;
    18871898                    break;
    18881899
     
    23762387        host = tr_strdup( DEFAULT_HOST );
    23772388    if( rpcurl == NULL )
    2378         rpcurl = tr_strdup_printf( "http://%s:%d%s", host, port, DEFAULT_URL );
     2389        rpcurl = tr_strdup_printf( "%s:%d%s", host, port, DEFAULT_URL );
    23792390
    23802391    exit_status = processArgs( rpcurl, argc, (const char**)argv );
Note: See TracChangeset for help on using the changeset viewer.