mirror of
https://github.com/moonlight-stream/moonlight-embedded.git
synced 2026-02-16 10:30:47 +00:00
Store encryption key's in XDG cache directory and make location changable
This commit is contained in:
16
src/config.c
16
src/config.c
@@ -30,6 +30,8 @@
|
||||
#define MOONLIGHT_PATH "/moonlight/"
|
||||
#define USER_PATHS ":~/.moonlight/:./"
|
||||
|
||||
#define DEFAULT_CACHE_DIR ".cache/"
|
||||
|
||||
#define write_config_string(fd, key, value) fprintf(fd, "%s = %s\n", key, value)
|
||||
#define write_config_int(fd, key, value) fprintf(fd, "%s = %d\n", key, value)
|
||||
#define write_config_bool(fd, key, value) fprintf(fd, "%s = %s\n", key, value?"true":"false");
|
||||
@@ -55,6 +57,7 @@ static struct option long_options[] = {
|
||||
{"config", required_argument, NULL, 'o'},
|
||||
{"platform", required_argument, 0, 'p'},
|
||||
{"save", required_argument, NULL, 'q'},
|
||||
{"keydir", required_argument, NULL, 'r'},
|
||||
{0, 0, 0, 0},
|
||||
};
|
||||
|
||||
@@ -168,6 +171,9 @@ static void parse_argument(int c, char* value, PCONFIGURATION config) {
|
||||
case 'q':
|
||||
config->config_file = value;
|
||||
break;
|
||||
case 'r':
|
||||
strcpy(config->key_dir, value);
|
||||
break;
|
||||
case 1:
|
||||
if (config->action == NULL)
|
||||
config->action = value;
|
||||
@@ -266,6 +272,16 @@ void config_parse(int argc, char* argv[], PCONFIGURATION config) {
|
||||
if (config->config_file != NULL)
|
||||
config_save(config->config_file, config);
|
||||
|
||||
if (config->key_dir[0] == 0x0) {
|
||||
const char *xdg_cache_dir = getenv("XDG_CACHE_DIR");
|
||||
if (xdg_cache_dir != NULL)
|
||||
sprintf(config->key_dir, "%s/moonlight", xdg_cache_dir);
|
||||
else {
|
||||
const char *xdg_cache_dir = getenv("HOME");
|
||||
sprintf(config->key_dir, "%s/" DEFAULT_CACHE_DIR "moonlight", xdg_cache_dir);
|
||||
}
|
||||
}
|
||||
|
||||
if (config->stream.bitrate == -1) {
|
||||
if (config->stream.height >= 1080 && config->stream.fps >= 60)
|
||||
config->stream.bitrate = 20000;
|
||||
|
||||
@@ -36,6 +36,7 @@ typedef struct _CONFIGURATION {
|
||||
char* mapping;
|
||||
char* platform;
|
||||
char* config_file;
|
||||
char key_dir[4096];
|
||||
bool sops;
|
||||
bool localaudio;
|
||||
struct input_config inputs[MAX_INPUTS];
|
||||
|
||||
@@ -120,7 +120,8 @@ static void help() {
|
||||
printf("\t-input <device>\t\tUse <device> as input. Can be used multiple times\n");
|
||||
printf("\t-mapping <file>\t\tUse <file> as gamepad mapping configuration file (use before -input)\n");
|
||||
printf("\t-audio <device>\t\tUse <device> as ALSA audio output device (default sysdefault)\n");
|
||||
printf("\t-localaudio\t\tPlay audio locally\n\n");
|
||||
printf("\t-localaudio\t\tPlay audio locally\n");
|
||||
printf("\t-keydir <directory>\tLoad encryption keys from directory\n\n");
|
||||
printf("Use Ctrl+Alt+Shift+Q to exit streaming session\n\n");
|
||||
exit(0);
|
||||
}
|
||||
@@ -173,7 +174,7 @@ int main(int argc, char* argv[]) {
|
||||
}
|
||||
|
||||
PSERVER_DATA server;
|
||||
if (gs_init(server, config.address, ".") != GS_OK) {
|
||||
if (gs_init(server, config.address, config.key_dir) != GS_OK) {
|
||||
fprintf(stderr, "Can't connect to server %s\n", config.address);
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user