Add a new flag in remote for connecting through a Unix domain socket. (#3552)

This commit is contained in:
Kobaxidze256
2022-08-19 01:09:55 +00:00
committed by GitHub
parent 479a16787e
commit c4537e6d80
2 changed files with 16 additions and 1 deletions

View File

@@ -84,6 +84,8 @@ struct Config
std::string netrc; std::string netrc;
std::string session_id; std::string session_id;
std::string torrent_ids; std::string torrent_ids;
std::string unix_socket_path;
bool debug = false; bool debug = false;
bool use_ssl = false; bool use_ssl = false;
}; };
@@ -232,7 +234,7 @@ enum
**** ****
***/ ***/
static auto constexpr Options = std::array<tr_option, 96>{ static auto constexpr Options = std::array<tr_option, 97>{
{ { 'a', "add", "Add torrent files by filename or URL", "a", false, nullptr }, { { 'a', "add", "Add torrent files by filename or URL", "a", false, nullptr },
{ 970, "alt-speed", "Use the alternate Limits", "as", false, nullptr }, { 970, "alt-speed", "Use the alternate Limits", "as", false, nullptr },
{ 971, "no-alt-speed", "Don't use the alternate Limits", "AS", false, nullptr }, { 971, "no-alt-speed", "Don't use the alternate Limits", "AS", false, nullptr },
@@ -277,6 +279,7 @@ static auto constexpr Options = std::array<tr_option, 96>{
{ 'l', "list", "List all torrents", "l", false, nullptr }, { 'l', "list", "List all torrents", "l", false, nullptr },
{ 'L', "labels", "Set the current torrents' labels", "L", true, "<label[,label...]>" }, { 'L', "labels", "Set the current torrents' labels", "L", true, "<label[,label...]>" },
{ 960, "move", "Move current torrent's data to a new folder", nullptr, true, "<path>" }, { 960, "move", "Move current torrent's data to a new folder", nullptr, true, "<path>" },
{ 968, "unix-socket", "Use a Unix domain socket", nullptr, true, "<path>" },
{ 961, "find", "Tell Transmission where to find a torrent's data", nullptr, true, "<path>" }, { 961, "find", "Tell Transmission where to find a torrent's data", nullptr, true, "<path>" },
{ 964, "rename", "Rename torrents root folder or a file", nullptr, true, "<name>" }, { 964, "rename", "Rename torrents root folder or a file", nullptr, true, "<name>" },
{ 965, "path", "Provide path for rename functions", nullptr, true, "<path>" }, { 965, "path", "Provide path for rename functions", nullptr, true, "<path>" },
@@ -411,6 +414,7 @@ static int getOptMode(int val)
case 'a': /* add torrent */ case 'a': /* add torrent */
case 'b': /* debug */ case 'b': /* debug */
case 'n': /* auth */ case 'n': /* auth */
case 968: /* Unix domain socket */
case 810: /* authenv */ case 810: /* authenv */
case 'N': /* netrc */ case 'N': /* netrc */
case 820: /* UseSSL */ case 820: /* UseSSL */
@@ -2258,6 +2262,11 @@ static CURL* tr_curl_easy_init(struct evbuffer* writebuf, Config& config)
CURLOPT_ENCODING, CURLOPT_ENCODING,
""); /* "" tells curl to fill in the blanks with what it was compiled to support */ ""); /* "" tells curl to fill in the blanks with what it was compiled to support */
if (auto const& str = config.unix_socket_path; !std::empty(str))
{
(void)curl_easy_setopt(curl, CURLOPT_UNIX_SOCKET_PATH, str.c_str());
}
if (auto const& str = config.netrc; !std::empty(str)) if (auto const& str = config.netrc; !std::empty(str))
{ {
(void)curl_easy_setopt(curl, CURLOPT_NETRC_FILE, str.c_str()); (void)curl_easy_setopt(curl, CURLOPT_NETRC_FILE, str.c_str());
@@ -2444,6 +2453,10 @@ static int processArgs(char const* rpcurl, int argc, char const* const* argv, Co
config.debug = true; config.debug = true;
break; break;
case 968: /* Unix domain socket */
config.unix_socket_path = optarg;
break;
case 'n': /* auth */ case 'n': /* auth */
config.auth = optarg; config.auth = optarg;
break; break;

View File

@@ -255,6 +255,8 @@ Remove the current torrent(s) and delete their downloaded data.
Reannounce the current torrent(s). This is the same as the GUI's "ask tracker for more peers" button. Reannounce the current torrent(s). This is the same as the GUI's "ask tracker for more peers" button.
.It Fl -move .It Fl -move
Move the current torrents' data from their current locations to the specified directory. Move the current torrents' data from their current locations to the specified directory.
.It Fl -unix-socket
Connect using a Unix domain socket.
.It Fl -find .It Fl -find
Tell Transmission where to look for the current torrents' data. Tell Transmission where to look for the current torrents' data.
.It Fl sr Fl -seedratio Ar ratio .It Fl sr Fl -seedratio Ar ratio