Ignore:
Timestamp:
Apr 15, 2009, 9:05:58 PM (13 years ago)
Author:
jhujhiti
Message:

(trunk) #1497 Options to listen on specific network sockets

File:
1 edited

Legend:

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

    r8199 r8242  
    3838#include "utils.h"
    3939#include "web.h"
     40#include "net.h"
    4041
    4142#define MY_NAME "RPC Server"
     
    5354    tr_bool            isWhitelistEnabled;
    5455    tr_port            port;
     56    struct in_addr     bindAddress;
    5557    struct evhttp *    httpd;
    5658    tr_session *       session;
     
    529531{
    530532    tr_rpc_server * server  = vserver;
     533    tr_address addr;
    531534
    532535    if( !server->httpd )
    533536    {
     537        addr.type = TR_AF_INET;
     538        addr.addr.addr4 = server->bindAddress;
    534539        server->httpd = evhttp_new( tr_eventGetBase( server->session ) );
    535         evhttp_bind_socket( server->httpd, "0.0.0.0", server->port );
     540        evhttp_bind_socket( server->httpd, tr_ntop_non_ts( &addr ),
     541                            server->port );
    536542        evhttp_set_gencb( server->httpd, handle_request, server );
    537543
     
    708714}
    709715
     716const char *
     717tr_rpcGetBindAddress( const tr_rpc_server * server )
     718{
     719    tr_address addr;
     720    addr.type = TR_AF_INET;
     721    addr.addr.addr4 = server->bindAddress;
     722    return tr_ntop_non_ts( &addr );
     723}
     724
    710725/****
    711726*****  LIFE CYCLE
     
    746761    int64_t i;
    747762    const char *str;
     763    tr_address address;
    748764
    749765    s = tr_new0( tr_rpc_server, 1 );
     
    781797        s->password = strdup( str );
    782798
     799    found = tr_bencDictFindStr( settings, TR_PREFS_KEY_RPC_BIND_ADDRESS, &str );
     800    assert( found );
     801    if( tr_pton( str, &address ) == NULL ) {
     802        tr_err( _( "%s is not a valid address" ), str );
     803        address = tr_inaddr_any;
     804    } else if( address.type != TR_AF_INET ) {
     805        tr_err( _( "%s is not an IPv4 address. RPC listeners must be IPv4" ),
     806                   str );
     807        address = tr_inaddr_any;
     808    }
     809    s->bindAddress = address.addr.addr4;
     810
    783811#ifdef HAVE_ZLIB
    784812    s->stream.zalloc = (alloc_func) Z_NULL;
Note: See TracChangeset for help on using the changeset viewer.