diff --git a/unix/CMakeLists.txt b/unix/CMakeLists.txt index 4c1009c..d72eaf8 100644 --- a/unix/CMakeLists.txt +++ b/unix/CMakeLists.txt @@ -3,6 +3,7 @@ add_subdirectory(common) add_subdirectory(vncconfig) add_subdirectory(vncpasswd) add_subdirectory(kasmvncpasswd) +add_subdirectory(kasmxproxy) install(PROGRAMS vncserver DESTINATION ${BIN_DIR}) install(FILES vncserver.man DESTINATION ${MAN_DIR}/man1 RENAME vncserver.1) diff --git a/unix/kasmxproxy/.gitignore b/unix/kasmxproxy/.gitignore new file mode 100644 index 0000000..78f1a3d --- /dev/null +++ b/unix/kasmxproxy/.gitignore @@ -0,0 +1 @@ +kasmxproxy diff --git a/unix/kasmxproxy/CMakeLists.txt b/unix/kasmxproxy/CMakeLists.txt new file mode 100644 index 0000000..648438e --- /dev/null +++ b/unix/kasmxproxy/CMakeLists.txt @@ -0,0 +1,8 @@ +include_directories(${X11_INCLUDE_DIR}) + +add_executable(kasmxproxy + kasmxproxy.c) + +target_link_libraries(kasmxproxy ${X11_LIBRARIES}) + +install(TARGETS kasmxproxy DESTINATION ${BIN_DIR}) diff --git a/unix/kasmxproxy/kasmxproxy.c b/unix/kasmxproxy/kasmxproxy.c new file mode 100644 index 0000000..cea6c4d --- /dev/null +++ b/unix/kasmxproxy/kasmxproxy.c @@ -0,0 +1,84 @@ +/* Copyright (C) 2021 Kasm. All Rights Reserved. + * + * This is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this software; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, + * USA. + */ + +#include +#include +#include +#include +#include +#include +#include + +static void help(const char name[]) { + printf("Usage: %s [opts]\n\n" + "-a --app-display disp App display, default :0\n" + "-v --vnc-display disp VNC display, default :1\n" + "\n" + "-f --fps fps FPS, default 30\n" + "-r --resize Enable resize, default disabled.\n" + " Do not enable this if there's a physical screen\n" + " connected to the app display.\n", + name); + exit(1); +} + +int main(int argc, char **argv) { + + const char *appstr = ":0"; + const char *vncstr = ":1"; + uint8_t resize = 0; + uint8_t fps = 30; + + const struct option longargs[] = { + {"app-display", 1, NULL, 'a'}, + {"vnc-display", 1, NULL, 'v'}, + {"resize", 0, NULL, 'r'}, + {"fps", 1, NULL, 'f'}, + + {NULL, 0, NULL, 0}, + }; + + while (1) { + int c = getopt_long(argc, argv, "a:v:rf:", longargs, NULL); + if (c == -1) + break; + switch (c) { + case 'a': + appstr = strdup(optarg); + break; + case 'v': + vncstr = strdup(optarg); + break; + case 'r': + resize = 1; + break; + case 'f': + fps = atoi(optarg); + if (fps < 1 || fps > 120) { + printf("Invalid fps\n"); + return 1; + } + break; + default: + help(argv[0]); + break; + } + } + + return 0; +}