From 361e5f7ea7999e907df788980b1093d693e336d6 Mon Sep 17 00:00:00 2001 From: ReenigneArcher <42013603+ReenigneArcher@users.noreply.github.com> Date: Wed, 16 Feb 2022 17:50:52 -0500 Subject: [PATCH 1/8] Create dependabot.yml --- .github/dependabot.yml | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 .github/dependabot.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 00000000..60b85432 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,8 @@ +version: 2 +updates: + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "daily" + target-branch: "nightly" + open-pull-requests-limit: 20 From 27d273545459aec5df2eca9811fbb207e1747a41 Mon Sep 17 00:00:00 2001 From: ReenigneArcher <42013603+ReenigneArcher@users.noreply.github.com> Date: Wed, 16 Feb 2022 17:51:05 -0500 Subject: [PATCH 2/8] Create clang.yml --- .github/workflows/clang.yml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 .github/workflows/clang.yml diff --git a/.github/workflows/clang.yml b/.github/workflows/clang.yml new file mode 100644 index 00000000..3b1f05d5 --- /dev/null +++ b/.github/workflows/clang.yml @@ -0,0 +1,23 @@ +name: clang-format-lint + +on: + pull_request: + branches: [master, nightly] + types: [opened, synchronize, edited, reopened] + +jobs: + lint: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Clang format lint + uses: DoozyX/clang-format-lint-action@v0.13 + with: + source: './sunshine' + extensions: 'cpp,h' + clangFormatVersion: 13 + style: file + inplace: False From 2be7790415db4529e43da1dcc26fd38da9e93b8f Mon Sep 17 00:00:00 2001 From: ReenigneArcher <42013603+ReenigneArcher@users.noreply.github.com> Date: Wed, 16 Feb 2022 17:58:06 -0500 Subject: [PATCH 3/8] Update clang.yml - Add upload artifacts --- .github/workflows/clang.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/clang.yml b/.github/workflows/clang.yml index 3b1f05d5..a7f71dce 100644 --- a/.github/workflows/clang.yml +++ b/.github/workflows/clang.yml @@ -21,3 +21,9 @@ jobs: clangFormatVersion: 13 style: file inplace: False + + - name: Upload Artifacts + uses: actions/upload-artifact@v2 + with: + name: clang-formatted-files + path: sunshine/ From 5163ec93b4410d8f95e2e7c5bad91bc11f6f8c6f Mon Sep 17 00:00:00 2001 From: ReenigneArcher <42013603+ReenigneArcher@users.noreply.github.com> Date: Wed, 16 Feb 2022 18:02:05 -0500 Subject: [PATCH 4/8] Update clang.yml --- .github/workflows/clang.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/clang.yml b/.github/workflows/clang.yml index a7f71dce..6ade2d0b 100644 --- a/.github/workflows/clang.yml +++ b/.github/workflows/clang.yml @@ -20,7 +20,7 @@ jobs: extensions: 'cpp,h' clangFormatVersion: 13 style: file - inplace: False + inplace: True - name: Upload Artifacts uses: actions/upload-artifact@v2 From 320b691086745b44f3127f4e73b95c546acafc03 Mon Sep 17 00:00:00 2001 From: ReenigneArcher <42013603+ReenigneArcher@users.noreply.github.com> Date: Wed, 16 Feb 2022 18:09:23 -0500 Subject: [PATCH 5/8] Update clang.yml - Use job strategy matrix - inplace True allows artifacts to be uploaded; however workflow succeeds even if there are errors - inplace False fails workflow if there are errors --- .github/workflows/clang.yml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/clang.yml b/.github/workflows/clang.yml index 6ade2d0b..1031378e 100644 --- a/.github/workflows/clang.yml +++ b/.github/workflows/clang.yml @@ -7,7 +7,12 @@ on: jobs: lint: + name: Clang Format Lint runs-on: ubuntu-latest + strategy: + fail-fast: false # false to test all, true to fail entire job if any fail + matrix: + inplace: [ True, False ] # removed ubuntu_18_04 for now steps: - name: Checkout @@ -20,10 +25,11 @@ jobs: extensions: 'cpp,h' clangFormatVersion: 13 style: file - inplace: True + inplace: ${{ matrix.inplace }} - name: Upload Artifacts + if: ${{ matrix.inplace == True }} uses: actions/upload-artifact@v2 with: - name: clang-formatted-files + name: sunshine path: sunshine/ From 37edcb1b55dd9a6320cd9d164f11170c20951650 Mon Sep 17 00:00:00 2001 From: ReenigneArcher <42013603+ReenigneArcher@users.noreply.github.com> Date: Wed, 16 Feb 2022 18:10:54 -0500 Subject: [PATCH 6/8] Update clang.yml - Fix syntax error --- .github/workflows/clang.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/clang.yml b/.github/workflows/clang.yml index 1031378e..204a9360 100644 --- a/.github/workflows/clang.yml +++ b/.github/workflows/clang.yml @@ -28,7 +28,7 @@ jobs: inplace: ${{ matrix.inplace }} - name: Upload Artifacts - if: ${{ matrix.inplace == True }} + if: ${{ matrix.inplace == 'True' }} uses: actions/upload-artifact@v2 with: name: sunshine From f54a32feac37214525937d0f9d59269d0a8b2223 Mon Sep 17 00:00:00 2001 From: ReenigneArcher <42013603+ReenigneArcher@users.noreply.github.com> Date: Wed, 16 Feb 2022 18:13:16 -0500 Subject: [PATCH 7/8] Update clang.yml --- .github/workflows/clang.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/clang.yml b/.github/workflows/clang.yml index 204a9360..d87256bc 100644 --- a/.github/workflows/clang.yml +++ b/.github/workflows/clang.yml @@ -12,7 +12,7 @@ jobs: strategy: fail-fast: false # false to test all, true to fail entire job if any fail matrix: - inplace: [ True, False ] # removed ubuntu_18_04 for now + inplace: [ true, false ] # removed ubuntu_18_04 for now steps: - name: Checkout @@ -28,7 +28,7 @@ jobs: inplace: ${{ matrix.inplace }} - name: Upload Artifacts - if: ${{ matrix.inplace == 'True' }} + if: ${{ matrix.inplace == true }} uses: actions/upload-artifact@v2 with: name: sunshine From d6183430ef15ab6425f8c51194d15adbdcabc7ad Mon Sep 17 00:00:00 2001 From: ReenigneArcher <42013603+ReenigneArcher@users.noreply.github.com> Date: Wed, 16 Feb 2022 18:23:56 -0500 Subject: [PATCH 8/8] clang lint --- sunshine/confighttp.cpp | 82 ++++++++++++++++--------------- sunshine/httpcommon.cpp | 3 +- sunshine/main.cpp | 2 +- sunshine/nvhttp.cpp | 4 +- sunshine/platform/linux/audio.cpp | 2 +- sunshine/platform/linux/x11grab.h | 2 +- sunshine/platform/windows/misc.h | 4 +- sunshine/process.cpp | 22 +++++---- sunshine/utility.h | 4 +- sunshine/video.cpp | 4 +- 10 files changed, 67 insertions(+), 62 deletions(-) diff --git a/sunshine/confighttp.cpp b/sunshine/confighttp.cpp index f90b6d96..c21089de 100644 --- a/sunshine/confighttp.cpp +++ b/sunshine/confighttp.cpp @@ -93,8 +93,8 @@ bool authenticate(resp_https_t response, req_https_t request) { } //If credentials are shown, redirect the user to a /welcome page - if(config::sunshine.username.empty()){ - send_redirect(response,request,"/welcome"); + if(config::sunshine.username.empty()) { + send_redirect(response, request, "/welcome"); return false; } @@ -202,8 +202,8 @@ void getPasswordPage(resp_https_t response, req_https_t request) { void getWelcomePage(resp_https_t response, req_https_t request) { print_req(request); - if(!config::sunshine.username.empty()){ - send_redirect(response,request,"/"); + if(!config::sunshine.username.empty()) { + send_redirect(response, request, "/"); return; } std::string header = read_file(WEB_DIR "header-no-nav.html"); @@ -496,16 +496,18 @@ void savePassword(resp_https_t response, req_https_t request) { auto newPassword = inputTree.count("newPassword") > 0 ? inputTree.get("newPassword") : ""; auto confirmPassword = inputTree.count("confirmNewPassword") > 0 ? inputTree.get("confirmNewPassword") : ""; if(newUsername.length() == 0) newUsername = username; - if(newUsername.length() == 0){ + if(newUsername.length() == 0) { outputTree.put("status", false); outputTree.put("error", "Invalid Username"); - } else { + } + else { auto hash = util::hex(crypto::hash(password + config::sunshine.salt)).to_string(); if(config::sunshine.username.empty() || (username == config::sunshine.username && hash == config::sunshine.password)) { if(newPassword.empty() || newPassword != confirmPassword) { outputTree.put("status", false); outputTree.put("error", "Password Mismatch"); - } else { + } + else { http::save_user_creds(config::sunshine.credentials_file, newUsername, newPassword); http::reload_user_creds(config::sunshine.credentials_file); outputTree.put("status", true); @@ -555,9 +557,9 @@ void savePin(resp_https_t response, req_https_t request) { } } -void unpairAll(resp_https_t response, req_https_t request){ +void unpairAll(resp_https_t response, req_https_t request) { if(!authenticate(response, request)) return; - + print_req(request); pt::ptree outputTree; @@ -571,9 +573,9 @@ void unpairAll(resp_https_t response, req_https_t request){ outputTree.put("status", true); } -void closeApp(resp_https_t response, req_https_t request){ +void closeApp(resp_https_t response, req_https_t request) { if(!authenticate(response, request)) return; - + print_req(request); pt::ptree outputTree; @@ -597,35 +599,35 @@ void start() { ctx->use_certificate_chain_file(config::nvhttp.cert); ctx->use_private_key_file(config::nvhttp.pkey, boost::asio::ssl::context::pem); https_server_t server { ctx, 0 }; - server.default_resource = not_found; - server.resource["^/$"]["GET"] = getIndexPage; - server.resource["^/pin$"]["GET"] = getPinPage; - server.resource["^/apps$"]["GET"] = getAppsPage; - server.resource["^/clients$"]["GET"] = getClientsPage; - server.resource["^/config$"]["GET"] = getConfigPage; - server.resource["^/password$"]["GET"] = getPasswordPage; - server.resource["^/welcome$"]["GET"] = getWelcomePage; - server.resource["^/troubleshooting$"]["GET"] = getTroubleshootingPage; - server.resource["^/api/pin"]["POST"] = savePin; - server.resource["^/api/apps$"]["GET"] = getApps; - server.resource["^/api/apps$"]["POST"] = saveApp; - server.resource["^/api/config$"]["GET"] = getConfig; - server.resource["^/api/config$"]["POST"] = saveConfig; - server.resource["^/api/password$"]["POST"] = savePassword; - server.resource["^/api/apps/([0-9]+)$"]["DELETE"] = deleteApp; - server.resource["^/api/clients/unpair$"]["POST"] = unpairAll; - server.resource["^/api/apps/close"]["POST"] = closeApp; - server.resource["^/images/favicon.ico$"]["GET"] = getFaviconImage; - server.resource["^/images/logo-sunshine-45.png$"]["GET"] = getSunshineLogoImage; - server.resource["^/third_party/bootstrap.min.css$"]["GET"] = getBootstrapCss; - server.resource["^/third_party/bootstrap.bundle.min.js$"]["GET"] = getBootstrapJs; - server.resource["^/fontawesome/css/all.min.css$"]["GET"] = getFontAwesomeCss; - server.resource["^/fontawesome/webfonts/fa-brands-400.ttf$"]["GET"] = getFontAwesomeBrands; - server.resource["^/fontawesome/webfonts/fa-solid-900.ttf$"]["GET"] = getFontAwesomeSolid; - server.resource["^/third_party/vue.js$"]["GET"] = getVueJs; - server.config.reuse_address = true; - server.config.address = "0.0.0.0"s; - server.config.port = port_https; + server.default_resource = not_found; + server.resource["^/$"]["GET"] = getIndexPage; + server.resource["^/pin$"]["GET"] = getPinPage; + server.resource["^/apps$"]["GET"] = getAppsPage; + server.resource["^/clients$"]["GET"] = getClientsPage; + server.resource["^/config$"]["GET"] = getConfigPage; + server.resource["^/password$"]["GET"] = getPasswordPage; + server.resource["^/welcome$"]["GET"] = getWelcomePage; + server.resource["^/troubleshooting$"]["GET"] = getTroubleshootingPage; + server.resource["^/api/pin"]["POST"] = savePin; + server.resource["^/api/apps$"]["GET"] = getApps; + server.resource["^/api/apps$"]["POST"] = saveApp; + server.resource["^/api/config$"]["GET"] = getConfig; + server.resource["^/api/config$"]["POST"] = saveConfig; + server.resource["^/api/password$"]["POST"] = savePassword; + server.resource["^/api/apps/([0-9]+)$"]["DELETE"] = deleteApp; + server.resource["^/api/clients/unpair$"]["POST"] = unpairAll; + server.resource["^/api/apps/close"]["POST"] = closeApp; + server.resource["^/images/favicon.ico$"]["GET"] = getFaviconImage; + server.resource["^/images/logo-sunshine-45.png$"]["GET"] = getSunshineLogoImage; + server.resource["^/third_party/bootstrap.min.css$"]["GET"] = getBootstrapCss; + server.resource["^/third_party/bootstrap.bundle.min.js$"]["GET"] = getBootstrapJs; + server.resource["^/fontawesome/css/all.min.css$"]["GET"] = getFontAwesomeCss; + server.resource["^/fontawesome/webfonts/fa-brands-400.ttf$"]["GET"] = getFontAwesomeBrands; + server.resource["^/fontawesome/webfonts/fa-solid-900.ttf$"]["GET"] = getFontAwesomeSolid; + server.resource["^/third_party/vue.js$"]["GET"] = getVueJs; + server.config.reuse_address = true; + server.config.address = "0.0.0.0"s; + server.config.port = port_https; try { server.bind(); diff --git a/sunshine/httpcommon.cpp b/sunshine/httpcommon.cpp index 14249456..91074144 100644 --- a/sunshine/httpcommon.cpp +++ b/sunshine/httpcommon.cpp @@ -56,7 +56,8 @@ int init() { } if(user_creds_exist(config::sunshine.credentials_file)) { if(reload_user_creds(config::sunshine.credentials_file)) return -1; - } else { + } + else { BOOST_LOG(info) << "Open the Web UI to set your new username and password and getting started"; } return 0; diff --git a/sunshine/main.cpp b/sunshine/main.cpp index b5126f66..bcab4b3b 100644 --- a/sunshine/main.cpp +++ b/sunshine/main.cpp @@ -24,8 +24,8 @@ #include "rtsp.h" #include "thread_pool.h" #include "upnp.h" -#include "video.h" #include "version.h" +#include "video.h" #include "platform/common.h" extern "C" { diff --git a/sunshine/nvhttp.cpp b/sunshine/nvhttp.cpp index 8afdb35a..5da896e2 100644 --- a/sunshine/nvhttp.cpp +++ b/sunshine/nvhttp.cpp @@ -765,7 +765,7 @@ void cancel(resp_https_t response, req_https_t request) { void appasset(resp_https_t response, req_https_t request) { print_req(request); - auto args = request->parse_query_string(); + auto args = request->parse_query_string(); auto app_image = proc::proc.get_app_image(util::from_view(args.at("appid"))); std::ifstream in(app_image, std::ios::binary); @@ -934,7 +934,7 @@ void start() { tcp.join(); } -void erase_all_clients(){ +void erase_all_clients() { map_id_client.clear(); save_state(); } diff --git a/sunshine/platform/linux/audio.cpp b/sunshine/platform/linux/audio.cpp index facb5f3b..c210da24 100644 --- a/sunshine/platform/linux/audio.cpp +++ b/sunshine/platform/linux/audio.cpp @@ -77,7 +77,7 @@ std::unique_ptr microphone(const std::uint8_t *mapping, int channels, std }); pa_buffer_attr pa_attr = {}; - pa_attr.maxlength = frame_size * 8; + pa_attr.maxlength = frame_size * 8; int status; diff --git a/sunshine/platform/linux/x11grab.h b/sunshine/platform/linux/x11grab.h index 3d2868c8..9fde2664 100644 --- a/sunshine/platform/linux/x11grab.h +++ b/sunshine/platform/linux/x11grab.h @@ -21,7 +21,7 @@ void freeCursorCtx(cursor_ctx_raw_t *ctx); void freeDisplay(_XDisplay *xdisplay); using cursor_ctx_t = util::safe_ptr; -using xdisplay_t = util::safe_ptr<_XDisplay, freeDisplay>; +using xdisplay_t = util::safe_ptr<_XDisplay, freeDisplay>; class cursor_t { public: diff --git a/sunshine/platform/windows/misc.h b/sunshine/platform/windows/misc.h index 4effddf5..4cd8791f 100644 --- a/sunshine/platform/windows/misc.h +++ b/sunshine/platform/windows/misc.h @@ -1,13 +1,13 @@ #ifndef SUNSHINE_WINDOWS_MISC_H #define SUNSHINE_WINDOWS_MISC_H +#include #include #include -#include namespace platf { void print_status(const std::string_view &prefix, HRESULT status); HDESK syncThreadDesktop(); -} +} // namespace platf #endif \ No newline at end of file diff --git a/sunshine/process.cpp b/sunshine/process.cpp index f94b84fd..7fd900c5 100644 --- a/sunshine/process.cpp +++ b/sunshine/process.cpp @@ -6,14 +6,14 @@ #include "process.h" +#include #include #include -#include +#include +#include #include #include -#include -#include #include "main.h" #include "utility.h" @@ -112,9 +112,11 @@ int proc_t::execute(int app_id) { if(proc.cmd.empty()) { BOOST_LOG(debug) << "Executing [Desktop]"sv; placebo = true; - } else { - boost::filesystem::path working_dir = proc.working_dir.empty() ? - boost::filesystem::path(proc.cmd).parent_path() : boost::filesystem::path(proc.working_dir); + } + else { + boost::filesystem::path working_dir = proc.working_dir.empty() ? + boost::filesystem::path(proc.cmd).parent_path() : + boost::filesystem::path(proc.working_dir); if(proc.output.empty() || proc.output == "null"sv) { BOOST_LOG(info) << "Executing: ["sv << proc.cmd << ']'; _process = bp::child(_process_handle, proc.cmd, _env, bp::start_dir(working_dir), bp::std_out > bp::null, bp::std_err > bp::null, ec); @@ -195,14 +197,14 @@ std::vector &proc_t::get_apps() { /// Returns default image if image configuration is not set. /// returns http content-type header compatible image type std::string proc_t::get_app_image(int app_id) { - auto app_index = app_id -1; + auto app_index = app_id - 1; if(app_index < 0 || app_index >= _apps.size()) { BOOST_LOG(error) << "Couldn't find app with ID ["sv << app_id << ']'; return SUNSHINE_ASSETS_DIR "/box.png"; } auto app_image_path = _apps[app_index].image_path; - if (app_image_path.empty()) { + if(app_image_path.empty()) { return SUNSHINE_ASSETS_DIR "/box.png"; } @@ -210,7 +212,7 @@ std::string proc_t::get_app_image(int app_id) { boost::to_lower(image_extension); std::error_code code; - if (!std::filesystem::exists(app_image_path, code) || image_extension != ".png") { + if(!std::filesystem::exists(app_image_path, code) || image_extension != ".png") { return SUNSHINE_ASSETS_DIR "/box.png"; } @@ -351,7 +353,7 @@ std::optional parse(const std::string &file_name) { ctx.working_dir = parse_env_val(this_env, *working_dir); } - if (image_path) { + if(image_path) { ctx.image_path = parse_env_val(this_env, *image_path); } diff --git a/sunshine/utility.h b/sunshine/utility.h index 0e585e21..59776bf1 100644 --- a/sunshine/utility.h +++ b/sunshine/utility.h @@ -62,8 +62,8 @@ struct argument_type { typedef U type; }; x &operator=(x &&) noexcept = default; \ x(); -#define KITTY_DEFAULT_CONSTR_MOVE(x) \ - x(x &&) noexcept = default; \ +#define KITTY_DEFAULT_CONSTR_MOVE(x) \ + x(x &&) noexcept = default; \ x &operator=(x &&) noexcept = default; #define KITTY_DEFAULT_CONSTR_MOVE_THROW(x) \ diff --git a/sunshine/video.cpp b/sunshine/video.cpp index 1a3d51e9..15807eaa 100644 --- a/sunshine/video.cpp +++ b/sunshine/video.cpp @@ -1280,7 +1280,7 @@ void captureThreadSync() { ctx.shutdown_event->raise(true); ctx.join_event->raise(true); } - }); + }); while(encode_run_sync(synced_session_ctxs, ctx) == encode_e::reinit) {} } @@ -1296,7 +1296,7 @@ void capture_async( auto lg = util::fail_guard([&]() { images->stop(); shutdown_event->raise(true); - }); + }); auto ref = capture_thread_async.ref(); if(!ref) {