mirror of
https://github.com/LizardByte/Sunshine.git
synced 2025-02-11 15:40:11 +00:00
Merge pull request #55 from SunshineStream/add-clang-linter
Add clang linter
This commit is contained in:
commit
a4fa42fa96
8
.github/dependabot.yml
vendored
Normal file
8
.github/dependabot.yml
vendored
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
version: 2
|
||||||
|
updates:
|
||||||
|
- package-ecosystem: "github-actions"
|
||||||
|
directory: "/"
|
||||||
|
schedule:
|
||||||
|
interval: "daily"
|
||||||
|
target-branch: "nightly"
|
||||||
|
open-pull-requests-limit: 20
|
35
.github/workflows/clang.yml
vendored
Normal file
35
.github/workflows/clang.yml
vendored
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
name: clang-format-lint
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
branches: [master, nightly]
|
||||||
|
types: [opened, synchronize, edited, reopened]
|
||||||
|
|
||||||
|
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
|
||||||
|
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: ${{ matrix.inplace }}
|
||||||
|
|
||||||
|
- name: Upload Artifacts
|
||||||
|
if: ${{ matrix.inplace == true }}
|
||||||
|
uses: actions/upload-artifact@v2
|
||||||
|
with:
|
||||||
|
name: sunshine
|
||||||
|
path: sunshine/
|
@ -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 credentials are shown, redirect the user to a /welcome page
|
||||||
if(config::sunshine.username.empty()){
|
if(config::sunshine.username.empty()) {
|
||||||
send_redirect(response,request,"/welcome");
|
send_redirect(response, request, "/welcome");
|
||||||
return false;
|
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) {
|
void getWelcomePage(resp_https_t response, req_https_t request) {
|
||||||
print_req(request);
|
print_req(request);
|
||||||
if(!config::sunshine.username.empty()){
|
if(!config::sunshine.username.empty()) {
|
||||||
send_redirect(response,request,"/");
|
send_redirect(response, request, "/");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
std::string header = read_file(WEB_DIR "header-no-nav.html");
|
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<std::string>("newPassword") : "";
|
auto newPassword = inputTree.count("newPassword") > 0 ? inputTree.get<std::string>("newPassword") : "";
|
||||||
auto confirmPassword = inputTree.count("confirmNewPassword") > 0 ? inputTree.get<std::string>("confirmNewPassword") : "";
|
auto confirmPassword = inputTree.count("confirmNewPassword") > 0 ? inputTree.get<std::string>("confirmNewPassword") : "";
|
||||||
if(newUsername.length() == 0) newUsername = username;
|
if(newUsername.length() == 0) newUsername = username;
|
||||||
if(newUsername.length() == 0){
|
if(newUsername.length() == 0) {
|
||||||
outputTree.put("status", false);
|
outputTree.put("status", false);
|
||||||
outputTree.put("error", "Invalid Username");
|
outputTree.put("error", "Invalid Username");
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
auto hash = util::hex(crypto::hash(password + config::sunshine.salt)).to_string();
|
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(config::sunshine.username.empty() || (username == config::sunshine.username && hash == config::sunshine.password)) {
|
||||||
if(newPassword.empty() || newPassword != confirmPassword) {
|
if(newPassword.empty() || newPassword != confirmPassword) {
|
||||||
outputTree.put("status", false);
|
outputTree.put("status", false);
|
||||||
outputTree.put("error", "Password Mismatch");
|
outputTree.put("error", "Password Mismatch");
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
http::save_user_creds(config::sunshine.credentials_file, newUsername, newPassword);
|
http::save_user_creds(config::sunshine.credentials_file, newUsername, newPassword);
|
||||||
http::reload_user_creds(config::sunshine.credentials_file);
|
http::reload_user_creds(config::sunshine.credentials_file);
|
||||||
outputTree.put("status", true);
|
outputTree.put("status", true);
|
||||||
@ -555,7 +557,7 @@ 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;
|
if(!authenticate(response, request)) return;
|
||||||
|
|
||||||
print_req(request);
|
print_req(request);
|
||||||
@ -571,7 +573,7 @@ void unpairAll(resp_https_t response, req_https_t request){
|
|||||||
outputTree.put("status", true);
|
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;
|
if(!authenticate(response, request)) return;
|
||||||
|
|
||||||
print_req(request);
|
print_req(request);
|
||||||
|
@ -56,7 +56,8 @@ int init() {
|
|||||||
}
|
}
|
||||||
if(user_creds_exist(config::sunshine.credentials_file)) {
|
if(user_creds_exist(config::sunshine.credentials_file)) {
|
||||||
if(reload_user_creds(config::sunshine.credentials_file)) return -1;
|
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";
|
BOOST_LOG(info) << "Open the Web UI to set your new username and password and getting started";
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -24,8 +24,8 @@
|
|||||||
#include "rtsp.h"
|
#include "rtsp.h"
|
||||||
#include "thread_pool.h"
|
#include "thread_pool.h"
|
||||||
#include "upnp.h"
|
#include "upnp.h"
|
||||||
#include "video.h"
|
|
||||||
#include "version.h"
|
#include "version.h"
|
||||||
|
#include "video.h"
|
||||||
|
|
||||||
#include "platform/common.h"
|
#include "platform/common.h"
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
@ -934,7 +934,7 @@ void start() {
|
|||||||
tcp.join();
|
tcp.join();
|
||||||
}
|
}
|
||||||
|
|
||||||
void erase_all_clients(){
|
void erase_all_clients() {
|
||||||
map_id_client.clear();
|
map_id_client.clear();
|
||||||
save_state();
|
save_state();
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
#ifndef SUNSHINE_WINDOWS_MISC_H
|
#ifndef SUNSHINE_WINDOWS_MISC_H
|
||||||
#define SUNSHINE_WINDOWS_MISC_H
|
#define SUNSHINE_WINDOWS_MISC_H
|
||||||
|
|
||||||
|
#include <string_view>
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <winnt.h>
|
#include <winnt.h>
|
||||||
#include <string_view>
|
|
||||||
|
|
||||||
namespace platf {
|
namespace platf {
|
||||||
void print_status(const std::string_view &prefix, HRESULT status);
|
void print_status(const std::string_view &prefix, HRESULT status);
|
||||||
HDESK syncThreadDesktop();
|
HDESK syncThreadDesktop();
|
||||||
}
|
} // namespace platf
|
||||||
|
|
||||||
#endif
|
#endif
|
@ -6,14 +6,14 @@
|
|||||||
|
|
||||||
#include "process.h"
|
#include "process.h"
|
||||||
|
|
||||||
|
#include <filesystem>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <filesystem>
|
|
||||||
|
|
||||||
|
#include <boost/algorithm/string.hpp>
|
||||||
|
#include <boost/filesystem.hpp>
|
||||||
#include <boost/property_tree/json_parser.hpp>
|
#include <boost/property_tree/json_parser.hpp>
|
||||||
#include <boost/property_tree/ptree.hpp>
|
#include <boost/property_tree/ptree.hpp>
|
||||||
#include <boost/filesystem.hpp>
|
|
||||||
#include <boost/algorithm/string.hpp>
|
|
||||||
|
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include "utility.h"
|
#include "utility.h"
|
||||||
@ -112,9 +112,11 @@ int proc_t::execute(int app_id) {
|
|||||||
if(proc.cmd.empty()) {
|
if(proc.cmd.empty()) {
|
||||||
BOOST_LOG(debug) << "Executing [Desktop]"sv;
|
BOOST_LOG(debug) << "Executing [Desktop]"sv;
|
||||||
placebo = true;
|
placebo = true;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
boost::filesystem::path working_dir = proc.working_dir.empty() ?
|
boost::filesystem::path working_dir = proc.working_dir.empty() ?
|
||||||
boost::filesystem::path(proc.cmd).parent_path() : boost::filesystem::path(proc.working_dir);
|
boost::filesystem::path(proc.cmd).parent_path() :
|
||||||
|
boost::filesystem::path(proc.working_dir);
|
||||||
if(proc.output.empty() || proc.output == "null"sv) {
|
if(proc.output.empty() || proc.output == "null"sv) {
|
||||||
BOOST_LOG(info) << "Executing: ["sv << proc.cmd << ']';
|
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);
|
_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<ctx_t> &proc_t::get_apps() {
|
|||||||
/// Returns default image if image configuration is not set.
|
/// Returns default image if image configuration is not set.
|
||||||
/// returns http content-type header compatible image type
|
/// returns http content-type header compatible image type
|
||||||
std::string proc_t::get_app_image(int app_id) {
|
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()) {
|
if(app_index < 0 || app_index >= _apps.size()) {
|
||||||
BOOST_LOG(error) << "Couldn't find app with ID ["sv << app_id << ']';
|
BOOST_LOG(error) << "Couldn't find app with ID ["sv << app_id << ']';
|
||||||
return SUNSHINE_ASSETS_DIR "/box.png";
|
return SUNSHINE_ASSETS_DIR "/box.png";
|
||||||
}
|
}
|
||||||
|
|
||||||
auto app_image_path = _apps[app_index].image_path;
|
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";
|
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);
|
boost::to_lower(image_extension);
|
||||||
|
|
||||||
std::error_code code;
|
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";
|
return SUNSHINE_ASSETS_DIR "/box.png";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -351,7 +353,7 @@ std::optional<proc::proc_t> parse(const std::string &file_name) {
|
|||||||
ctx.working_dir = parse_env_val(this_env, *working_dir);
|
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);
|
ctx.image_path = parse_env_val(this_env, *image_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user