1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2025-01-04 05:56:02 +00:00
transmission/libtransmission/port-forwarding.h
Charles Kerr 257d98545b
refactor: add tr_port_forwarding::Mediator (#3855)
* refactor: add a Mediator class to decouple tr_session and tr_port_forwarding

* refactor: add tr_port_forwarding::Mediator::privatePeerPort()

* refactor: add tr_port_forwarding::Mediator::onPortForwarded()

* chore: avoid unnecessary include of timer.h in other headers

* refactor: use a uniform timerMaker() API in mediators
2022-10-01 09:12:49 -05:00

45 lines
1.2 KiB
C++

// This file Copyright © 2008-2022 Mnemosyne LLC.
// It may be used under GPLv2 (SPDX: GPL-2.0-only), GPLv3 (SPDX: GPL-3.0-only),
// or any future license endorsed by Mnemosyne LLC.
// License text can be found in the licenses/ folder.
#pragma once
#ifndef __TRANSMISSION__
#error only libtransmission should #include this header.
#endif
#include <memory> // for std::unique_ptr
#include "transmission.h" // for tr_port_forwarding_state
#include "net.h"
namespace libtransmission
{
class TimerMaker;
}
class tr_port_forwarding
{
public:
class Mediator
{
public:
virtual ~Mediator() = default;
[[nodiscard]] virtual tr_port privatePeerPort() const = 0;
[[nodiscard]] virtual tr_address incomingPeerAddress() const = 0;
[[nodiscard]] virtual libtransmission::TimerMaker& timerMaker() = 0;
virtual void onPortForwarded(tr_port public_port, tr_port private_port) = 0;
};
[[nodiscard]] static std::unique_ptr<tr_port_forwarding> create(Mediator&);
virtual ~tr_port_forwarding() = default;
[[nodiscard]] virtual bool isEnabled() const = 0;
[[nodiscard]] virtual tr_port_forwarding_state state() const = 0;
virtual void portChanged() = 0;
virtual void setEnabled(bool enabled) = 0;
};