Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 87 additions & 0 deletions snap/snapcraft.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
name: wsgate
version: "1.2.0.444"
summary: FreeRDP WebConnect
description: A HTML5 gateway to FreeRDP
architectures:
- amd64
confinement: strict
base: core18
apps:
wsgate:
command: usr/bin/wsgate
plugs:
- network
- network-bind
grade: stable
parts:
ehs:
plugin: cmake
source: https://github.com/cloudbase/EHS.git
source-type: git
configflags:
- "-DCMAKE_INSTALL_PREFIX=/usr"
build-packages:
- cmake
- g++
- pkg-config
- zlib1g-dev
- libssl-dev
- libboost-dev
- libboost-filesystem-dev
- libboost-program-options-dev
- libboost-system-dev
- libboost-regex-dev
wsgate:
plugin: cmake
after: [ehs]
source-subdir: wsgate
source: .
#source-type: git
configflags:
- "-DCMAKE_INSTALL_PREFIX=/usr"
build-packages:
- pkg-config
- libfreerdp-dev
- libcpprest-dev
- libpng-dev
stage-packages:
- libboost-filesystem1.65.1
- libboost-program-options1.65.1
- libboost-regex1.65.1
- libboost-system1.65.1
- libcpprest2.10
- libfreerdp-cache1.1
- libfreerdp-codec1.1
- libfreerdp-common1.1.0
- libfreerdp-core1.1
- libfreerdp-crypto1.1
- libfreerdp-gdi1.1
- libfreerdp-locale1.1
- libfreerdp-primitives1.1
- libfreerdp-utils1.1
- libicu60
- libjpeg-turbo8
- libwinpr-crt0.1
- libwinpr-dsparse0.1
- libwinpr-environment0.1
- libwinpr-file0.1
- libwinpr-handle0.1
- libwinpr-heap0.1
- libwinpr-input0.1
- libwinpr-interlocked0.1
- libwinpr-library0.1
- libwinpr-path0.1
- libwinpr-pool0.1
- libwinpr-registry0.1
- libwinpr-rpc0.1
- libwinpr-sspi0.1
- libwinpr-synch0.1
- libwinpr-sysinfo0.1
- libwinpr-thread0.1
- libwinpr-utils0.1
- libx11-6
- libxau6
- libxcb1
- libxdmcp6
- libxkbfile1

1 change: 1 addition & 0 deletions wsgate/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -607,3 +607,4 @@ endif()
add_executable(wsgate ${WSGATE_SOURCES})

target_link_libraries(wsgate ${LIBS})
install(TARGETS wsgate DESTINATION bin)
184 changes: 101 additions & 83 deletions wsgate/webroot/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ project("wsgate")

# if MSVC, prevent it from capturing output
if(MSVC)
set(ENV{VS_UNICODE_OUTPUT} "")
set(ENV{VS_UNICODE_OUTPUT} "")
endif()
# define js files
set(JS_FILES modernizr-debug.js mootools-debug.js simpletabs-debug.js vkb-debug.js wsgate-debug.js)
set(JS_STRIPPED_FILES)
set(IMAGE_FILES FreeRDP_Logo.png c_default.png c_none.png favicon.ico)
set(ASSET_DIRS fonts images)

# create destionation dir for js files
execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/js)
Expand All @@ -24,99 +26,115 @@ find_package(Perl)
find_package(Java)

if (PERL_FOUND)
add_custom_command(
OUTPUT index.html
COMMAND ${PERL_EXECUTABLE} ${CMAKE_SOURCE_DIR}/tools/strip-debug.pl ${CMAKE_CURRENT_SOURCE_DIR}/index-debug.html > ${CMAKE_CURRENT_BINARY_DIR}/index.html
#COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/index.html.tmp ${CMAKE_CURRENT_BINARY_DIR}/index.html
# clean-up tempfile
#COMMAND ${CMAKE_COMMAND} -E remove -f ${CMAKE_CURRENT_BINARY_DIR}/index.html.tmp
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/index-debug.html
)

# strip debug and generate js files
foreach(js_file ${JS_FILES})
string(REPLACE "-debug" "" stripped_js_file ${js_file})

add_custom_command(
OUTPUT js/${stripped_js_file}
COMMAND ${PERL_EXECUTABLE} ${CMAKE_SOURCE_DIR}/tools/strip-debug.pl ${CMAKE_CURRENT_SOURCE_DIR}/js/${js_file} > ${CMAKE_CURRENT_BINARY_DIR}/js/${stripped_js_file}
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/js/${js_file}
)

set(JS_STRIPPED_FILES ${JS_STRIPPED_FILES} js/${stripped_js_file})
endforeach()

# strip debug and generate css files
foreach(css_file ${CSS_FILES})
string(REPLACE "-debug" "" stripped_css_file ${css_file})
add_custom_command(
OUTPUT css/${stripped_css_file}
COMMAND ${PERL_EXECUTABLE} ${CMAKE_SOURCE_DIR}/tools/strip-debug.pl ${CMAKE_CURRENT_SOURCE_DIR}/css/${css_file} > ${CMAKE_CURRENT_BINARY_DIR}/css/${stripped_css_file}
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/css/${css_file}
)

set(CSS_STRIPPED_FILES ${CSS_STRIPPED_FILES} css/${stripped_css_file})
endforeach()
add_custom_command(
OUTPUT index.html
COMMAND ${PERL_EXECUTABLE} ${CMAKE_SOURCE_DIR}/tools/strip-debug.pl ${CMAKE_CURRENT_SOURCE_DIR}/index-debug.html > ${CMAKE_CURRENT_BINARY_DIR}/index.html
#COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/index.html.tmp ${CMAKE_CURRENT_BINARY_DIR}/index.html
# clean-up tempfile
#COMMAND ${CMAKE_COMMAND} -E remove -f ${CMAKE_CURRENT_BINARY_DIR}/index.html.tmp
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/index-debug.html
)

# strip debug and generate js files
foreach(js_file ${JS_FILES})
string(REPLACE "-debug" "" stripped_js_file ${js_file})

add_custom_command(
OUTPUT js/${stripped_js_file}
COMMAND ${PERL_EXECUTABLE} ${CMAKE_SOURCE_DIR}/tools/strip-debug.pl ${CMAKE_CURRENT_SOURCE_DIR}/js/${js_file} > ${CMAKE_CURRENT_BINARY_DIR}/js/${stripped_js_file}
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/js/${js_file}
)

set(JS_STRIPPED_FILES ${JS_STRIPPED_FILES} js/${stripped_js_file})
endforeach()

# strip debug and generate css files
foreach(css_file ${CSS_FILES})
string(REPLACE "-debug" "" stripped_css_file ${css_file})
add_custom_command(
OUTPUT css/${stripped_css_file}
COMMAND ${PERL_EXECUTABLE} ${CMAKE_SOURCE_DIR}/tools/strip-debug.pl ${CMAKE_CURRENT_SOURCE_DIR}/css/${css_file} > ${CMAKE_CURRENT_BINARY_DIR}/css/${stripped_css_file}
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/css/${css_file}
)

set(CSS_STRIPPED_FILES ${CSS_STRIPPED_FILES} css/${stripped_css_file})
endforeach()

else()
message(WARNING "Perl not found. *-debug.{html|js|css} will only be renamed (not stripped).")

# just copy index-debug.html and change its name to index.html
add_custom_command(
OUTPUT index.html
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/index-debug.html ${CMAKE_CURRENT_BINARY_DIR}/index.html
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/index-debug.html
)

# just copy *-debug.js and change its name to *.js
foreach(js_file ${JS_FILES})
string(REPLACE "-debug" "" stripped_js_file ${js_file})
add_custom_command(
OUTPUT js/${stripped_js_file}
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/js/${js_file} ${CMAKE_CURRENT_BINARY_DIR}/js/${stripped_js_file}
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/js/${js_file}
)
set(JS_STRIPPED_FILES ${JS_STRIPPED_FILES} js/${stripped_js_file})
endforeach()

# just copy *-debug.css and change its name to *.css
foreach(css_file ${CSS_FILES})
string(REPLACE "-debug" "" stripped_css_file ${css_file})
add_custom_command(
OUTPUT css/${stripped_css_file}
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/css/${css_file} ${CMAKE_CURRENT_BINARY_DIR}/css/${stripped_css_file}
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/css/${css_file}
)
set(CSS_STRIPPED_FILES ${CSS_STRIPPED_FILES} css/${stripped_css_file})
endforeach()
message(WARNING "Perl not found. *-debug.{html|js|css} will only be renamed (not stripped).")

# just copy index-debug.html and change its name to index.html
add_custom_command(
OUTPUT index.html
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/index-debug.html ${CMAKE_CURRENT_BINARY_DIR}/index.html
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/index-debug.html
)

# just copy *-debug.js and change its name to *.js
foreach(js_file ${JS_FILES})
string(REPLACE "-debug" "" stripped_js_file ${js_file})
add_custom_command(
OUTPUT js/${stripped_js_file}
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/js/${js_file} ${CMAKE_CURRENT_BINARY_DIR}/js/${stripped_js_file}
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/js/${js_file}
)
set(JS_STRIPPED_FILES ${JS_STRIPPED_FILES} js/${stripped_js_file})
endforeach()

# just copy *-debug.css and change its name to *.css
foreach(css_file ${CSS_FILES})
string(REPLACE "-debug" "" stripped_css_file ${css_file})
add_custom_command(
OUTPUT css/${stripped_css_file}
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/css/${css_file} ${CMAKE_CURRENT_BINARY_DIR}/css/${stripped_css_file}
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/css/${css_file}
)
set(CSS_STRIPPED_FILES ${CSS_STRIPPED_FILES} css/${stripped_css_file})
endforeach()
endif()

# the following section has not been tested yet
# if java found, use yuicompressor.jar to compress the js and css files
if (JAVA_FOUND)
# use the same work-around as above for stdout redirection.
foreach(stripped_js_file ${JS_STRIPPED_FILES})
add_custom_command(
OUTPUT js/${stripped_js_file}
COMMAND ${Java_JAVA_EXECUTABLE} -jar ${CMAKE_SOURCE_DIR}/tools/yuicompressor.jar --type js ${CMAKE_CURRENT_BINARY_DIR}/js/${stripped_js_file} > ${CMAKE_CURRENT_BINARY_DIR}/js/${stripped_js_file}
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/js/${stripped_js_file}
)

endforeach()

foreach(stripped_css_file ${CSS_STRIPPED_FILES})
add_custom_command(
OUTPUT css/${stripped_css_file}
COMMAND ${Java_JAVA_EXECUTABLE} -jar ${CMAKE_SOURCE_DIR}/tools/yuicompressor.jar --type css ${CMAKE_CURRENT_BINARY_DIR}/css/${stripped_css_file} > ${CMAKE_CURRENT_BINARY_DIR}/css/${stripped_css_file}
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/css/${stripped_css_file}
)
endforeach()
# use the same work-around as above for stdout redirection.
foreach(stripped_js_file ${JS_STRIPPED_FILES})
add_custom_command(
OUTPUT js/${stripped_js_file}
COMMAND ${Java_JAVA_EXECUTABLE} -jar ${CMAKE_SOURCE_DIR}/tools/yuicompressor.jar --type js ${CMAKE_CURRENT_BINARY_DIR}/js/${stripped_js_file} > ${CMAKE_CURRENT_BINARY_DIR}/js/${stripped_js_file}
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/js/${stripped_js_file}
)

endforeach()

foreach(stripped_css_file ${CSS_STRIPPED_FILES})
add_custom_command(
OUTPUT css/${stripped_css_file}
COMMAND ${Java_JAVA_EXECUTABLE} -jar ${CMAKE_SOURCE_DIR}/tools/yuicompressor.jar --type css ${CMAKE_CURRENT_BINARY_DIR}/css/${stripped_css_file} > ${CMAKE_CURRENT_BINARY_DIR}/css/${stripped_css_file}
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/css/${stripped_css_file}
)
endforeach()
else()
message(STATUS "Java executable not found. Files will not be compressed.")
message(STATUS "Java executable not found. Files will not be compressed.")
endif()

foreach(img_file ${IMAGE_FILES})
message(${img_file})
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${img_file} ${CMAKE_CURRENT_BINARY_DIR}/${img_file} COPYONLY)
endforeach()

foreach(asset_folder ${ASSET_DIRS})
message(${asset_folder})
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/${asset_folder} DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
endforeach()

SET_SOURCE_FILES_PROPERTIES(${JS_STRIPPED_FILES} PROPERTIES GENERATED TRUE)

SET_SOURCE_FILES_PROPERTIES(${CSS_STRIPPED_FILES} PROPERTIES GENERATED TRUE)

add_custom_target(strip_debug ALL DEPENDS index.html ${JS_STRIPPED_FILES} ${CMAKE_CURRENT_BINARY_DIR}/${CSS_STRIPPED_FILES})
add_custom_target(strip_debug ALL DEPENDS index.html ${JS_STRIPPED_FILES} ${CMAKE_CURRENT_BINARY_DIR}/${CSS_STRIPPED_FILES})
install(
DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
DESTINATION share/wsgate
PATTERN "Makefile" EXCLUDE
PATTERN "CMakeFiles" EXCLUDE
PATTERN "cmake_install.cmake" EXCLUDE)
10 changes: 9 additions & 1 deletion wsgate/wsgateEHS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,15 @@ namespace wsgate{
if (HTML == mt) {
ostringstream oss;

oss << (request->Secure() ? "wss://" : "ws://") << thisHost << "/wsgate";
if (request->Secure() || request->Headers("X-Forwarded-Proto") == "https")
{
oss << "wss://";
}
else
{
oss << "ws://";
}
oss << thisHost << "/wsgate";

replace_all(body, "%WSURI%", oss.str());
replace_all(body, "%JSDEBUG%", (bDynDebug ? "-debug" : ""));
Expand Down