Compare commits
20 Commits
KASM-1910-
...
easy-start
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ba942e102e | ||
|
|
c4cc856e56 | ||
|
|
7d842fe3d2 | ||
|
|
7c4896ac66 | ||
|
|
24336b236a | ||
|
|
8a11d171d5 | ||
|
|
892c285963 | ||
|
|
26cc3845b0 | ||
|
|
f046e3340c | ||
|
|
bd144b71bf | ||
|
|
66d999beaf | ||
|
|
3584d8c3cb | ||
|
|
f8bcfcc493 | ||
|
|
22654f7ab6 | ||
|
|
33327c1159 | ||
|
|
aeec23bd68 | ||
|
|
34a389f714 | ||
|
|
b8fd6a28a4 | ||
|
|
240b1342fd | ||
|
|
640a195e3e |
@@ -1,14 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
set -e
|
|
||||||
|
|
||||||
check_directory_exists() {
|
|
||||||
local remote_dir="$1"
|
|
||||||
|
|
||||||
curl --output /dev/null --silent --head --fail "$remote_dir"
|
|
||||||
}
|
|
||||||
|
|
||||||
S3_URL="https://${S3_BUCKET}.s3.amazonaws.com/${S3_BUILD_DIRECTORY}/";
|
|
||||||
if check_directory_exists "$S3_URL"; then
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
@@ -1,33 +1,16 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
is_kasmvnc_package() {
|
|
||||||
local package="$1";
|
|
||||||
|
|
||||||
echo "$package" | grep -E -q 'kasmvncserver_|rpm'
|
|
||||||
}
|
|
||||||
|
|
||||||
function prepare_upload_filename() {
|
function prepare_upload_filename() {
|
||||||
local package="$1";
|
local package="$1";
|
||||||
|
|
||||||
if ! is_kasmvnc_package "$package"; then
|
|
||||||
export upload_filename="$package"
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
|
|
||||||
.ci/detect_os_arch_package_format "$package" > /tmp/os_arch_package_format;
|
.ci/detect_os_arch_package_format "$package" > /tmp/os_arch_package_format;
|
||||||
source /tmp/os_arch_package_format;
|
source /tmp/os_arch_package_format;
|
||||||
detect_release_branch
|
detect_release_branch
|
||||||
|
|
||||||
detect_revision "$package" "$OS_ARCH"
|
|
||||||
if [ -n "$REVISION" ]; then
|
|
||||||
REVISION="_${REVISION}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -n "$RELEASE_BRANCH" ]; then
|
if [ -n "$RELEASE_BRANCH" ]; then
|
||||||
export upload_filename="kasmvncserver_${PACKAGE_OS}_${RELEASE_VERSION}${REVISION}_${OS_ARCH}.${PACKAGE_FORMAT}";
|
export upload_filename="kasmvncserver_${PACKAGE_OS}_${RELEASE_VERSION}_${OS_ARCH}.${PACKAGE_FORMAT}";
|
||||||
else
|
else
|
||||||
export SANITIZED_BRANCH="$(echo $CI_COMMIT_REF_NAME | sed 's/\//_/g')";
|
export SANITIZED_BRANCH="$(echo $CI_COMMIT_REF_NAME | sed 's/\//_/g')";
|
||||||
export upload_filename="kasmvncserver_${PACKAGE_OS}_${RELEASE_VERSION}_${SANITIZED_BRANCH}_${CI_COMMIT_SHA:0:6}${REVISION}_${OS_ARCH}.${PACKAGE_FORMAT}";
|
export upload_filename="kasmvncserver_${PACKAGE_OS}_${RELEASE_VERSION}_${SANITIZED_BRANCH}_${CI_COMMIT_SHA:0:6}_${OS_ARCH}.${PACKAGE_FORMAT}";
|
||||||
fi
|
fi
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -42,7 +25,6 @@ function upload_to_s3() {
|
|||||||
export BUILD_STATUS="{\"key\":\"doc\", \"state\":\"SUCCESSFUL\", \"name\":\"${upload_filename}\", \"url\":\"${S3_URL}\"}";
|
export BUILD_STATUS="{\"key\":\"doc\", \"state\":\"SUCCESSFUL\", \"name\":\"${upload_filename}\", \"url\":\"${S3_URL}\"}";
|
||||||
curl --request POST --header "PRIVATE-TOKEN:${GITLAB_API_TOKEN}" "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/statuses/${CI_COMMIT_SHA}?state=success&name=build-url&target_url=${S3_URL}";
|
curl --request POST --header "PRIVATE-TOKEN:${GITLAB_API_TOKEN}" "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/statuses/${CI_COMMIT_SHA}?state=success&name=build-url&target_url=${S3_URL}";
|
||||||
};
|
};
|
||||||
|
|
||||||
function prepare_to_run_scripts_and_s3_uploads() {
|
function prepare_to_run_scripts_and_s3_uploads() {
|
||||||
export DEBIAN_FRONTEND=noninteractive;
|
export DEBIAN_FRONTEND=noninteractive;
|
||||||
apt-get update;
|
apt-get update;
|
||||||
@@ -56,16 +38,3 @@ detect_release_branch() {
|
|||||||
export RELEASE_BRANCH=1;
|
export RELEASE_BRANCH=1;
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
detect_revision() {
|
|
||||||
local package="$1"
|
|
||||||
local arch="$2"
|
|
||||||
|
|
||||||
REVISION=
|
|
||||||
|
|
||||||
if ! echo "$package" | grep -q '+'; then
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
|
|
||||||
REVISION=$(echo "$package" | sed "s/_${arch}.\+//" | sed 's/.\++//')
|
|
||||||
}
|
|
||||||
|
|||||||
1
.dockerignore
Normal file
1
.dockerignore
Normal file
@@ -0,0 +1 @@
|
|||||||
|
builder/build
|
||||||
@@ -6,22 +6,11 @@ variables:
|
|||||||
GITLAB_SHARED_DIND_DIR: /builds/$CI_PROJECT_PATH/shared
|
GITLAB_SHARED_DIND_DIR: /builds/$CI_PROJECT_PATH/shared
|
||||||
GIT_SUBMODULE_STRATEGY: normal
|
GIT_SUBMODULE_STRATEGY: normal
|
||||||
GIT_FETCH_EXTRA_FLAGS: --tags
|
GIT_FETCH_EXTRA_FLAGS: --tags
|
||||||
# S3_BUILD_DIRECTORY: kasmvnc/${CI_COMMIT_SHA}
|
|
||||||
S3_BUILD_DIRECTORY: kasmvnc/159d7527955f131e096cf1602b7f9f66cc5d66cb
|
|
||||||
|
|
||||||
stages:
|
stages:
|
||||||
- check_if_build_was_already_uploaded_for_the_commit
|
|
||||||
- build
|
- build
|
||||||
- upload
|
- upload
|
||||||
|
|
||||||
check_if_build_was_already_uploaded_for_the_commit:
|
|
||||||
stage: check_if_build_was_already_uploaded_for_the_commit
|
|
||||||
script:
|
|
||||||
- apk add bash
|
|
||||||
- apk add curl
|
|
||||||
# - TODO: Try uploading and fail if the file .lock exists.
|
|
||||||
- .ci/check_if_build_was_already_uploaded
|
|
||||||
|
|
||||||
.prepare_build: &prepare_build
|
.prepare_build: &prepare_build
|
||||||
- ls -l
|
- ls -l
|
||||||
- pwd
|
- pwd
|
||||||
@@ -45,18 +34,6 @@ build_ubuntu_bionic:
|
|||||||
paths:
|
paths:
|
||||||
- output/
|
- output/
|
||||||
|
|
||||||
build_ubuntu_bionic_libjpeg_turbo:
|
|
||||||
stage: build
|
|
||||||
before_script:
|
|
||||||
- *prepare_build
|
|
||||||
after_script:
|
|
||||||
- *prepare_artfacts
|
|
||||||
script:
|
|
||||||
- bash builder/build-package ubuntu bionic +libjpeg-turbo_latest
|
|
||||||
artifacts:
|
|
||||||
paths:
|
|
||||||
- output/
|
|
||||||
|
|
||||||
build_ubuntu_focal:
|
build_ubuntu_focal:
|
||||||
stage: build
|
stage: build
|
||||||
before_script:
|
before_script:
|
||||||
@@ -123,9 +100,10 @@ upload:
|
|||||||
before_script:
|
before_script:
|
||||||
- . .ci/upload.sh
|
- . .ci/upload.sh
|
||||||
script:
|
script:
|
||||||
|
- export S3_BUILD_DIRECTORY="kasmvnc/${CI_COMMIT_SHA}"
|
||||||
- prepare_to_run_scripts_and_s3_uploads
|
- prepare_to_run_scripts_and_s3_uploads
|
||||||
- export RELEASE_VERSION=$(.ci/next_release_version "$CI_COMMIT_REF_NAME")
|
- export RELEASE_VERSION=$(.ci/next_release_version "$CI_COMMIT_REF_NAME")
|
||||||
- for package in `find output/ -type f -name '*.deb' -or -name '*.rpm'`; do
|
- for package in `find output/ -type f -name 'kasmvncserver_*.deb' -or -name '*.rpm'`; do
|
||||||
prepare_upload_filename "$package";
|
prepare_upload_filename "$package";
|
||||||
echo;
|
echo;
|
||||||
echo "File to upload $upload_filename";
|
echo "File to upload $upload_filename";
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ include(CheckLibraryExists)
|
|||||||
include(CheckTypeSize)
|
include(CheckTypeSize)
|
||||||
include(CheckCSourceCompiles)
|
include(CheckCSourceCompiles)
|
||||||
include(CheckCXXSourceCompiles)
|
include(CheckCXXSourceCompiles)
|
||||||
include(CheckCXXCompilerFlag)
|
|
||||||
include(CheckCSourceRuns)
|
include(CheckCSourceRuns)
|
||||||
|
|
||||||
include(CMakeMacroLibtoolFile)
|
include(CMakeMacroLibtoolFile)
|
||||||
@@ -209,9 +208,6 @@ if(ENABLE_PAM)
|
|||||||
endif()
|
endif()
|
||||||
set(HAVE_PAM ${ENABLE_PAM})
|
set(HAVE_PAM ${ENABLE_PAM})
|
||||||
|
|
||||||
# Check for SSE2
|
|
||||||
check_cxx_compiler_flag(-msse2 COMPILER_SUPPORTS_SSE2)
|
|
||||||
|
|
||||||
# Generate config.h and make sure the source finds it
|
# Generate config.h and make sure the source finds it
|
||||||
configure_file(config.h.in config.h)
|
configure_file(config.h.in config.h)
|
||||||
add_definitions(-DHAVE_CONFIG_H)
|
add_definitions(-DHAVE_CONFIG_H)
|
||||||
|
|||||||
@@ -3,17 +3,8 @@ Docker CE
|
|||||||
|
|
||||||
# Build a deb/rpm package
|
# Build a deb/rpm package
|
||||||
```
|
```
|
||||||
# builder/build-package <os> <os_codename> <build_tag>
|
# builder/build-package <os> <os_codename>
|
||||||
# os_codename is what "lsb_release -c" outputs, e.g. buster, focal.
|
# os_codename is what "lsb_release -c" outputs, e.g. buster, focal.
|
||||||
#
|
|
||||||
# build_tag allows building multiple versions of deb package (rpm not supported)
|
|
||||||
# targeting a single distro release (e.g. Ubuntu Bionic). If build_tag is given,
|
|
||||||
# the package name will include build_tag as part of Debian revision. For
|
|
||||||
# example:
|
|
||||||
# * with build_tag: kasmvncserver_0.9.1~beta-1+libjpeg-turbo-latest_amd64.deb
|
|
||||||
# * without build_tag: kasmvncserver_0.9.1~beta-1_amd64.deb
|
|
||||||
# You need to have .build and .deb.build for the build_tag.
|
|
||||||
#
|
|
||||||
# Packages will be placed under builder/build/
|
# Packages will be placed under builder/build/
|
||||||
|
|
||||||
builder/build-package ubuntu bionic
|
builder/build-package ubuntu bionic
|
||||||
@@ -79,14 +70,3 @@ packages installed with XFCE.
|
|||||||
```
|
```
|
||||||
builder/test-deb-barebones ubuntu focal
|
builder/test-deb-barebones ubuntu focal
|
||||||
```
|
```
|
||||||
# CI development
|
|
||||||
|
|
||||||
S3 upload code is extracted to various files in `.ci`. It's possible to iterate
|
|
||||||
locally by doing stuff like this:
|
|
||||||
|
|
||||||
```
|
|
||||||
bash -c '
|
|
||||||
. .ci/upload.sh;
|
|
||||||
prepare_upload_filename "bionic/kasmvncserver_0.9.1~beta-1+libjpeg-turbo-latest_amd64.deb";
|
|
||||||
echo $upload_filename;'
|
|
||||||
```
|
|
||||||
|
|||||||
@@ -5,17 +5,12 @@ set -e
|
|||||||
cd "$(dirname "$0")/.."
|
cd "$(dirname "$0")/.."
|
||||||
. builder/os_ver_cli.sh
|
. builder/os_ver_cli.sh
|
||||||
|
|
||||||
L_UID=$(id -u) #Ubuntu already has UID env var, but this should work on all Linix systems
|
docker build -t debbuilder_${os}:${os_codename} -f \
|
||||||
L_GID=$(id -g)
|
builder/dockerfile.${os}_${os_codename}.deb.build .
|
||||||
|
|
||||||
builder_image=debbuilder_${os}:${os_codename}${build_tag_for_images}
|
|
||||||
docker build --build-arg KASMVNC_PACKAGE_DIR="builder/build/${os_codename}" \
|
|
||||||
--build-arg L_UID="$L_UID" \
|
|
||||||
-t "$builder_image" -f \
|
|
||||||
builder/dockerfile.${os}_${os_codename}${build_tag}.deb.build .
|
|
||||||
|
|
||||||
deb_output_dir=$(cd .. && echo $PWD)
|
deb_output_dir=$(cd .. && echo $PWD)
|
||||||
docker run --rm -v "$deb_output_dir":/src -e BUILD_TAG="$build_tag" \
|
L_UID=$(id -u) #Ubuntu already has UID env var, but this should work on all Linix systems
|
||||||
--user "$L_UID:$L_GID" \
|
L_GID=$(id -g)
|
||||||
"$builder_image" /bin/bash -c \
|
docker run --rm -v "$deb_output_dir":/src --user $L_UID:$L_GID \
|
||||||
|
debbuilder_${os}:${os_codename} /bin/bash -c \
|
||||||
'/src/*/builder/build-deb-inside-docker'
|
'/src/*/builder/build-deb-inside-docker'
|
||||||
|
|||||||
@@ -2,31 +2,12 @@
|
|||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
prepare_docker_copy_of_debian_dir_and_cd_to_id() {
|
cd "$(dirname "$0")/.."
|
||||||
cd "$(dirname "$0")/.."
|
|
||||||
|
|
||||||
local mounted_src_dir="$PWD"
|
|
||||||
local docker_src_dir="$HOME/src"
|
|
||||||
|
|
||||||
mkdir "$docker_src_dir"
|
|
||||||
cd "$docker_src_dir"
|
|
||||||
cp -a "$mounted_src_dir/debian/" .
|
|
||||||
ln -s "$mounted_src_dir/builder" .
|
|
||||||
}
|
|
||||||
|
|
||||||
prepare_docker_copy_of_debian_dir_and_cd_to_id
|
|
||||||
|
|
||||||
os=$(lsb_release -is | tr '[:upper:]' '[:lower:]')
|
os=$(lsb_release -is | tr '[:upper:]' '[:lower:]')
|
||||||
os_codename=$(lsb_release -cs)
|
os_codename=$(lsb_release -cs)
|
||||||
os_dir="builder/build/${os_codename}"
|
os_dir="builder/build/${os_codename}"
|
||||||
|
|
||||||
if [ "$BUILD_TAG" = "+libjpeg-turbo_latest" ]; then
|
|
||||||
echo 'libjpeg 62 libjpeg-turbo (>= 2.1.1)' > debian/shlibs.local
|
|
||||||
|
|
||||||
debian_revision="$(echo $BUILD_TAG | tr _ -)"
|
|
||||||
sed -i -e "1 s/)/$debian_revision)/" debian/changelog
|
|
||||||
fi
|
|
||||||
|
|
||||||
dpkg-buildpackage -us -uc -b
|
dpkg-buildpackage -us -uc -b
|
||||||
mkdir -p "$os_dir"
|
mkdir -p "$os_dir"
|
||||||
cp ../*.deb "$os_dir"
|
cp ../*.deb "$os_dir"
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ set -e
|
|||||||
|
|
||||||
os="$1"
|
os="$1"
|
||||||
codename="$2"
|
codename="$2"
|
||||||
build_tag="$3"
|
|
||||||
|
|
||||||
detect_package_format() {
|
detect_package_format() {
|
||||||
package_format=rpm
|
package_format=rpm
|
||||||
@@ -13,17 +12,8 @@ detect_package_format() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
warn_build_tag_not_supported_for_rpm_and_exit() {
|
|
||||||
if [[ "$build_tag" && "$package_format" = "rpm" ]]; then
|
|
||||||
echo >&2 "<build_tag> isn't supported for rpm"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
cd "$(dirname "$0")/.."
|
cd "$(dirname "$0")/.."
|
||||||
|
|
||||||
detect_package_format
|
detect_package_format
|
||||||
warn_build_tag_not_supported_for_rpm_and_exit
|
builder/build-tarball "$os" "$codename"
|
||||||
|
builder/build-${package_format} "$os" "$codename"
|
||||||
builder/build-tarball "$os" "$codename" "$build_tag"
|
|
||||||
builder/build-${package_format} "$os" "$codename" "$build_tag"
|
|
||||||
|
|||||||
@@ -2,18 +2,8 @@
|
|||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
warn_build_tag_not_supported_for_rpm_and_exit() {
|
|
||||||
local build_tag="$1"
|
|
||||||
|
|
||||||
if [[ -n "$build_tag" ]]; then
|
|
||||||
echo >&2 "<build_tag> isn't supported for rpm"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
cd "$(dirname "$0")/.."
|
cd "$(dirname "$0")/.."
|
||||||
. builder/os_ver_cli.sh
|
. builder/os_ver_cli.sh
|
||||||
warn_build_tag_not_supported_for_rpm_and_exit "$build_tag"
|
|
||||||
|
|
||||||
docker build -t kasmvnc_rpmbuilder_${os}:${os_codename} -f \
|
docker build -t kasmvnc_rpmbuilder_${os}:${os_codename} -f \
|
||||||
builder/dockerfile.${os}_${os_codename}.rpm.build .
|
builder/dockerfile.${os}_${os_codename}.rpm.build .
|
||||||
|
|||||||
@@ -12,13 +12,6 @@ build_www_dir() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
move_libjpeg_turbo_to_os_specific_dir() {
|
|
||||||
chown $L_UID:$L_GID $shared_with_docker_dir/${os_codename}/*
|
|
||||||
mkdir -p $PWD/builder/build/${os_codename}/
|
|
||||||
mv $shared_with_docker_dir/${os_codename}/libjpeg-turbo*.deb \
|
|
||||||
$PWD/builder/build/${os_codename}/
|
|
||||||
}
|
|
||||||
|
|
||||||
shared_with_docker_dir=${GITLAB_SHARED_DIND_DIR:-/tmp}
|
shared_with_docker_dir=${GITLAB_SHARED_DIND_DIR:-/tmp}
|
||||||
|
|
||||||
cd "$(dirname "$0")/.."
|
cd "$(dirname "$0")/.."
|
||||||
@@ -26,21 +19,13 @@ cd "$(dirname "$0")/.."
|
|||||||
|
|
||||||
build_www_dir
|
build_www_dir
|
||||||
|
|
||||||
builder_image=kasmvncbuilder:$os_codename${build_tag_for_images}
|
docker build -t kasmvncbuilder:$os_codename \
|
||||||
docker build -t "$builder_image" \
|
-f builder/dockerfile.${os}_${os_codename}.build .
|
||||||
-f builder/dockerfile.${os}_${os_codename}${build_tag}.build .
|
|
||||||
mkdir -p builder/build
|
mkdir -p builder/build
|
||||||
docker run -v $shared_with_docker_dir:/build -e BUILD_TAG="$build_tag" \
|
docker run -v $shared_with_docker_dir:/build --rm kasmvncbuilder:$os_codename
|
||||||
--rm "$builder_image"
|
|
||||||
|
|
||||||
L_GID=$(id -g)
|
L_GID=$(id -g)
|
||||||
L_UID=$(id -u)
|
L_UID=$(id -u)
|
||||||
tarball_name="kasmvnc.${os}_${os_codename}.tar.gz"
|
tarball_name="kasmvnc.${os}_${os_codename}.tar.gz"
|
||||||
tarball_name_with_build_tag="kasmvnc.${os}_${os_codename}${build_tag}.tar.gz"
|
|
||||||
chown $L_UID:$L_GID $shared_with_docker_dir/$tarball_name
|
chown $L_UID:$L_GID $shared_with_docker_dir/$tarball_name
|
||||||
mv $shared_with_docker_dir/$tarball_name \
|
mv $shared_with_docker_dir/$tarball_name $PWD/builder/build/
|
||||||
$PWD/builder/build/"$tarball_name_with_build_tag"
|
|
||||||
|
|
||||||
if [ "$build_tag" = "+libjpeg-turbo_latest" ]; then
|
|
||||||
move_libjpeg_turbo_to_os_specific_dir
|
|
||||||
fi
|
|
||||||
|
|||||||
@@ -84,7 +84,3 @@ fi
|
|||||||
make servertarball
|
make servertarball
|
||||||
|
|
||||||
cp kasmvnc*.tar.gz /build/kasmvnc.${KASMVNC_BUILD_OS}_${KASMVNC_BUILD_OS_CODENAME}.tar.gz
|
cp kasmvnc*.tar.gz /build/kasmvnc.${KASMVNC_BUILD_OS}_${KASMVNC_BUILD_OS_CODENAME}.tar.gz
|
||||||
if [ "$BUILD_TAG" = "+libjpeg-turbo_latest" ]; then
|
|
||||||
mkdir -p /build/${KASMVNC_BUILD_OS_CODENAME}/
|
|
||||||
cp /libjpeg-turbo/libjpeg*.deb /build/${KASMVNC_BUILD_OS_CODENAME}/
|
|
||||||
fi
|
|
||||||
|
|||||||
@@ -22,7 +22,8 @@ RUN cd /tmp/libwebp-1.0.2 && \
|
|||||||
|
|
||||||
RUN useradd -m docker && echo "docker:docker" | chpasswd
|
RUN useradd -m docker && echo "docker:docker" | chpasswd
|
||||||
|
|
||||||
COPY --chown=docker:docker . /src/
|
COPY . /src
|
||||||
|
RUN chown -R docker:docker /src
|
||||||
|
|
||||||
USER docker
|
USER docker
|
||||||
ENTRYPOINT ["/src/builder/build.sh"]
|
ENTRYPOINT ["/src/builder/build.sh"]
|
||||||
|
|||||||
@@ -24,7 +24,8 @@ RUN cd /tmp/libwebp-1.0.2 && \
|
|||||||
|
|
||||||
RUN useradd -m docker && echo "docker:docker" | chpasswd && adduser docker sudo
|
RUN useradd -m docker && echo "docker:docker" | chpasswd && adduser docker sudo
|
||||||
|
|
||||||
COPY --chown=docker:docker . /src/
|
COPY . /src
|
||||||
|
RUN chown -R docker:docker /src
|
||||||
|
|
||||||
USER docker
|
USER docker
|
||||||
ENTRYPOINT ["/src/builder/build.sh"]
|
ENTRYPOINT ["/src/builder/build.sh"]
|
||||||
|
|||||||
@@ -9,11 +9,4 @@ RUN apt-get update && \
|
|||||||
COPY ./debian/control /tmp
|
COPY ./debian/control /tmp
|
||||||
RUN apt-get update && echo YYY | mk-build-deps --install --remove /tmp/control
|
RUN apt-get update && echo YYY | mk-build-deps --install --remove /tmp/control
|
||||||
|
|
||||||
ARG L_UID
|
USER 1000
|
||||||
RUN if [ "$L_UID" -eq 0 ]; then \
|
|
||||||
useradd -m docker; \
|
|
||||||
else \
|
|
||||||
useradd -m docker -u $L_UID;\
|
|
||||||
fi
|
|
||||||
|
|
||||||
USER docker
|
|
||||||
|
|||||||
@@ -42,8 +42,8 @@ COPY startup/ $STARTUPDIR
|
|||||||
### START CUSTOM STUFF ####
|
### START CUSTOM STUFF ####
|
||||||
|
|
||||||
ARG KASMVNC_PACKAGE_DIR
|
ARG KASMVNC_PACKAGE_DIR
|
||||||
COPY $KASMVNC_PACKAGE_DIR/kasmvncserver_*.deb /tmp/
|
COPY $KASMVNC_PACKAGE_DIR/kasmvncserver_*.deb /tmp
|
||||||
RUN rm -f /tmp/kasmvncserver_*+*.deb; dpkg -i /tmp/*.deb; apt-get -yf install
|
RUN dpkg -i /tmp/*.deb; apt-get -yf install
|
||||||
|
|
||||||
### END CUSTOM STUFF ###
|
### END CUSTOM STUFF ###
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
FROM debian:buster-slim
|
FROM debian:buster-slim
|
||||||
|
|
||||||
ARG KASMVNC_PACKAGE_DIR
|
ARG KASMVNC_PACKAGE_DIR
|
||||||
COPY $KASMVNC_PACKAGE_DIR/kasmvncserver_*.deb /tmp/
|
COPY $KASMVNC_PACKAGE_DIR/kasmvncserver_*.deb /tmp
|
||||||
RUN rm -f /tmp/kasmvncserver_*+*.deb; apt-get update && dpkg -i /tmp/*.deb; apt-get -yf install
|
RUN apt-get update && dpkg -i /tmp/*.deb; apt-get -yf install
|
||||||
RUN apt-get update && apt-get -y install xterm
|
RUN apt-get update && apt-get -y install xterm
|
||||||
|
|
||||||
COPY startup/deb/kasmvncserver-easy-start /usr/local/bin
|
COPY startup/deb/kasmvncserver-easy-start /usr/local/bin
|
||||||
|
|||||||
@@ -24,7 +24,8 @@ RUN cd /tmp/libwebp-1.0.2 && \
|
|||||||
|
|
||||||
RUN useradd -m docker && echo "docker:docker" | chpasswd && adduser docker sudo
|
RUN useradd -m docker && echo "docker:docker" | chpasswd && adduser docker sudo
|
||||||
|
|
||||||
COPY --chown=docker:docker . /src/
|
COPY . /src
|
||||||
|
RUN chown -R docker:docker /src
|
||||||
|
|
||||||
USER docker
|
USER docker
|
||||||
ENTRYPOINT ["/src/builder/build.sh"]
|
ENTRYPOINT ["/src/builder/build.sh"]
|
||||||
|
|||||||
@@ -9,11 +9,4 @@ RUN apt-get update && \
|
|||||||
COPY ./debian/control /tmp
|
COPY ./debian/control /tmp
|
||||||
RUN apt-get update && echo YYY | mk-build-deps --install --remove /tmp/control
|
RUN apt-get update && echo YYY | mk-build-deps --install --remove /tmp/control
|
||||||
|
|
||||||
ARG L_UID
|
USER 1000
|
||||||
RUN if [ "$L_UID" -eq 0 ]; then \
|
|
||||||
useradd -m docker; \
|
|
||||||
else \
|
|
||||||
useradd -m docker -u $L_UID;\
|
|
||||||
fi
|
|
||||||
|
|
||||||
USER docker
|
|
||||||
|
|||||||
@@ -34,6 +34,14 @@ RUN apt-get purge -y pm-utils xscreensaver*
|
|||||||
RUN apt-get update && apt-get install -y vim less
|
RUN apt-get update && apt-get install -y vim less
|
||||||
RUN apt-get update && apt-get -y install lsb-release
|
RUN apt-get update && apt-get -y install lsb-release
|
||||||
|
|
||||||
|
RUN apt-get update && apt-get install -y task-cinnamon-desktop
|
||||||
|
RUN apt-get update && apt-get install -y task-gnome-desktop
|
||||||
|
RUN mkdir -p /usr/share/man/man1
|
||||||
|
RUN apt-get update && apt-get install -y apt-utils openjdk-11-jre
|
||||||
|
RUN apt-get update && apt-get install -y task-lxde-desktop
|
||||||
|
RUN apt-get update && apt-get install -y task-mate-desktop
|
||||||
|
RUN apt-get update && apt-get install -y task-kde-desktop
|
||||||
|
|
||||||
RUN echo 'source $STARTUPDIR/generate_container_user' >> $HOME/.bashrc
|
RUN echo 'source $STARTUPDIR/generate_container_user' >> $HOME/.bashrc
|
||||||
|
|
||||||
RUN mkdir -p $STARTUPDIR
|
RUN mkdir -p $STARTUPDIR
|
||||||
@@ -42,8 +50,8 @@ COPY startup/ $STARTUPDIR
|
|||||||
### START CUSTOM STUFF ####
|
### START CUSTOM STUFF ####
|
||||||
|
|
||||||
ARG KASMVNC_PACKAGE_DIR
|
ARG KASMVNC_PACKAGE_DIR
|
||||||
COPY $KASMVNC_PACKAGE_DIR/kasmvncserver_*.deb /tmp/
|
COPY $KASMVNC_PACKAGE_DIR/kasmvncserver_*.deb /tmp
|
||||||
RUN rm -f /tmp/kasmvncserver_*+*.deb; dpkg -i /tmp/*.deb; apt-get -yf install
|
RUN dpkg -i /tmp/*.deb; apt-get -yf install
|
||||||
|
|
||||||
### END CUSTOM STUFF ###
|
### END CUSTOM STUFF ###
|
||||||
|
|
||||||
|
|||||||
@@ -31,7 +31,8 @@ RUN cd /tmp/libwebp-1.0.2 && \
|
|||||||
|
|
||||||
RUN useradd -m docker && echo "docker:docker" | chpasswd
|
RUN useradd -m docker && echo "docker:docker" | chpasswd
|
||||||
|
|
||||||
COPY --chown=docker:docker . /src/
|
COPY . /src
|
||||||
|
RUN chown -R docker:docker /src
|
||||||
|
|
||||||
USER docker
|
USER docker
|
||||||
ENTRYPOINT ["/src/builder/build.sh"]
|
ENTRYPOINT ["/src/builder/build.sh"]
|
||||||
|
|||||||
@@ -24,7 +24,8 @@ RUN cd /tmp/libwebp-1.0.2 && \
|
|||||||
|
|
||||||
RUN useradd -m docker && echo "docker:docker" | chpasswd && adduser docker sudo
|
RUN useradd -m docker && echo "docker:docker" | chpasswd && adduser docker sudo
|
||||||
|
|
||||||
COPY --chown=docker:docker . /src/
|
COPY . /src
|
||||||
|
RUN chown -R docker:docker /src
|
||||||
|
|
||||||
USER docker
|
USER docker
|
||||||
ENTRYPOINT ["/src/builder/build.sh"]
|
ENTRYPOINT ["/src/builder/build.sh"]
|
||||||
|
|||||||
@@ -9,11 +9,4 @@ RUN apt-get update && \
|
|||||||
COPY ./debian/control /tmp
|
COPY ./debian/control /tmp
|
||||||
RUN apt-get update && echo YYY | mk-build-deps --install --remove /tmp/control
|
RUN apt-get update && echo YYY | mk-build-deps --install --remove /tmp/control
|
||||||
|
|
||||||
ARG L_UID
|
USER 1000
|
||||||
RUN if [ "$L_UID" -eq 0 ]; then \
|
|
||||||
useradd -m docker; \
|
|
||||||
else \
|
|
||||||
useradd -m docker -u $L_UID;\
|
|
||||||
fi
|
|
||||||
|
|
||||||
USER docker
|
|
||||||
|
|||||||
@@ -42,8 +42,8 @@ COPY startup/ $STARTUPDIR
|
|||||||
### START CUSTOM STUFF ####
|
### START CUSTOM STUFF ####
|
||||||
|
|
||||||
ARG KASMVNC_PACKAGE_DIR
|
ARG KASMVNC_PACKAGE_DIR
|
||||||
COPY $KASMVNC_PACKAGE_DIR/kasmvncserver_*.deb /tmp/
|
COPY $KASMVNC_PACKAGE_DIR/kasmvncserver_*.deb /tmp
|
||||||
RUN rm -f /tmp/kasmvncserver_*+*.deb; dpkg -i /tmp/*.deb; apt-get -yf install
|
RUN dpkg -i /tmp/*.deb; apt-get -yf install
|
||||||
|
|
||||||
### END CUSTOM STUFF ###
|
### END CUSTOM STUFF ###
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,8 @@ RUN cd /tmp/libwebp-1.0.2 && ./configure && make && make install
|
|||||||
|
|
||||||
RUN useradd -m docker && echo "docker:docker" | chpasswd && adduser docker sudo
|
RUN useradd -m docker && echo "docker:docker" | chpasswd && adduser docker sudo
|
||||||
|
|
||||||
COPY --chown=docker:docker . /src/
|
COPY . /src
|
||||||
|
RUN chown -R docker:docker /src
|
||||||
|
|
||||||
|
|
||||||
USER docker
|
USER docker
|
||||||
|
|||||||
@@ -1,39 +0,0 @@
|
|||||||
FROM ubuntu:18.04
|
|
||||||
|
|
||||||
ENV KASMVNC_BUILD_OS ubuntu
|
|
||||||
ENV KASMVNC_BUILD_OS_CODENAME bionic
|
|
||||||
ENV XORG_VER 1.20.10
|
|
||||||
|
|
||||||
RUN sed -i 's$# deb-src$deb-src$' /etc/apt/sources.list
|
|
||||||
|
|
||||||
RUN apt-get update && \
|
|
||||||
apt-get -y install sudo
|
|
||||||
|
|
||||||
RUN apt-get update && apt-get -y build-dep xorg-server libxfont-dev
|
|
||||||
RUN apt-get update && apt-get -y install cmake git libgnutls28-dev vim wget tightvncserver
|
|
||||||
RUN apt-get update && apt-get -y install libpng-dev libtiff-dev libgif-dev libavcodec-dev libssl-dev
|
|
||||||
|
|
||||||
RUN apt-get update && apt-get install -y cmake nasm gcc
|
|
||||||
RUN git clone https://github.com/libjpeg-turbo/libjpeg-turbo.git
|
|
||||||
RUN export MAKEFLAGS=-j`nproc`; cd libjpeg-turbo && cmake -G"Unix Makefiles" && make deb
|
|
||||||
RUN export MAKEFLAGS=-j`nproc`; cd libjpeg-turbo && cmake -DCMAKE_INSTALL_PREFIX=/usr/local -G"Unix Makefiles" && make && make install
|
|
||||||
|
|
||||||
# Additions for webp
|
|
||||||
RUN cd /tmp && wget https://storage.googleapis.com/downloads.webmproject.org/releases/webp/libwebp-1.0.2.tar.gz
|
|
||||||
RUN cd /tmp && tar -xzvf /tmp/libwebp-*
|
|
||||||
RUN cd /tmp/libwebp-1.0.2 && \
|
|
||||||
./configure --enable-static --disable-shared && \
|
|
||||||
make && make install
|
|
||||||
|
|
||||||
# Fix for older required libs
|
|
||||||
#RUN cd /tmp && wget http://launchpadlibrarian.net/347526424/libxfont1-dev_1.5.2-4ubuntu2_amd64.deb && \
|
|
||||||
# wget http://launchpadlibrarian.net/347526425/libxfont1_1.5.2-4ubuntu2_amd64.deb && \
|
|
||||||
# dpkg -i libxfont1_1.5.2-4ubuntu2_amd64.deb && \
|
|
||||||
# dpkg -i libxfont1-dev_1.5.2-4ubuntu2_amd64.deb
|
|
||||||
|
|
||||||
RUN useradd -m docker && echo "docker:docker" | chpasswd && adduser docker sudo
|
|
||||||
|
|
||||||
COPY --chown=docker:docker . /src
|
|
||||||
|
|
||||||
USER docker
|
|
||||||
ENTRYPOINT ["/src/builder/build.sh"]
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
FROM ubuntu:bionic
|
|
||||||
|
|
||||||
RUN apt-get update && \
|
|
||||||
apt-get -y install vim build-essential devscripts equivs
|
|
||||||
|
|
||||||
ARG KASMVNC_PACKAGE_DIR
|
|
||||||
COPY $KASMVNC_PACKAGE_DIR/libjpeg-turbo*deb /tmp
|
|
||||||
RUN apt-get install /tmp/libjpeg-turbo*deb
|
|
||||||
|
|
||||||
# Install build-deps for the package.
|
|
||||||
COPY ./debian/control /tmp
|
|
||||||
RUN apt-get update && echo YYY | mk-build-deps --install --remove /tmp/control
|
|
||||||
|
|
||||||
ENV LD_LIBRARY_PATH="/opt/libjpeg-turbo/lib64/:$LD_LIBRARY_PATH"
|
|
||||||
|
|
||||||
ARG L_UID
|
|
||||||
RUN if [ "$L_UID" -eq 0 ]; then \
|
|
||||||
useradd -m docker; \
|
|
||||||
else \
|
|
||||||
useradd -m docker -u $L_UID;\
|
|
||||||
fi
|
|
||||||
|
|
||||||
USER docker
|
|
||||||
@@ -1,58 +0,0 @@
|
|||||||
FROM ubuntu:bionic
|
|
||||||
|
|
||||||
ENV DISPLAY=:1 \
|
|
||||||
VNC_PORT=8443 \
|
|
||||||
VNC_RESOLUTION=1280x720 \
|
|
||||||
MAX_FRAME_RATE=24 \
|
|
||||||
VNCOPTIONS="-PreferBandwidth -DynamicQualityMin=4 -DynamicQualityMax=7" \
|
|
||||||
HOME=/home/user \
|
|
||||||
TERM=xterm \
|
|
||||||
STARTUPDIR=/dockerstartup \
|
|
||||||
INST_SCRIPTS=/dockerstartup/install \
|
|
||||||
KASM_RX_HOME=/dockerstartup/kasmrx \
|
|
||||||
DEBIAN_FRONTEND=noninteractive \
|
|
||||||
VNC_COL_DEPTH=24 \
|
|
||||||
VNC_RESOLUTION=1280x1024 \
|
|
||||||
VNC_PW=vncpassword \
|
|
||||||
VNC_USER=user \
|
|
||||||
VNC_VIEW_ONLY_PW=vncviewonlypassword \
|
|
||||||
LD_LIBRARY_PATH=/opt/libjpeg-turbo/lib64/:/usr/local/lib/ \
|
|
||||||
OMP_WAIT_POLICY=PASSIVE \
|
|
||||||
SHELL=/bin/bash \
|
|
||||||
SINGLE_APPLICATION=0 \
|
|
||||||
KASMVNC_BUILD_OS=ubuntu \
|
|
||||||
KASMVNC_BUILD_OS_CODENAME=bionic
|
|
||||||
|
|
||||||
EXPOSE $VNC_PORT
|
|
||||||
|
|
||||||
WORKDIR $HOME
|
|
||||||
|
|
||||||
### REQUIRED STUFF ###
|
|
||||||
|
|
||||||
RUN apt-get update && apt-get install -y supervisor xfce4 xfce4-terminal xterm libnss-wrapper gettext wget
|
|
||||||
RUN apt-get purge -y pm-utils xscreensaver*
|
|
||||||
RUN apt-get update && apt-get install -y vim less
|
|
||||||
RUN apt-get update && apt-get -y install lsb-release
|
|
||||||
|
|
||||||
RUN echo 'source $STARTUPDIR/generate_container_user' >> $HOME/.bashrc
|
|
||||||
|
|
||||||
RUN mkdir -p $STARTUPDIR
|
|
||||||
COPY startup/ $STARTUPDIR
|
|
||||||
|
|
||||||
### START CUSTOM STUFF ####
|
|
||||||
|
|
||||||
ARG KASMVNC_PACKAGE_DIR
|
|
||||||
COPY $KASMVNC_PACKAGE_DIR/libjpeg-turbo_*.deb /tmp
|
|
||||||
RUN apt-get install /tmp/libjpeg-turbo*deb
|
|
||||||
|
|
||||||
ARG BUILD_DEBIAN_REVISION
|
|
||||||
COPY $KASMVNC_PACKAGE_DIR/kasmvncserver_*$BUILD_DEBIAN_REVISION*.deb /tmp
|
|
||||||
RUN dpkg -i /tmp/*.deb; apt-get -yf install
|
|
||||||
|
|
||||||
### END CUSTOM STUFF ###
|
|
||||||
|
|
||||||
RUN chown -R 1000:0 $HOME
|
|
||||||
USER 1000:ssl-cert
|
|
||||||
WORKDIR $HOME
|
|
||||||
|
|
||||||
ENTRYPOINT [ "/dockerstartup/vnc_startup.sh" ]
|
|
||||||
@@ -28,7 +28,8 @@ RUN cd /tmp/libwebp-1.0.2 && \
|
|||||||
|
|
||||||
RUN useradd -m docker && echo "docker:docker" | chpasswd && adduser docker sudo
|
RUN useradd -m docker && echo "docker:docker" | chpasswd && adduser docker sudo
|
||||||
|
|
||||||
COPY --chown=docker:docker . /src/
|
COPY . /src
|
||||||
|
RUN chown -R docker:docker /src
|
||||||
|
|
||||||
USER docker
|
USER docker
|
||||||
ENTRYPOINT ["/src/builder/build.sh"]
|
ENTRYPOINT ["/src/builder/build.sh"]
|
||||||
|
|||||||
@@ -7,11 +7,4 @@ RUN apt-get update && \
|
|||||||
COPY ./debian/control /tmp
|
COPY ./debian/control /tmp
|
||||||
RUN apt-get update && echo YYY | mk-build-deps --install --remove /tmp/control
|
RUN apt-get update && echo YYY | mk-build-deps --install --remove /tmp/control
|
||||||
|
|
||||||
ARG L_UID
|
USER 1000
|
||||||
RUN if [ "$L_UID" -eq 0 ]; then \
|
|
||||||
useradd -m docker; \
|
|
||||||
else \
|
|
||||||
useradd -m docker -u $L_UID;\
|
|
||||||
fi
|
|
||||||
|
|
||||||
USER docker
|
|
||||||
|
|||||||
@@ -42,8 +42,8 @@ COPY startup/ $STARTUPDIR
|
|||||||
### START CUSTOM STUFF ####
|
### START CUSTOM STUFF ####
|
||||||
|
|
||||||
ARG KASMVNC_PACKAGE_DIR
|
ARG KASMVNC_PACKAGE_DIR
|
||||||
COPY $KASMVNC_PACKAGE_DIR/kasmvncserver_*.deb /tmp/
|
COPY $KASMVNC_PACKAGE_DIR/kasmvncserver_*.deb /tmp
|
||||||
RUN rm -f /tmp/kasmvncserver_*+*.deb; dpkg -i /tmp/*.deb; apt-get -yf install
|
RUN dpkg -i /tmp/*.deb; apt-get -yf install
|
||||||
|
|
||||||
### END CUSTOM STUFF ###
|
### END CUSTOM STUFF ###
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
FROM ubuntu:focal
|
FROM ubuntu:focal
|
||||||
|
|
||||||
ARG KASMVNC_PACKAGE_DIR
|
ARG KASMVNC_PACKAGE_DIR
|
||||||
COPY $KASMVNC_PACKAGE_DIR/kasmvncserver_*.deb /tmp/
|
COPY $KASMVNC_PACKAGE_DIR/kasmvncserver_*.deb /tmp
|
||||||
RUN rm -f /tmp/kasmvncserver_*+*.deb; apt-get update && dpkg -i /tmp/*.deb; apt-get -yf install
|
RUN apt-get update && dpkg -i /tmp/*.deb; apt-get -yf install
|
||||||
RUN apt-get update && apt-get -y install xterm lsb-release
|
RUN apt-get update && apt-get -y install xterm lsb-release
|
||||||
|
|
||||||
RUN useradd -m foo && addgroup foo ssl-cert
|
RUN useradd -m foo && addgroup foo ssl-cert
|
||||||
|
|||||||
@@ -24,7 +24,8 @@ RUN cd /tmp/libwebp-1.0.2 && \
|
|||||||
|
|
||||||
RUN useradd -m docker && echo "docker:docker" | chpasswd && adduser docker sudo
|
RUN useradd -m docker && echo "docker:docker" | chpasswd && adduser docker sudo
|
||||||
|
|
||||||
COPY --chown=docker:docker . /src/
|
COPY . /src
|
||||||
|
RUN chown -R docker:docker /src
|
||||||
|
|
||||||
USER docker
|
USER docker
|
||||||
ENTRYPOINT ["/src/builder/build.sh"]
|
ENTRYPOINT ["/src/builder/build.sh"]
|
||||||
|
|||||||
@@ -9,11 +9,4 @@ RUN apt-get update && \
|
|||||||
COPY ./debian/control /tmp
|
COPY ./debian/control /tmp
|
||||||
RUN apt-get update && echo YYY | mk-build-deps --install --remove /tmp/control
|
RUN apt-get update && echo YYY | mk-build-deps --install --remove /tmp/control
|
||||||
|
|
||||||
ARG L_UID
|
USER 1000
|
||||||
RUN if [ "$L_UID" -eq 0 ]; then \
|
|
||||||
useradd -m docker; \
|
|
||||||
else \
|
|
||||||
useradd -m docker -u $L_UID;\
|
|
||||||
fi
|
|
||||||
|
|
||||||
USER docker
|
|
||||||
|
|||||||
@@ -42,8 +42,8 @@ COPY startup/ $STARTUPDIR
|
|||||||
### START CUSTOM STUFF ####
|
### START CUSTOM STUFF ####
|
||||||
|
|
||||||
ARG KASMVNC_PACKAGE_DIR
|
ARG KASMVNC_PACKAGE_DIR
|
||||||
COPY $KASMVNC_PACKAGE_DIR/kasmvncserver_*.deb /tmp/
|
COPY $KASMVNC_PACKAGE_DIR/kasmvncserver_*.deb /tmp
|
||||||
RUN rm -f /tmp/kasmvncserver_*+*.deb; dpkg -i /tmp/*.deb; apt-get -yf install
|
RUN dpkg -i /tmp/*.deb; apt-get -yf install
|
||||||
|
|
||||||
RUN mkdir ~/.vnc && echo '/usr/bin/xfce4-session &' >> ~/.vnc/xstartup && \
|
RUN mkdir ~/.vnc && echo '/usr/bin/xfce4-session &' >> ~/.vnc/xstartup && \
|
||||||
chmod +x ~/.vnc/xstartup
|
chmod +x ~/.vnc/xstartup
|
||||||
|
|||||||
@@ -3,11 +3,6 @@ default_os_codename=bionic
|
|||||||
|
|
||||||
os=${1:-$default_os}
|
os=${1:-$default_os}
|
||||||
os_codename=${2:-$default_os_codename}
|
os_codename=${2:-$default_os_codename}
|
||||||
build_tag="${3:-}"
|
|
||||||
if [[ -n "$build_tag" ]]; then
|
|
||||||
build_tag_for_images="_${build_tag#+}"
|
|
||||||
build_debian_revision="$(echo $build_tag | tr _ -)"
|
|
||||||
fi
|
|
||||||
os_image="$os:$os_codename"
|
os_image="$os:$os_codename"
|
||||||
|
|
||||||
echo "Building for $os_image"
|
echo "Building for $os_image"
|
||||||
|
|||||||
@@ -5,25 +5,183 @@ set -e
|
|||||||
display=:10
|
display=:10
|
||||||
interface=0.0.0.0
|
interface=0.0.0.0
|
||||||
cert_group=ssl-cert
|
cert_group=ssl-cert
|
||||||
|
xstartup_script=~/.vnc/xstartup
|
||||||
if [[ "$1" = "--help" ]]; then
|
de_was_selected_file="$HOME/.vnc/.kasmvncserver-easy-start-de-was-selected"
|
||||||
cat >&2 <<-USAGE
|
|
||||||
Usage: `basename $0` [options]
|
|
||||||
-d Debug output
|
|
||||||
-kill Kill vncserver
|
|
||||||
--help show this help
|
|
||||||
USAGE
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ "$1" = "-d" ]]; then
|
|
||||||
log_option="-log *:stderr:100"
|
|
||||||
fi
|
|
||||||
|
|
||||||
action=start
|
action=start
|
||||||
if [[ "$1" = "-kill" ]]; then
|
|
||||||
action=kill
|
manual_xstartup_choice="Manually edit xstartup"
|
||||||
fi
|
declare -A all_desktop_environments=(
|
||||||
|
[Cinnamon]=cinnamon-session
|
||||||
|
[Mate]="XDG_CURRENT_DESKTOP=MATE dbus-launch --exit-with-session mate-session"
|
||||||
|
[LXDE]=lxsession [Lxqt]=startlxqt
|
||||||
|
[KDE]=startkde
|
||||||
|
[Gnome]="XDG_CURRENT_DESKTOP=GNOME dbus-launch --exit-with-session /usr/bin/gnome-session"
|
||||||
|
[XFCE]=xfce4-session)
|
||||||
|
|
||||||
|
readarray -t sorted_desktop_environments < <(for de in "${!all_desktop_environments[@]}"; do echo "$de"; done | sort)
|
||||||
|
|
||||||
|
all_desktop_environments[$manual_xstartup_choice]=""
|
||||||
|
sorted_desktop_environments+=("$manual_xstartup_choice")
|
||||||
|
|
||||||
|
detected_desktop_environments=()
|
||||||
|
declare -A numbered_desktop_environments
|
||||||
|
|
||||||
|
debug() {
|
||||||
|
if [ -z "$debug" ]; then return; fi
|
||||||
|
|
||||||
|
echo "$@"
|
||||||
|
}
|
||||||
|
|
||||||
|
print_detected_desktop_environments() {
|
||||||
|
declare -i i=1
|
||||||
|
|
||||||
|
echo "Please choose Desktop Environment to run:"
|
||||||
|
for detected_de in "${detected_desktop_environments[@]}"; do
|
||||||
|
echo "[$i] $detected_de"
|
||||||
|
numbered_desktop_environments[$i]=$detected_de
|
||||||
|
i+=1
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
detect_desktop_environments() {
|
||||||
|
for de_name in "${sorted_desktop_environments[@]}"; do
|
||||||
|
if [[ "$de_name" = "$manual_xstartup_choice" ]]; then
|
||||||
|
detected_desktop_environments+=("$de_name")
|
||||||
|
continue;
|
||||||
|
fi
|
||||||
|
|
||||||
|
local executable=${all_desktop_environments[$de_name]}
|
||||||
|
executable=($executable)
|
||||||
|
executable=${executable[-1]}
|
||||||
|
|
||||||
|
if detect_desktop_environment "$de_name" "$executable"; then
|
||||||
|
detected_desktop_environments+=("$de_name")
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
ask_user_to_choose_de() {
|
||||||
|
while : ; do
|
||||||
|
print_detected_desktop_environments
|
||||||
|
read -r de_number_to_run
|
||||||
|
de_name_from_number "$de_number_to_run"
|
||||||
|
if [[ -n "$de_name" ]]; then
|
||||||
|
break;
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Incorrect number: $de_number_to_run"
|
||||||
|
echo
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
remember_de_choice() {
|
||||||
|
touch "$de_was_selected_file"
|
||||||
|
}
|
||||||
|
|
||||||
|
de_was_selected_on_previous_run() {
|
||||||
|
[[ -f "$de_was_selected_file" ]]
|
||||||
|
}
|
||||||
|
|
||||||
|
detect_desktop_environment() {
|
||||||
|
local de_name="$1"
|
||||||
|
local executable="$2"
|
||||||
|
|
||||||
|
if command -v "$executable" &>/dev/null; then
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
did_user_forbid_replacing_xstartup() {
|
||||||
|
grep -q -v KasmVNC-safe-to-replace-this-file "$xstartup_script"
|
||||||
|
}
|
||||||
|
|
||||||
|
de_cmd_from_name() {
|
||||||
|
de_cmd=${all_desktop_environments[$de_name]}
|
||||||
|
}
|
||||||
|
|
||||||
|
de_name_from_number() {
|
||||||
|
local de_number_to_run="$1"
|
||||||
|
|
||||||
|
de_name=${numbered_desktop_environments[$de_number_to_run]}
|
||||||
|
}
|
||||||
|
|
||||||
|
warn_xstartup_will_be_overwriten() {
|
||||||
|
echo -n "WARNING: $xstartup_script will be overwritten y/N?"
|
||||||
|
read -r do_overwrite_xstartup
|
||||||
|
if [[ "$do_overwrite_xstartup" = "y" || "$do_overwrite_xstartup" = "Y" ]]; then
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
setup_de_to_run_via_xstartup() {
|
||||||
|
warn_xstartup_will_be_overwriten
|
||||||
|
generate_xstartup "$de_name"
|
||||||
|
}
|
||||||
|
|
||||||
|
generate_xstartup() {
|
||||||
|
local de_name="$1"
|
||||||
|
|
||||||
|
de_cmd_from_name
|
||||||
|
|
||||||
|
cat <<-SCRIPT > "$xstartup_script"
|
||||||
|
#!/bin/sh
|
||||||
|
exec $de_cmd
|
||||||
|
SCRIPT
|
||||||
|
chmod +x "$xstartup_script"
|
||||||
|
}
|
||||||
|
|
||||||
|
enable_debug() {
|
||||||
|
debug=1
|
||||||
|
log_option="-log *:stderr:100"
|
||||||
|
}
|
||||||
|
|
||||||
|
kill_vnc_server() {
|
||||||
|
vncserver -kill $display
|
||||||
|
}
|
||||||
|
|
||||||
|
process_cli_options() {
|
||||||
|
for option in "$@"; do
|
||||||
|
case "$option" in
|
||||||
|
--help)
|
||||||
|
show_help
|
||||||
|
exit
|
||||||
|
;;
|
||||||
|
-d)
|
||||||
|
enable_debug
|
||||||
|
;;
|
||||||
|
-kill)
|
||||||
|
kill_vnc_server
|
||||||
|
exit
|
||||||
|
;;
|
||||||
|
-select-de)
|
||||||
|
action=select-de-and-start
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo >&2 "Unsupported argument: $option"
|
||||||
|
exit 1
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
user_asked_to_select_de() {
|
||||||
|
[[ "$action" = "select-de-and-start" ]]
|
||||||
|
}
|
||||||
|
show_help() {
|
||||||
|
cat >&2 <<-USAGE
|
||||||
|
Usage: `basename $0` [options]
|
||||||
|
-d Debug output
|
||||||
|
-kill Kill vncserver
|
||||||
|
-select-de Select desktop environent to run
|
||||||
|
--help show this help
|
||||||
|
USAGE
|
||||||
|
}
|
||||||
|
|
||||||
|
process_cli_options "$@"
|
||||||
|
|
||||||
if groups | grep -qvw ssl-cert; then
|
if groups | grep -qvw ssl-cert; then
|
||||||
cat <<-EOF
|
cat <<-EOF
|
||||||
@@ -33,9 +191,14 @@ EOF
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "$action" = "kill" ]]; then
|
if user_asked_to_select_de || ! de_was_selected_on_previous_run; then
|
||||||
vncserver -kill $display
|
detect_desktop_environments
|
||||||
exit
|
ask_user_to_choose_de
|
||||||
|
debug "You selected $de_name desktop environment"
|
||||||
|
if [[ "$de_name" != "$manual_xstartup_choice" ]]; then
|
||||||
|
setup_de_to_run_via_xstartup
|
||||||
|
fi
|
||||||
|
remember_de_choice
|
||||||
fi
|
fi
|
||||||
|
|
||||||
vncserver $display -interface $interface
|
vncserver $display -interface $interface
|
||||||
|
|||||||
@@ -61,6 +61,8 @@ kasmvncpasswd -d -u "$VNC_USER-to-delete" $HOME/.kasmpasswd
|
|||||||
chmod 0600 $HOME/.kasmpasswd
|
chmod 0600 $HOME/.kasmpasswd
|
||||||
openssl req -x509 -nodes -days 3650 -newkey rsa:2048 -keyout $HOME/.vnc/self.pem -out $HOME/.vnc/self.pem -subj "/C=US/ST=VA/L=None/O=None/OU=DoFu/CN=kasm/emailAddress=none@none.none"
|
openssl req -x509 -nodes -days 3650 -newkey rsa:2048 -keyout $HOME/.vnc/self.pem -out $HOME/.vnc/self.pem -subj "/C=US/ST=VA/L=None/O=None/OU=DoFu/CN=kasm/emailAddress=none@none.none"
|
||||||
|
|
||||||
|
exec /bin/bash
|
||||||
|
|
||||||
vncserver :1 -interface 0.0.0.0
|
vncserver :1 -interface 0.0.0.0
|
||||||
vncserver -kill :1
|
vncserver -kill :1
|
||||||
|
|
||||||
|
|||||||
@@ -5,12 +5,10 @@ set -e
|
|||||||
cd "$(dirname "$0")"
|
cd "$(dirname "$0")"
|
||||||
. ./os_ver_cli.sh
|
. ./os_ver_cli.sh
|
||||||
|
|
||||||
tester_image=kasmvnctester_${os}:$os_codename${build_tag_for_images}
|
|
||||||
docker build --build-arg KASMVNC_PACKAGE_DIR="build/${os_codename}" \
|
docker build --build-arg KASMVNC_PACKAGE_DIR="build/${os_codename}" \
|
||||||
--build-arg BUILD_DEBIAN_REVISION="$build_debian_revision" \
|
-t kasmvnctester_${os}:$os_codename \
|
||||||
-t "$tester_image" \
|
-f dockerfile.${os}_${os_codename}.deb.test .
|
||||||
-f dockerfile.${os}_${os_codename}${build_tag}.deb.test .
|
docker run -it -v $(realpath ${PWD}/..):/src -p 8443:8443 --rm \
|
||||||
docker run -it -p 443:8443 --rm \
|
|
||||||
-e KASMVNC_VERBOSE_LOGGING=$KASMVNC_VERBOSE_LOGGING \
|
-e KASMVNC_VERBOSE_LOGGING=$KASMVNC_VERBOSE_LOGGING \
|
||||||
-e "VNC_USER=foo" -e "VNC_PW=foobar" \
|
-e "VNC_USER=foo" -e "VNC_PW=foobar" \
|
||||||
"$tester_image"
|
kasmvnctester_${os}:$os_codename
|
||||||
|
|||||||
@@ -24,8 +24,6 @@
|
|||||||
#include <rfb/PixelBuffer.h>
|
#include <rfb/PixelBuffer.h>
|
||||||
#include <rfb/PixelFormat.h>
|
#include <rfb/PixelFormat.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <map>
|
|
||||||
#include <string>
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace network {
|
namespace network {
|
||||||
@@ -36,17 +34,6 @@ namespace network {
|
|||||||
|
|
||||||
// from main thread
|
// from main thread
|
||||||
void mainUpdateScreen(rfb::PixelBuffer *pb);
|
void mainUpdateScreen(rfb::PixelBuffer *pb);
|
||||||
void mainUpdateBottleneckStats(const char userid[], const char stats[]);
|
|
||||||
void mainClearBottleneckStats(const char userid[]);
|
|
||||||
void mainUpdateServerFrameStats(uint8_t changedPerc, uint32_t all,
|
|
||||||
uint32_t jpeg, uint32_t webp, uint32_t analysis,
|
|
||||||
uint32_t jpegarea, uint32_t webparea,
|
|
||||||
uint16_t njpeg, uint16_t nwebp,
|
|
||||||
uint16_t enc, uint16_t scale, uint16_t shot,
|
|
||||||
uint16_t w, uint16_t h);
|
|
||||||
void mainUpdateClientFrameStats(const char userid[], uint32_t render, uint32_t all,
|
|
||||||
uint32_t ping);
|
|
||||||
void mainUpdateUserInfo(const uint8_t ownerConn, const uint8_t numUsers);
|
|
||||||
|
|
||||||
// from network threads
|
// from network threads
|
||||||
uint8_t *netGetScreenshot(uint16_t w, uint16_t h,
|
uint8_t *netGetScreenshot(uint16_t w, uint16_t h,
|
||||||
@@ -55,25 +42,13 @@ namespace network {
|
|||||||
uint8_t netAddUser(const char name[], const char pw[], const bool write);
|
uint8_t netAddUser(const char name[], const char pw[], const bool write);
|
||||||
uint8_t netRemoveUser(const char name[]);
|
uint8_t netRemoveUser(const char name[]);
|
||||||
uint8_t netGiveControlTo(const char name[]);
|
uint8_t netGiveControlTo(const char name[]);
|
||||||
void netGetBottleneckStats(char *buf, uint32_t len);
|
|
||||||
void netGetFrameStats(char *buf, uint32_t len);
|
|
||||||
uint8_t netServerFrameStatsReady();
|
|
||||||
|
|
||||||
enum USER_ACTION {
|
enum USER_ACTION {
|
||||||
//USER_ADD, - handled locally for interactivity
|
//USER_ADD, - handled locally for interactivity
|
||||||
USER_REMOVE,
|
USER_REMOVE,
|
||||||
USER_GIVE_CONTROL,
|
USER_GIVE_CONTROL,
|
||||||
WANT_FRAME_STATS_SERVERONLY,
|
|
||||||
WANT_FRAME_STATS_ALL,
|
|
||||||
WANT_FRAME_STATS_OWNER,
|
|
||||||
WANT_FRAME_STATS_SPECIFIC,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
uint8_t netRequestFrameStats(USER_ACTION what, const char *client);
|
|
||||||
uint8_t netOwnerConnected();
|
|
||||||
uint8_t netNumActiveUsers();
|
|
||||||
uint8_t netGetClientFrameStatsNum();
|
|
||||||
|
|
||||||
struct action_data {
|
struct action_data {
|
||||||
enum USER_ACTION action;
|
enum USER_ACTION action;
|
||||||
kasmpasswd_entry_t data;
|
kasmpasswd_entry_t data;
|
||||||
@@ -93,40 +68,6 @@ namespace network {
|
|||||||
std::vector<uint8_t> cachedJpeg;
|
std::vector<uint8_t> cachedJpeg;
|
||||||
uint16_t cachedW, cachedH;
|
uint16_t cachedW, cachedH;
|
||||||
uint8_t cachedQ;
|
uint8_t cachedQ;
|
||||||
|
|
||||||
std::map<std::string, std::string> bottleneckStats;
|
|
||||||
pthread_mutex_t statMutex;
|
|
||||||
|
|
||||||
struct clientFrameStats_t {
|
|
||||||
uint32_t render;
|
|
||||||
uint32_t all;
|
|
||||||
uint32_t ping;
|
|
||||||
};
|
|
||||||
struct serverFrameStats_t {
|
|
||||||
uint32_t all;
|
|
||||||
uint32_t jpeg;
|
|
||||||
uint32_t webp;
|
|
||||||
uint32_t analysis;
|
|
||||||
uint32_t jpegarea;
|
|
||||||
uint32_t webparea;
|
|
||||||
uint16_t njpeg;
|
|
||||||
uint16_t nwebp;
|
|
||||||
uint16_t enc;
|
|
||||||
uint16_t scale;
|
|
||||||
uint16_t shot;
|
|
||||||
uint16_t w;
|
|
||||||
uint16_t h;
|
|
||||||
uint8_t changedPerc;
|
|
||||||
|
|
||||||
uint8_t inprogress;
|
|
||||||
};
|
|
||||||
std::map<std::string, clientFrameStats_t> clientFrameStats;
|
|
||||||
serverFrameStats_t serverFrameStats;
|
|
||||||
pthread_mutex_t frameStatMutex;
|
|
||||||
|
|
||||||
uint8_t ownerConnected;
|
|
||||||
uint8_t activeUsers;
|
|
||||||
pthread_mutex_t userInfoMutex;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,7 +21,6 @@
|
|||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <network/GetAPI.h>
|
#include <network/GetAPI.h>
|
||||||
#include <rfb/ConnParams.h>
|
#include <rfb/ConnParams.h>
|
||||||
#include <rfb/EncodeManager.h>
|
|
||||||
#include <rfb/LogWriter.h>
|
#include <rfb/LogWriter.h>
|
||||||
#include <rfb/JpegCompressor.h>
|
#include <rfb/JpegCompressor.h>
|
||||||
#include <rfb/xxhash.h>
|
#include <rfb/xxhash.h>
|
||||||
@@ -33,6 +32,10 @@ using namespace rfb;
|
|||||||
|
|
||||||
static LogWriter vlog("GetAPIMessager");
|
static LogWriter vlog("GetAPIMessager");
|
||||||
|
|
||||||
|
PixelBuffer *progressiveBilinearScale(const PixelBuffer *pb,
|
||||||
|
const uint16_t tgtw, const uint16_t tgth,
|
||||||
|
const float tgtdiff);
|
||||||
|
|
||||||
struct TightJPEGConfiguration {
|
struct TightJPEGConfiguration {
|
||||||
int quality;
|
int quality;
|
||||||
int subsampling;
|
int subsampling;
|
||||||
@@ -53,16 +56,10 @@ static const struct TightJPEGConfiguration conf[10] = {
|
|||||||
|
|
||||||
GetAPIMessager::GetAPIMessager(const char *passwdfile_): passwdfile(passwdfile_),
|
GetAPIMessager::GetAPIMessager(const char *passwdfile_): passwdfile(passwdfile_),
|
||||||
screenW(0), screenH(0), screenHash(0),
|
screenW(0), screenH(0), screenHash(0),
|
||||||
cachedW(0), cachedH(0), cachedQ(0),
|
cachedW(0), cachedH(0), cachedQ(0) {
|
||||||
ownerConnected(0), activeUsers(0) {
|
|
||||||
|
|
||||||
pthread_mutex_init(&screenMutex, NULL);
|
pthread_mutex_init(&screenMutex, NULL);
|
||||||
pthread_mutex_init(&userMutex, NULL);
|
pthread_mutex_init(&userMutex, NULL);
|
||||||
pthread_mutex_init(&statMutex, NULL);
|
|
||||||
pthread_mutex_init(&frameStatMutex, NULL);
|
|
||||||
pthread_mutex_init(&userInfoMutex, NULL);
|
|
||||||
|
|
||||||
serverFrameStats.inprogress = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// from main thread
|
// from main thread
|
||||||
@@ -98,78 +95,6 @@ void GetAPIMessager::mainUpdateScreen(rfb::PixelBuffer *pb) {
|
|||||||
pthread_mutex_unlock(&screenMutex);
|
pthread_mutex_unlock(&screenMutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GetAPIMessager::mainUpdateBottleneckStats(const char userid[], const char stats[]) {
|
|
||||||
if (pthread_mutex_trylock(&statMutex))
|
|
||||||
return;
|
|
||||||
|
|
||||||
bottleneckStats[userid] = stats;
|
|
||||||
|
|
||||||
pthread_mutex_unlock(&statMutex);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GetAPIMessager::mainClearBottleneckStats(const char userid[]) {
|
|
||||||
if (pthread_mutex_lock(&statMutex))
|
|
||||||
return;
|
|
||||||
|
|
||||||
bottleneckStats.erase(userid);
|
|
||||||
|
|
||||||
pthread_mutex_unlock(&statMutex);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GetAPIMessager::mainUpdateServerFrameStats(uint8_t changedPerc,
|
|
||||||
uint32_t all, uint32_t jpeg, uint32_t webp, uint32_t analysis,
|
|
||||||
uint32_t jpegarea, uint32_t webparea,
|
|
||||||
uint16_t njpeg, uint16_t nwebp,
|
|
||||||
uint16_t enc, uint16_t scale, uint16_t shot,
|
|
||||||
uint16_t w, uint16_t h) {
|
|
||||||
|
|
||||||
if (pthread_mutex_lock(&frameStatMutex))
|
|
||||||
return;
|
|
||||||
|
|
||||||
serverFrameStats.changedPerc = changedPerc;
|
|
||||||
serverFrameStats.all = all;
|
|
||||||
serverFrameStats.jpeg = jpeg;
|
|
||||||
serverFrameStats.webp = webp;
|
|
||||||
serverFrameStats.analysis = analysis;
|
|
||||||
serverFrameStats.jpegarea = jpegarea;
|
|
||||||
serverFrameStats.webparea = webparea;
|
|
||||||
serverFrameStats.njpeg = njpeg;
|
|
||||||
serverFrameStats.nwebp = nwebp;
|
|
||||||
serverFrameStats.enc = enc;
|
|
||||||
serverFrameStats.scale = scale;
|
|
||||||
serverFrameStats.shot = shot;
|
|
||||||
serverFrameStats.w = w;
|
|
||||||
serverFrameStats.h = h;
|
|
||||||
|
|
||||||
pthread_mutex_unlock(&frameStatMutex);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GetAPIMessager::mainUpdateClientFrameStats(const char userid[], uint32_t render,
|
|
||||||
uint32_t all, uint32_t ping) {
|
|
||||||
|
|
||||||
if (pthread_mutex_lock(&frameStatMutex))
|
|
||||||
return;
|
|
||||||
|
|
||||||
clientFrameStats_t s;
|
|
||||||
s.render = render;
|
|
||||||
s.all = all;
|
|
||||||
s.ping = ping;
|
|
||||||
|
|
||||||
clientFrameStats[userid] = s;
|
|
||||||
|
|
||||||
pthread_mutex_unlock(&frameStatMutex);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GetAPIMessager::mainUpdateUserInfo(const uint8_t ownerConn, const uint8_t numUsers) {
|
|
||||||
if (pthread_mutex_lock(&userInfoMutex))
|
|
||||||
return;
|
|
||||||
|
|
||||||
ownerConnected = ownerConn;
|
|
||||||
activeUsers = numUsers;
|
|
||||||
|
|
||||||
pthread_mutex_unlock(&userInfoMutex);
|
|
||||||
}
|
|
||||||
|
|
||||||
// from network threads
|
// from network threads
|
||||||
uint8_t *GetAPIMessager::netGetScreenshot(uint16_t w, uint16_t h,
|
uint8_t *GetAPIMessager::netGetScreenshot(uint16_t w, uint16_t h,
|
||||||
const uint8_t q, const bool dedup,
|
const uint8_t q, const bool dedup,
|
||||||
@@ -361,271 +286,3 @@ uint8_t GetAPIMessager::netGiveControlTo(const char name[]) {
|
|||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GetAPIMessager::netGetBottleneckStats(char *buf, uint32_t len) {
|
|
||||||
/*
|
|
||||||
{
|
|
||||||
"username.1": {
|
|
||||||
"192.168.100.2:14908": [ 100, 100, 100, 100 ],
|
|
||||||
"192.168.100.3:14918": [ 100, 100, 100, 100 ]
|
|
||||||
},
|
|
||||||
"username.2": {
|
|
||||||
"192.168.100.5:14904": [ 100, 100, 100, 100 ]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
std::map<std::string, std::string>::const_iterator it;
|
|
||||||
const char *prev = NULL;
|
|
||||||
FILE *f;
|
|
||||||
|
|
||||||
if (pthread_mutex_lock(&statMutex)) {
|
|
||||||
buf[0] = 0;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Conservative estimate
|
|
||||||
if (len < bottleneckStats.size() * 60) {
|
|
||||||
buf[0] = 0;
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
f = fmemopen(buf, len, "w");
|
|
||||||
|
|
||||||
fprintf(f, "{\n");
|
|
||||||
|
|
||||||
for (it = bottleneckStats.begin(); it != bottleneckStats.end(); it++) {
|
|
||||||
// user@127.0.0.1_1627311208.791752::websocket
|
|
||||||
const char *id = it->first.c_str();
|
|
||||||
const char *data = it->second.c_str();
|
|
||||||
|
|
||||||
const char *at = strchr(id, '@');
|
|
||||||
if (!at)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
const unsigned userlen = at - id;
|
|
||||||
if (prev && !strncmp(prev, id, userlen)) {
|
|
||||||
// Same user
|
|
||||||
fprintf(f, ",\n\t\t\"%s\": %s", at + 1, data);
|
|
||||||
} else {
|
|
||||||
// New one
|
|
||||||
if (prev) {
|
|
||||||
fprintf(f, "\n\t},\n");
|
|
||||||
}
|
|
||||||
fprintf(f, "\t\"%.*s\": {\n", userlen, id);
|
|
||||||
fprintf(f, "\t\t\"%s\": %s", at + 1, data);
|
|
||||||
}
|
|
||||||
|
|
||||||
prev = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!bottleneckStats.size())
|
|
||||||
fprintf(f, "}\n");
|
|
||||||
else
|
|
||||||
fprintf(f, "\n\t}\n}\n");
|
|
||||||
|
|
||||||
fclose(f);
|
|
||||||
|
|
||||||
out:
|
|
||||||
pthread_mutex_unlock(&statMutex);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GetAPIMessager::netGetFrameStats(char *buf, uint32_t len) {
|
|
||||||
/*
|
|
||||||
{
|
|
||||||
"frame" : {
|
|
||||||
"resx": 1024,
|
|
||||||
"resy": 1280,
|
|
||||||
"changed": 75,
|
|
||||||
"server_time": 23
|
|
||||||
},
|
|
||||||
"server_side" : [
|
|
||||||
{ "process_name": "Analysis", "time": 20 },
|
|
||||||
{ "process_name": "TightWEBPEncoder", "time": 20, "count": 64, "area": 12 },
|
|
||||||
{ "process_name": "TightJPEGEncoder", "time": 20, "count": 64, "area": 12 }
|
|
||||||
],
|
|
||||||
"client_side" : [
|
|
||||||
{
|
|
||||||
"client": "123.1.2.1:1211",
|
|
||||||
"client_time": 20,
|
|
||||||
"ping": 20,
|
|
||||||
"processes" : [
|
|
||||||
{ "process_name": "scanRenderQ", "time": 20 }
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
std::map<std::string, clientFrameStats_t>::const_iterator it;
|
|
||||||
unsigned i = 0;
|
|
||||||
FILE *f;
|
|
||||||
|
|
||||||
if (pthread_mutex_lock(&frameStatMutex)) {
|
|
||||||
buf[0] = 0;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const unsigned num = clientFrameStats.size();
|
|
||||||
|
|
||||||
// Conservative estimate
|
|
||||||
if (len < 1024) {
|
|
||||||
buf[0] = 0;
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
f = fmemopen(buf, len, "w");
|
|
||||||
|
|
||||||
fprintf(f, "{\n");
|
|
||||||
|
|
||||||
fprintf(f, "\t\"frame\" : {\n"
|
|
||||||
"\t\t\"resx\": %u,\n"
|
|
||||||
"\t\t\"resy\": %u,\n"
|
|
||||||
"\t\t\"changed\": %u,\n"
|
|
||||||
"\t\t\"server_time\": %u\n"
|
|
||||||
"\t},\n",
|
|
||||||
serverFrameStats.w,
|
|
||||||
serverFrameStats.h,
|
|
||||||
serverFrameStats.changedPerc,
|
|
||||||
serverFrameStats.all);
|
|
||||||
|
|
||||||
fprintf(f, "\t\"server_side\" : [\n"
|
|
||||||
"\t\t{ \"process_name\": \"Analysis\", \"time\": %u },\n"
|
|
||||||
"\t\t{ \"process_name\": \"Screenshot\", \"time\": %u },\n"
|
|
||||||
"\t\t{ \"process_name\": \"Encoding_total\", \"time\": %u, \"videoscaling\": %u },\n"
|
|
||||||
"\t\t{ \"process_name\": \"TightJPEGEncoder\", \"time\": %u, \"count\": %u, \"area\": %u },\n"
|
|
||||||
"\t\t{ \"process_name\": \"TightWEBPEncoder\", \"time\": %u, \"count\": %u, \"area\": %u }\n"
|
|
||||||
"\t],\n",
|
|
||||||
serverFrameStats.analysis,
|
|
||||||
serverFrameStats.shot,
|
|
||||||
serverFrameStats.enc,
|
|
||||||
serverFrameStats.scale,
|
|
||||||
serverFrameStats.jpeg,
|
|
||||||
serverFrameStats.njpeg,
|
|
||||||
serverFrameStats.jpegarea,
|
|
||||||
serverFrameStats.webp,
|
|
||||||
serverFrameStats.nwebp,
|
|
||||||
serverFrameStats.webparea);
|
|
||||||
|
|
||||||
fprintf(f, "\t\"client_side\" : [\n");
|
|
||||||
|
|
||||||
for (it = clientFrameStats.begin(); it != clientFrameStats.end(); it++, i++) {
|
|
||||||
const char *id = it->first.c_str();
|
|
||||||
const clientFrameStats_t &s = it->second;
|
|
||||||
|
|
||||||
fprintf(f, "\t\t\{\n"
|
|
||||||
"\t\t\t\"client\": \"%s\",\n"
|
|
||||||
"\t\t\t\"client_time\": %u,\n"
|
|
||||||
"\t\t\t\"ping\": %u,\n"
|
|
||||||
"\t\t\t\"processes\" : [\n"
|
|
||||||
"\t\t\t\t{ \"process_name\": \"scanRenderQ\", \"time\": %u }\n"
|
|
||||||
"\t\t\t]\n"
|
|
||||||
"\t\t}",
|
|
||||||
id,
|
|
||||||
s.all,
|
|
||||||
s.ping,
|
|
||||||
s.render);
|
|
||||||
|
|
||||||
if (i == num - 1)
|
|
||||||
fprintf(f, "\n");
|
|
||||||
else
|
|
||||||
fprintf(f, ",\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
fprintf(f, "\t]\n}\n");
|
|
||||||
|
|
||||||
fclose(f);
|
|
||||||
|
|
||||||
serverFrameStats.inprogress = 0;
|
|
||||||
|
|
||||||
out:
|
|
||||||
pthread_mutex_unlock(&frameStatMutex);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t GetAPIMessager::netRequestFrameStats(USER_ACTION what, const char *client) {
|
|
||||||
// Return 1 for success
|
|
||||||
action_data act;
|
|
||||||
act.action = what;
|
|
||||||
if (client) {
|
|
||||||
strncpy(act.data.password, client, PASSWORD_LEN);
|
|
||||||
act.data.password[PASSWORD_LEN - 1] = '\0';
|
|
||||||
}
|
|
||||||
|
|
||||||
// In progress already?
|
|
||||||
bool fail = false;
|
|
||||||
if (pthread_mutex_lock(&frameStatMutex))
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
if (serverFrameStats.inprogress) {
|
|
||||||
fail = true;
|
|
||||||
vlog.error("Frame stats request already in progress, refusing another");
|
|
||||||
} else {
|
|
||||||
clientFrameStats.clear();
|
|
||||||
memset(&serverFrameStats, 0, sizeof(serverFrameStats_t));
|
|
||||||
serverFrameStats.inprogress = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
pthread_mutex_unlock(&frameStatMutex);
|
|
||||||
if (fail)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
// Send it in
|
|
||||||
if (pthread_mutex_lock(&userMutex))
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
actionQueue.push_back(act);
|
|
||||||
|
|
||||||
pthread_mutex_unlock(&userMutex);
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t GetAPIMessager::netOwnerConnected() {
|
|
||||||
uint8_t ret;
|
|
||||||
|
|
||||||
if (pthread_mutex_lock(&userInfoMutex))
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
ret = ownerConnected;
|
|
||||||
|
|
||||||
pthread_mutex_unlock(&userInfoMutex);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t GetAPIMessager::netNumActiveUsers() {
|
|
||||||
uint8_t ret;
|
|
||||||
|
|
||||||
if (pthread_mutex_lock(&userInfoMutex))
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
ret = activeUsers;
|
|
||||||
|
|
||||||
pthread_mutex_unlock(&userInfoMutex);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t GetAPIMessager::netGetClientFrameStatsNum() {
|
|
||||||
uint8_t ret;
|
|
||||||
|
|
||||||
if (pthread_mutex_lock(&frameStatMutex))
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
ret = clientFrameStats.size();
|
|
||||||
|
|
||||||
pthread_mutex_unlock(&frameStatMutex);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t GetAPIMessager::netServerFrameStatsReady() {
|
|
||||||
uint8_t ret;
|
|
||||||
|
|
||||||
if (pthread_mutex_lock(&frameStatMutex))
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
ret = serverFrameStats.w != 0;
|
|
||||||
|
|
||||||
pthread_mutex_unlock(&frameStatMutex);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -40,8 +40,6 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include <wordexp.h>
|
#include <wordexp.h>
|
||||||
#include <sys/types.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include "websocket.h"
|
#include "websocket.h"
|
||||||
|
|
||||||
#include <network/GetAPI.h>
|
#include <network/GetAPI.h>
|
||||||
@@ -461,67 +459,6 @@ static uint8_t givecontrolCb(void *messager, const char name[])
|
|||||||
return msgr->netGiveControlTo(name);
|
return msgr->netGiveControlTo(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void bottleneckStatsCb(void *messager, char *buf, uint32_t len)
|
|
||||||
{
|
|
||||||
GetAPIMessager *msgr = (GetAPIMessager *) messager;
|
|
||||||
msgr->netGetBottleneckStats(buf, len);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void frameStatsCb(void *messager, char *buf, uint32_t len)
|
|
||||||
{
|
|
||||||
GetAPIMessager *msgr = (GetAPIMessager *) messager;
|
|
||||||
msgr->netGetFrameStats(buf, len);
|
|
||||||
}
|
|
||||||
|
|
||||||
static uint8_t requestFrameStatsNoneCb(void *messager)
|
|
||||||
{
|
|
||||||
GetAPIMessager *msgr = (GetAPIMessager *) messager;
|
|
||||||
return msgr->netRequestFrameStats(GetAPIMessager::WANT_FRAME_STATS_SERVERONLY, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
static uint8_t requestFrameStatsOwnerCb(void *messager)
|
|
||||||
{
|
|
||||||
GetAPIMessager *msgr = (GetAPIMessager *) messager;
|
|
||||||
return msgr->netRequestFrameStats(GetAPIMessager::WANT_FRAME_STATS_OWNER, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
static uint8_t requestFrameStatsAllCb(void *messager)
|
|
||||||
{
|
|
||||||
GetAPIMessager *msgr = (GetAPIMessager *) messager;
|
|
||||||
return msgr->netRequestFrameStats(GetAPIMessager::WANT_FRAME_STATS_ALL, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
static uint8_t requestFrameStatsOneCb(void *messager, const char *client)
|
|
||||||
{
|
|
||||||
GetAPIMessager *msgr = (GetAPIMessager *) messager;
|
|
||||||
return msgr->netRequestFrameStats(GetAPIMessager::WANT_FRAME_STATS_SPECIFIC, client);
|
|
||||||
}
|
|
||||||
|
|
||||||
static uint8_t ownerConnectedCb(void *messager)
|
|
||||||
{
|
|
||||||
GetAPIMessager *msgr = (GetAPIMessager *) messager;
|
|
||||||
return msgr->netOwnerConnected();
|
|
||||||
}
|
|
||||||
|
|
||||||
static uint8_t numActiveUsersCb(void *messager)
|
|
||||||
{
|
|
||||||
GetAPIMessager *msgr = (GetAPIMessager *) messager;
|
|
||||||
return msgr->netNumActiveUsers();
|
|
||||||
}
|
|
||||||
|
|
||||||
static uint8_t getClientFrameStatsNumCb(void *messager)
|
|
||||||
{
|
|
||||||
GetAPIMessager *msgr = (GetAPIMessager *) messager;
|
|
||||||
return msgr->netGetClientFrameStatsNum();
|
|
||||||
}
|
|
||||||
|
|
||||||
static uint8_t serverFrameStatsReadyCb(void *messager)
|
|
||||||
{
|
|
||||||
GetAPIMessager *msgr = (GetAPIMessager *) messager;
|
|
||||||
return msgr->netServerFrameStatsReady();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
WebsocketListener::WebsocketListener(const struct sockaddr *listenaddr,
|
WebsocketListener::WebsocketListener(const struct sockaddr *listenaddr,
|
||||||
socklen_t listenaddrlen,
|
socklen_t listenaddrlen,
|
||||||
bool sslonly, const char *cert, const char *certkey,
|
bool sslonly, const char *cert, const char *certkey,
|
||||||
@@ -566,7 +503,7 @@ WebsocketListener::WebsocketListener(const struct sockaddr *listenaddr,
|
|||||||
if (bind(sock, &sa.u.sa, listenaddrlen) == -1) {
|
if (bind(sock, &sa.u.sa, listenaddrlen) == -1) {
|
||||||
int e = errorNumber;
|
int e = errorNumber;
|
||||||
closesocket(sock);
|
closesocket(sock);
|
||||||
throw SocketException("failed to bind socket, is someone else on our -websocketPort?", e);
|
throw SocketException("failed to bind socket", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
listen(sock); // sets the internal fd
|
listen(sock); // sets the internal fd
|
||||||
@@ -576,16 +513,13 @@ WebsocketListener::WebsocketListener(const struct sockaddr *listenaddr,
|
|||||||
//
|
//
|
||||||
internalSocket = socket(AF_UNIX, SOCK_STREAM, 0);
|
internalSocket = socket(AF_UNIX, SOCK_STREAM, 0);
|
||||||
|
|
||||||
char sockname[32];
|
|
||||||
sprintf(sockname, ".KasmVNCSock%u", getpid());
|
|
||||||
|
|
||||||
struct sockaddr_un addr;
|
struct sockaddr_un addr;
|
||||||
addr.sun_family = AF_UNIX;
|
addr.sun_family = AF_UNIX;
|
||||||
strcpy(addr.sun_path, sockname);
|
strcpy(addr.sun_path, ".KasmVNCSock");
|
||||||
addr.sun_path[0] = '\0';
|
addr.sun_path[0] = '\0';
|
||||||
|
|
||||||
if (bind(internalSocket, (struct sockaddr *) &addr,
|
if (bind(internalSocket, (struct sockaddr *) &addr,
|
||||||
sizeof(sa_family_t) + strlen(sockname))) {
|
sizeof(sa_family_t) + sizeof(".KasmVNCSock"))) {
|
||||||
throw SocketException("failed to bind socket", errorNumber);
|
throw SocketException("failed to bind socket", errorNumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -614,18 +548,6 @@ WebsocketListener::WebsocketListener(const struct sockaddr *listenaddr,
|
|||||||
settings.adduserCb = adduserCb;
|
settings.adduserCb = adduserCb;
|
||||||
settings.removeCb = removeCb;
|
settings.removeCb = removeCb;
|
||||||
settings.givecontrolCb = givecontrolCb;
|
settings.givecontrolCb = givecontrolCb;
|
||||||
settings.bottleneckStatsCb = bottleneckStatsCb;
|
|
||||||
settings.frameStatsCb = frameStatsCb;
|
|
||||||
|
|
||||||
settings.requestFrameStatsNoneCb = requestFrameStatsNoneCb;
|
|
||||||
settings.requestFrameStatsOwnerCb = requestFrameStatsOwnerCb;
|
|
||||||
settings.requestFrameStatsAllCb = requestFrameStatsAllCb;
|
|
||||||
settings.requestFrameStatsOneCb = requestFrameStatsOneCb;
|
|
||||||
|
|
||||||
settings.ownerConnectedCb = ownerConnectedCb;
|
|
||||||
settings.numActiveUsersCb = numActiveUsersCb;
|
|
||||||
settings.getClientFrameStatsNumCb = getClientFrameStatsNumCb;
|
|
||||||
settings.serverFrameStatsReadyCb = serverFrameStatsReadyCb;
|
|
||||||
|
|
||||||
pthread_t tid;
|
pthread_t tid;
|
||||||
pthread_create(&tid, NULL, start_server, NULL);
|
pthread_create(&tid, NULL, start_server, NULL);
|
||||||
|
|||||||
@@ -566,7 +566,7 @@ int parse_handshake(ws_ctx_t *ws_ctx, char *handshake) {
|
|||||||
headers->key3[0] = '\0';
|
headers->key3[0] = '\0';
|
||||||
|
|
||||||
if ((strlen(handshake) < 92) || (bcmp(handshake, "GET ", 4) != 0) ||
|
if ((strlen(handshake) < 92) || (bcmp(handshake, "GET ", 4) != 0) ||
|
||||||
(!strcasestr(handshake, "Upgrade: websocket"))) {
|
(!strstr(handshake, "Upgrade: websocket"))) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
start = handshake+4;
|
start = handshake+4;
|
||||||
@@ -583,11 +583,11 @@ int parse_handshake(ws_ctx_t *ws_ctx, char *handshake) {
|
|||||||
headers->host[end-start] = '\0';
|
headers->host[end-start] = '\0';
|
||||||
|
|
||||||
headers->origin[0] = '\0';
|
headers->origin[0] = '\0';
|
||||||
start = strcasestr(handshake, "\r\nOrigin: ");
|
start = strstr(handshake, "\r\nOrigin: ");
|
||||||
if (start) {
|
if (start) {
|
||||||
start += 10;
|
start += 10;
|
||||||
} else {
|
} else {
|
||||||
start = strcasestr(handshake, "\r\nSec-WebSocket-Origin: ");
|
start = strstr(handshake, "\r\nSec-WebSocket-Origin: ");
|
||||||
if (!start) { return 0; }
|
if (!start) { return 0; }
|
||||||
start += 24;
|
start += 24;
|
||||||
}
|
}
|
||||||
@@ -595,7 +595,7 @@ int parse_handshake(ws_ctx_t *ws_ctx, char *handshake) {
|
|||||||
strncpy(headers->origin, start, end-start);
|
strncpy(headers->origin, start, end-start);
|
||||||
headers->origin[end-start] = '\0';
|
headers->origin[end-start] = '\0';
|
||||||
|
|
||||||
start = strcasestr(handshake, "\r\nSec-WebSocket-Version: ");
|
start = strstr(handshake, "\r\nSec-WebSocket-Version: ");
|
||||||
if (start) {
|
if (start) {
|
||||||
// HyBi/RFC 6455
|
// HyBi/RFC 6455
|
||||||
start += 25;
|
start += 25;
|
||||||
@@ -605,7 +605,7 @@ int parse_handshake(ws_ctx_t *ws_ctx, char *handshake) {
|
|||||||
ws_ctx->hixie = 0;
|
ws_ctx->hixie = 0;
|
||||||
ws_ctx->hybi = strtol(headers->version, NULL, 10);
|
ws_ctx->hybi = strtol(headers->version, NULL, 10);
|
||||||
|
|
||||||
start = strcasestr(handshake, "\r\nSec-WebSocket-Key: ");
|
start = strstr(handshake, "\r\nSec-WebSocket-Key: ");
|
||||||
if (!start) { return 0; }
|
if (!start) { return 0; }
|
||||||
start += 21;
|
start += 21;
|
||||||
end = strstr(start, "\r\n");
|
end = strstr(start, "\r\n");
|
||||||
@@ -619,7 +619,7 @@ int parse_handshake(ws_ctx_t *ws_ctx, char *handshake) {
|
|||||||
strncpy(headers->connection, start, end-start);
|
strncpy(headers->connection, start, end-start);
|
||||||
headers->connection[end-start] = '\0';
|
headers->connection[end-start] = '\0';
|
||||||
|
|
||||||
start = strcasestr(handshake, "\r\nSec-WebSocket-Protocol: ");
|
start = strstr(handshake, "\r\nSec-WebSocket-Protocol: ");
|
||||||
if (!start) { return 0; }
|
if (!start) { return 0; }
|
||||||
start += 26;
|
start += 26;
|
||||||
end = strstr(start, "\r\n");
|
end = strstr(start, "\r\n");
|
||||||
@@ -637,14 +637,14 @@ int parse_handshake(ws_ctx_t *ws_ctx, char *handshake) {
|
|||||||
strncpy(headers->key3, start, 8);
|
strncpy(headers->key3, start, 8);
|
||||||
headers->key3[8] = '\0';
|
headers->key3[8] = '\0';
|
||||||
|
|
||||||
start = strcasestr(handshake, "\r\nSec-WebSocket-Key1: ");
|
start = strstr(handshake, "\r\nSec-WebSocket-Key1: ");
|
||||||
if (!start) { return 0; }
|
if (!start) { return 0; }
|
||||||
start += 22;
|
start += 22;
|
||||||
end = strstr(start, "\r\n");
|
end = strstr(start, "\r\n");
|
||||||
strncpy(headers->key1, start, end-start);
|
strncpy(headers->key1, start, end-start);
|
||||||
headers->key1[end-start] = '\0';
|
headers->key1[end-start] = '\0';
|
||||||
|
|
||||||
start = strcasestr(handshake, "\r\nSec-WebSocket-Key2: ");
|
start = strstr(handshake, "\r\nSec-WebSocket-Key2: ");
|
||||||
if (!start) { return 0; }
|
if (!start) { return 0; }
|
||||||
start += 22;
|
start += 22;
|
||||||
end = strstr(start, "\r\n");
|
end = strstr(start, "\r\n");
|
||||||
@@ -1074,89 +1074,6 @@ static uint8_t ownerapi(ws_ctx_t *ws_ctx, const char *in) {
|
|||||||
|
|
||||||
wserr("Passed give_control request to main thread\n");
|
wserr("Passed give_control request to main thread\n");
|
||||||
ret = 1;
|
ret = 1;
|
||||||
} else entry("/api/get_bottleneck_stats") {
|
|
||||||
char statbuf[4096];
|
|
||||||
settings.bottleneckStatsCb(settings.messager, statbuf, 4096);
|
|
||||||
|
|
||||||
sprintf(buf, "HTTP/1.1 200 OK\r\n"
|
|
||||||
"Server: KasmVNC/4.0\r\n"
|
|
||||||
"Connection: close\r\n"
|
|
||||||
"Content-type: text/plain\r\n"
|
|
||||||
"Content-length: %lu\r\n"
|
|
||||||
"\r\n", strlen(statbuf));
|
|
||||||
ws_send(ws_ctx, buf, strlen(buf));
|
|
||||||
ws_send(ws_ctx, statbuf, strlen(statbuf));
|
|
||||||
|
|
||||||
wserr("Sent bottleneck stats to API caller\n");
|
|
||||||
ret = 1;
|
|
||||||
} else entry("/api/get_frame_stats") {
|
|
||||||
char statbuf[4096], decname[1024];
|
|
||||||
unsigned waitfor;
|
|
||||||
|
|
||||||
param = parse_get(args, "client", &len);
|
|
||||||
if (len) {
|
|
||||||
memcpy(buf, param, len);
|
|
||||||
buf[len] = '\0';
|
|
||||||
percent_decode(buf, decname);
|
|
||||||
} else {
|
|
||||||
wserr("client param required\n");
|
|
||||||
goto nope;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!decname[0])
|
|
||||||
goto nope;
|
|
||||||
|
|
||||||
if (!strcmp(decname, "none")) {
|
|
||||||
waitfor = 0;
|
|
||||||
if (!settings.requestFrameStatsNoneCb(settings.messager))
|
|
||||||
goto nope;
|
|
||||||
} else if (!strcmp(decname, "auto")) {
|
|
||||||
waitfor = settings.ownerConnectedCb(settings.messager);
|
|
||||||
if (!waitfor) {
|
|
||||||
if (!settings.requestFrameStatsNoneCb(settings.messager))
|
|
||||||
goto nope;
|
|
||||||
} else {
|
|
||||||
if (!settings.requestFrameStatsOwnerCb(settings.messager))
|
|
||||||
goto nope;
|
|
||||||
}
|
|
||||||
} else if (!strcmp(decname, "all")) {
|
|
||||||
waitfor = settings.numActiveUsersCb(settings.messager);
|
|
||||||
if (!settings.requestFrameStatsAllCb(settings.messager))
|
|
||||||
goto nope;
|
|
||||||
} else {
|
|
||||||
waitfor = 1;
|
|
||||||
if (!settings.requestFrameStatsOneCb(settings.messager, decname))
|
|
||||||
goto nope;
|
|
||||||
}
|
|
||||||
|
|
||||||
while (1) {
|
|
||||||
usleep(10 * 1000);
|
|
||||||
if (settings.serverFrameStatsReadyCb(settings.messager))
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (waitfor) {
|
|
||||||
unsigned waits;
|
|
||||||
for (waits = 0; waits < 20; waits++) { // wait up to 2s
|
|
||||||
if (settings.getClientFrameStatsNumCb(settings.messager) >= waitfor)
|
|
||||||
break;
|
|
||||||
usleep(100 * 1000);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
settings.frameStatsCb(settings.messager, statbuf, 4096);
|
|
||||||
|
|
||||||
sprintf(buf, "HTTP/1.1 200 OK\r\n"
|
|
||||||
"Server: KasmVNC/4.0\r\n"
|
|
||||||
"Connection: close\r\n"
|
|
||||||
"Content-type: text/plain\r\n"
|
|
||||||
"Content-length: %lu\r\n"
|
|
||||||
"\r\n", strlen(statbuf));
|
|
||||||
ws_send(ws_ctx, buf, strlen(buf));
|
|
||||||
ws_send(ws_ctx, statbuf, strlen(statbuf));
|
|
||||||
|
|
||||||
wserr("Sent frame stats to API caller\n");
|
|
||||||
ret = 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef entry
|
#undef entry
|
||||||
|
|||||||
@@ -84,18 +84,6 @@ typedef struct {
|
|||||||
const uint8_t write);
|
const uint8_t write);
|
||||||
uint8_t (*removeCb)(void *messager, const char name[]);
|
uint8_t (*removeCb)(void *messager, const char name[]);
|
||||||
uint8_t (*givecontrolCb)(void *messager, const char name[]);
|
uint8_t (*givecontrolCb)(void *messager, const char name[]);
|
||||||
void (*bottleneckStatsCb)(void *messager, char *buf, uint32_t len);
|
|
||||||
void (*frameStatsCb)(void *messager, char *buf, uint32_t len);
|
|
||||||
|
|
||||||
uint8_t (*requestFrameStatsNoneCb)(void *messager);
|
|
||||||
uint8_t (*requestFrameStatsOwnerCb)(void *messager);
|
|
||||||
uint8_t (*requestFrameStatsAllCb)(void *messager);
|
|
||||||
uint8_t (*requestFrameStatsOneCb)(void *messager, const char *client);
|
|
||||||
|
|
||||||
uint8_t (*ownerConnectedCb)(void *messager);
|
|
||||||
uint8_t (*numActiveUsersCb)(void *messager);
|
|
||||||
uint8_t (*getClientFrameStatsNumCb)(void *messager);
|
|
||||||
uint8_t (*serverFrameStatsReadyCb)(void *messager);
|
|
||||||
} settings_t;
|
} settings_t;
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|||||||
@@ -21,7 +21,6 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <sys/types.h>
|
|
||||||
#include "websocket.h"
|
#include "websocket.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -224,12 +223,9 @@ static void do_proxy(ws_ctx_t *ws_ctx, int target) {
|
|||||||
|
|
||||||
void proxy_handler(ws_ctx_t *ws_ctx) {
|
void proxy_handler(ws_ctx_t *ws_ctx) {
|
||||||
|
|
||||||
char sockname[32];
|
|
||||||
sprintf(sockname, ".KasmVNCSock%u", getpid());
|
|
||||||
|
|
||||||
struct sockaddr_un addr;
|
struct sockaddr_un addr;
|
||||||
addr.sun_family = AF_UNIX;
|
addr.sun_family = AF_UNIX;
|
||||||
strcpy(addr.sun_path, sockname);
|
strcpy(addr.sun_path, ".KasmVNCSock");
|
||||||
addr.sun_path[0] = '\0';
|
addr.sun_path[0] = '\0';
|
||||||
|
|
||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
@@ -247,7 +243,7 @@ void proxy_handler(ws_ctx_t *ws_ctx) {
|
|||||||
handler_msg("connecting to VNC target\n");
|
handler_msg("connecting to VNC target\n");
|
||||||
|
|
||||||
if (connect(tsock, (struct sockaddr *) &addr,
|
if (connect(tsock, (struct sockaddr *) &addr,
|
||||||
sizeof(sa_family_t) + strlen(sockname)) < 0) {
|
sizeof(sa_family_t) + sizeof(".KasmVNCSock")) < 0) {
|
||||||
|
|
||||||
handler_emsg("Could not connect to target: %s\n",
|
handler_emsg("Could not connect to target: %s\n",
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
|
|||||||
@@ -48,7 +48,6 @@ set(RFB_SOURCES
|
|||||||
Security.cxx
|
Security.cxx
|
||||||
SecurityServer.cxx
|
SecurityServer.cxx
|
||||||
SecurityClient.cxx
|
SecurityClient.cxx
|
||||||
SelfBench.cxx
|
|
||||||
SSecurityPlain.cxx
|
SSecurityPlain.cxx
|
||||||
SSecurityStack.cxx
|
SSecurityStack.cxx
|
||||||
SSecurityVncAuth.cxx
|
SSecurityVncAuth.cxx
|
||||||
@@ -64,7 +63,6 @@ set(RFB_SOURCES
|
|||||||
VNCServerST.cxx
|
VNCServerST.cxx
|
||||||
ZRLEEncoder.cxx
|
ZRLEEncoder.cxx
|
||||||
ZRLEDecoder.cxx
|
ZRLEDecoder.cxx
|
||||||
cpuid.cxx
|
|
||||||
encodings.cxx
|
encodings.cxx
|
||||||
util.cxx
|
util.cxx
|
||||||
xxhash.c)
|
xxhash.c)
|
||||||
@@ -98,27 +96,6 @@ if(GNUTLS_FOUND)
|
|||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# SSE2
|
|
||||||
|
|
||||||
set(SSE2_SOURCES
|
|
||||||
scale_sse2.cxx)
|
|
||||||
|
|
||||||
set(SCALE_DUMMY_SOURCES
|
|
||||||
scale_dummy.cxx)
|
|
||||||
|
|
||||||
if(COMPILER_SUPPORTS_SSE2)
|
|
||||||
set_source_files_properties(${SSE2_SOURCES} PROPERTIES COMPILE_FLAGS ${COMPILE_FLAGS} -msse2)
|
|
||||||
set(RFB_SOURCES
|
|
||||||
${RFB_SOURCES}
|
|
||||||
${SSE2_SOURCES}
|
|
||||||
)
|
|
||||||
else()
|
|
||||||
set(RFB_SOURCES
|
|
||||||
${RFB_SOURCES}
|
|
||||||
${SCALE_DUMMY_SOURCES}
|
|
||||||
)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
add_library(rfb STATIC ${RFB_SOURCES})
|
add_library(rfb STATIC ${RFB_SOURCES})
|
||||||
|
|
||||||
target_link_libraries(rfb ${RFB_LIBRARIES})
|
target_link_libraries(rfb ${RFB_LIBRARIES})
|
||||||
|
|||||||
@@ -695,8 +695,6 @@ bool ComparingUpdateTracker::compare(bool skipScrollDetection, const Region &ski
|
|||||||
std::vector<Rect> rects;
|
std::vector<Rect> rects;
|
||||||
std::vector<Rect>::iterator i;
|
std::vector<Rect>::iterator i;
|
||||||
|
|
||||||
changedPerc = 100;
|
|
||||||
|
|
||||||
if (!enabled)
|
if (!enabled)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@@ -751,13 +749,8 @@ bool ComparingUpdateTracker::compare(bool skipScrollDetection, const Region &ski
|
|||||||
for (i = rects.begin(); i != rects.end(); i++)
|
for (i = rects.begin(); i != rects.end(); i++)
|
||||||
totalPixels += i->area();
|
totalPixels += i->area();
|
||||||
newChanged.get_rects(&rects);
|
newChanged.get_rects(&rects);
|
||||||
unsigned newchangedarea = 0;
|
for (i = rects.begin(); i != rects.end(); i++)
|
||||||
for (i = rects.begin(); i != rects.end(); i++) {
|
|
||||||
missedPixels += i->area();
|
missedPixels += i->area();
|
||||||
newchangedarea += i->area();
|
|
||||||
}
|
|
||||||
|
|
||||||
changedPerc = newchangedarea * 100 / fb->area();
|
|
||||||
|
|
||||||
if (changed.equals(newChanged))
|
if (changed.equals(newChanged))
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -48,8 +48,6 @@ namespace rfb {
|
|||||||
virtual void getUpdateInfo(UpdateInfo* info, const Region& cliprgn);
|
virtual void getUpdateInfo(UpdateInfo* info, const Region& cliprgn);
|
||||||
virtual void clear();
|
virtual void clear();
|
||||||
|
|
||||||
rdr::U8 changedPerc;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void compareRect(const Rect& r, Region* newchanged, const Region &skipCursorArea);
|
void compareRect(const Rect& r, Region* newchanged, const Region &skipCursorArea);
|
||||||
PixelBuffer* fb;
|
PixelBuffer* fb;
|
||||||
|
|||||||
@@ -298,11 +298,6 @@ size_t Congestion::getBandwidth()
|
|||||||
return congWindow * 1000 / safeBaseRTT;
|
return congWindow * 1000 / safeBaseRTT;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned Congestion::getPingTime() const
|
|
||||||
{
|
|
||||||
return safeBaseRTT;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Congestion::debugTrace(const char* filename, int fd)
|
void Congestion::debugTrace(const char* filename, int fd)
|
||||||
{
|
{
|
||||||
#ifdef CONGESTION_TRACE
|
#ifdef CONGESTION_TRACE
|
||||||
|
|||||||
@@ -51,8 +51,6 @@ namespace rfb {
|
|||||||
// per second.
|
// per second.
|
||||||
size_t getBandwidth();
|
size_t getBandwidth();
|
||||||
|
|
||||||
unsigned getPingTime() const;
|
|
||||||
|
|
||||||
// debugTrace() writes the current congestion window, as well as the
|
// debugTrace() writes the current congestion window, as well as the
|
||||||
// congestion window of the underlying TCP layer, to the specified
|
// congestion window of the underlying TCP layer, to the specified
|
||||||
// file
|
// file
|
||||||
|
|||||||
@@ -37,7 +37,6 @@ ConnParams::ConnParams()
|
|||||||
width(0), height(0), useCopyRect(false),
|
width(0), height(0), useCopyRect(false),
|
||||||
supportsLocalCursor(false), supportsLocalXCursor(false),
|
supportsLocalCursor(false), supportsLocalXCursor(false),
|
||||||
supportsLocalCursorWithAlpha(false),
|
supportsLocalCursorWithAlpha(false),
|
||||||
supportsVMWareCursor(false),
|
|
||||||
supportsCursorPosition(false),
|
supportsCursorPosition(false),
|
||||||
supportsDesktopResize(false), supportsExtendedDesktopSize(false),
|
supportsDesktopResize(false), supportsExtendedDesktopSize(false),
|
||||||
supportsDesktopRename(false), supportsLastRect(false),
|
supportsDesktopRename(false), supportsLastRect(false),
|
||||||
@@ -124,7 +123,6 @@ void ConnParams::setEncodings(int nEncodings, const rdr::S32* encodings)
|
|||||||
useCopyRect = false;
|
useCopyRect = false;
|
||||||
supportsLocalCursor = false;
|
supportsLocalCursor = false;
|
||||||
supportsLocalCursorWithAlpha = false;
|
supportsLocalCursorWithAlpha = false;
|
||||||
supportsVMWareCursor = false;
|
|
||||||
supportsDesktopResize = false;
|
supportsDesktopResize = false;
|
||||||
supportsExtendedDesktopSize = false;
|
supportsExtendedDesktopSize = false;
|
||||||
supportsLocalXCursor = false;
|
supportsLocalXCursor = false;
|
||||||
@@ -155,9 +153,6 @@ void ConnParams::setEncodings(int nEncodings, const rdr::S32* encodings)
|
|||||||
case pseudoEncodingCursorWithAlpha:
|
case pseudoEncodingCursorWithAlpha:
|
||||||
supportsLocalCursorWithAlpha = true;
|
supportsLocalCursorWithAlpha = true;
|
||||||
break;
|
break;
|
||||||
case pseudoEncodingVMwareCursor:
|
|
||||||
supportsVMWareCursor = true;
|
|
||||||
break;
|
|
||||||
case pseudoEncodingDesktopSize:
|
case pseudoEncodingDesktopSize:
|
||||||
supportsDesktopResize = true;
|
supportsDesktopResize = true;
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -102,7 +102,6 @@ namespace rfb {
|
|||||||
bool supportsLocalCursor;
|
bool supportsLocalCursor;
|
||||||
bool supportsLocalXCursor;
|
bool supportsLocalXCursor;
|
||||||
bool supportsLocalCursorWithAlpha;
|
bool supportsLocalCursorWithAlpha;
|
||||||
bool supportsVMWareCursor;
|
|
||||||
bool supportsCursorPosition;
|
bool supportsCursorPosition;
|
||||||
bool supportsDesktopResize;
|
bool supportsDesktopResize;
|
||||||
bool supportsExtendedDesktopSize;
|
bool supportsExtendedDesktopSize;
|
||||||
|
|||||||
@@ -22,12 +22,10 @@
|
|||||||
#include <omp.h>
|
#include <omp.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include <rfb/cpuid.h>
|
|
||||||
#include <rfb/EncCache.h>
|
#include <rfb/EncCache.h>
|
||||||
#include <rfb/EncodeManager.h>
|
#include <rfb/EncodeManager.h>
|
||||||
#include <rfb/Encoder.h>
|
#include <rfb/Encoder.h>
|
||||||
#include <rfb/Palette.h>
|
#include <rfb/Palette.h>
|
||||||
#include <rfb/scale_sse2.h>
|
|
||||||
#include <rfb/SConnection.h>
|
#include <rfb/SConnection.h>
|
||||||
#include <rfb/ServerCore.h>
|
#include <rfb/ServerCore.h>
|
||||||
#include <rfb/SMsgWriter.h>
|
#include <rfb/SMsgWriter.h>
|
||||||
@@ -361,8 +359,6 @@ void EncodeManager::doUpdate(bool allowLossy, const Region& changed_,
|
|||||||
changed = changed_;
|
changed = changed_;
|
||||||
|
|
||||||
gettimeofday(&start, NULL);
|
gettimeofday(&start, NULL);
|
||||||
memset(&jpegstats, 0, sizeof(codecstats_t));
|
|
||||||
memset(&webpstats, 0, sizeof(codecstats_t));
|
|
||||||
|
|
||||||
if (allowLossy && activeEncoders[encoderFullColour] == encoderTightWEBP) {
|
if (allowLossy && activeEncoders[encoderFullColour] == encoderTightWEBP) {
|
||||||
const unsigned rate = 1024 * 1000 / rfb::Server::frameRate;
|
const unsigned rate = 1024 * 1000 / rfb::Server::frameRate;
|
||||||
@@ -897,7 +893,7 @@ void EncodeManager::updateVideoStats(const std::vector<Rect> &rects, const Pixel
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PixelBuffer *rfb::nearestScale(const PixelBuffer *pb, const uint16_t w, const uint16_t h,
|
static PixelBuffer *nearestScale(const PixelBuffer *pb, const uint16_t w, const uint16_t h,
|
||||||
const float diff)
|
const float diff)
|
||||||
{
|
{
|
||||||
ManagedPixelBuffer *newpb = new ManagedPixelBuffer(pb->getPF(), w, h);
|
ManagedPixelBuffer *newpb = new ManagedPixelBuffer(pb->getPF(), w, h);
|
||||||
@@ -922,7 +918,7 @@ PixelBuffer *rfb::nearestScale(const PixelBuffer *pb, const uint16_t w, const ui
|
|||||||
return newpb;
|
return newpb;
|
||||||
}
|
}
|
||||||
|
|
||||||
PixelBuffer *rfb::bilinearScale(const PixelBuffer *pb, const uint16_t w, const uint16_t h,
|
static PixelBuffer *bilinearScale(const PixelBuffer *pb, const uint16_t w, const uint16_t h,
|
||||||
const float diff)
|
const float diff)
|
||||||
{
|
{
|
||||||
ManagedPixelBuffer *newpb = new ManagedPixelBuffer(pb->getPF(), w, h);
|
ManagedPixelBuffer *newpb = new ManagedPixelBuffer(pb->getPF(), w, h);
|
||||||
@@ -970,68 +966,10 @@ PixelBuffer *rfb::bilinearScale(const PixelBuffer *pb, const uint16_t w, const u
|
|||||||
return newpb;
|
return newpb;
|
||||||
}
|
}
|
||||||
|
|
||||||
PixelBuffer *rfb::progressiveBilinearScale(const PixelBuffer *pb,
|
PixelBuffer *progressiveBilinearScale(const PixelBuffer *pb,
|
||||||
const uint16_t tgtw, const uint16_t tgth,
|
const uint16_t tgtw, const uint16_t tgth,
|
||||||
const float tgtdiff)
|
const float tgtdiff)
|
||||||
{
|
{
|
||||||
if (supportsSSE2()) {
|
|
||||||
if (tgtdiff >= 0.5f) {
|
|
||||||
ManagedPixelBuffer *newpb = new ManagedPixelBuffer(pb->getPF(), tgtw, tgth);
|
|
||||||
|
|
||||||
int oldstride, newstride;
|
|
||||||
const rdr::U8 *oldpx = pb->getBuffer(pb->getRect(), &oldstride);
|
|
||||||
rdr::U8 *newpx = newpb->getBufferRW(newpb->getRect(), &newstride);
|
|
||||||
|
|
||||||
SSE2_scale(oldpx, tgtw, tgth, newpx, oldstride, newstride, tgtdiff);
|
|
||||||
return newpb;
|
|
||||||
}
|
|
||||||
|
|
||||||
PixelBuffer *newpb;
|
|
||||||
uint16_t neww, newh, oldw, oldh;
|
|
||||||
bool del = false;
|
|
||||||
|
|
||||||
do {
|
|
||||||
oldw = pb->getRect().width();
|
|
||||||
oldh = pb->getRect().height();
|
|
||||||
neww = oldw / 2;
|
|
||||||
newh = oldh / 2;
|
|
||||||
|
|
||||||
newpb = new ManagedPixelBuffer(pb->getPF(), neww, newh);
|
|
||||||
|
|
||||||
int oldstride, newstride;
|
|
||||||
const rdr::U8 *oldpx = pb->getBuffer(pb->getRect(), &oldstride);
|
|
||||||
rdr::U8 *newpx = ((ManagedPixelBuffer *) newpb)->getBufferRW(newpb->getRect(),
|
|
||||||
&newstride);
|
|
||||||
|
|
||||||
SSE2_halve(oldpx, neww, newh, newpx, oldstride, newstride);
|
|
||||||
|
|
||||||
if (del)
|
|
||||||
delete pb;
|
|
||||||
del = true;
|
|
||||||
|
|
||||||
pb = newpb;
|
|
||||||
} while (tgtw * 2 < neww);
|
|
||||||
|
|
||||||
// Final, non-halving step
|
|
||||||
if (tgtw != neww || tgth != newh) {
|
|
||||||
oldw = pb->getRect().width();
|
|
||||||
oldh = pb->getRect().height();
|
|
||||||
|
|
||||||
newpb = new ManagedPixelBuffer(pb->getPF(), tgtw, tgth);
|
|
||||||
|
|
||||||
int oldstride, newstride;
|
|
||||||
const rdr::U8 *oldpx = pb->getBuffer(pb->getRect(), &oldstride);
|
|
||||||
rdr::U8 *newpx = ((ManagedPixelBuffer *) newpb)->getBufferRW(newpb->getRect(),
|
|
||||||
&newstride);
|
|
||||||
|
|
||||||
SSE2_scale(oldpx, tgtw, tgth, newpx, oldstride, newstride, tgtdiff);
|
|
||||||
if (del)
|
|
||||||
delete pb;
|
|
||||||
}
|
|
||||||
|
|
||||||
return newpb;
|
|
||||||
} // SSE2
|
|
||||||
|
|
||||||
if (tgtdiff >= 0.5f)
|
if (tgtdiff >= 0.5f)
|
||||||
return bilinearScale(pb, tgtw, tgth, tgtdiff);
|
return bilinearScale(pb, tgtw, tgth, tgtdiff);
|
||||||
|
|
||||||
@@ -1076,7 +1014,6 @@ void EncodeManager::writeRects(const Region& changed, const PixelBuffer* pb,
|
|||||||
std::vector<uint8_t> isWebp, fromCache;
|
std::vector<uint8_t> isWebp, fromCache;
|
||||||
std::vector<Palette> palettes;
|
std::vector<Palette> palettes;
|
||||||
std::vector<std::vector<uint8_t> > compresseds;
|
std::vector<std::vector<uint8_t> > compresseds;
|
||||||
std::vector<uint32_t> ms;
|
|
||||||
uint32_t i;
|
uint32_t i;
|
||||||
|
|
||||||
if (rfb::Server::rectThreads > 0)
|
if (rfb::Server::rectThreads > 0)
|
||||||
@@ -1141,13 +1078,9 @@ void EncodeManager::writeRects(const Region& changed, const PixelBuffer* pb,
|
|||||||
palettes.resize(subrects.size());
|
palettes.resize(subrects.size());
|
||||||
compresseds.resize(subrects.size());
|
compresseds.resize(subrects.size());
|
||||||
scaledrects.resize(subrects.size());
|
scaledrects.resize(subrects.size());
|
||||||
ms.resize(subrects.size());
|
|
||||||
|
|
||||||
// In case the current resolution is above the max video res, and video was detected,
|
// In case the current resolution is above the max video res, and video was detected,
|
||||||
// scale to that res, keeping aspect ratio
|
// scale to that res, keeping aspect ratio
|
||||||
struct timeval scalestart;
|
|
||||||
gettimeofday(&scalestart, NULL);
|
|
||||||
|
|
||||||
const PixelBuffer *scaledpb = NULL;
|
const PixelBuffer *scaledpb = NULL;
|
||||||
if (videoDetected &&
|
if (videoDetected &&
|
||||||
(maxVideoX < pb->getRect().width() || maxVideoY < pb->getRect().height())) {
|
(maxVideoX < pb->getRect().width() || maxVideoY < pb->getRect().height())) {
|
||||||
@@ -1196,25 +1129,15 @@ void EncodeManager::writeRects(const Region& changed, const PixelBuffer* pb,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
scalingTime = msSince(&scalestart);
|
|
||||||
|
|
||||||
#pragma omp parallel for schedule(dynamic, 1)
|
#pragma omp parallel for schedule(dynamic, 1)
|
||||||
for (i = 0; i < subrects.size(); ++i) {
|
for (i = 0; i < subrects.size(); ++i) {
|
||||||
encoderTypes[i] = getEncoderType(subrects[i], pb, &palettes[i], compresseds[i],
|
encoderTypes[i] = getEncoderType(subrects[i], pb, &palettes[i], compresseds[i],
|
||||||
&isWebp[i], &fromCache[i],
|
&isWebp[i], &fromCache[i],
|
||||||
scaledpb, scaledrects[i], ms[i]);
|
scaledpb, scaledrects[i]);
|
||||||
checkWebpFallback(start);
|
checkWebpFallback(start);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < subrects.size(); ++i) {
|
|
||||||
if (encoderTypes[i] == encoderFullColour) {
|
|
||||||
if (isWebp[i])
|
|
||||||
webpstats.ms += ms[i];
|
|
||||||
else
|
|
||||||
jpegstats.ms += ms[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (start) {
|
if (start) {
|
||||||
encodingTime = msSince(start);
|
encodingTime = msSince(start);
|
||||||
|
|
||||||
@@ -1255,8 +1178,7 @@ void EncodeManager::writeRects(const Region& changed, const PixelBuffer* pb,
|
|||||||
uint8_t EncodeManager::getEncoderType(const Rect& rect, const PixelBuffer *pb,
|
uint8_t EncodeManager::getEncoderType(const Rect& rect, const PixelBuffer *pb,
|
||||||
Palette *pal, std::vector<uint8_t> &compressed,
|
Palette *pal, std::vector<uint8_t> &compressed,
|
||||||
uint8_t *isWebp, uint8_t *fromCache,
|
uint8_t *isWebp, uint8_t *fromCache,
|
||||||
const PixelBuffer *scaledpb, const Rect& scaledrect,
|
const PixelBuffer *scaledpb, const Rect& scaledrect) const
|
||||||
uint32_t &ms) const
|
|
||||||
{
|
{
|
||||||
struct RectInfo info;
|
struct RectInfo info;
|
||||||
unsigned int maxColours = 256;
|
unsigned int maxColours = 256;
|
||||||
@@ -1309,12 +1231,9 @@ uint8_t EncodeManager::getEncoderType(const Rect& rect, const PixelBuffer *pb,
|
|||||||
|
|
||||||
*isWebp = 0;
|
*isWebp = 0;
|
||||||
*fromCache = 0;
|
*fromCache = 0;
|
||||||
ms = 0;
|
|
||||||
if (type == encoderFullColour) {
|
if (type == encoderFullColour) {
|
||||||
uint32_t len;
|
uint32_t len;
|
||||||
const void *data;
|
const void *data;
|
||||||
struct timeval start;
|
|
||||||
gettimeofday(&start, NULL);
|
|
||||||
|
|
||||||
if (encCache->enabled &&
|
if (encCache->enabled &&
|
||||||
(data = encCache->get(activeEncoders[encoderFullColour],
|
(data = encCache->get(activeEncoders[encoderFullColour],
|
||||||
@@ -1355,8 +1274,6 @@ uint8_t EncodeManager::getEncoderType(const Rect& rect, const PixelBuffer *pb,
|
|||||||
compressed,
|
compressed,
|
||||||
videoDetected);
|
videoDetected);
|
||||||
}
|
}
|
||||||
|
|
||||||
ms = msSince(&start);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
delete ppb;
|
delete ppb;
|
||||||
@@ -1375,15 +1292,10 @@ void EncodeManager::writeSubRect(const Rect& rect, const PixelBuffer *pb,
|
|||||||
encoder = startRect(rect, type, compressed.size() == 0, isWebp);
|
encoder = startRect(rect, type, compressed.size() == 0, isWebp);
|
||||||
|
|
||||||
if (compressed.size()) {
|
if (compressed.size()) {
|
||||||
if (isWebp) {
|
if (isWebp)
|
||||||
((TightWEBPEncoder *) encoder)->writeOnly(compressed);
|
((TightWEBPEncoder *) encoder)->writeOnly(compressed);
|
||||||
webpstats.area += rect.area();
|
else
|
||||||
webpstats.rects++;
|
|
||||||
} else {
|
|
||||||
((TightJPEGEncoder *) encoder)->writeOnly(compressed);
|
((TightJPEGEncoder *) encoder)->writeOnly(compressed);
|
||||||
jpegstats.area += rect.area();
|
|
||||||
jpegstats.rects++;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if (encoder->flags & EncoderUseNativePF) {
|
if (encoder->flags & EncoderUseNativePF) {
|
||||||
ppb = preparePixelBuffer(rect, pb, false);
|
ppb = preparePixelBuffer(rect, pb, false);
|
||||||
|
|||||||
@@ -68,24 +68,9 @@ namespace rfb {
|
|||||||
const RenderedCursor* renderedCursor,
|
const RenderedCursor* renderedCursor,
|
||||||
size_t maxUpdateSize);
|
size_t maxUpdateSize);
|
||||||
|
|
||||||
void clearEncodingTime() {
|
|
||||||
encodingTime = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
unsigned getEncodingTime() const {
|
unsigned getEncodingTime() const {
|
||||||
return encodingTime;
|
return encodingTime;
|
||||||
};
|
};
|
||||||
unsigned getScalingTime() const {
|
|
||||||
return scalingTime;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct codecstats_t {
|
|
||||||
uint32_t ms;
|
|
||||||
uint32_t area;
|
|
||||||
uint32_t rects;
|
|
||||||
};
|
|
||||||
|
|
||||||
codecstats_t jpegstats, webpstats;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void doUpdate(bool allowLossy, const Region& changed,
|
void doUpdate(bool allowLossy, const Region& changed,
|
||||||
@@ -120,8 +105,7 @@ namespace rfb {
|
|||||||
uint8_t getEncoderType(const Rect& rect, const PixelBuffer *pb, Palette *pal,
|
uint8_t getEncoderType(const Rect& rect, const PixelBuffer *pb, Palette *pal,
|
||||||
std::vector<uint8_t> &compressed, uint8_t *isWebp,
|
std::vector<uint8_t> &compressed, uint8_t *isWebp,
|
||||||
uint8_t *fromCache,
|
uint8_t *fromCache,
|
||||||
const PixelBuffer *scaledpb, const Rect& scaledrect,
|
const PixelBuffer *scaledpb, const Rect& scaledrect) const;
|
||||||
uint32_t &ms) const;
|
|
||||||
virtual bool handleTimeout(Timer* t);
|
virtual bool handleTimeout(Timer* t);
|
||||||
|
|
||||||
bool checkSolidTile(const Rect& r, const rdr::U8* colourValue,
|
bool checkSolidTile(const Rect& r, const rdr::U8* colourValue,
|
||||||
@@ -199,7 +183,6 @@ namespace rfb {
|
|||||||
bool webpTookTooLong;
|
bool webpTookTooLong;
|
||||||
unsigned encodingTime;
|
unsigned encodingTime;
|
||||||
unsigned maxEncodingTime, framesSinceEncPrint;
|
unsigned maxEncodingTime, framesSinceEncPrint;
|
||||||
unsigned scalingTime;
|
|
||||||
|
|
||||||
EncCache *encCache;
|
EncCache *encCache;
|
||||||
|
|
||||||
@@ -215,13 +198,6 @@ namespace rfb {
|
|||||||
virtual rdr::U8* getBufferRW(const Rect& r, int* stride);
|
virtual rdr::U8* getBufferRW(const Rect& r, int* stride);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
PixelBuffer *nearestScale(const PixelBuffer *pb, const uint16_t w, const uint16_t h,
|
|
||||||
const float diff);
|
|
||||||
PixelBuffer *bilinearScale(const PixelBuffer *pb, const uint16_t w, const uint16_t h,
|
|
||||||
const float diff);
|
|
||||||
PixelBuffer *progressiveBilinearScale(const PixelBuffer *pb, const uint16_t w, const uint16_t h,
|
|
||||||
const float diff);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -63,8 +63,7 @@ namespace rfb {
|
|||||||
const size_t* lengths,
|
const size_t* lengths,
|
||||||
const rdr::U8* const* data);
|
const rdr::U8* const* data);
|
||||||
|
|
||||||
virtual void sendStats(const bool toClient = true) = 0;
|
virtual void sendStats() = 0;
|
||||||
virtual void handleFrameStats(rdr::U32 all, rdr::U32 render) = 0;
|
|
||||||
|
|
||||||
virtual bool canChangeKasmSettings() const = 0;
|
virtual bool canChangeKasmSettings() const = 0;
|
||||||
|
|
||||||
|
|||||||
@@ -80,9 +80,6 @@ void SMsgReader::readMsg()
|
|||||||
case msgTypeRequestStats:
|
case msgTypeRequestStats:
|
||||||
readRequestStats();
|
readRequestStats();
|
||||||
break;
|
break;
|
||||||
case msgTypeFrameStats:
|
|
||||||
readFrameStats();
|
|
||||||
break;
|
|
||||||
case msgTypeKeyEvent:
|
case msgTypeKeyEvent:
|
||||||
readKeyEvent();
|
readKeyEvent();
|
||||||
break;
|
break;
|
||||||
@@ -349,14 +346,6 @@ void SMsgReader::readRequestStats()
|
|||||||
handler->sendStats();
|
handler->sendStats();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SMsgReader::readFrameStats()
|
|
||||||
{
|
|
||||||
is->skip(3);
|
|
||||||
rdr::U32 all = is->readU32();
|
|
||||||
rdr::U32 render = is->readU32();
|
|
||||||
handler->handleFrameStats(all, render);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SMsgReader::readQEMUMessage()
|
void SMsgReader::readQEMUMessage()
|
||||||
{
|
{
|
||||||
int subType = is->readU8();
|
int subType = is->readU8();
|
||||||
|
|||||||
@@ -57,7 +57,6 @@ namespace rfb {
|
|||||||
void readClientCutText();
|
void readClientCutText();
|
||||||
void readExtendedClipboard(rdr::S32 len);
|
void readExtendedClipboard(rdr::S32 len);
|
||||||
void readRequestStats();
|
void readRequestStats();
|
||||||
void readFrameStats();
|
|
||||||
|
|
||||||
void readQEMUMessage();
|
void readQEMUMessage();
|
||||||
void readQEMUKeyEvent();
|
void readQEMUKeyEvent();
|
||||||
|
|||||||
@@ -43,7 +43,6 @@ SMsgWriter::SMsgWriter(ConnParams* cp_, rdr::OutStream* os_)
|
|||||||
needSetDesktopSize(false), needExtendedDesktopSize(false),
|
needSetDesktopSize(false), needExtendedDesktopSize(false),
|
||||||
needSetDesktopName(false), needSetCursor(false),
|
needSetDesktopName(false), needSetCursor(false),
|
||||||
needSetXCursor(false), needSetCursorWithAlpha(false),
|
needSetXCursor(false), needSetCursorWithAlpha(false),
|
||||||
needSetVMWareCursor(false),
|
|
||||||
needCursorPos(false),
|
needCursorPos(false),
|
||||||
needLEDState(false), needQEMUKeyEvent(false)
|
needLEDState(false), needQEMUKeyEvent(false)
|
||||||
{
|
{
|
||||||
@@ -209,12 +208,6 @@ void SMsgWriter::writeStats(const char* str, int len)
|
|||||||
endMsg();
|
endMsg();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SMsgWriter::writeRequestFrameStats()
|
|
||||||
{
|
|
||||||
startMsg(msgTypeRequestFrameStats);
|
|
||||||
endMsg();
|
|
||||||
}
|
|
||||||
|
|
||||||
void SMsgWriter::writeFence(rdr::U32 flags, unsigned len, const char data[])
|
void SMsgWriter::writeFence(rdr::U32 flags, unsigned len, const char data[])
|
||||||
{
|
{
|
||||||
if (!cp->supportsFence)
|
if (!cp->supportsFence)
|
||||||
@@ -322,16 +315,6 @@ bool SMsgWriter::writeSetCursorWithAlpha()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SMsgWriter::writeSetVMwareCursor()
|
|
||||||
{
|
|
||||||
if (!cp->supportsVMWareCursor)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
needSetVMWareCursor = true;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void SMsgWriter::writeCursorPos()
|
void SMsgWriter::writeCursorPos()
|
||||||
{
|
{
|
||||||
if (!cp->supportsEncoding(pseudoEncodingVMwareCursorPosition))
|
if (!cp->supportsEncoding(pseudoEncodingVMwareCursorPosition))
|
||||||
@@ -366,7 +349,7 @@ bool SMsgWriter::needFakeUpdate()
|
|||||||
{
|
{
|
||||||
if (needSetDesktopName)
|
if (needSetDesktopName)
|
||||||
return true;
|
return true;
|
||||||
if (needSetCursor || needSetXCursor || needSetCursorWithAlpha || needSetVMWareCursor)
|
if (needSetCursor || needSetXCursor || needSetCursorWithAlpha)
|
||||||
return true;
|
return true;
|
||||||
if (needCursorPos)
|
if (needCursorPos)
|
||||||
return true;
|
return true;
|
||||||
@@ -422,8 +405,6 @@ void SMsgWriter::writeFramebufferUpdateStart(int nRects)
|
|||||||
nRects++;
|
nRects++;
|
||||||
if (needSetCursorWithAlpha)
|
if (needSetCursorWithAlpha)
|
||||||
nRects++;
|
nRects++;
|
||||||
if (needSetVMWareCursor)
|
|
||||||
nRects++;
|
|
||||||
if (needCursorPos)
|
if (needCursorPos)
|
||||||
nRects++;
|
nRects++;
|
||||||
if (needLEDState)
|
if (needLEDState)
|
||||||
@@ -541,15 +522,6 @@ void SMsgWriter::writePseudoRects()
|
|||||||
needSetCursorWithAlpha = false;
|
needSetCursorWithAlpha = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (needSetVMWareCursor) {
|
|
||||||
const Cursor& cursor = cp->cursor();
|
|
||||||
|
|
||||||
writeSetVMwareCursorRect(cursor.width(), cursor.height(),
|
|
||||||
cursor.hotspot().x, cursor.hotspot().y,
|
|
||||||
cursor.getBuffer());
|
|
||||||
needSetVMWareCursor = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (needCursorPos) {
|
if (needCursorPos) {
|
||||||
const Point& cursorPos = cp->cursorPos();
|
const Point& cursorPos = cp->cursorPos();
|
||||||
|
|
||||||
@@ -740,28 +712,6 @@ void SMsgWriter::writeSetCursorWithAlphaRect(int width, int height,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SMsgWriter::writeSetVMwareCursorRect(int width, int height,
|
|
||||||
int hotspotX, int hotspotY,
|
|
||||||
const rdr::U8* data)
|
|
||||||
{
|
|
||||||
if (!cp->supportsVMWareCursor)
|
|
||||||
throw Exception("Client does not support local cursors");
|
|
||||||
if (++nRectsInUpdate > nRectsInHeader && nRectsInHeader)
|
|
||||||
throw Exception("SMsgWriter::writeSetVMwareCursorRect: nRects out of sync");
|
|
||||||
|
|
||||||
os->writeS16(hotspotX);
|
|
||||||
os->writeS16(hotspotY);
|
|
||||||
os->writeU16(width);
|
|
||||||
os->writeU16(height);
|
|
||||||
os->writeU32(pseudoEncodingVMwareCursor);
|
|
||||||
|
|
||||||
os->writeU8(1); // Alpha cursor
|
|
||||||
os->pad(1);
|
|
||||||
|
|
||||||
// FIXME: Should alpha be premultiplied?
|
|
||||||
os->writeBytes(data, width*height*4);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SMsgWriter::writeSetVMwareCursorPositionRect(int hotspotX, int hotspotY)
|
void SMsgWriter::writeSetVMwareCursorPositionRect(int hotspotX, int hotspotY)
|
||||||
{
|
{
|
||||||
if (!cp->supportsEncoding(pseudoEncodingVMwareCursorPosition))
|
if (!cp->supportsEncoding(pseudoEncodingVMwareCursorPosition))
|
||||||
|
|||||||
@@ -65,8 +65,6 @@ namespace rfb {
|
|||||||
|
|
||||||
void writeStats(const char* str, int len);
|
void writeStats(const char* str, int len);
|
||||||
|
|
||||||
void writeRequestFrameStats();
|
|
||||||
|
|
||||||
// writeFence() sends a new fence request or response to the client.
|
// writeFence() sends a new fence request or response to the client.
|
||||||
void writeFence(rdr::U32 flags, unsigned len, const char data[]);
|
void writeFence(rdr::U32 flags, unsigned len, const char data[]);
|
||||||
|
|
||||||
@@ -92,7 +90,6 @@ namespace rfb {
|
|||||||
bool writeSetCursor();
|
bool writeSetCursor();
|
||||||
bool writeSetXCursor();
|
bool writeSetXCursor();
|
||||||
bool writeSetCursorWithAlpha();
|
bool writeSetCursorWithAlpha();
|
||||||
bool writeSetVMwareCursor();
|
|
||||||
|
|
||||||
// Notifies the client that the cursor pointer was moved by the server.
|
// Notifies the client that the cursor pointer was moved by the server.
|
||||||
void writeCursorPos();
|
void writeCursorPos();
|
||||||
@@ -152,9 +149,6 @@ namespace rfb {
|
|||||||
void writeSetCursorWithAlphaRect(int width, int height,
|
void writeSetCursorWithAlphaRect(int width, int height,
|
||||||
int hotspotX, int hotspotY,
|
int hotspotX, int hotspotY,
|
||||||
const rdr::U8* data);
|
const rdr::U8* data);
|
||||||
void writeSetVMwareCursorRect(int width, int height,
|
|
||||||
int hotspotX, int hotspotY,
|
|
||||||
const rdr::U8* data);
|
|
||||||
void writeSetVMwareCursorPositionRect(int hotspotX, int hotspotY);
|
void writeSetVMwareCursorPositionRect(int hotspotX, int hotspotY);
|
||||||
void writeLEDStateRect(rdr::U8 state);
|
void writeLEDStateRect(rdr::U8 state);
|
||||||
void writeQEMUKeyEventRect();
|
void writeQEMUKeyEventRect();
|
||||||
@@ -171,7 +165,6 @@ namespace rfb {
|
|||||||
bool needSetCursor;
|
bool needSetCursor;
|
||||||
bool needSetXCursor;
|
bool needSetXCursor;
|
||||||
bool needSetCursorWithAlpha;
|
bool needSetCursorWithAlpha;
|
||||||
bool needSetVMWareCursor;
|
|
||||||
bool needCursorPos;
|
bool needCursorPos;
|
||||||
bool needLEDState;
|
bool needLEDState;
|
||||||
bool needQEMUKeyEvent;
|
bool needQEMUKeyEvent;
|
||||||
|
|||||||
@@ -1,197 +0,0 @@
|
|||||||
/* Copyright (C) 2021 Kasm Web
|
|
||||||
*
|
|
||||||
* 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 <rfb/ComparingUpdateTracker.h>
|
|
||||||
#include <rfb/EncodeManager.h>
|
|
||||||
#include <rfb/LogWriter.h>
|
|
||||||
#include <rfb/SConnection.h>
|
|
||||||
#include <rfb/ServerCore.h>
|
|
||||||
#include <rfb/PixelBuffer.h>
|
|
||||||
#include <rfb/TightJPEGEncoder.h>
|
|
||||||
#include <rfb/TightWEBPEncoder.h>
|
|
||||||
#include <rfb/util.h>
|
|
||||||
#include <sys/time.h>
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
using namespace rfb;
|
|
||||||
static LogWriter vlog("SelfBench");
|
|
||||||
|
|
||||||
static const PixelFormat pfRGBX(32, 24, false, true, 255, 255, 255, 0, 8, 16);
|
|
||||||
|
|
||||||
#define RUNS 64
|
|
||||||
|
|
||||||
#define W 1600
|
|
||||||
#define H 1200
|
|
||||||
|
|
||||||
void SelfBench() {
|
|
||||||
|
|
||||||
unsigned i, runs;
|
|
||||||
struct timeval start;
|
|
||||||
|
|
||||||
ManagedPixelBuffer f1(pfRGBX, W, H);
|
|
||||||
ManagedPixelBuffer f2(pfRGBX, W, H);
|
|
||||||
ManagedPixelBuffer screen(pfRGBX, W, H);
|
|
||||||
|
|
||||||
int stride;
|
|
||||||
rdr::U8 *f1ptr = f1.getBufferRW(f1.getRect(), &stride);
|
|
||||||
rdr::U8 *f2ptr = f2.getBufferRW(f2.getRect(), &stride);
|
|
||||||
rdr::U8 * const screenptr = screen.getBufferRW(screen.getRect(), &stride);
|
|
||||||
|
|
||||||
rdr::U8 * const f1orig = f1ptr;
|
|
||||||
rdr::U8 * const f2orig = f2ptr;
|
|
||||||
|
|
||||||
for (i = 0; i < W * H * 4; i += 4) {
|
|
||||||
f1ptr[0] = rand();
|
|
||||||
f1ptr[1] = rand();
|
|
||||||
f1ptr[2] = rand();
|
|
||||||
|
|
||||||
f2ptr[0] = rand();
|
|
||||||
f2ptr[1] = rand();
|
|
||||||
f2ptr[2] = rand();
|
|
||||||
|
|
||||||
f1ptr += 4;
|
|
||||||
f2ptr += 4;
|
|
||||||
}
|
|
||||||
|
|
||||||
vlog.info("Running micro-benchmarks (single-threaded, runs depending on task)");
|
|
||||||
|
|
||||||
// Encoding
|
|
||||||
std::vector<uint8_t> vec;
|
|
||||||
|
|
||||||
TightJPEGEncoder jpeg(NULL);
|
|
||||||
|
|
||||||
gettimeofday(&start, NULL);
|
|
||||||
runs = RUNS;
|
|
||||||
for (i = 0; i < runs; i++) {
|
|
||||||
jpeg.compressOnly(&f1, 8, vec, false);
|
|
||||||
}
|
|
||||||
vlog.info("Jpeg compression at quality 8 took %u ms (%u runs)", msSince(&start), runs);
|
|
||||||
|
|
||||||
gettimeofday(&start, NULL);
|
|
||||||
runs = RUNS;
|
|
||||||
for (i = 0; i < runs; i++) {
|
|
||||||
jpeg.compressOnly(&f1, 4, vec, false);
|
|
||||||
}
|
|
||||||
vlog.info("Jpeg compression at quality 4 took %u ms (%u runs)", msSince(&start), runs);
|
|
||||||
|
|
||||||
|
|
||||||
TightWEBPEncoder webp(NULL);
|
|
||||||
|
|
||||||
gettimeofday(&start, NULL);
|
|
||||||
runs = RUNS / 8;
|
|
||||||
for (i = 0; i < runs; i++) {
|
|
||||||
webp.compressOnly(&f1, 8, vec, false);
|
|
||||||
}
|
|
||||||
vlog.info("Webp compression at quality 8 took %u ms (%u runs)", msSince(&start), runs);
|
|
||||||
|
|
||||||
gettimeofday(&start, NULL);
|
|
||||||
runs = RUNS / 4;
|
|
||||||
for (i = 0; i < runs; i++) {
|
|
||||||
webp.compressOnly(&f1, 4, vec, false);
|
|
||||||
}
|
|
||||||
vlog.info("Webp compression at quality 4 took %u ms (%u runs)", msSince(&start), runs);
|
|
||||||
|
|
||||||
// Scaling
|
|
||||||
gettimeofday(&start, NULL);
|
|
||||||
runs = RUNS;
|
|
||||||
for (i = 0; i < runs; i++) {
|
|
||||||
PixelBuffer *pb = nearestScale(&f1, W * 0.8, H * 0.8, 0.8);
|
|
||||||
delete pb;
|
|
||||||
}
|
|
||||||
vlog.info("Nearest scaling to 80%% took %u ms (%u runs)", msSince(&start), runs);
|
|
||||||
|
|
||||||
gettimeofday(&start, NULL);
|
|
||||||
runs = RUNS;
|
|
||||||
for (i = 0; i < runs; i++) {
|
|
||||||
PixelBuffer *pb = nearestScale(&f1, W * 0.4, H * 0.4, 0.4);
|
|
||||||
delete pb;
|
|
||||||
}
|
|
||||||
vlog.info("Nearest scaling to 40%% took %u ms (%u runs)", msSince(&start), runs);
|
|
||||||
|
|
||||||
gettimeofday(&start, NULL);
|
|
||||||
runs = RUNS;
|
|
||||||
for (i = 0; i < runs; i++) {
|
|
||||||
PixelBuffer *pb = bilinearScale(&f1, W * 0.8, H * 0.8, 0.8);
|
|
||||||
delete pb;
|
|
||||||
}
|
|
||||||
vlog.info("Bilinear scaling to 80%% took %u ms (%u runs)", msSince(&start), runs);
|
|
||||||
|
|
||||||
gettimeofday(&start, NULL);
|
|
||||||
runs = RUNS;
|
|
||||||
for (i = 0; i < runs; i++) {
|
|
||||||
PixelBuffer *pb = bilinearScale(&f1, W * 0.4, H * 0.4, 0.4);
|
|
||||||
delete pb;
|
|
||||||
}
|
|
||||||
vlog.info("Bilinear scaling to 40%% took %u ms (%u runs)", msSince(&start), runs);
|
|
||||||
|
|
||||||
gettimeofday(&start, NULL);
|
|
||||||
runs = RUNS;
|
|
||||||
for (i = 0; i < runs; i++) {
|
|
||||||
PixelBuffer *pb = progressiveBilinearScale(&f1, W * 0.8, H * 0.8, 0.8);
|
|
||||||
delete pb;
|
|
||||||
}
|
|
||||||
vlog.info("Progressive bilinear scaling to 80%% took %u ms (%u runs)", msSince(&start), runs);
|
|
||||||
|
|
||||||
gettimeofday(&start, NULL);
|
|
||||||
runs = RUNS;
|
|
||||||
for (i = 0; i < runs; i++) {
|
|
||||||
PixelBuffer *pb = progressiveBilinearScale(&f1, W * 0.4, H * 0.4, 0.4);
|
|
||||||
delete pb;
|
|
||||||
}
|
|
||||||
vlog.info("Progressive bilinear scaling to 40%% took %u ms (%u runs)", msSince(&start), runs);
|
|
||||||
|
|
||||||
// Analysis
|
|
||||||
ComparingUpdateTracker *comparer = new ComparingUpdateTracker(&screen);
|
|
||||||
Region cursorReg;
|
|
||||||
|
|
||||||
Server::detectScrolling.setParam(false);
|
|
||||||
Server::detectHorizontal.setParam(false);
|
|
||||||
|
|
||||||
gettimeofday(&start, NULL);
|
|
||||||
runs = RUNS;
|
|
||||||
for (i = 0; i < runs; i++) {
|
|
||||||
memcpy(screenptr, i % 2 ? f1orig : f2orig, W * H * 4);
|
|
||||||
comparer->compare(true, cursorReg);
|
|
||||||
}
|
|
||||||
vlog.info("Analysis took %u ms (%u runs) (incl. memcpy overhead)", msSince(&start), runs);
|
|
||||||
|
|
||||||
Server::detectScrolling.setParam(true);
|
|
||||||
|
|
||||||
gettimeofday(&start, NULL);
|
|
||||||
runs = RUNS;
|
|
||||||
for (i = 0; i < runs; i++) {
|
|
||||||
memcpy(screenptr, i % 2 ? f1orig : f2orig, W * H * 4);
|
|
||||||
comparer->compare(false, cursorReg);
|
|
||||||
}
|
|
||||||
vlog.info("Analysis w/ scroll detection took %u ms (%u runs) (incl. memcpy overhead)", msSince(&start), runs);
|
|
||||||
|
|
||||||
Server::detectHorizontal.setParam(true);
|
|
||||||
delete comparer;
|
|
||||||
comparer = new ComparingUpdateTracker(&screen);
|
|
||||||
|
|
||||||
gettimeofday(&start, NULL);
|
|
||||||
runs = RUNS / 2;
|
|
||||||
for (i = 0; i < runs; i++) {
|
|
||||||
memcpy(screenptr, i % 2 ? f1orig : f2orig, W * H * 4);
|
|
||||||
comparer->compare(false, cursorReg);
|
|
||||||
}
|
|
||||||
vlog.info("Analysis w/ horizontal scroll detection took %u ms (%u runs) (incl. memcpy overhead)", msSince(&start), runs);
|
|
||||||
|
|
||||||
exit(0);
|
|
||||||
}
|
|
||||||
@@ -113,10 +113,6 @@ rfb::BoolParameter rfb::Server::ignoreClientSettingsKasm
|
|||||||
("IgnoreClientSettingsKasm",
|
("IgnoreClientSettingsKasm",
|
||||||
"Ignore the additional client settings exposed in Kasm.",
|
"Ignore the additional client settings exposed in Kasm.",
|
||||||
false);
|
false);
|
||||||
rfb::BoolParameter rfb::Server::selfBench
|
|
||||||
("SelfBench",
|
|
||||||
"Run self-benchmarks and exit.",
|
|
||||||
false);
|
|
||||||
rfb::IntParameter rfb::Server::dynamicQualityMin
|
rfb::IntParameter rfb::Server::dynamicQualityMin
|
||||||
("DynamicQualityMin",
|
("DynamicQualityMin",
|
||||||
"The minimum dynamic JPEG quality, 0 = low, 9 = high",
|
"The minimum dynamic JPEG quality, 0 = low, 9 = high",
|
||||||
|
|||||||
@@ -74,7 +74,6 @@ namespace rfb {
|
|||||||
static BoolParameter detectScrolling;
|
static BoolParameter detectScrolling;
|
||||||
static BoolParameter detectHorizontal;
|
static BoolParameter detectHorizontal;
|
||||||
static BoolParameter ignoreClientSettingsKasm;
|
static BoolParameter ignoreClientSettingsKasm;
|
||||||
static BoolParameter selfBench;
|
|
||||||
static PresetParameter preferBandwidth;
|
static PresetParameter preferBandwidth;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -17,7 +17,6 @@
|
|||||||
* USA.
|
* USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <network/GetAPI.h>
|
|
||||||
#include <network/TcpSocket.h>
|
#include <network/TcpSocket.h>
|
||||||
|
|
||||||
#include <rfb/ComparingUpdateTracker.h>
|
#include <rfb/ComparingUpdateTracker.h>
|
||||||
@@ -62,7 +61,7 @@ VNCSConnectionST::VNCSConnectionST(VNCServerST* server_, network::Socket *s,
|
|||||||
continuousUpdates(false), encodeManager(this, &server_->encCache),
|
continuousUpdates(false), encodeManager(this, &server_->encCache),
|
||||||
needsPermCheck(false), pointerEventTime(0),
|
needsPermCheck(false), pointerEventTime(0),
|
||||||
clientHasCursor(false),
|
clientHasCursor(false),
|
||||||
accessRights(AccessDefault), startTime(time(0)), frameTracking(false)
|
accessRights(AccessDefault), startTime(time(0))
|
||||||
{
|
{
|
||||||
setStreams(&sock->inStream(), &sock->outStream());
|
setStreams(&sock->inStream(), &sock->outStream());
|
||||||
peerEndpoint.buf = sock->getPeerEndpoint();
|
peerEndpoint.buf = sock->getPeerEndpoint();
|
||||||
@@ -99,9 +98,6 @@ VNCSConnectionST::VNCSConnectionST(VNCServerST* server_, network::Socket *s,
|
|||||||
gettimeofday(&lastKeyEvent, NULL);
|
gettimeofday(&lastKeyEvent, NULL);
|
||||||
|
|
||||||
server->clients.push_front(this);
|
server->clients.push_front(this);
|
||||||
|
|
||||||
if (server->apimessager)
|
|
||||||
server->apimessager->mainUpdateUserInfo(checkOwnerConn(), server->clients.size());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -132,11 +128,6 @@ VNCSConnectionST::~VNCSConnectionST()
|
|||||||
server->clients.remove(this);
|
server->clients.remove(this);
|
||||||
|
|
||||||
delete [] fenceData;
|
delete [] fenceData;
|
||||||
|
|
||||||
if (server->apimessager) {
|
|
||||||
server->apimessager->mainUpdateUserInfo(checkOwnerConn(), server->clients.size());
|
|
||||||
server->apimessager->mainClearBottleneckStats(peerEndpoint.buf);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -576,7 +567,6 @@ bool VNCSConnectionST::needRenderedCursor()
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!cp.supportsLocalCursorWithAlpha &&
|
if (!cp.supportsLocalCursorWithAlpha &&
|
||||||
!cp.supportsVMWareCursor &&
|
|
||||||
!cp.supportsLocalCursor && !cp.supportsLocalXCursor)
|
!cp.supportsLocalCursor && !cp.supportsLocalXCursor)
|
||||||
return true;
|
return true;
|
||||||
if (!server->cursorPos.equals(pointerEventPos) &&
|
if (!server->cursorPos.equals(pointerEventPos) &&
|
||||||
@@ -1194,7 +1184,6 @@ bool VNCSConnectionST::isCongested()
|
|||||||
void VNCSConnectionST::writeFramebufferUpdate()
|
void VNCSConnectionST::writeFramebufferUpdate()
|
||||||
{
|
{
|
||||||
congestion.updatePosition(sock->outStream().length());
|
congestion.updatePosition(sock->outStream().length());
|
||||||
encodeManager.clearEncodingTime();
|
|
||||||
|
|
||||||
// We're in the middle of processing a command that's supposed to be
|
// We're in the middle of processing a command that's supposed to be
|
||||||
// synchronised. Allowing an update to slip out right now might violate
|
// synchronised. Allowing an update to slip out right now might violate
|
||||||
@@ -1240,9 +1229,6 @@ void VNCSConnectionST::writeFramebufferUpdate()
|
|||||||
// window.
|
// window.
|
||||||
sock->cork(true);
|
sock->cork(true);
|
||||||
|
|
||||||
if (frameTracking)
|
|
||||||
writer()->writeRequestFrameStats();
|
|
||||||
|
|
||||||
// First take care of any updates that cannot contain framebuffer data
|
// First take care of any updates that cannot contain framebuffer data
|
||||||
// changes.
|
// changes.
|
||||||
writeNoDataUpdate();
|
writeNoDataUpdate();
|
||||||
@@ -1473,7 +1459,7 @@ static void pruneStatList(std::list<struct timeval> &list, const struct timeval
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void VNCSConnectionST::sendStats(const bool toClient) {
|
void VNCSConnectionST::sendStats() {
|
||||||
char buf[1024];
|
char buf[1024];
|
||||||
struct timeval now;
|
struct timeval now;
|
||||||
|
|
||||||
@@ -1512,28 +1498,8 @@ void VNCSConnectionST::sendStats(const bool toClient) {
|
|||||||
|
|
||||||
#undef ten
|
#undef ten
|
||||||
|
|
||||||
if (toClient) {
|
vlog.info("Sending client stats:\n%s\n", buf);
|
||||||
vlog.info("Sending client stats:\n%s\n", buf);
|
writer()->writeStats(buf, strlen(buf));
|
||||||
writer()->writeStats(buf, strlen(buf));
|
|
||||||
} else if (server->apimessager) {
|
|
||||||
server->apimessager->mainUpdateBottleneckStats(peerEndpoint.buf, buf);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void VNCSConnectionST::handleFrameStats(rdr::U32 all, rdr::U32 render)
|
|
||||||
{
|
|
||||||
if (server->apimessager) {
|
|
||||||
const char *at = strchr(peerEndpoint.buf, '@');
|
|
||||||
if (!at)
|
|
||||||
at = peerEndpoint.buf;
|
|
||||||
else
|
|
||||||
at++;
|
|
||||||
|
|
||||||
server->apimessager->mainUpdateClientFrameStats(at, render, all,
|
|
||||||
congestion.getPingTime());
|
|
||||||
}
|
|
||||||
|
|
||||||
frameTracking = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// setCursor() is called whenever the cursor has changed shape or pixel format.
|
// setCursor() is called whenever the cursor has changed shape or pixel format.
|
||||||
@@ -1554,13 +1520,11 @@ void VNCSConnectionST::setCursor()
|
|||||||
clientHasCursor = true;
|
clientHasCursor = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!writer()->writeSetVMwareCursor()) {
|
if (!writer()->writeSetCursorWithAlpha()) {
|
||||||
if (!writer()->writeSetCursorWithAlpha()) {
|
if (!writer()->writeSetCursor()) {
|
||||||
if (!writer()->writeSetCursor()) {
|
if (!writer()->writeSetXCursor()) {
|
||||||
if (!writer()->writeSetXCursor()) {
|
// No client support
|
||||||
// No client support
|
return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1647,15 +1611,3 @@ int VNCSConnectionST::getStatus()
|
|||||||
return 4;
|
return 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool VNCSConnectionST::checkOwnerConn() const
|
|
||||||
{
|
|
||||||
std::list<VNCSConnectionST*>::const_iterator it;
|
|
||||||
|
|
||||||
for (it = server->clients.begin(); it != server->clients.end(); it++) {
|
|
||||||
bool write, owner;
|
|
||||||
if ((*it)->getPerms(write, owner) && owner)
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -164,35 +164,6 @@ namespace rfb {
|
|||||||
void setStatus(int status);
|
void setStatus(int status);
|
||||||
int getStatus();
|
int getStatus();
|
||||||
|
|
||||||
virtual void sendStats(const bool toClient = true);
|
|
||||||
virtual void handleFrameStats(rdr::U32 all, rdr::U32 render);
|
|
||||||
|
|
||||||
bool is_owner() const {
|
|
||||||
bool write, owner;
|
|
||||||
if (getPerms(write, owner) && owner)
|
|
||||||
return true;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setFrameTracking() {
|
|
||||||
frameTracking = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
EncodeManager::codecstats_t getJpegStats() const {
|
|
||||||
return encodeManager.jpegstats;
|
|
||||||
}
|
|
||||||
|
|
||||||
EncodeManager::codecstats_t getWebpStats() const {
|
|
||||||
return encodeManager.webpstats;
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned getEncodingTime() const {
|
|
||||||
return encodeManager.getEncodingTime();
|
|
||||||
}
|
|
||||||
unsigned getScalingTime() const {
|
|
||||||
return encodeManager.getScalingTime();
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// SConnection callbacks
|
// SConnection callbacks
|
||||||
|
|
||||||
@@ -220,6 +191,7 @@ namespace rfb {
|
|||||||
virtual void supportsContinuousUpdates();
|
virtual void supportsContinuousUpdates();
|
||||||
virtual void supportsLEDState();
|
virtual void supportsLEDState();
|
||||||
|
|
||||||
|
virtual void sendStats();
|
||||||
virtual bool canChangeKasmSettings() const {
|
virtual bool canChangeKasmSettings() const {
|
||||||
return (accessRights & (AccessPtrEvents | AccessKeyEvents)) ==
|
return (accessRights & (AccessPtrEvents | AccessKeyEvents)) ==
|
||||||
(AccessPtrEvents | AccessKeyEvents);
|
(AccessPtrEvents | AccessKeyEvents);
|
||||||
@@ -247,8 +219,6 @@ namespace rfb {
|
|||||||
|
|
||||||
bool getPerms(bool &write, bool &owner) const;
|
bool getPerms(bool &write, bool &owner) const;
|
||||||
|
|
||||||
bool checkOwnerConn() const;
|
|
||||||
|
|
||||||
// Congestion control
|
// Congestion control
|
||||||
void writeRTTPing();
|
void writeRTTPing();
|
||||||
bool isCongested();
|
bool isCongested();
|
||||||
@@ -324,8 +294,6 @@ namespace rfb {
|
|||||||
time_t startTime;
|
time_t startTime;
|
||||||
|
|
||||||
std::vector<CopyPassRect> copypassed;
|
std::vector<CopyPassRect> copypassed;
|
||||||
|
|
||||||
bool frameTracking;
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -53,7 +53,6 @@
|
|||||||
|
|
||||||
#include <network/GetAPI.h>
|
#include <network/GetAPI.h>
|
||||||
|
|
||||||
#include <rfb/cpuid.h>
|
|
||||||
#include <rfb/ComparingUpdateTracker.h>
|
#include <rfb/ComparingUpdateTracker.h>
|
||||||
#include <rfb/KeyRemapper.h>
|
#include <rfb/KeyRemapper.h>
|
||||||
#include <rfb/ListConnInfo.h>
|
#include <rfb/ListConnInfo.h>
|
||||||
@@ -77,8 +76,6 @@ static LogWriter slog("VNCServerST");
|
|||||||
LogWriter VNCServerST::connectionsLog("Connections");
|
LogWriter VNCServerST::connectionsLog("Connections");
|
||||||
EncCache VNCServerST::encCache;
|
EncCache VNCServerST::encCache;
|
||||||
|
|
||||||
void SelfBench();
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// -=- VNCServerST Implementation
|
// -=- VNCServerST Implementation
|
||||||
//
|
//
|
||||||
@@ -131,13 +128,10 @@ VNCServerST::VNCServerST(const char* name_, SDesktop* desktop_)
|
|||||||
renderedCursorInvalid(false),
|
renderedCursorInvalid(false),
|
||||||
queryConnectionHandler(0), keyRemapper(&KeyRemapper::defInstance),
|
queryConnectionHandler(0), keyRemapper(&KeyRemapper::defInstance),
|
||||||
lastConnectionTime(0), disableclients(false),
|
lastConnectionTime(0), disableclients(false),
|
||||||
frameTimer(this), apimessager(NULL), trackingFrameStats(0)
|
frameTimer(this), apimessager(NULL)
|
||||||
{
|
{
|
||||||
lastUserInputTime = lastDisconnectTime = time(0);
|
lastUserInputTime = lastDisconnectTime = time(0);
|
||||||
slog.debug("creating single-threaded server %s", name.buf);
|
slog.debug("creating single-threaded server %s", name.buf);
|
||||||
slog.info("CPU capability: SSE2 %s, AVX512f %s",
|
|
||||||
supportsSSE2() ? "yes" : "no",
|
|
||||||
supportsAVX512f() ? "yes" : "no");
|
|
||||||
|
|
||||||
DLPRegion.enabled = DLPRegion.percents = false;
|
DLPRegion.enabled = DLPRegion.percents = false;
|
||||||
|
|
||||||
@@ -216,11 +210,6 @@ VNCServerST::VNCServerST(const char* name_, SDesktop* desktop_)
|
|||||||
if (inotify_add_watch(inotifyfd, kasmpasswdpath, IN_CLOSE_WRITE | IN_DELETE_SELF) < 0)
|
if (inotify_add_watch(inotifyfd, kasmpasswdpath, IN_CLOSE_WRITE | IN_DELETE_SELF) < 0)
|
||||||
slog.error("Failed to set watch");
|
slog.error("Failed to set watch");
|
||||||
}
|
}
|
||||||
|
|
||||||
trackingClient[0] = 0;
|
|
||||||
|
|
||||||
if (Server::selfBench)
|
|
||||||
SelfBench();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
VNCServerST::~VNCServerST()
|
VNCServerST::~VNCServerST()
|
||||||
@@ -282,11 +271,6 @@ void VNCServerST::removeSocket(network::Socket* sock) {
|
|||||||
std::list<VNCSConnectionST*>::iterator ci;
|
std::list<VNCSConnectionST*>::iterator ci;
|
||||||
for (ci = clients.begin(); ci != clients.end(); ci++) {
|
for (ci = clients.begin(); ci != clients.end(); ci++) {
|
||||||
if ((*ci)->getSock() == sock) {
|
if ((*ci)->getSock() == sock) {
|
||||||
|
|
||||||
if (clipboardClient == *ci)
|
|
||||||
handleClipboardAnnounce(*ci, false);
|
|
||||||
clipboardRequestors.remove(*ci);
|
|
||||||
|
|
||||||
// - Delete the per-Socket resources
|
// - Delete the per-Socket resources
|
||||||
delete *ci;
|
delete *ci;
|
||||||
|
|
||||||
@@ -790,8 +774,7 @@ int VNCServerST::msToNextUpdate()
|
|||||||
return frameTimer.getRemainingMs();
|
return frameTimer.getRemainingMs();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void checkAPIMessages(network::GetAPIMessager *apimessager,
|
static void checkAPIMessages(network::GetAPIMessager *apimessager)
|
||||||
rdr::U8 &trackingFrameStats, char trackingClient[])
|
|
||||||
{
|
{
|
||||||
if (pthread_mutex_lock(&apimessager->userMutex))
|
if (pthread_mutex_lock(&apimessager->userMutex))
|
||||||
return;
|
return;
|
||||||
@@ -844,20 +827,6 @@ static void checkAPIMessages(network::GetAPIMessager *apimessager,
|
|||||||
slog.error("Tried to give control to nonexistent user %s", act.data.user);
|
slog.error("Tried to give control to nonexistent user %s", act.data.user);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case network::GetAPIMessager::WANT_FRAME_STATS_SERVERONLY:
|
|
||||||
trackingFrameStats = act.action;
|
|
||||||
break;
|
|
||||||
case network::GetAPIMessager::WANT_FRAME_STATS_ALL:
|
|
||||||
trackingFrameStats = act.action;
|
|
||||||
break;
|
|
||||||
case network::GetAPIMessager::WANT_FRAME_STATS_OWNER:
|
|
||||||
trackingFrameStats = act.action;
|
|
||||||
break;
|
|
||||||
case network::GetAPIMessager::WANT_FRAME_STATS_SPECIFIC:
|
|
||||||
trackingFrameStats = act.action;
|
|
||||||
memcpy(trackingClient, act.data.password, 128);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (set) {
|
if (set) {
|
||||||
@@ -954,9 +923,6 @@ void VNCServerST::writeUpdate()
|
|||||||
assert(blockCounter == 0);
|
assert(blockCounter == 0);
|
||||||
assert(desktopStarted);
|
assert(desktopStarted);
|
||||||
|
|
||||||
struct timeval start;
|
|
||||||
gettimeofday(&start, NULL);
|
|
||||||
|
|
||||||
if (DLPRegion.enabled) {
|
if (DLPRegion.enabled) {
|
||||||
comparer->enable_copyrect(false);
|
comparer->enable_copyrect(false);
|
||||||
blackOut();
|
blackOut();
|
||||||
@@ -983,9 +949,6 @@ void VNCServerST::writeUpdate()
|
|||||||
else
|
else
|
||||||
comparer->disable();
|
comparer->disable();
|
||||||
|
|
||||||
struct timeval beforeAnalysis;
|
|
||||||
gettimeofday(&beforeAnalysis, NULL);
|
|
||||||
|
|
||||||
// Skip scroll detection if the client is slow, and didn't get the previous one yet
|
// Skip scroll detection if the client is slow, and didn't get the previous one yet
|
||||||
if (comparer->compare(clients.size() == 1 && (*clients.begin())->has_copypassed(),
|
if (comparer->compare(clients.size() == 1 && (*clients.begin())->has_copypassed(),
|
||||||
cursorReg))
|
cursorReg))
|
||||||
@@ -993,8 +956,6 @@ void VNCServerST::writeUpdate()
|
|||||||
|
|
||||||
comparer->clear();
|
comparer->clear();
|
||||||
|
|
||||||
const unsigned analysisMs = msSince(&beforeAnalysis);
|
|
||||||
|
|
||||||
encCache.clear();
|
encCache.clear();
|
||||||
encCache.enabled = clients.size() > 1;
|
encCache.enabled = clients.size() > 1;
|
||||||
|
|
||||||
@@ -1020,22 +981,11 @@ void VNCServerST::writeUpdate()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned shottime = 0;
|
|
||||||
if (apimessager) {
|
if (apimessager) {
|
||||||
struct timeval shotstart;
|
|
||||||
gettimeofday(&shotstart, NULL);
|
|
||||||
apimessager->mainUpdateScreen(pb);
|
apimessager->mainUpdateScreen(pb);
|
||||||
shottime = msSince(&shotstart);
|
|
||||||
|
|
||||||
trackingFrameStats = 0;
|
checkAPIMessages(apimessager);
|
||||||
checkAPIMessages(apimessager, trackingFrameStats, trackingClient);
|
|
||||||
}
|
}
|
||||||
const rdr::U8 origtrackingFrameStats = trackingFrameStats;
|
|
||||||
|
|
||||||
EncodeManager::codecstats_t jpegstats, webpstats;
|
|
||||||
unsigned enctime = 0, scaletime = 0;
|
|
||||||
memset(&jpegstats, 0, sizeof(EncodeManager::codecstats_t));
|
|
||||||
memset(&webpstats, 0, sizeof(EncodeManager::codecstats_t));
|
|
||||||
|
|
||||||
for (ci = clients.begin(); ci != clients.end(); ci = ci_next) {
|
for (ci = clients.begin(); ci != clients.end(); ci = ci_next) {
|
||||||
ci_next = ci; ci_next++;
|
ci_next = ci; ci_next++;
|
||||||
@@ -1043,68 +993,10 @@ void VNCServerST::writeUpdate()
|
|||||||
if (permcheck)
|
if (permcheck)
|
||||||
(*ci)->recheckPerms();
|
(*ci)->recheckPerms();
|
||||||
|
|
||||||
if (trackingFrameStats == network::GetAPIMessager::WANT_FRAME_STATS_ALL ||
|
|
||||||
(trackingFrameStats == network::GetAPIMessager::WANT_FRAME_STATS_OWNER &&
|
|
||||||
(*ci)->is_owner()) ||
|
|
||||||
(trackingFrameStats == network::GetAPIMessager::WANT_FRAME_STATS_SPECIFIC &&
|
|
||||||
strstr((*ci)->getPeerEndpoint(), trackingClient))) {
|
|
||||||
|
|
||||||
(*ci)->setFrameTracking();
|
|
||||||
|
|
||||||
// Only one owner
|
|
||||||
if (trackingFrameStats == network::GetAPIMessager::WANT_FRAME_STATS_OWNER)
|
|
||||||
trackingFrameStats = network::GetAPIMessager::WANT_FRAME_STATS_SERVERONLY;
|
|
||||||
}
|
|
||||||
|
|
||||||
(*ci)->add_copied(ui.copied, ui.copy_delta);
|
(*ci)->add_copied(ui.copied, ui.copy_delta);
|
||||||
(*ci)->add_copypassed(ui.copypassed);
|
(*ci)->add_copypassed(ui.copypassed);
|
||||||
(*ci)->add_changed(ui.changed);
|
(*ci)->add_changed(ui.changed);
|
||||||
(*ci)->writeFramebufferUpdateOrClose();
|
(*ci)->writeFramebufferUpdateOrClose();
|
||||||
|
|
||||||
if (apimessager) {
|
|
||||||
(*ci)->sendStats(false);
|
|
||||||
const EncodeManager::codecstats_t subjpeg = (*ci)->getJpegStats();
|
|
||||||
const EncodeManager::codecstats_t subwebp = (*ci)->getWebpStats();
|
|
||||||
|
|
||||||
jpegstats.ms += subjpeg.ms;
|
|
||||||
jpegstats.area += subjpeg.area;
|
|
||||||
jpegstats.rects += subjpeg.rects;
|
|
||||||
|
|
||||||
webpstats.ms += subwebp.ms;
|
|
||||||
webpstats.area += subwebp.area;
|
|
||||||
webpstats.rects += subwebp.rects;
|
|
||||||
|
|
||||||
enctime += (*ci)->getEncodingTime();
|
|
||||||
scaletime += (*ci)->getScalingTime();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (trackingFrameStats) {
|
|
||||||
if (enctime) {
|
|
||||||
const unsigned totalMs = msSince(&start);
|
|
||||||
|
|
||||||
if (apimessager)
|
|
||||||
apimessager->mainUpdateServerFrameStats(comparer->changedPerc, totalMs,
|
|
||||||
jpegstats.ms, webpstats.ms,
|
|
||||||
analysisMs,
|
|
||||||
jpegstats.area, webpstats.area,
|
|
||||||
jpegstats.rects, webpstats.rects,
|
|
||||||
enctime, scaletime, shottime,
|
|
||||||
pb->getRect().width(),
|
|
||||||
pb->getRect().height());
|
|
||||||
} else {
|
|
||||||
// Zero encoding time means this was a no-data frame; restore the stats request
|
|
||||||
if (apimessager && pthread_mutex_lock(&apimessager->userMutex) == 0) {
|
|
||||||
|
|
||||||
network::GetAPIMessager::action_data act;
|
|
||||||
act.action = (network::GetAPIMessager::USER_ACTION) origtrackingFrameStats;
|
|
||||||
memcpy(act.data.password, trackingClient, 128);
|
|
||||||
|
|
||||||
apimessager->actionQueue.push_back(act);
|
|
||||||
|
|
||||||
pthread_mutex_unlock(&apimessager->userMutex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -267,9 +267,6 @@ namespace rfb {
|
|||||||
|
|
||||||
network::GetAPIMessager *apimessager;
|
network::GetAPIMessager *apimessager;
|
||||||
|
|
||||||
rdr::U8 trackingFrameStats;
|
|
||||||
char trackingClient[128];
|
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
bool enabled;
|
bool enabled;
|
||||||
int x1, y1, x2, y2;
|
int x1, y1, x2, y2;
|
||||||
|
|||||||
@@ -1,70 +0,0 @@
|
|||||||
/* Copyright (C) 2021 Kasm Web
|
|
||||||
*
|
|
||||||
* 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 <stdint.h>
|
|
||||||
|
|
||||||
static uint32_t cpuid[4] = { 0 };
|
|
||||||
static uint32_t extcpuid[4] = { 0 };
|
|
||||||
|
|
||||||
static void getcpuid() {
|
|
||||||
if (cpuid[0])
|
|
||||||
return;
|
|
||||||
|
|
||||||
#if defined(__x86_64__) || defined(__i386__)
|
|
||||||
uint32_t eax, ecx = 0;
|
|
||||||
|
|
||||||
eax = 1; // normal feature bits
|
|
||||||
|
|
||||||
__asm__ __volatile__(
|
|
||||||
"cpuid\n\t"
|
|
||||||
: "=a"(cpuid[0]), "=b"(cpuid[1]), "=c"(cpuid[2]), "=d"(cpuid[3])
|
|
||||||
: "0"(eax), "2"(ecx)
|
|
||||||
);
|
|
||||||
|
|
||||||
eax = 7; // ext feature bits
|
|
||||||
ecx = 0;
|
|
||||||
|
|
||||||
__asm__ __volatile__(
|
|
||||||
"cpuid\n\t"
|
|
||||||
: "=a"(extcpuid[0]), "=b"(extcpuid[1]), "=c"(extcpuid[2]), "=d"(extcpuid[3])
|
|
||||||
: "0"(eax), "2"(ecx)
|
|
||||||
);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace rfb {
|
|
||||||
|
|
||||||
bool supportsSSE2() {
|
|
||||||
getcpuid();
|
|
||||||
#if defined(__x86_64__) || defined(__i386__)
|
|
||||||
#define bit_SSE2 (1 << 26)
|
|
||||||
return cpuid[3] & bit_SSE2;
|
|
||||||
#endif
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool supportsAVX512f() {
|
|
||||||
getcpuid();
|
|
||||||
#if defined(__x86_64__) || defined(__i386__)
|
|
||||||
#define bit_AVX512f (1 << 16)
|
|
||||||
return extcpuid[1] & bit_AVX512f;
|
|
||||||
#endif
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
}; // namespace rfb
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
/* Copyright (C) 2021 Kasm Web
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __RFB_CPUID_H__
|
|
||||||
#define __RFB_CPUID_H__
|
|
||||||
|
|
||||||
namespace rfb {
|
|
||||||
|
|
||||||
bool supportsSSE2();
|
|
||||||
bool supportsAVX512f();
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -86,7 +86,6 @@ namespace rfb {
|
|||||||
const int pseudoEncodingVideoOutTimeLevel100 = -1887;
|
const int pseudoEncodingVideoOutTimeLevel100 = -1887;
|
||||||
|
|
||||||
// VMware-specific
|
// VMware-specific
|
||||||
const int pseudoEncodingVMwareCursor = 0x574d5664;
|
|
||||||
const int pseudoEncodingVMwareCursorPosition = 0x574d5666;
|
const int pseudoEncodingVMwareCursorPosition = 0x574d5666;
|
||||||
|
|
||||||
// UltraVNC-specific
|
// UltraVNC-specific
|
||||||
|
|||||||
@@ -30,7 +30,6 @@ namespace rfb {
|
|||||||
|
|
||||||
// kasm
|
// kasm
|
||||||
const int msgTypeStats = 178;
|
const int msgTypeStats = 178;
|
||||||
const int msgTypeRequestFrameStats = 179;
|
|
||||||
|
|
||||||
const int msgTypeServerFence = 248;
|
const int msgTypeServerFence = 248;
|
||||||
|
|
||||||
@@ -48,7 +47,6 @@ namespace rfb {
|
|||||||
|
|
||||||
// kasm
|
// kasm
|
||||||
const int msgTypeRequestStats = 178;
|
const int msgTypeRequestStats = 178;
|
||||||
const int msgTypeFrameStats = 179;
|
|
||||||
|
|
||||||
const int msgTypeClientFence = 248;
|
const int msgTypeClientFence = 248;
|
||||||
|
|
||||||
|
|||||||
@@ -1,37 +0,0 @@
|
|||||||
/* Copyright (C) 2021 Kasm Web
|
|
||||||
*
|
|
||||||
* 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 <rfb/scale_sse2.h>
|
|
||||||
|
|
||||||
namespace rfb {
|
|
||||||
|
|
||||||
void SSE2_halve(const uint8_t *oldpx,
|
|
||||||
const uint16_t tgtw, const uint16_t tgth,
|
|
||||||
uint8_t *newpx,
|
|
||||||
const unsigned oldstride, const unsigned newstride) {
|
|
||||||
}
|
|
||||||
|
|
||||||
// Handles factors between 0.5 and 1.0
|
|
||||||
void SSE2_scale(const uint8_t *oldpx,
|
|
||||||
const uint16_t tgtw, const uint16_t tgth,
|
|
||||||
uint8_t *newpx,
|
|
||||||
const unsigned oldstride, const unsigned newstride,
|
|
||||||
const float tgtdiff) {
|
|
||||||
}
|
|
||||||
|
|
||||||
}; // namespace rfb
|
|
||||||
@@ -1,257 +0,0 @@
|
|||||||
/* Copyright (C) 2021 Kasm Web
|
|
||||||
*
|
|
||||||
* 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 <emmintrin.h>
|
|
||||||
|
|
||||||
#include <rfb/scale_sse2.h>
|
|
||||||
|
|
||||||
namespace rfb {
|
|
||||||
|
|
||||||
/*
|
|
||||||
static void print128(const char msg[], const __m128i v) {
|
|
||||||
union {
|
|
||||||
__m128i v;
|
|
||||||
uint8_t c[16];
|
|
||||||
} u;
|
|
||||||
|
|
||||||
u.v = v;
|
|
||||||
|
|
||||||
printf("%s %02x,%02x,%02x,%02x,%02x,%02x,%02x,%02x,%02x,%02x,%02x,%02x,%02x,%02x,%02x,%02x\n",
|
|
||||||
msg,
|
|
||||||
u.c[0],
|
|
||||||
u.c[1],
|
|
||||||
u.c[2],
|
|
||||||
u.c[3],
|
|
||||||
u.c[4],
|
|
||||||
u.c[5],
|
|
||||||
u.c[6],
|
|
||||||
u.c[7],
|
|
||||||
u.c[8],
|
|
||||||
u.c[9],
|
|
||||||
u.c[10],
|
|
||||||
u.c[11],
|
|
||||||
u.c[12],
|
|
||||||
u.c[13],
|
|
||||||
u.c[14],
|
|
||||||
u.c[15]);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
void SSE2_halve(const uint8_t *oldpx,
|
|
||||||
const uint16_t tgtw, const uint16_t tgth,
|
|
||||||
uint8_t *newpx,
|
|
||||||
const unsigned oldstride, const unsigned newstride) {
|
|
||||||
uint16_t x, y;
|
|
||||||
const uint16_t srcw = tgtw * 2, srch = tgth * 2;
|
|
||||||
const __m128i zero = _mm_setzero_si128();
|
|
||||||
const __m128i shift = _mm_set_epi32(0, 0, 0, 2);
|
|
||||||
const __m128i low = _mm_set_epi32(0, 0, 0xffffffff, 0xffffffff);
|
|
||||||
const __m128i high = _mm_set_epi32(0xffffffff, 0xffffffff, 0, 0);
|
|
||||||
|
|
||||||
for (y = 0; y < srch; y += 2) {
|
|
||||||
const uint8_t * const row0 = oldpx + oldstride * y * 4;
|
|
||||||
const uint8_t * const row1 = oldpx + oldstride * (y + 1) * 4;
|
|
||||||
|
|
||||||
uint8_t * const dst = newpx + newstride * (y / 2) * 4;
|
|
||||||
|
|
||||||
for (x = 0; x < srcw; x += 4) {
|
|
||||||
__m128i lo, hi, a, b, c, d;
|
|
||||||
lo = _mm_loadu_si128((__m128i *) &row0[x * 4]);
|
|
||||||
hi = _mm_loadu_si128((__m128i *) &row1[x * 4]);
|
|
||||||
|
|
||||||
a = _mm_unpacklo_epi8(lo, zero);
|
|
||||||
b = _mm_unpackhi_epi8(lo, zero);
|
|
||||||
c = _mm_unpacklo_epi8(hi, zero);
|
|
||||||
d = _mm_unpackhi_epi8(hi, zero);
|
|
||||||
|
|
||||||
a = _mm_add_epi16(a, c);
|
|
||||||
b = _mm_add_epi16(b, d);
|
|
||||||
|
|
||||||
c = _mm_srli_si128(a, 8);
|
|
||||||
a = _mm_and_si128(a, low);
|
|
||||||
a = _mm_add_epi16(a, c);
|
|
||||||
|
|
||||||
d = _mm_slli_si128(b, 8);
|
|
||||||
b = _mm_and_si128(b, high);
|
|
||||||
b = _mm_add_epi16(b, d);
|
|
||||||
|
|
||||||
a = _mm_add_epi16(a, b);
|
|
||||||
|
|
||||||
a = _mm_srl_epi16(a, shift);
|
|
||||||
a = _mm_packus_epi16(a, zero);
|
|
||||||
|
|
||||||
_mm_storel_epi64((__m128i *) &dst[(x / 2) * 4], a);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (; x < srcw; x += 2) {
|
|
||||||
// Remainder in C
|
|
||||||
uint8_t i;
|
|
||||||
for (i = 0; i < 4; i++) {
|
|
||||||
dst[(x / 2) * 4 + i] =
|
|
||||||
(row0[x * 4 + i] +
|
|
||||||
row0[(x + 1) * 4 + i] +
|
|
||||||
row1[x * 4 + i] +
|
|
||||||
row1[(x + 1) * 4 + i]) / 4;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Handles factors between 0.5 and 1.0
|
|
||||||
void SSE2_scale(const uint8_t *oldpx,
|
|
||||||
const uint16_t tgtw, const uint16_t tgth,
|
|
||||||
uint8_t *newpx,
|
|
||||||
const unsigned oldstride, const unsigned newstride,
|
|
||||||
const float tgtdiff) {
|
|
||||||
|
|
||||||
uint16_t x, y;
|
|
||||||
const __m128i zero = _mm_setzero_si128();
|
|
||||||
const __m128i low = _mm_set_epi32(0, 0, 0xffffffff, 0xffffffff);
|
|
||||||
const __m128i high = _mm_set_epi32(0xffffffff, 0xffffffff, 0, 0);
|
|
||||||
const float invdiff = 1 / tgtdiff;
|
|
||||||
|
|
||||||
for (y = 0; y < tgth; y++) {
|
|
||||||
const float ny = y * invdiff;
|
|
||||||
const uint16_t lowy = ny;
|
|
||||||
const uint16_t highy = lowy + 1;
|
|
||||||
const uint16_t bot = (ny - lowy) * 256;
|
|
||||||
const uint16_t top = 256 - bot;
|
|
||||||
const uint32_t * const row0 = (uint32_t *) (oldpx + oldstride * lowy * 4);
|
|
||||||
const uint32_t * const row1 = (uint32_t *) (oldpx + oldstride * highy * 4);
|
|
||||||
const uint8_t * const brow0 = (uint8_t *) row0;
|
|
||||||
const uint8_t * const brow1 = (uint8_t *) row1;
|
|
||||||
|
|
||||||
uint8_t * const dst = newpx + newstride * y * 4;
|
|
||||||
|
|
||||||
const __m128i vertmul = _mm_set1_epi16(top);
|
|
||||||
const __m128i vertmul2 = _mm_set1_epi16(bot);
|
|
||||||
|
|
||||||
for (x = 0; x < tgtw; x += 2) {
|
|
||||||
const float nx[2] = {
|
|
||||||
x * invdiff,
|
|
||||||
(x + 1) * invdiff,
|
|
||||||
};
|
|
||||||
const uint16_t lowx[2] = {
|
|
||||||
(uint16_t) nx[0],
|
|
||||||
(uint16_t) nx[1],
|
|
||||||
};
|
|
||||||
const uint16_t highx[2] = {
|
|
||||||
(uint16_t) (lowx[0] + 1),
|
|
||||||
(uint16_t) (lowx[1] + 1),
|
|
||||||
};
|
|
||||||
const uint16_t right[2] = {
|
|
||||||
(uint16_t) ((nx[0] - lowx[0]) * 256),
|
|
||||||
(uint16_t) ((nx[1] - lowx[1]) * 256),
|
|
||||||
};
|
|
||||||
const uint16_t left[2] = {
|
|
||||||
(uint16_t) (256 - right[0]),
|
|
||||||
(uint16_t) (256 - right[1]),
|
|
||||||
};
|
|
||||||
|
|
||||||
const __m128i horzmul = _mm_set_epi16(
|
|
||||||
right[0],
|
|
||||||
right[0],
|
|
||||||
right[0],
|
|
||||||
right[0],
|
|
||||||
left[0],
|
|
||||||
left[0],
|
|
||||||
left[0],
|
|
||||||
left[0]
|
|
||||||
);
|
|
||||||
const __m128i horzmul2 = _mm_set_epi16(
|
|
||||||
right[1],
|
|
||||||
right[1],
|
|
||||||
right[1],
|
|
||||||
right[1],
|
|
||||||
left[1],
|
|
||||||
left[1],
|
|
||||||
left[1],
|
|
||||||
left[1]
|
|
||||||
);
|
|
||||||
|
|
||||||
__m128i lo, hi, a, b, c, d;
|
|
||||||
lo = _mm_setr_epi32(row0[lowx[0]],
|
|
||||||
row0[highx[0]],
|
|
||||||
row0[lowx[1]],
|
|
||||||
row0[highx[1]]);
|
|
||||||
hi = _mm_setr_epi32(row1[lowx[0]],
|
|
||||||
row1[highx[0]],
|
|
||||||
row1[lowx[1]],
|
|
||||||
row1[highx[1]]);
|
|
||||||
|
|
||||||
a = _mm_unpacklo_epi8(lo, zero);
|
|
||||||
b = _mm_unpackhi_epi8(lo, zero);
|
|
||||||
c = _mm_unpacklo_epi8(hi, zero);
|
|
||||||
d = _mm_unpackhi_epi8(hi, zero);
|
|
||||||
|
|
||||||
a = _mm_mullo_epi16(a, vertmul);
|
|
||||||
b = _mm_mullo_epi16(b, vertmul);
|
|
||||||
c = _mm_mullo_epi16(c, vertmul2);
|
|
||||||
d = _mm_mullo_epi16(d, vertmul2);
|
|
||||||
|
|
||||||
a = _mm_add_epi16(a, c);
|
|
||||||
a = _mm_srli_epi16(a, 8);
|
|
||||||
b = _mm_add_epi16(b, d);
|
|
||||||
b = _mm_srli_epi16(b, 8);
|
|
||||||
|
|
||||||
a = _mm_mullo_epi16(a, horzmul);
|
|
||||||
b = _mm_mullo_epi16(b, horzmul2);
|
|
||||||
|
|
||||||
lo = _mm_srli_si128(a, 8);
|
|
||||||
a = _mm_and_si128(a, low);
|
|
||||||
a = _mm_add_epi16(a, lo);
|
|
||||||
|
|
||||||
hi = _mm_slli_si128(b, 8);
|
|
||||||
b = _mm_and_si128(b, high);
|
|
||||||
b = _mm_add_epi16(b, hi);
|
|
||||||
|
|
||||||
a = _mm_add_epi16(a, b);
|
|
||||||
a = _mm_srli_epi16(a, 8);
|
|
||||||
|
|
||||||
a = _mm_packus_epi16(a, zero);
|
|
||||||
|
|
||||||
_mm_storel_epi64((__m128i *) &dst[x * 4], a);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (; x < tgtw; x++) {
|
|
||||||
// Remainder in C
|
|
||||||
const float nx = x * invdiff;
|
|
||||||
const uint16_t lowx = nx;
|
|
||||||
const uint16_t highx = lowx + 1;
|
|
||||||
const uint16_t right = (nx - lowx) * 256;
|
|
||||||
const uint16_t left = 256 - right;
|
|
||||||
|
|
||||||
uint8_t i;
|
|
||||||
uint32_t val, val2;
|
|
||||||
for (i = 0; i < 4; i++) {
|
|
||||||
val = brow0[lowx * 4 + i] * left;
|
|
||||||
val += brow0[highx * 4 + i] * right;
|
|
||||||
val >>= 8;
|
|
||||||
|
|
||||||
val2 = brow1[lowx * 4 + i] * left;
|
|
||||||
val2 += brow1[highx * 4 + i] * right;
|
|
||||||
val2 >>= 8;
|
|
||||||
|
|
||||||
dst[x * 4 + i] =
|
|
||||||
(val * top + val2 * bot) >> 8;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}; // namespace rfb
|
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
/* Copyright (C) 2021 Kasm Web
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __RFB_SCALE_SSE2_H__
|
|
||||||
#define __RFB_SCALE_SSE2_H__
|
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
namespace rfb {
|
|
||||||
|
|
||||||
void SSE2_halve(const uint8_t *oldpx,
|
|
||||||
const uint16_t tgtw, const uint16_t tgth,
|
|
||||||
uint8_t *newpx,
|
|
||||||
const unsigned oldstride, const unsigned newstride);
|
|
||||||
|
|
||||||
void SSE2_scale(const uint8_t *oldpx,
|
|
||||||
const uint16_t tgtw, const uint16_t tgth,
|
|
||||||
uint8_t *newpx,
|
|
||||||
const unsigned oldstride, const unsigned newstride,
|
|
||||||
const float tgtdiff);
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
2
debian/Makefile.to_fakebuild_tar_package
vendored
2
debian/Makefile.to_fakebuild_tar_package
vendored
@@ -1,7 +1,7 @@
|
|||||||
TARGET_OS := $(shell lsb_release -is | tr '[:upper:]' '[:lower:]')
|
TARGET_OS := $(shell lsb_release -is | tr '[:upper:]' '[:lower:]')
|
||||||
TARGET_OS_CODENAME := $(shell lsb_release -cs | tr '[:upper:]' '[:lower:]')
|
TARGET_OS_CODENAME := $(shell lsb_release -cs | tr '[:upper:]' '[:lower:]')
|
||||||
TARBALL_DIR := builder/build
|
TARBALL_DIR := builder/build
|
||||||
TARBALL := $(TARBALL_DIR)/kasmvnc.$(TARGET_OS)_$(TARGET_OS_CODENAME)$(BUILD_TAG).tar.gz
|
TARBALL := $(TARBALL_DIR)/kasmvnc.$(TARGET_OS)_$(TARGET_OS_CODENAME).tar.gz
|
||||||
TAR_DATA := $(shell mktemp -d)
|
TAR_DATA := $(shell mktemp -d)
|
||||||
SRC := $(TAR_DATA)/usr/local
|
SRC := $(TAR_DATA)/usr/local
|
||||||
SRC_BIN := $(SRC)/bin
|
SRC_BIN := $(SRC)/bin
|
||||||
|
|||||||
2
kasmweb
2
kasmweb
Submodule kasmweb updated: d1e4bda4b3...67466077c0
@@ -317,10 +317,6 @@ Log clipboard and keyboard actions. Info logs just clipboard direction and size,
|
|||||||
verbose adds the contents for both.
|
verbose adds the contents for both.
|
||||||
.
|
.
|
||||||
.TP
|
.TP
|
||||||
.B \-selfBench
|
|
||||||
Run a set of self-benchmarks and exit.
|
|
||||||
.
|
|
||||||
.TP
|
|
||||||
.B \-noWebsocket
|
.B \-noWebsocket
|
||||||
Disable websockets and expose a traditional VNC port (5901, etc.).
|
Disable websockets and expose a traditional VNC port (5901, etc.).
|
||||||
.
|
.
|
||||||
|
|||||||
Reference in New Issue
Block a user