Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 3 commits into from
Aug 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 14 additions & 1 deletion utils/remote.cc
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ struct Config
std::string netrc;
std::string session_id;
std::string torrent_ids;
std::string unix_socket_path;

bool debug = false;
bool use_ssl = false;
};
Expand Down Expand Up @@ -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 },
{ 970, "alt-speed", "Use the alternate Limits", "as", false, nullptr },
{ 971, "no-alt-speed", "Don't use the alternate Limits", "AS", false, nullptr },
Expand Down Expand Up @@ -277,6 +279,7 @@ static auto constexpr Options = std::array<tr_option, 96>{
{ 'l', "list", "List all torrents", "l", false, nullptr },
{ '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>" },
{ 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>" },
{ 964, "rename", "Rename torrents root folder or a file", nullptr, true, "<name>" },
{ 965, "path", "Provide path for rename functions", nullptr, true, "<path>" },
Expand Down Expand Up @@ -411,6 +414,7 @@ static int getOptMode(int val)
case 'a': /* add torrent */
case 'b': /* debug */
case 'n': /* auth */
case 968: /* Unix domain socket */
case 810: /* authenv */
case 'N': /* netrc */
case 820: /* UseSSL */
Expand Down Expand Up @@ -2258,6 +2262,11 @@ static CURL* tr_curl_easy_init(struct evbuffer* writebuf, Config& config)
CURLOPT_ENCODING,
""); /* "" 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))
{
(void)curl_easy_setopt(curl, CURLOPT_NETRC_FILE, str.c_str());
Expand Down Expand Up @@ -2444,6 +2453,10 @@ static int processArgs(char const* rpcurl, int argc, char const* const* argv, Co
config.debug = true;
break;

case 968: /* Unix domain socket */
config.unix_socket_path = optarg;
break;

case 'n': /* auth */
config.auth = optarg;
break;
Expand Down
2 changes: 2 additions & 0 deletions utils/transmission-remote.1
Original file line number Diff line number Diff line change
Expand Up @@ -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.
.It Fl -move
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
Tell Transmission where to look for the current torrents' data.
.It Fl sr Fl -seedratio Ar ratio
Expand Down