feat(ui): add port mapping table (#1681)
This commit is contained in:
@@ -16,6 +16,8 @@
|
||||
|
||||
#include "config.h"
|
||||
#include "main.h"
|
||||
#include "nvhttp.h"
|
||||
#include "rtsp.h"
|
||||
#include "utility.h"
|
||||
|
||||
#include "platform/common.h"
|
||||
@@ -1049,7 +1051,7 @@ namespace config {
|
||||
bool_f(vars, "always_send_scancodes", input.always_send_scancodes);
|
||||
|
||||
int port = sunshine.port;
|
||||
int_f(vars, "port"s, port);
|
||||
int_between_f(vars, "port"s, port, { 1024 + nvhttp::PORT_HTTPS, 65535 - rtsp_stream::RTSP_SETUP_PORT });
|
||||
sunshine.port = (std::uint16_t) port;
|
||||
|
||||
string_restricted_f(vars, "address_family", sunshine.address_family, { "ipv4"sv, "both"sv });
|
||||
|
||||
12
src/main.cpp
12
src/main.cpp
@@ -836,7 +836,15 @@ write_file(const char *path, const std::string_view &contents) {
|
||||
*/
|
||||
std::uint16_t
|
||||
map_port(int port) {
|
||||
// TODO: Ensure port is in the range of 21-65535
|
||||
// calculate the port from the config port
|
||||
auto mapped_port = (std::uint16_t)((int) config::sunshine.port + port);
|
||||
|
||||
// Ensure port is in the range of 1024-65535
|
||||
if (mapped_port < 1024 || mapped_port > 65535) {
|
||||
BOOST_LOG(warning) << "Port out of range: "sv << mapped_port;
|
||||
}
|
||||
|
||||
// TODO: Ensure port is not already in use by another application
|
||||
return (std::uint16_t)((int) config::sunshine.port + port);
|
||||
|
||||
return mapped_port;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user