Allow the RPC server to listen on an IPv6 address

This commit is contained in:
Sebastiaan Lokhorst 2017-01-28 21:18:38 +01:00
parent 4f9d9ad92b
commit ac661ff099
4 changed files with 10 additions and 13 deletions

View File

@ -136,7 +136,7 @@ static struct tr_option const options[] =
{ 912, "encryption-tolerated", "Prefer unencrypted peer connections", "et", 0, NULL },
{ 'i', "bind-address-ipv4", "Where to listen for peer connections", "i", 1, "<ipv4 addr>" },
{ 'I', "bind-address-ipv6", "Where to listen for peer connections", "I", 1, "<ipv6 addr>" },
{ 'r', "rpc-bind-address", "Where to listen for RPC connections", "r", 1, "<ipv4 addr>" },
{ 'r', "rpc-bind-address", "Where to listen for RPC connections", "r", 1, "<ip addr>" },
{ 953, "global-seedratio", "All torrents, unless overridden by a per-torrent setting, should seed until a specific ratio", "gsr", 1, "ratio" },
{ 954, "no-global-seedratio", "All torrents, unless overridden by a per-torrent setting, should seed regardless of ratio", "GSR", 0, NULL },
{ 'x', "pid-file", "Enable PID file", "x", 1, "<pid-file>" },

View File

@ -41,7 +41,7 @@ via RPC commands from transmission's web interface or
.It Fl a Fl -allowed Ar x.x.x.x,...
Allow RPC access to a comma-delimited whitelist of IP addresses.
Wildcards can be specified in an address by using '*'.
Default: "127.0.0.1"
Default: "127.0.0.1,::1"
Example: "127.0.0.*,192.168.1.*"
.It Fl b Fl -blocklist
Enable peer blocklists. Transmission understands the bluetack blocklist file format.
@ -84,7 +84,7 @@ Listen for IPv4 BitTorrent connections on a specific address. Only one IPv4 list
.It Fl I Fl -bind-address-ipv6
Listen for IPv6 BitTorrent connections on a specific address. Only one IPv6 listening address is allowed. Default: :: (All addresses)
.It Fl r Fl -rpc-bind-address
Listen for RPC connections on a specific address. This must be an IPv4 address. Only one RPC listening address is allowed. Default: 0.0.0.0 (All addresses)
Listen for RPC connections on a specific address. This must be an IPv4 or IPv6 address. Only one RPC listening address is allowed. Default: 0.0.0.0 (All IPv4 addresses)
.It Fl -paused
Pause all torrents on startup
.It Fl L Fl -peerlimit-global Ar limit

View File

@ -54,7 +54,7 @@ struct tr_rpc_server
bool isWhitelistEnabled;
tr_port port;
char* url;
struct in_addr bindAddress;
struct tr_address bindAddress;
struct evhttp* httpd;
struct event* start_retry_timer;
int start_retry_counter;
@ -957,10 +957,7 @@ bool tr_rpcIsPasswordEnabled(tr_rpc_server const* server)
char const* tr_rpcGetBindAddress(tr_rpc_server const* server)
{
tr_address addr;
addr.type = TR_AF_INET;
addr.addr.addr4 = server->bindAddress;
return tr_address_to_string(&addr);
return tr_address_to_string(&server->bindAddress);
}
/****
@ -1115,17 +1112,17 @@ tr_rpc_server* tr_rpcInit(tr_session* session, tr_variant* settings)
tr_logAddNamedError(MY_NAME, _("%s is not a valid address"), str);
address = tr_inaddr_any;
}
else if (address.type != TR_AF_INET)
else if (address.type != TR_AF_INET && address.type != TR_AF_INET6)
{
tr_logAddNamedError(MY_NAME, _("%s is not an IPv4 address. RPC listeners must be IPv4"), str);
tr_logAddNamedError(MY_NAME, _("%s is not an IPv4 or IPv6 address. RPC listeners must be IPv4 or IPv6"), str);
address = tr_inaddr_any;
}
s->bindAddress = address.addr.addr4;
s->bindAddress = address;
if (s->isEnabled)
{
tr_logAddNamedInfo(MY_NAME, _("Serving RPC and Web requests on port 127.0.0.1:%d%s"), (int)s->port, s->url);
tr_logAddNamedInfo(MY_NAME, _("Serving RPC and Web requests on %s:%d%s"), tr_rpcGetBindAddress(s), (int)s->port, s->url);
tr_runInEventThread(session, startServer, s);
if (s->isWhitelistEnabled)

View File

@ -127,7 +127,7 @@ char const* tr_getDefaultDownloadDir(void);
#define TR_DEFAULT_BIND_ADDRESS_IPV4 "0.0.0.0"
#define TR_DEFAULT_BIND_ADDRESS_IPV6 "::"
#define TR_DEFAULT_RPC_WHITELIST "127.0.0.1"
#define TR_DEFAULT_RPC_WHITELIST "127.0.0.1,::1"
#define TR_DEFAULT_RPC_PORT_STR "9091"
#define TR_DEFAULT_RPC_URL_STR "/transmission/"
#define TR_DEFAULT_PEER_PORT_STR "51413"