3030#include " utility.h"
3131#include " uuid.h"
3232
33- namespace confighttp {
3433using namespace std ::literals;
35- constexpr auto PORT_HTTPS = 47990 ;
3634
35+ namespace confighttp {
3736namespace fs = std::filesystem;
3837namespace pt = boost::property_tree;
3938
@@ -67,7 +66,7 @@ void print_req(const req_https_t &request) {
6766
6867void send_unauthorized (resp_https_t response, req_https_t request) {
6968 auto address = request->remote_endpoint_address ();
70- BOOST_LOG (info) << ' [ ' << address << " ] -- denied " sv;
69+ BOOST_LOG (info) << " Web UI: [ " sv << address << " ] -- not authorized " sv;
7170 const SimpleWeb::CaseInsensitiveMultimap headers {
7271 { " WWW-Authenticate" , R"( Basic realm="Sunshine Gamestream Host", charset="UTF-8")" }
7372 };
@@ -78,8 +77,8 @@ bool authenticate(resp_https_t response, req_https_t request) {
7877 auto address = request->remote_endpoint_address ();
7978 auto ip_type = net::from_address (address);
8079
81- if (ip_type > http::origin_pin_allowed ) {
82- BOOST_LOG (info) << ' [ ' << address << " ] -- denied" sv;
80+ if (ip_type > http::origin_web_ui_allowed ) {
81+ BOOST_LOG (info) << " Web UI: [ " sv << address << " ] -- denied" sv;
8382 response->write (SimpleWeb::StatusCode::client_error_forbidden);
8483 return false ;
8584 }
@@ -455,6 +454,8 @@ void savePin(resp_https_t response, req_https_t request) {
455454void start () {
456455 auto shutdown_event = mail::man->event <bool >(mail::shutdown);
457456
457+ auto port_https = map_port (PORT_HTTPS);
458+
458459 auto ctx = std::make_shared<boost::asio::ssl::context>(boost::asio::ssl::context::tls);
459460 ctx->use_certificate_chain_file (config::nvhttp.cert );
460461 ctx->use_private_key_file (config::nvhttp.pkey , boost::asio::ssl::context::pem);
@@ -475,14 +476,14 @@ void start() {
475476 server.resource [" ^/api/apps/([0-9]+)$" ][" DELETE" ] = deleteApp;
476477 server.config .reuse_address = true ;
477478 server.config .address = " 0.0.0.0" s;
478- server.config .port = PORT_HTTPS ;
479+ server.config .port = port_https ;
479480
480481 try {
481482 server.bind ();
482- BOOST_LOG (info) << " Configuration UI available at [https://localhost:" sv << PORT_HTTPS << " ]" ;
483+ BOOST_LOG (info) << " Configuration UI available at [https://localhost:" sv << port_https << " ]" ;
483484 }
484485 catch (boost::system::system_error &err) {
485- BOOST_LOG (fatal) << " Couldn't bind http server to ports [" sv << PORT_HTTPS << " ]: " sv << err.what ();
486+ BOOST_LOG (fatal) << " Couldn't bind http server to ports [" sv << port_https << " ]: " sv << err.what ();
486487
487488 shutdown_event->raise (true );
488489 return ;
@@ -497,7 +498,7 @@ void start() {
497498 return ;
498499 }
499500
500- BOOST_LOG (fatal) << " Couldn't start Configuration HTTP server to ports [" sv << PORT_HTTPS << " , " sv << PORT_HTTPS << " ]: " sv << err.what ();
501+ BOOST_LOG (fatal) << " Couldn't start Configuration HTTPS server to port [" sv << port_https << " ]: " sv << err.what ();
501502 shutdown_event->raise (true );
502503 return ;
503504 }
0 commit comments