RAII helper that runs shutdown cleanup when destroyed.
More...
|
| | ~deinit_t () |
| | Destroy the UPnP deinitializer.
|
| bool | create_ipv6_pinholes () |
| | Opens pinholes for IPv6 traffic if the IGD is capable.
|
| bool | journal_mapping (const owned_mapping_t &mapping, bool added) |
| | Append recovery intent before creating a permanent rule, or completion after removing it.
|
| bool | remember_mapping (owned_mapping_t mapping, bool recovery_intent_already_written=false) |
| | Remember a rule independently of discovery and persist permanent-rule intent before adding it.
|
| bool | map_upnp_port (const IGDdatas &data, const urls_t &urls, const std::string &lan_addr, const mapping_t &mapping) |
| | Maps one port without deleting or adopting a rule belonging to another application.
|
| void | unmap_owned_ports (bool stale_only=false) |
| | Remove only recorded rules whose current destination, port and description still match.
|
| bool | map_all_upnp_ports (const igd_t &igd, const std::string &addr) |
| | Maps every port on an IGD, stopping early on shutdown.
|
| void | map_outer_upnp_ports (std::vector< igd_t > &igds, const std::vector< std::string > &igd_hosts, std::size_t inner, bool first_pass) |
| | Behind double NAT, map the ports on the IGD in front of the gateway.
|
| void | upnp_thread_proc () |
| | Maintains UPnP port forwarding rules.
|
|
| static mapping_lookup_t | lookup_mapping (const owned_mapping_t &wanted, bool recorded) |
| | Query one rule, corroborating a broken zero-port response only for recorded mappings.
|
| static std::size_t | find_gateway (const device_t &device, std::vector< igd_t > &igds, std::vector< std::string > &igd_hosts, const std::string &lan_addr) |
| | Find the IGD of the network this host is attached to.
|
| static std::filesystem::path | journal_path () |
| | Locate the append-only recovery journal used even when UPnP is disabled at the next start.
|
RAII helper that runs shutdown cleanup when destroyed.
Definition at line 232 of file upnp.cpp.
◆ deinit_t()
| upnp::deinit_t::deinit_t |
( |
| ) |
|
|
inline |
◆ ~deinit_t()
| upnp::deinit_t::~deinit_t |
( |
| ) |
|
|
inlinevirtual |
◆ create_ipv6_pinholes()
| bool upnp::deinit_t::create_ipv6_pinholes |
( |
| ) |
|
|
inline |
Opens pinholes for IPv6 traffic if the IGD is capable.
Not many IGDs support this feature, so we perform error logging with debug level.
- Returns
- true if the pinholes were opened successfully.
Definition at line 273 of file upnp.cpp.
◆ find_gateway()
| std::size_t upnp::deinit_t::find_gateway |
( |
const device_t & | device, |
|
|
std::vector< igd_t > & | igds, |
|
|
std::vector< std::string > & | igd_hosts, |
|
|
const std::string & | lan_addr ) |
|
inlinestatic |
Find the IGD of the network this host is attached to.
Behind two routers, the IGD chosen by UPNP_GetValidIGD() may be the outer one, which can't reach this host. The other IGDs that answered discovery are described and the closest one is selected.
- Parameters
-
| device | Device list from upnpDiscover(). |
| igds | List holding the IGD chosen by UPNP_GetValidIGD(); the other IGDs are appended to it. |
| igd_hosts | Receives the address of each IGD in igds. |
| lan_addr | This host's local address. |
- Returns
- Index of the selected IGD in igds.
Definition at line 588 of file upnp.cpp.
◆ journal_mapping()
| bool upnp::deinit_t::journal_mapping |
( |
const owned_mapping_t & | mapping, |
|
|
bool | added ) |
|
inline |
Append recovery intent before creating a permanent rule, or completion after removing it.
- Parameters
-
| mapping | Rule to record. |
| added | Whether this records creation intent. |
- Returns
- Whether the complete event reached the file stream successfully.
Definition at line 341 of file upnp.cpp.
◆ journal_path()
| std::filesystem::path upnp::deinit_t::journal_path |
( |
| ) |
|
|
inlinestatic |
Locate the append-only recovery journal used even when UPnP is disabled at the next start.
- Returns
- File containing outstanding permanent-rule intents.
Definition at line 728 of file upnp.cpp.
◆ lookup_mapping()
Query one rule, corroborating a broken zero-port response only for recorded mappings.
Definition at line 393 of file upnp.cpp.
◆ map_all_upnp_ports()
| bool upnp::deinit_t::map_all_upnp_ports |
( |
const igd_t & | igd, |
|
|
const std::string & | addr ) |
|
inline |
Maps every port on an IGD, stopping early on shutdown.
- Parameters
-
| igd | The IGD to map the ports on. |
| addr | Address the ports are forwarded to. |
- Returns
- Whether every requested mapping succeeded before shutdown.
Definition at line 566 of file upnp.cpp.
◆ map_outer_upnp_ports()
| void upnp::deinit_t::map_outer_upnp_ports |
( |
std::vector< igd_t > & | igds, |
|
|
const std::vector< std::string > & | igd_hosts, |
|
|
std::size_t | inner, |
|
|
bool | first_pass ) |
|
inline |
Behind double NAT, map the ports on the IGD in front of the gateway.
If the gateway's external address is private, the same ports are mapped on the IGD in front of it, forwarded to the gateway's external address. That IGD is kept to remove the mappings on shutdown.
- Parameters
-
| igds | The discovered IGDs. |
| igd_hosts | Address of each IGD in igds. |
| inner | Index of the gateway in igds. |
| first_pass | Whether this is the first mapping pass since the mappings were last completed. |
Definition at line 612 of file upnp.cpp.
◆ map_upnp_port()
| bool upnp::deinit_t::map_upnp_port |
( |
const IGDdatas & | data, |
|
|
const urls_t & | urls, |
|
|
const std::string & | lan_addr, |
|
|
const mapping_t & | mapping ) |
|
inline |
Maps one port without deleting or adopting a rule belonging to another application.
- Parameters
-
| data | Gateway's WAN connection service. |
| urls | Gateway's control URLs. |
| lan_addr | Desired destination address. |
| mapping | Desired forwarding rule. |
- Returns
- Whether the desired destination is reachable through this mapping.
Definition at line 429 of file upnp.cpp.
◆ remember_mapping()
| bool upnp::deinit_t::remember_mapping |
( |
owned_mapping_t | mapping, |
|
|
bool | recovery_intent_already_written = false ) |
|
inline |
Remember a rule independently of discovery and persist permanent-rule intent before adding it.
- Parameters
-
| mapping | Rule owned by Hermes. |
- Returns
- Whether the rule can safely be managed.
Definition at line 378 of file upnp.cpp.
◆ unmap_owned_ports()
| void upnp::deinit_t::unmap_owned_ports |
( |
bool | stale_only = false | ) |
|
|
inline |
Remove only recorded rules whose current destination, port and description still match.
- Parameters
-
| stale_only | Whether to retain rules wanted by the current discovery pass. |
Definition at line 521 of file upnp.cpp.
◆ upnp_thread_proc()
| void upnp::deinit_t::upnp_thread_proc |
( |
| ) |
|
|
inline |
Maintains UPnP port forwarding rules.
Definition at line 645 of file upnp.cpp.
◆ generation
| std::size_t upnp::deinit_t::generation = 0 |
Current successful discovery pass.
Definition at line 735 of file upnp.cpp.
◆ mapped_outer_host
| std::string upnp::deinit_t::mapped_outer_host |
Last outer gateway logged as mapped.
Definition at line 734 of file upnp.cpp.
◆ mappings
| std::vector<mapping_t> upnp::deinit_t::mappings |
Ports requested by Hermes.
Definition at line 732 of file upnp.cpp.
◆ owned_mappings
Rules retained independently of discovery results.
Definition at line 733 of file upnp.cpp.
◆ upnp_thread
| std::jthread upnp::deinit_t::upnp_thread |
Worker thread that refreshes mappings until shutdown.
Definition at line 737 of file upnp.cpp.
◆ warned_no_outer_igd
| bool upnp::deinit_t::warned_no_outer_igd = false |
Whether the missing outer IGD has already been reported.
Definition at line 736 of file upnp.cpp.
The documentation for this class was generated from the following file: