refactor: no macros in transmission.h (#8099)

* refactor: replace TR_RPC_SESSION_ID_HEADER macro with TrRpcSessionIdHeader constant

refactor: replace TR_RPC_RPC_VERSION_HEADER macro with TrRpcVersionHeader constant

* refactor: remove macro TR_DEFAULT_RPC_PORT_STR

* refactor: remove macro TR_DEFAULT_PEER_PORT_STR

* refactor: remove macro TR_DEFAULT_PEER_LIMIT_GLOBAL_STR

* refactor: remove macro TR_DEFAULT_PEER_LIMIT_TORRENT_STR

* refactor: remove macro TR_DEFAULT_PEER_SOCKET_TOS_STR

* refactor: replace DEFAULT_BLOCKLIST_FILENAME macro with TrDefaultBlocklistFilename constant

* refactor: rename TrHttpServerDefaultBasePath to TrDefaultHttpServerBasePath for consistency with other defaults

* refactor: group constants together near the top of transmission.h

* refactor: hardcode string lengths to avoid FTBFS on older C++17 compilers

* refactor: move macros to the tr_getopt clients

* refactor: explicitly specify the parameter index to avoid passing in TrRpcSessionIdHeader twice

* refactor: add an error message to new static_asserts
This commit is contained in:
Charles Kerr
2026-01-14 07:52:57 -06:00
committed by GitHub
parent 70bc3eec48
commit 140958a8a1
11 changed files with 62 additions and 69 deletions

View File

@@ -49,6 +49,8 @@ sig_atomic_t manualUpdate = false;
char const* torrentPath = nullptr;
using Arg = tr_option::Arg;
static_assert(TrDefaultPeerPort == 51413, "update 'port' desc");
static_assert(TrDefaultPeerSocketTos == "le", "update 'tos' desc");
auto constexpr Options = std::array<tr_option, 20>{ {
{ 'b', "blocklist", "Enable peer blocklists", "b", Arg::None, nullptr },
{ 'B', "no-blocklist", "Disable peer blocklists", "B", Arg::None, nullptr },
@@ -61,11 +63,10 @@ auto constexpr Options = std::array<tr_option, 20>{ {
{ 'g', "config-dir", "Where to find configuration files", "g", Arg::Required, "<path>" },
{ 'm', "portmap", "Enable portmapping via NAT-PMP or UPnP", "m", Arg::None, nullptr },
{ 'M', "no-portmap", "Disable portmapping", "M", Arg::None, nullptr },
{ 'p', "port", "Port for incoming peers (Default: " TR_DEFAULT_PEER_PORT_STR ")", "p", Arg::Required, "<port>" },
{ 'p', "port", "Port for incoming peers (Default: 51413)", "p", Arg::Required, "<port>" },
{ 't',
"tos",
"Peer socket DSCP / ToS setting (number, or a DSCP string, e.g. 'af11' or 'cs0', default=" TR_DEFAULT_PEER_SOCKET_TOS_STR
")",
"Peer socket DSCP / ToS. Number or DSCP string, e.g. 'af11' or 'cs0' (Default: 'le')",
"t",
Arg::Required,
"<dscp-or-tos>" },