Compare commits
10 Commits
8ae34783c1
...
74ad24b410
Author | SHA1 | Date |
---|---|---|
Yat Ho | 74ad24b410 | |
Yat Ho | 9dfc4bbfde | |
Yat Ho | 4f4831a82b | |
Yat Ho | effc776e1a | |
Yat Ho | 1a5671efbd | |
Yat Ho | 62c8062bba | |
Pooyan Khanjankhani | 821a6816ef | |
Dzmitry Neviadomski | ef18816b7f | |
Dzmitry Neviadomski | 0e25584e78 | |
Dzmitry Neviadomski | bd0b74fccb |
|
@ -41,7 +41,7 @@ On macOS, Transmission is usually built with Xcode. Everywhere else, it's CMake
|
||||||
- Prefer `enum class` over `enum`
|
- Prefer `enum class` over `enum`
|
||||||
- Prefer new-style headers, e.g. `<cstring>` over `<string.h>`
|
- Prefer new-style headers, e.g. `<cstring>` over `<string.h>`
|
||||||
- Fix any warnings in new code before merging
|
- Fix any warnings in new code before merging
|
||||||
- Run `./code-style.sh` on your code to ensure the whole codebase has consistent indentation.
|
- Run `./code_style.sh` on your code to ensure the whole codebase has consistent indentation.
|
||||||
|
|
||||||
Note that Transmission existed in C for over a decade and those idioms don't change overnight. "Follow the C++ core guidelines" can be difficult when working with older code, and the maintainers will understand that when reviewing your PRs. :smiley:
|
Note that Transmission existed in C for over a decade and those idioms don't change overnight. "Follow the C++ core guidelines" can be difficult when working with older code, and the maintainers will understand that when reviewing your PRs. :smiley:
|
||||||
|
|
||||||
|
|
|
@ -404,7 +404,7 @@ struct tr_socket_address
|
||||||
};
|
};
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
class std::hash<tr_socket_address>
|
struct std::hash<tr_socket_address>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
std::size_t operator()(tr_socket_address const& socket_address) const noexcept
|
std::size_t operator()(tr_socket_address const& socket_address) const noexcept
|
||||||
|
|
|
@ -140,16 +140,10 @@ tr_natpmp::PulseResult tr_natpmp::pulse(tr_port local_port, bool is_enabled)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (state_ == State::Idle)
|
if ((state_ == State::Idle || state_ == State::Err) &&
|
||||||
|
(is_mapped_ ? tr_time() >= renew_time_ : is_enabled && has_discovered_))
|
||||||
{
|
{
|
||||||
if (is_enabled && !is_mapped_ && has_discovered_)
|
state_ = State::SendMap;
|
||||||
{
|
|
||||||
state_ = State::SendMap;
|
|
||||||
}
|
|
||||||
else if (is_mapped_ && tr_time() >= renew_time_)
|
|
||||||
{
|
|
||||||
state_ = State::SendMap;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (state_ == State::SendMap && canSendCommand())
|
if (state_ == State::SendMap && canSendCommand())
|
||||||
|
|
|
@ -39,7 +39,6 @@ namespace
|
||||||
enum class UpnpState : uint8_t
|
enum class UpnpState : uint8_t
|
||||||
{
|
{
|
||||||
Idle,
|
Idle,
|
||||||
Failed,
|
|
||||||
WillDiscover, // next action is upnpDiscover()
|
WillDiscover, // next action is upnpDiscover()
|
||||||
Discovering, // currently making blocking upnpDiscover() call in a worker thread
|
Discovering, // currently making blocking upnpDiscover() call in a worker thread
|
||||||
WillMap, // next action is UPNP_AddPortMapping()
|
WillMap, // next action is UPNP_AddPortMapping()
|
||||||
|
@ -58,9 +57,7 @@ struct tr_upnp
|
||||||
~tr_upnp()
|
~tr_upnp()
|
||||||
{
|
{
|
||||||
TR_ASSERT(!isMapped);
|
TR_ASSERT(!isMapped);
|
||||||
TR_ASSERT(
|
TR_ASSERT(state == UpnpState::Idle || state == UpnpState::WillDiscover || state == UpnpState::Discovering);
|
||||||
state == UpnpState::Idle || state == UpnpState::Failed || state == UpnpState::WillDiscover ||
|
|
||||||
state == UpnpState::Discovering);
|
|
||||||
|
|
||||||
FreeUPNPUrls(&urls);
|
FreeUPNPUrls(&urls);
|
||||||
}
|
}
|
||||||
|
@ -298,7 +295,7 @@ tr_port_forwarding_state tr_upnpPulse(
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
handle->state = UpnpState::Failed;
|
handle->state = UpnpState::WillDiscover;
|
||||||
tr_logAddDebug(fmt::format("UPNP_GetValidIGD failed: {} ({})", tr_strerror(errno), errno));
|
tr_logAddDebug(fmt::format("UPNP_GetValidIGD failed: {} ({})", tr_strerror(errno), errno));
|
||||||
tr_logAddDebug("If your router supports UPnP, please make sure UPnP is enabled!");
|
tr_logAddDebug("If your router supports UPnP, please make sure UPnP is enabled!");
|
||||||
}
|
}
|
||||||
|
@ -306,15 +303,15 @@ tr_port_forwarding_state tr_upnpPulse(
|
||||||
freeUPNPDevlist(devlist);
|
freeUPNPDevlist(devlist);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((handle->state == UpnpState::Idle) && (handle->isMapped) &&
|
if (handle->state == UpnpState::Idle && handle->isMapped &&
|
||||||
(!is_enabled || handle->advertised_port != advertised_port || handle->local_port != local_port))
|
(!is_enabled || handle->advertised_port != advertised_port || handle->local_port != local_port))
|
||||||
{
|
{
|
||||||
handle->state = UpnpState::WillUnmap;
|
handle->state = UpnpState::WillUnmap;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_enabled && handle->isMapped && do_port_check &&
|
if (is_enabled && handle->isMapped && do_port_check &&
|
||||||
((get_specific_port_mapping_entry(handle, "TCP") != UPNPCOMMAND_SUCCESS) ||
|
(get_specific_port_mapping_entry(handle, "TCP") != UPNPCOMMAND_SUCCESS ||
|
||||||
(get_specific_port_mapping_entry(handle, "UDP") != UPNPCOMMAND_SUCCESS)))
|
get_specific_port_mapping_entry(handle, "UDP") != UPNPCOMMAND_SUCCESS))
|
||||||
{
|
{
|
||||||
tr_logAddInfo(fmt::format(
|
tr_logAddInfo(fmt::format(
|
||||||
_("Local port {local_port} is not forwarded to {advertised_port}"),
|
_("Local port {local_port} is not forwarded to {advertised_port}"),
|
||||||
|
@ -339,7 +336,7 @@ tr_port_forwarding_state tr_upnpPulse(
|
||||||
handle->local_port = {};
|
handle->local_port = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((handle->state == UpnpState::Idle) && is_enabled && !handle->isMapped)
|
if (handle->state == UpnpState::Idle && is_enabled && !handle->isMapped)
|
||||||
{
|
{
|
||||||
handle->state = UpnpState::WillMap;
|
handle->state = UpnpState::WillMap;
|
||||||
}
|
}
|
||||||
|
@ -376,15 +373,14 @@ tr_port_forwarding_state tr_upnpPulse(
|
||||||
fmt::arg("advertised_port", advertised_port.host())));
|
fmt::arg("advertised_port", advertised_port.host())));
|
||||||
handle->advertised_port = advertised_port;
|
handle->advertised_port = advertised_port;
|
||||||
handle->local_port = local_port;
|
handle->local_port = local_port;
|
||||||
handle->state = UpnpState::Idle;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
tr_logAddInfo(_("If your router supports UPnP, please make sure UPnP is enabled!"));
|
tr_logAddInfo(_("If your router supports UPnP, please make sure UPnP is enabled!"));
|
||||||
handle->advertised_port = {};
|
handle->advertised_port = {};
|
||||||
handle->local_port = {};
|
handle->local_port = {};
|
||||||
handle->state = UpnpState::Failed;
|
|
||||||
}
|
}
|
||||||
|
handle->state = UpnpState::Idle;
|
||||||
}
|
}
|
||||||
|
|
||||||
return port_fwd_state(handle->state, handle->isMapped);
|
return port_fwd_state(handle->state, handle->isMapped);
|
||||||
|
|
|
@ -74,7 +74,7 @@ auto constexpr TrUnixSocketPrefix = "unix:"sv;
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
auto inline constexpr TrUnixAddrStrLen = size_t{ INET6_ADDRSTRLEN };
|
auto inline constexpr TrUnixAddrStrLen = size_t{ INET6_ADDRSTRLEN };
|
||||||
#else
|
#else
|
||||||
auto inline constexpr TrUnixAddrStrLen = size_t{ sizeof(((struct sockaddr_un*)nullptr)->sun_path) +
|
auto inline constexpr TrUnixAddrStrLen = size_t{ sizeof(std::declval<struct sockaddr_un>().sun_path) +
|
||||||
std::size(TrUnixSocketPrefix) };
|
std::size(TrUnixSocketPrefix) };
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -150,7 +150,7 @@ Get a file list for the current torrent(s)
|
||||||
.It Fl g Fl -get Ar all | file-index | files
|
.It Fl g Fl -get Ar all | file-index | files
|
||||||
Mark file(s) for download.
|
Mark file(s) for download.
|
||||||
.Ar all
|
.Ar all
|
||||||
marks all all of the torrent's files for downloading,
|
marks all of the torrent's files for downloading,
|
||||||
.Ar file-index
|
.Ar file-index
|
||||||
adds a single file to the download list, and
|
adds a single file to the download list, and
|
||||||
.Ar files
|
.Ar files
|
||||||
|
|
Loading…
Reference in New Issue