Skip to content

Commit 76c3bab

Browse files
ReenigneArcherc2vi
authored andcommitted
fix(api): return proper json objects (LizardByte#3544)
1 parent 3a42861 commit 76c3bab

File tree

19 files changed

+363
-349
lines changed

19 files changed

+363
-349
lines changed

.github/workflows/CI.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -887,7 +887,6 @@ jobs:
887887
mingw-w64-ucrt-x86_64-graphviz
888888
mingw-w64-ucrt-x86_64-MinHook
889889
mingw-w64-ucrt-x86_64-miniupnpc
890-
mingw-w64-ucrt-x86_64-nlohmann-json
891890
mingw-w64-ucrt-x86_64-nodejs
892891
mingw-w64-ucrt-x86_64-nsis
893892
mingw-w64-ucrt-x86_64-onevpl

cmake/compile_definitions/common.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ list(APPEND SUNSHINE_EXTERNAL_LIBRARIES
149149
${CMAKE_THREAD_LIBS_INIT}
150150
enet
151151
libdisplaydevice::display_device
152+
nlohmann_json::nlohmann_json
152153
opus
153154
${FFMPEG_LIBRARIES}
154155
${Boost_LIBRARIES}

cmake/compile_definitions/windows.cmake

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ list(PREPEND PLATFORM_LIBRARIES
7676
libstdc++.a
7777
libwinpthread.a
7878
minhook::minhook
79-
nlohmann_json::nlohmann_json
8079
ntdll
8180
setupapi
8281
shlwapi

cmake/dependencies/common.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ add_subdirectory("${CMAKE_SOURCE_DIR}/third-party/Simple-Web-Server")
1616
add_subdirectory("${CMAKE_SOURCE_DIR}/third-party/libdisplaydevice")
1717

1818
# common dependencies
19+
include("${CMAKE_MODULE_PATH}/dependencies/nlohmann_json.cmake")
1920
find_package(OpenSSL REQUIRED)
2021
find_package(PkgConfig REQUIRED)
2122
find_package(Threads REQUIRED)
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#
2+
# Loads the nlohmann_json library giving the priority to the system package first, with a fallback to FetchContent.
3+
#
4+
include_guard(GLOBAL)
5+
6+
find_package(nlohmann_json 3.11 QUIET GLOBAL)
7+
if(NOT nlohmann_json_FOUND)
8+
message(STATUS "nlohmann_json v3.11.x package not found in the system. Falling back to FetchContent.")
9+
include(FetchContent)
10+
11+
FetchContent_Declare(
12+
json
13+
URL https://github.com/nlohmann/json/releases/download/v3.11.3/json.tar.xz
14+
URL_HASH MD5=c23a33f04786d85c29fda8d16b5f0efd
15+
DOWNLOAD_EXTRACT_TIMESTAMP
16+
)
17+
FetchContent_MakeAvailable(json)
18+
endif()

cmake/dependencies/windows.cmake

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
# windows specific dependencies
22

3-
# nlohmann_json
4-
find_package(nlohmann_json CONFIG 3.11 REQUIRED)
5-
63
# Make sure MinHook is installed
74
find_library(MINHOOK_LIBRARY libMinHook.a REQUIRED)
85
find_path(MINHOOK_INCLUDE_DIR MinHook.h PATH_SUFFIXES include REQUIRED)

docs/api.md

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,23 @@ basic authentication with the admin username and password.
1212
## GET /api/apps
1313
@copydoc confighttp::getApps()
1414

15-
## GET /api/logs
16-
@copydoc confighttp::getLogs()
17-
1815
## POST /api/apps
1916
@copydoc confighttp::saveApp()
2017

18+
## POST /api/apps/close
19+
@copydoc confighttp::closeApp()
20+
2121
## DELETE /api/apps/{index}
2222
@copydoc confighttp::deleteApp()
2323

24-
## POST /api/covers/upload
25-
@copydoc confighttp::uploadCover()
24+
## GET /api/clients/list
25+
@copydoc confighttp::getClients()
26+
27+
## POST /api/clients/unpair
28+
@copydoc confighttp::unpair()
29+
30+
## POST /api/clients/unpair-all
31+
@copydoc confighttp::unpairAll()
2632

2733
## GET /api/config
2834
@copydoc confighttp::getConfig()
@@ -33,29 +39,23 @@ basic authentication with the admin username and password.
3339
## POST /api/config
3440
@copydoc confighttp::saveConfig()
3541

36-
## POST /api/restart
37-
@copydoc confighttp::restart()
42+
## POST /api/covers/upload
43+
@copydoc confighttp::uploadCover()
3844

39-
## POST /api/reset-display-device-persistence
40-
@copydoc confighttp::resetDisplayDevicePersistence()
45+
## GET /api/logs
46+
@copydoc confighttp::getLogs()
4147

4248
## POST /api/password
4349
@copydoc confighttp::savePassword()
4450

4551
## POST /api/pin
4652
@copydoc confighttp::savePin()
4753

48-
## POST /api/clients/unpair-all
49-
@copydoc confighttp::unpairAll()
50-
51-
## POST /api/clients/unpair
52-
@copydoc confighttp::unpair()
53-
54-
## GET /api/clients/list
55-
@copydoc confighttp::listClients()
54+
## POST /api/reset-display-device-persistence
55+
@copydoc confighttp::resetDisplayDevicePersistence()
5656

57-
## POST /api/apps/close
58-
@copydoc confighttp::closeApp()
57+
## POST /api/restart
58+
@copydoc confighttp::restart()
5959

6060
<div class="section_buttons">
6161

docs/app_examples.md

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -301,22 +301,19 @@ administrative privileges. Simply enable the elevated option in the WEB UI, or a
301301
This is an option for both prep-cmd and regular commands and will launch the process with the current user without a
302302
UAC prompt.
303303

304-
@note{It is important to write the values "true" and "false" as string values, not as the typical true/false
305-
values in most JSON.}
306-
307304
**Example**
308305
```json
309306
{
310307
"name": "Game With AntiCheat that Requires Admin",
311308
"output": "",
312309
"cmd": "ping 127.0.0.1",
313-
"exclude-global-prep-cmd": "false",
314-
"elevated": "true",
310+
"exclude-global-prep-cmd": false,
311+
"elevated": true,
315312
"prep-cmd": [
316313
{
317314
"do": "powershell.exe -command \"Start-Streaming\"",
318315
"undo": "powershell.exe -command \"Stop-Streaming\"",
319-
"elevated": "false"
316+
"elevated": false
320317
}
321318
],
322319
"image-path": ""

docs/building.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@ dependencies=(
9292
"mingw-w64-ucrt-x86_64-graphviz" # Optional, for docs
9393
"mingw-w64-ucrt-x86_64-MinHook"
9494
"mingw-w64-ucrt-x86_64-miniupnpc"
95-
"mingw-w64-ucrt-x86_64-nlohmann-json"
9695
"mingw-w64-ucrt-x86_64-nodejs"
9796
"mingw-w64-ucrt-x86_64-nsis"
9897
"mingw-w64-ucrt-x86_64-onevpl"

docs/configuration.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ editing the `conf` file in a text editor. Use the examples as reference.
225225
<tr>
226226
<td>Example</td>
227227
<td colspan="2">@code{}
228-
global_prep_cmd = [{"do":"nircmd.exe setdisplay 1280 720 32 144","undo":"nircmd.exe setdisplay 2560 1440 32 144"}]
228+
global_prep_cmd = [{"do":"nircmd.exe setdisplay 1280 720 32 144","elevated":true,"undo":"nircmd.exe setdisplay 2560 1440 32 144"}]
229229
@endcode</td>
230230
</tr>
231231
</table>

0 commit comments

Comments
 (0)