Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions docs/Doxyfile
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ LOOKUP_CACHE_SIZE = 0
# DOT_NUM_THREADS setting.
# Minimum value: 0, maximum value: 32, default value: 1.

NUM_PROC_THREADS = 1
NUM_PROC_THREADS = 0

#---------------------------------------------------------------------------
# Build related configuration options
Expand Down Expand Up @@ -672,7 +672,7 @@ SORT_MEMBER_DOCS = YES
# this will also influence the order of the classes in the class list.
# The default value is: NO.

SORT_BRIEF_DOCS = NO
SORT_BRIEF_DOCS = YES

# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen will sort the
# (brief and detailed) documentation of class members so that constructors and
Expand Down Expand Up @@ -919,7 +919,7 @@ WARN_LOGFILE =
# spaces. See also FILE_PATTERNS and EXTENSION_MAPPING
# Note: If this tag is empty the current directory is searched.

INPUT = ../src ../src/platform ../src/platform/linux ../src/platform/macos ../src/platform/windows
INPUT = ../src

# This tag can be used to specify the character encoding of the source files
# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses
Expand Down Expand Up @@ -1010,7 +1010,7 @@ FILE_PATTERNS = *.c \
# be searched for input files as well.
# The default value is: NO.

RECURSIVE = NO
RECURSIVE = YES

# The EXCLUDE tag can be used to specify files and/or directories that should be
# excluded from the INPUT source files. This way you can easily exclude a
Expand Down
55 changes: 39 additions & 16 deletions src/nvhttp.cpp
Original file line number Diff line number Diff line change
@@ -1,40 +1,38 @@
// Created by loki on 6/3/19.
/**
* @file nvhttp.h
*/

// macros
#define BOOST_BIND_GLOBAL_PLACEHOLDERS

#include "process.h"

// standard includes
#include <filesystem>

#include <boost/property_tree/json_parser.hpp>
#include <boost/property_tree/ptree.hpp>
#include <boost/property_tree/xml_parser.hpp>

#include <boost/asio/ssl/context.hpp>

// lib includes
#include <Simple-Web-Server/server_http.hpp>
#include <Simple-Web-Server/server_https.hpp>
#include <boost/asio/ssl/context.hpp>
#include <boost/asio/ssl/context_base.hpp>
#include <boost/property_tree/json_parser.hpp>
#include <boost/property_tree/ptree.hpp>
#include <boost/property_tree/xml_parser.hpp>


// local includes
#include "config.h"
#include "crypto.h"
#include "httpcommon.h"
#include "main.h"
#include "network.h"
#include "nvhttp.h"
#include "platform/common.h"
#include "process.h"
#include "rtsp.h"
#include "utility.h"
#include "uuid.h"

using namespace std::literals;
namespace nvhttp {

// The negative 4th version number tells Moonlight that this is Sunshine
constexpr auto VERSION = "7.1.431.-1";
constexpr auto GFE_VERSION = "3.23.0.74";

namespace fs = std::filesystem;
namespace pt = boost::property_tree;

Expand Down Expand Up @@ -512,6 +510,16 @@ void pair(std::shared_ptr<safe::queue_t<crypto::x509_t>> &add_cert, std::shared_
}
}

/**
* @brief Compare the user supplied pin to the Moonlight pin.
* @param pin The user supplied pin.
* @return `true` if the pin is correct, `false` otherwise.
*
* EXAMPLES:
* ```cpp
* bool pin_status = nvhttp::pin("1234");
* ```
*/
bool pin(std::string pin) {
pt::ptree tree;
if(map_id_sess.empty()) {
Expand Down Expand Up @@ -845,6 +853,14 @@ void appasset(resp_https_t response, req_https_t request) {
response->close_connection_after_response = true;
}

/**
* @brief Start the nvhttp server.
*
* EXAMPLES:
* ```cpp
* nvhttp::start();
* ```
*/
void start() {
auto shutdown_event = mail::man->event<bool>(mail::shutdown);

Expand Down Expand Up @@ -892,8 +908,7 @@ void start() {

X509_NAME_oneline(X509_get_subject_name(x509), subject_name, sizeof(subject_name));


BOOST_LOG(info) << subject_name << " -- "sv << (verified ? "verified"sv : "denied"sv);
BOOST_LOG(debug) << subject_name << " -- "sv << (verified ? "verified"sv : "denied"sv);
});

while(add_cert->peek()) {
Expand Down Expand Up @@ -984,6 +999,14 @@ void start() {
tcp.join();
}

/**
* @brief Remove all paired clients.
*
* EXAMPLES:
* ```cpp
* nvhttp::erase_all_clients();
* ```
*/
void erase_all_clients() {
map_id_client.clear();
save_state();
Expand Down
35 changes: 32 additions & 3 deletions src/nvhttp.h
Original file line number Diff line number Diff line change
@@ -1,15 +1,44 @@
// Created by loki on 6/3/19.
/**
* @file nvhttp.h
*/

// macros
#ifndef SUNSHINE_NVHTTP_H
#define SUNSHINE_NVHTTP_H

#include "thread_safe.h"
// standard includes
#include <string>

// local includes
#include "thread_safe.h"

/**
* @brief This namespace contains all the functions and variables related to the nvhttp (GameStream) server.
*/
namespace nvhttp {
constexpr auto PORT_HTTP = 0;

/**
* @brief The protocol version.
*/
constexpr auto VERSION = "7.1.431.-1";
// The negative 4th version number tells Moonlight that this is Sunshine

/**
* @brief The GFE version we are replicating.
*/
constexpr auto GFE_VERSION = "3.23.0.74";

/**
* @brief The HTTP port, as a difference from the config port.
*/
constexpr auto PORT_HTTP = 0;

/**
* @brief The HTTPS port, as a difference from the config port.
*/
constexpr auto PORT_HTTPS = -5;

// functions
void start();
bool pin(std::string pin);
void erase_all_clients();
Expand Down