Require RTSP encryption when encryption mode is set to mandatory

This also lets us provide a friendly error to the client when it is rejected.
This commit is contained in:
Cameron Gutman
2024-02-03 13:57:43 -06:00
parent f80b23750b
commit 3578727ff9
4 changed files with 49 additions and 16 deletions

View File

@@ -3,6 +3,7 @@
* @brief todo
*/
#include "network.h"
#include "config.h"
#include "utility.h"
#include <algorithm>
@@ -174,6 +175,22 @@ namespace net {
}
}
/**
* @brief Returns the encryption mode for the given remote endpoint address.
* @param address The address used to look up the desired encryption mode.
* @return The WAN or LAN encryption mode, based on the provided address.
*/
int
encryption_mode_for_address(boost::asio::ip::address address) {
auto nettype = net::from_address(address.to_string());
if (nettype == net::net_e::PC || nettype == net::net_e::LAN) {
return config::stream.lan_encryption_mode;
}
else {
return config::stream.wan_encryption_mode;
}
}
host_t
host_create(af_e af, ENetAddress &addr, std::size_t peers, std::uint16_t port) {
static std::once_flag enet_init_flag;