Listen to connections from localhost only, by default

vencrypt
Andri Yngvason 2019-12-31 10:33:40 +00:00
parent 9a634df223
commit 452ba2c4fb
1 changed files with 16 additions and 2 deletions

View File

@ -45,6 +45,9 @@
#include "pointer.h" #include "pointer.h"
#include "keyboard.h" #include "keyboard.h"
#define DEFAULT_ADDRESS "127.0.0.1"
#define DEFAULT_PORT 5900
enum frame_capture_backend_type { enum frame_capture_backend_type {
FRAME_CAPTURE_BACKEND_NONE = 0, FRAME_CAPTURE_BACKEND_NONE = 0,
FRAME_CAPTURE_BACKEND_SCREENCOPY, FRAME_CAPTURE_BACKEND_SCREENCOPY,
@ -501,7 +504,7 @@ void on_capture_done(struct frame_capture* capture)
int wayvnc_usage(FILE* stream, int rc) int wayvnc_usage(FILE* stream, int rc)
{ {
static const char* usage = static const char* usage =
"Usage: wayvnc [options]\n" "Usage: wayvnc [options] [address [port]]\n"
"\n" "\n"
" -c,--frame-capturing=screencopy|dmabuf Select frame capturing backend.\n" " -c,--frame-capturing=screencopy|dmabuf Select frame capturing backend.\n"
" -o,--output=<id> Select output to capture.\n" " -o,--output=<id> Select output to capture.\n"
@ -518,6 +521,9 @@ int main(int argc, char* argv[])
{ {
struct wayvnc self = { 0 }; struct wayvnc self = { 0 };
const char* address = DEFAULT_ADDRESS;
int port = DEFAULT_PORT;
int output_id = -1; int output_id = -1;
enum frame_capture_backend_type fcbackend = enum frame_capture_backend_type fcbackend =
FRAME_CAPTURE_BACKEND_SCREENCOPY; FRAME_CAPTURE_BACKEND_SCREENCOPY;
@ -560,6 +566,14 @@ int main(int argc, char* argv[])
} }
} }
int n_args = argc - optind;
if (n_args >= 1)
address = argv[optind];
if (n_args >= 2)
port = atoi(argv[optind + 1]);
if (init_wayland(&self) < 0) { if (init_wayland(&self) < 0) {
log_error("Failed to initialise wayland\n"); log_error("Failed to initialise wayland\n");
return 1; return 1;
@ -605,7 +619,7 @@ int main(int argc, char* argv[])
if (init_main_loop(&self) < 0) if (init_main_loop(&self) < 0)
goto main_loop_failure; goto main_loop_failure;
if (init_nvnc(&self, "0.0.0.0", 5900) < 0) if (init_nvnc(&self, address, port) < 0)
goto nvnc_failure; goto nvnc_failure;
screencopy_init(&self.screencopy_backend); screencopy_init(&self.screencopy_backend);