refactor: port forwarding (#3850)

* refactor: rename state enum type as tr_port_forwarding_state

* chore: use snake_case for tr_shared struct fields

* refactor: replace tr_shared with tr_port_forwarding

* refactor: make tr_natpmp_state an enum class

* refactor: uniform naming for port-forwarding module

* refactor: move output-only parameters in tr_natpmp::pulse() to return struct

* fix: use a nullptr multicastif if bindaddr is empty

* chore: use PascalCase for enum class values

* chore: clean up port-forwarding #includes

* chore: remove unused tr_port_forwarding::peerPort()
This commit is contained in:
Charles Kerr
2022-09-30 08:59:10 -05:00
committed by GitHub
parent a5ca289f41
commit bf156a97cf
12 changed files with 363 additions and 356 deletions

View File

@@ -9,22 +9,24 @@
#error only libtransmission should #include this header.
#endif
#include "net.h" // tr_port
#include <memory> // for std::unique_ptr
#include "transmission.h" // for tr_port_forwarding_state
struct tr_bindsockets;
struct tr_session;
struct tr_shared;
tr_shared* tr_sharedInit(tr_session&);
class tr_port_forwarding
{
public:
virtual ~tr_port_forwarding() = default;
void tr_sharedClose(tr_session&);
virtual void portChanged() = 0;
void tr_sharedPortChanged(tr_session&);
virtual void setEnabled(bool enabled) = 0;
void tr_sharedTraversalEnable(tr_shared*, bool is_enabled);
[[nodiscard]] virtual bool isEnabled() const = 0;
tr_port tr_sharedGetPeerPort(tr_shared const* s);
[[nodiscard]] virtual tr_port_forwarding_state state() const = 0;
bool tr_sharedTraversalIsEnabled(tr_shared const* s);
int tr_sharedTraversalStatus(tr_shared const*);
[[nodiscard]] static std::unique_ptr<tr_port_forwarding> create(tr_session&);
};