Ignore:
Timestamp:
Oct 1, 2008, 10:59:29 PM (13 years ago)
Author:
charles
Message:

add a separate flag for enabling/disabling the rpc address whitelist

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/rpc-server.c

    r6823 r6825  
    4343struct tr_rpc_server
    4444{
    45     unsigned int       isEnabled         : 1;
    46     unsigned int       isPasswordEnabled : 1;
     45    unsigned int       isEnabled          : 1;
     46    unsigned int       isPasswordEnabled  : 1;
     47    unsigned int       isWhitelistEnabled : 1;
    4748    uint16_t           port;
    4849    struct evhttp *    httpd;
     
    368369    const char * str;
    369370
     371    if( !server->isWhitelistEnabled )
     372        return 1;
     373
    370374    for( str = server->whitelist; str && *str; )
    371375    {
     
    412416        }
    413417
    414         if( server->whitelist && !isAddressAllowed( server, req->remote_host ) )
     418        if( !isAddressAllowed( server, req->remote_host ) )
    415419        {
    416420            send_simple_response( req, 401, "Unauthorized IP Address" );
     
    551555}
    552556
     557void
     558tr_rpcSetWhitelistEnabled( tr_rpc_server  * server,
     559                           int              isEnabled )
     560{
     561    server->isWhitelistEnabled = isEnabled != 0;
     562}
     563
     564int
     565tr_rpcGetWhitelistEnabled( const tr_rpc_server * server )
     566{
     567    return server->isWhitelistEnabled;
     568}
     569
    553570/****
    554571*****  PASSWORD
     
    626643            int          isEnabled,
    627644            uint16_t     port,
     645            int          isWhitelistEnabled,
    628646            const char * whitelist,
    629647            int          isPasswordEnabled,
     
    639657    s->username = tr_strdup( username );
    640658    s->password = tr_strdup( password );
     659    s->isWhitelistEnabled = isWhitelistEnabled != 0;
    641660    s->isPasswordEnabled = isPasswordEnabled != 0;
    642661    s->isEnabled = isEnabled != 0;
Note: See TracChangeset for help on using the changeset viewer.