MCPcopy Create free account
hub / github.com/ClassicOldSong/Apollo / serverinfo

Function serverinfo

src/nvhttp.cpp:883–1013  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

881
882 template<class T>
883 void serverinfo(std::shared_ptr<typename SimpleWeb::ServerBase<T>::Response> response, std::shared_ptr<typename SimpleWeb::ServerBase<T>::Request> request) {
884 print_req<T>(request);
885
886 int pair_status = 0;
887 if constexpr (std::is_same_v<SunshineHTTPS, T>) {
888 auto args = request->parse_query_string();
889 auto clientID = args.find("uniqueid"s);
890
891 if (clientID != std::end(args)) {
892 pair_status = 1;
893 }
894 }
895
896 auto local_endpoint = request->local_endpoint();
897
898 pt::ptree tree;
899
900 tree.put("root.<xmlattr>.status_code", 200);
901 tree.put("root.hostname", config::nvhttp.sunshine_name);
902
903 tree.put("root.appversion", VERSION);
904 tree.put("root.GfeVersion", GFE_VERSION);
905 tree.put("root.uniqueid", http::unique_id);
906 tree.put("root.HttpsPort", net::map_port(PORT_HTTPS));
907 tree.put("root.ExternalPort", net::map_port(PORT_HTTP));
908 tree.put("root.MaxLumaPixelsHEVC", video::active_hevc_mode > 1 ? "1869449984" : "0");
909
910 // Only include the MAC address for requests sent from paired clients over HTTPS.
911 // For HTTP requests, use a placeholder MAC address that Moonlight knows to ignore.
912 if constexpr (std::is_same_v<SunshineHTTPS, T>) {
913 tree.put("root.mac", platf::get_mac_address(net::addr_to_normalized_string(local_endpoint.address())));
914
915 auto named_cert_p = get_verified_cert(request);
916 if (!!(named_cert_p->perm & PERM::server_cmd)) {
917 pt::ptree& root_node = tree.get_child("root");
918
919 if (config::sunshine.server_cmds.size() > 0) {
920 // Broadcast server_cmds
921 for (const auto& cmd : config::sunshine.server_cmds) {
922 pt::ptree cmd_node;
923 cmd_node.put_value(cmd.cmd_name);
924 root_node.push_back(std::make_pair("ServerCommand", cmd_node));
925 }
926 }
927 } else {
928 BOOST_LOG(debug) << "Permission Get ServerCommand denied for [" << named_cert_p->name << "] (" << (uint32_t)named_cert_p->perm << ")";
929 }
930
931 tree.put("root.Permission", std::to_string((uint32_t)named_cert_p->perm));
932
933 #ifdef _WIN32
934 tree.put("root.VirtualDisplayCapable", true);
935 if (!!(named_cert_p->perm & PERM::_all_actions)) {
936 tree.put("root.VirtualDisplayDriverReady", proc::vDisplayDriverStatus == VDISPLAY::DRIVER_STATUS::OK);
937 } else {
938 tree.put("root.VirtualDisplayDriverReady", true);
939 }
940 #endif

Callers

nothing calls this directly

Calls 9

map_portFunction · 0.85
get_verified_certFunction · 0.85
get_running_app_uuidMethod · 0.80
writeMethod · 0.80
to_stringFunction · 0.70
get_mac_addressFunction · 0.50
sizeMethod · 0.45
runningMethod · 0.45

Tested by

no test coverage detected