Compare commits
12 Commits
v0.9.3-bet
...
KASM-1910-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8f1f88d6b2 | ||
|
|
2f91fbd235 | ||
|
|
3500489bb8 | ||
|
|
22362e73ad | ||
|
|
0a1f705637 | ||
|
|
02dc1a4b53 | ||
|
|
33dd45b6e5 | ||
|
|
c5d61ca63e | ||
|
|
bb2dc1787d | ||
|
|
2bdfd0f70a | ||
|
|
c9a4319ca7 | ||
|
|
b367d1711d |
14
.ci/check_if_build_was_already_uploaded
Executable file
14
.ci/check_if_build_was_already_uploaded
Executable file
@@ -0,0 +1,14 @@
|
|||||||
|
#!/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,36 +1,15 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
is_kasmvnc() {
|
is_kasmvnc_package() {
|
||||||
local package="$1";
|
local package="$1";
|
||||||
|
|
||||||
echo "$package" | grep -q 'kasmvncserver_'
|
echo "$package" | grep -E -q 'kasmvncserver_|rpm'
|
||||||
}
|
|
||||||
|
|
||||||
detect_deb_package_arch() {
|
|
||||||
local deb_package="$1"
|
|
||||||
echo "$deb_package" | sed -e 's/.\+_\([^.]\+\)\.\(d\?\)deb/\1/'
|
|
||||||
}
|
|
||||||
|
|
||||||
find_deb_package() {
|
|
||||||
local dbgsym_package="$1"
|
|
||||||
|
|
||||||
echo "$dbgsym_package" | sed -e 's/-dbgsym//; s/ddeb/deb/'
|
|
||||||
}
|
|
||||||
|
|
||||||
fetch_xvnc_md5sum() {
|
|
||||||
local deb_package="$1"
|
|
||||||
deb_package=$(realpath "$deb_package")
|
|
||||||
|
|
||||||
local tmpdir=$(mktemp -d)
|
|
||||||
cd "$tmpdir"
|
|
||||||
dpkg-deb -e "$deb_package"
|
|
||||||
cat DEBIAN/md5sums | grep bin/Xkasmvnc | cut -d' ' -f 1
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function prepare_upload_filename() {
|
function prepare_upload_filename() {
|
||||||
local package="$1";
|
local package="$1";
|
||||||
|
|
||||||
if ! is_kasmvnc "$package"; then
|
if ! is_kasmvnc_package "$package"; then
|
||||||
export upload_filename="$package"
|
export upload_filename="$package"
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
@@ -55,18 +34,19 @@ function prepare_upload_filename() {
|
|||||||
function upload_to_s3() {
|
function upload_to_s3() {
|
||||||
local package="$1";
|
local package="$1";
|
||||||
local upload_filename="$2";
|
local upload_filename="$2";
|
||||||
local s3_bucket="$3";
|
|
||||||
|
|
||||||
# Transfer to S3
|
# Transfer to S3
|
||||||
python3 amazon-s3-bitbucket-pipelines-python/s3_upload.py "${s3_bucket}" "$package" "${upload_filename}";
|
python3 amazon-s3-bitbucket-pipelines-python/s3_upload.py "${S3_BUCKET}" "$package" "${S3_BUILD_DIRECTORY}/${upload_filename}";
|
||||||
# Use the Gitlab API to tell Gitlab where the artifact was stored
|
# Use the Gitlab API to tell Gitlab where the artifact was stored
|
||||||
export S3_URL="https://${s3_bucket}.s3.amazonaws.com/${upload_filename}";
|
export S3_URL="https://${S3_BUCKET}.s3.amazonaws.com/${S3_BUILD_DIRECTORY}/${upload_filename}";
|
||||||
|
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}";
|
||||||
};
|
};
|
||||||
|
|
||||||
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;
|
||||||
apt-get install -y ruby2.7 git wget;
|
apt-get install -y ruby2.7 git;
|
||||||
apt-get install -y python3 python3-pip python3-boto3 curl pkg-config libxmlsec1-dev;
|
apt-get install -y python3 python3-pip python3-boto3 curl pkg-config libxmlsec1-dev;
|
||||||
git clone https://bitbucket.org/awslabs/amazon-s3-bitbucket-pipelines-python.git;
|
git clone https://bitbucket.org/awslabs/amazon-s3-bitbucket-pipelines-python.git;
|
||||||
};
|
};
|
||||||
|
|||||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -21,4 +21,3 @@ debian/files
|
|||||||
debian/kasmvncserver.substvars
|
debian/kasmvncserver.substvars
|
||||||
debian/kasmvncserver/
|
debian/kasmvncserver/
|
||||||
.pc
|
.pc
|
||||||
.vscode/
|
|
||||||
|
|||||||
296
.gitlab-ci.yml
296
.gitlab-ci.yml
@@ -3,370 +3,116 @@ services:
|
|||||||
- docker:dind
|
- docker:dind
|
||||||
|
|
||||||
variables:
|
variables:
|
||||||
KASMVNC_COMMIT_ID: $CI_COMMIT_SHA
|
|
||||||
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
|
||||||
# E.g. BUILD_JOBS: build_debian_buster,build_ubuntu_bionic. This will include
|
# S3_BUILD_DIRECTORY: kasmvnc/${CI_COMMIT_SHA}
|
||||||
# arm builds, because build_debian_buster_arm matches build_debian_buster.
|
S3_BUILD_DIRECTORY: kasmvnc/159d7527955f131e096cf1602b7f9f66cc5d66cb
|
||||||
# "BUILD_JOBS: none" won't build any build jobs, nor www.
|
|
||||||
BUILD_JOBS: all
|
|
||||||
|
|
||||||
stages:
|
stages:
|
||||||
- www
|
- 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
|
||||||
- pwd
|
- pwd
|
||||||
- apk add bash
|
- apk add bash
|
||||||
- mkdir -p "$GITLAB_SHARED_DIND_DIR" && chmod 777 "$GITLAB_SHARED_DIND_DIR"
|
- mkdir -p "$GITLAB_SHARED_DIND_DIR" && chmod 777 "$GITLAB_SHARED_DIND_DIR"
|
||||||
|
|
||||||
.prepare_www: &prepare_www
|
|
||||||
- tar -zxf output/www/kasm_www.tar.gz -C builder/
|
|
||||||
|
|
||||||
.prepare_artfacts: &prepare_artfacts
|
.prepare_artfacts: &prepare_artfacts
|
||||||
|
- mkdir output
|
||||||
- cp -r builder/build/* output/
|
- cp -r builder/build/* output/
|
||||||
- rm output/*.tar.gz
|
- rm output/*.tar.gz
|
||||||
|
|
||||||
build_www:
|
|
||||||
stage: www
|
|
||||||
allow_failure: false
|
|
||||||
before_script:
|
|
||||||
- *prepare_build
|
|
||||||
script:
|
|
||||||
- webpacked_www=$PWD/builder/www
|
|
||||||
- src_www=kasmweb
|
|
||||||
- docker build -t kasmweb/www -f builder/dockerfile.www.build .
|
|
||||||
- docker run --rm -v $PWD/builder/www:/build kasmweb/www:latest
|
|
||||||
- mkdir -p output/www
|
|
||||||
- cd builder
|
|
||||||
- tar -zcvf ../output/www/kasm_www.tar.gz www
|
|
||||||
only:
|
|
||||||
variables:
|
|
||||||
- $BUILD_JOBS !~ /^none$/
|
|
||||||
artifacts:
|
|
||||||
paths:
|
|
||||||
- output/
|
|
||||||
|
|
||||||
build_ubuntu_bionic:
|
build_ubuntu_bionic:
|
||||||
stage: build
|
stage: build
|
||||||
allow_failure: true
|
|
||||||
before_script:
|
before_script:
|
||||||
- *prepare_build
|
- *prepare_build
|
||||||
- *prepare_www
|
|
||||||
after_script:
|
after_script:
|
||||||
- *prepare_artfacts
|
- *prepare_artfacts
|
||||||
script:
|
script:
|
||||||
- bash builder/build-package ubuntu bionic
|
- bash builder/build-package ubuntu bionic
|
||||||
only:
|
|
||||||
variables:
|
|
||||||
- $BUILD_JOBS == 'all' || $BUILD_JOBS =~ $CI_JOB_NAME
|
|
||||||
artifacts:
|
|
||||||
paths:
|
|
||||||
- output/
|
|
||||||
|
|
||||||
build_ubuntu_bionic_arm:
|
|
||||||
stage: build
|
|
||||||
allow_failure: false
|
|
||||||
tags:
|
|
||||||
- arm
|
|
||||||
before_script:
|
|
||||||
- *prepare_build
|
|
||||||
- *prepare_www
|
|
||||||
after_script:
|
|
||||||
- *prepare_artfacts
|
|
||||||
script:
|
|
||||||
- bash builder/build-package ubuntu bionic
|
|
||||||
only:
|
|
||||||
variables:
|
|
||||||
- $BUILD_JOBS == 'all' || $BUILD_JOBS =~ $CI_JOB_NAME
|
|
||||||
artifacts:
|
artifacts:
|
||||||
paths:
|
paths:
|
||||||
- output/
|
- output/
|
||||||
|
|
||||||
build_ubuntu_bionic_libjpeg_turbo:
|
build_ubuntu_bionic_libjpeg_turbo:
|
||||||
stage: build
|
stage: build
|
||||||
allow_failure: false
|
|
||||||
before_script:
|
before_script:
|
||||||
- *prepare_build
|
- *prepare_build
|
||||||
- *prepare_www
|
|
||||||
after_script:
|
after_script:
|
||||||
- *prepare_artfacts
|
- *prepare_artfacts
|
||||||
script:
|
script:
|
||||||
- bash builder/build-package ubuntu bionic +libjpeg-turbo_latest
|
- bash builder/build-package ubuntu bionic +libjpeg-turbo_latest
|
||||||
only:
|
|
||||||
variables:
|
|
||||||
- $BUILD_JOBS == 'all' || $BUILD_JOBS =~ $CI_JOB_NAME
|
|
||||||
artifacts:
|
artifacts:
|
||||||
paths:
|
paths:
|
||||||
- output/
|
- output/
|
||||||
|
|
||||||
build_ubuntu_focal:
|
build_ubuntu_focal:
|
||||||
stage: build
|
stage: build
|
||||||
allow_failure: true
|
|
||||||
before_script:
|
before_script:
|
||||||
- *prepare_build
|
- *prepare_build
|
||||||
- *prepare_www
|
|
||||||
after_script:
|
after_script:
|
||||||
- *prepare_artfacts
|
- *prepare_artfacts
|
||||||
script:
|
script:
|
||||||
- bash builder/build-package ubuntu focal;
|
- bash builder/build-package ubuntu focal;
|
||||||
only:
|
|
||||||
variables:
|
|
||||||
- $BUILD_JOBS == 'all' || $BUILD_JOBS =~ $CI_JOB_NAME
|
|
||||||
artifacts:
|
|
||||||
paths:
|
|
||||||
- output/
|
|
||||||
|
|
||||||
build_ubuntu_focal_arm:
|
|
||||||
stage: build
|
|
||||||
allow_failure: true
|
|
||||||
tags:
|
|
||||||
- arm
|
|
||||||
before_script:
|
|
||||||
- *prepare_build
|
|
||||||
- *prepare_www
|
|
||||||
after_script:
|
|
||||||
- *prepare_artfacts
|
|
||||||
script:
|
|
||||||
- bash builder/build-package ubuntu focal;
|
|
||||||
only:
|
|
||||||
variables:
|
|
||||||
- $BUILD_JOBS == 'all' || $BUILD_JOBS =~ $CI_JOB_NAME
|
|
||||||
artifacts:
|
|
||||||
paths:
|
|
||||||
- output/
|
|
||||||
|
|
||||||
build_ubuntu_jammy:
|
|
||||||
stage: build
|
|
||||||
allow_failure: true
|
|
||||||
before_script:
|
|
||||||
- *prepare_build
|
|
||||||
- *prepare_www
|
|
||||||
after_script:
|
|
||||||
- *prepare_artfacts
|
|
||||||
script:
|
|
||||||
- bash builder/build-package ubuntu jammy;
|
|
||||||
only:
|
|
||||||
variables:
|
|
||||||
- $BUILD_JOBS == 'all' || $BUILD_JOBS =~ $CI_JOB_NAME
|
|
||||||
artifacts:
|
|
||||||
paths:
|
|
||||||
- output/
|
|
||||||
|
|
||||||
build_ubuntu_jammy_arm:
|
|
||||||
stage: build
|
|
||||||
allow_failure: true
|
|
||||||
tags:
|
|
||||||
- arm
|
|
||||||
before_script:
|
|
||||||
- *prepare_build
|
|
||||||
- *prepare_www
|
|
||||||
after_script:
|
|
||||||
- *prepare_artfacts
|
|
||||||
script:
|
|
||||||
- bash builder/build-package ubuntu jammy;
|
|
||||||
only:
|
|
||||||
variables:
|
|
||||||
- $BUILD_JOBS == 'all' || $BUILD_JOBS =~ $CI_JOB_NAME
|
|
||||||
artifacts:
|
artifacts:
|
||||||
paths:
|
paths:
|
||||||
- output/
|
- output/
|
||||||
|
|
||||||
build_debian_buster:
|
build_debian_buster:
|
||||||
stage: build
|
stage: build
|
||||||
allow_failure: true
|
|
||||||
before_script:
|
before_script:
|
||||||
- *prepare_build
|
- *prepare_build
|
||||||
- *prepare_www
|
|
||||||
after_script:
|
after_script:
|
||||||
- *prepare_artfacts
|
- *prepare_artfacts
|
||||||
script:
|
script:
|
||||||
- bash builder/build-package debian buster;
|
- bash builder/build-package debian buster;
|
||||||
only:
|
|
||||||
variables:
|
|
||||||
- $CI_COMMIT_MESSAGE =~ /\[full [cC][Ii]\]/ || $BUILD_JOBS =~ $CI_JOB_NAME
|
|
||||||
artifacts:
|
|
||||||
paths:
|
|
||||||
- output/
|
|
||||||
|
|
||||||
build_debian_buster_arm:
|
|
||||||
stage: build
|
|
||||||
allow_failure: true
|
|
||||||
tags:
|
|
||||||
- arm
|
|
||||||
before_script:
|
|
||||||
- *prepare_build
|
|
||||||
- *prepare_www
|
|
||||||
after_script:
|
|
||||||
- *prepare_artfacts
|
|
||||||
script:
|
|
||||||
- bash builder/build-package debian buster;
|
|
||||||
only:
|
|
||||||
variables:
|
|
||||||
- $CI_COMMIT_MESSAGE =~ /\[full [cC][Ii]\]/ || $BUILD_JOBS =~ $CI_JOB_NAME
|
|
||||||
artifacts:
|
artifacts:
|
||||||
paths:
|
paths:
|
||||||
- output/
|
- output/
|
||||||
|
|
||||||
build_debian_bullseye:
|
build_debian_bullseye:
|
||||||
stage: build
|
stage: build
|
||||||
allow_failure: true
|
|
||||||
before_script:
|
before_script:
|
||||||
- *prepare_build
|
- *prepare_build
|
||||||
- *prepare_www
|
|
||||||
after_script:
|
after_script:
|
||||||
- *prepare_artfacts
|
- *prepare_artfacts
|
||||||
script:
|
script:
|
||||||
- bash builder/build-package debian bullseye;
|
- bash builder/build-package debian bullseye;
|
||||||
only:
|
|
||||||
variables:
|
|
||||||
- $CI_COMMIT_MESSAGE =~ /\[full [cC][Ii]\]/ || $BUILD_JOBS =~ $CI_JOB_NAME
|
|
||||||
artifacts:
|
|
||||||
paths:
|
|
||||||
- output/
|
|
||||||
|
|
||||||
build_debian_bullseye_arm:
|
|
||||||
stage: build
|
|
||||||
allow_failure: true
|
|
||||||
tags:
|
|
||||||
- arm
|
|
||||||
before_script:
|
|
||||||
- *prepare_build
|
|
||||||
- *prepare_www
|
|
||||||
after_script:
|
|
||||||
- *prepare_artfacts
|
|
||||||
script:
|
|
||||||
- bash builder/build-package debian bullseye;
|
|
||||||
only:
|
|
||||||
variables:
|
|
||||||
- $CI_COMMIT_MESSAGE =~ /\[full [cC][Ii]\]/ || $BUILD_JOBS =~ $CI_JOB_NAME
|
|
||||||
artifacts:
|
artifacts:
|
||||||
paths:
|
paths:
|
||||||
- output/
|
- output/
|
||||||
|
|
||||||
build_kali_rolling:
|
build_kali_rolling:
|
||||||
stage: build
|
stage: build
|
||||||
allow_failure: true
|
|
||||||
before_script:
|
before_script:
|
||||||
- *prepare_build
|
- *prepare_build
|
||||||
- *prepare_www
|
|
||||||
after_script:
|
after_script:
|
||||||
- *prepare_artfacts
|
- *prepare_artfacts
|
||||||
script:
|
script:
|
||||||
- bash builder/build-package kali kali-rolling;
|
- bash builder/build-package kali kali-rolling;
|
||||||
only:
|
|
||||||
variables:
|
|
||||||
- $BUILD_JOBS == 'all' || $BUILD_JOBS =~ $CI_JOB_NAME
|
|
||||||
artifacts:
|
|
||||||
paths:
|
|
||||||
- output/
|
|
||||||
|
|
||||||
build_kali_rolling_arm:
|
|
||||||
stage: build
|
|
||||||
allow_failure: true
|
|
||||||
tags:
|
|
||||||
- arm
|
|
||||||
before_script:
|
|
||||||
- *prepare_build
|
|
||||||
- *prepare_www
|
|
||||||
after_script:
|
|
||||||
- *prepare_artfacts
|
|
||||||
script:
|
|
||||||
- bash builder/build-package kali kali-rolling;
|
|
||||||
only:
|
|
||||||
variables:
|
|
||||||
- $BUILD_JOBS == 'all' || $BUILD_JOBS =~ $CI_JOB_NAME
|
|
||||||
artifacts:
|
artifacts:
|
||||||
paths:
|
paths:
|
||||||
- output/
|
- output/
|
||||||
|
|
||||||
build_centos7:
|
build_centos7:
|
||||||
stage: build
|
stage: build
|
||||||
allow_failure: true
|
|
||||||
before_script:
|
before_script:
|
||||||
- *prepare_build
|
- *prepare_build
|
||||||
- *prepare_www
|
|
||||||
after_script:
|
after_script:
|
||||||
- *prepare_artfacts
|
- *prepare_artfacts
|
||||||
script:
|
script:
|
||||||
- bash builder/build-package centos core
|
- bash builder/build-package centos core
|
||||||
only:
|
|
||||||
variables:
|
|
||||||
- $BUILD_JOBS == 'all' || $BUILD_JOBS =~ $CI_JOB_NAME
|
|
||||||
artifacts:
|
|
||||||
paths:
|
|
||||||
- output/
|
|
||||||
|
|
||||||
build_oracle_8:
|
|
||||||
stage: build
|
|
||||||
allow_failure: true
|
|
||||||
before_script:
|
|
||||||
- *prepare_build
|
|
||||||
- *prepare_www
|
|
||||||
after_script:
|
|
||||||
- *prepare_artfacts
|
|
||||||
script:
|
|
||||||
- bash builder/build-package oracle 8;
|
|
||||||
only:
|
|
||||||
variables:
|
|
||||||
- $BUILD_JOBS == 'all' || $BUILD_JOBS =~ $CI_JOB_NAME
|
|
||||||
artifacts:
|
|
||||||
paths:
|
|
||||||
- output/
|
|
||||||
|
|
||||||
build_oracle_8_arm:
|
|
||||||
stage: build
|
|
||||||
allow_failure: true
|
|
||||||
tags:
|
|
||||||
- arm
|
|
||||||
before_script:
|
|
||||||
- *prepare_build
|
|
||||||
- *prepare_www
|
|
||||||
after_script:
|
|
||||||
- *prepare_artfacts
|
|
||||||
script:
|
|
||||||
- bash builder/build-package oracle 8;
|
|
||||||
only:
|
|
||||||
variables:
|
|
||||||
- $BUILD_JOBS == 'all' || $BUILD_JOBS =~ $CI_JOB_NAME
|
|
||||||
artifacts:
|
|
||||||
paths:
|
|
||||||
- output/
|
|
||||||
|
|
||||||
build_opensuse_15:
|
|
||||||
stage: build
|
|
||||||
allow_failure: true
|
|
||||||
before_script:
|
|
||||||
- *prepare_build
|
|
||||||
- *prepare_www
|
|
||||||
after_script:
|
|
||||||
- *prepare_artfacts
|
|
||||||
script:
|
|
||||||
- bash builder/build-package opensuse 15;
|
|
||||||
only:
|
|
||||||
variables:
|
|
||||||
- $BUILD_JOBS == 'all' || $BUILD_JOBS =~ $CI_JOB_NAME
|
|
||||||
artifacts:
|
|
||||||
paths:
|
|
||||||
- output/
|
|
||||||
|
|
||||||
build_opensuse_15_arm:
|
|
||||||
stage: build
|
|
||||||
allow_failure: true
|
|
||||||
tags:
|
|
||||||
- arm
|
|
||||||
before_script:
|
|
||||||
- *prepare_build
|
|
||||||
- *prepare_www
|
|
||||||
after_script:
|
|
||||||
- *prepare_artfacts
|
|
||||||
script:
|
|
||||||
- bash builder/build-package opensuse 15;
|
|
||||||
only:
|
|
||||||
variables:
|
|
||||||
- $BUILD_JOBS == 'all' || $BUILD_JOBS =~ $CI_JOB_NAME
|
|
||||||
artifacts:
|
artifacts:
|
||||||
paths:
|
paths:
|
||||||
- output/
|
- output/
|
||||||
@@ -378,24 +124,10 @@ upload:
|
|||||||
- . .ci/upload.sh
|
- . .ci/upload.sh
|
||||||
script:
|
script:
|
||||||
- prepare_to_run_scripts_and_s3_uploads
|
- prepare_to_run_scripts_and_s3_uploads
|
||||||
- S3_CRASHPAD_BUILD_DIRECTORY="kasmvnc/crashpad/${CI_COMMIT_SHA}"
|
|
||||||
- for dbgsym_package in `find output/ -type f -name '*dbgsym*deb'`; do
|
|
||||||
deb_package=$(find_deb_package "$dbgsym_package");
|
|
||||||
xvnc_md5sum=$(fetch_xvnc_md5sum "$deb_package");
|
|
||||||
upload_filename="${S3_CRASHPAD_BUILD_DIRECTORY}/${xvnc_md5sum}/kasmvncserver-dbgsym.deb";
|
|
||||||
echo;
|
|
||||||
echo "File to upload $upload_filename";
|
|
||||||
upload_to_s3 "$dbgsym_package" "$upload_filename" "$S3_BUCKET";
|
|
||||||
rm "$dbgsym_package";
|
|
||||||
done
|
|
||||||
- export S3_BUILD_DIRECTORY="kasmvnc/${CI_COMMIT_SHA}"
|
|
||||||
- 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 '*.deb' -or -name '*.rpm'`; do
|
||||||
prepare_upload_filename "$package";
|
prepare_upload_filename "$package";
|
||||||
upload_filename="${S3_BUILD_DIRECTORY}/$upload_filename";
|
|
||||||
echo;
|
echo;
|
||||||
echo "File to upload $upload_filename";
|
echo "File to upload $upload_filename";
|
||||||
upload_to_s3 "$package" "$upload_filename" "$S3_BUCKET";
|
upload_to_s3 "$package" "$upload_filename";
|
||||||
UPLOAD_NAME=$(basename $upload_filename | sed 's#kasmvncserver_##' | sed -r 's#_([0-9]{1,3}\.){2}[0-9]{1,2}_\S+?([a-f0-9]{6})##' | sed -r 's#\.(deb|rpm)##');
|
|
||||||
curl --request POST --header "PRIVATE-TOKEN:${GITLAB_API_TOKEN}" "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/statuses/${CI_COMMIT_SHA}?state=success&name=${UPLOAD_NAME}&target_url=${S3_URL}";
|
|
||||||
done
|
done
|
||||||
|
|||||||
108
DEBUGGING.md
108
DEBUGGING.md
@@ -1,108 +0,0 @@
|
|||||||
# Debugging
|
|
||||||
In the case where KasmVNC crashes and a backtrace is produced. Developers need a way to make the backtrace useful for debugging. This document covers where the backtrace is logged and how to use a debug symbol package and gdb to gain more information from the backtrace, such as filename, function name, and line number.
|
|
||||||
|
|
||||||
## Test Symbolization
|
|
||||||
If you want to induce a crash to test that you can symbolize a backtrace you can start KasmVNC and then issue the following command.
|
|
||||||
|
|
||||||
killall -SEGV Xvnc
|
|
||||||
|
|
||||||
This will cause KasmVNC to terminate with a backtrace similar to the following. You will find the backtrace in the log file at $HOME/.vnc/$HOSTNAME:$DISPLAY.log where HOME is your user's profile path, HOSTNAME is the hostname of the system, and DISPLAY is the assigned display number for the session.
|
|
||||||
|
|
||||||
(EE)
|
|
||||||
(EE) Backtrace:
|
|
||||||
(EE) 0: /usr/bin/Xvnc (xorg_backtrace+0x4d) [0x5e48dd]
|
|
||||||
(EE) 1: /usr/bin/Xvnc (0x400000+0x1e8259) [0x5e8259]
|
|
||||||
(EE) 2: /lib/x86_64-linux-gnu/libpthread.so.0 (0x7f5a57ef6000+0x12980) [0x7f5a57f08980]
|
|
||||||
(EE) 3: /lib/x86_64-linux-gnu/libc.so.6 (epoll_wait+0x57) [0x7f5a552eca47]
|
|
||||||
(EE) 4: /usr/bin/Xvnc (ospoll_wait+0x37) [0x5e8d07]
|
|
||||||
(EE) 5: /usr/bin/Xvnc (WaitForSomething+0x1c3) [0x5e2813]
|
|
||||||
(EE) 6: /usr/bin/Xvnc (Dispatch+0xa7) [0x597007]
|
|
||||||
(EE) 7: /usr/bin/Xvnc (dix_main+0x36e) [0x59b1fe]
|
|
||||||
(EE) 8: /lib/x86_64-linux-gnu/libc.so.6 (__libc_start_main+0xe7) [0x7f5a551ecbf7]
|
|
||||||
(EE) 9: /usr/bin/Xvnc (_start+0x2a) [0x46048a]
|
|
||||||
(EE)
|
|
||||||
(EE) Received signal 11 sent by process 17182, uid 0
|
|
||||||
(EE)
|
|
||||||
Fatal server error:
|
|
||||||
(EE) Caught signal 11 (Segmentation fault). Server aborting
|
|
||||||
(EE)
|
|
||||||
|
|
||||||
## Debug Symbol Package
|
|
||||||
In order to make use of this backtrace, you will need to symbolize the backtrace. Each build of KasmVNC produced by our pipelines comes with a corresponding debug symbol package that can be downloaded. You need two pieces of information to get the package, the git commit ID of KasmVNC and the MD5 sum of Xkasmvnc binary on your system.
|
|
||||||
|
|
||||||
The git commit ID can be found using Xvnc -version:
|
|
||||||
|
|
||||||
ubuntu@matt-dev-vm-1:~$ Xvnc -version
|
|
||||||
Xvnc KasmVNC 0.9.94002f39917dca0ad82ac0c29a75c723b538b32b - built Feb 17 2022 15:21:01
|
|
||||||
Copyright (C) 1999-2018 KasmVNC Team and many others (see README.me)
|
|
||||||
See http://kasmweb.com for information on KasmVNC.
|
|
||||||
Underlying X server release 12010000, The X.Org Foundation
|
|
||||||
|
|
||||||
The MD5 sum can be obtained using the md5sum command:
|
|
||||||
|
|
||||||
md5sum /usr/bin/Xkasmvnc
|
|
||||||
57ee7028239c5a737c0aeee4a34138c3 /usr/bin/Xkasmvnc
|
|
||||||
|
|
||||||
With these two pieces of information, you can get the debug symbol package at https://kasmweb-build-artifacts.s3.amazonaws.com/kasmvnc/crashpad/[COMMITID]/[MD5SUM]/kasmvncserver-dbgsym.deb, in the above example it would be.
|
|
||||||
|
|
||||||
[https://kasmweb-build-artifacts.s3.amazonaws.com/kasmvnc/crashpad/94002f39917dca0ad82ac0c29a75c723b538b32b/57ee7028239c5a737c0aeee4a34138c3/kasmvncserver-dbgsym.deb](https://kasmweb-build-artifacts.s3.amazonaws.com/kasmvnc/crashpad/94002f39917dca0ad82ac0c29a75c723b538b32b/57ee7028239c5a737c0aeee4a34138c3/kasmvncserver-dbgsym.deb "https://kasmweb-build-artifacts.s3.amazonaws.com/kasmvnc/crashpad/94002f39917dca0ad82ac0c29a75c723b538b32b/57ee7028239c5a737c0aeee4a34138c3/kasmvncserver-dbgsym.deb")
|
|
||||||
|
|
||||||
Use wget or curl to download the debug symbol package and then install it.
|
|
||||||
|
|
||||||
wget https://kasmweb-build-artifacts.s3.amazonaws.com/kasmvnc/crashpad/94002f39917dca0ad82ac0c29a75c723b538b32b/57ee7028239c5a737c0aeee4a34138c3/kasmvncserver-dbgsym.deb
|
|
||||||
sudo dpkg -i kasmvncserver-dbgsym.deb
|
|
||||||
|
|
||||||
## Symbolize a Backtrace
|
|
||||||
With the KasmVNC binary and debug symbol package installed on the system, you can use gdb or addr2line to get more information, such as the filename, function name, and line number that the backtrace line is referring to.
|
|
||||||
|
|
||||||
Here is a single line from a backtrace. The following example shows how to retrieve additional information that can help with debugging the crash.
|
|
||||||
(EE) 8: /usr/bin/Xvnc (0x400000+0x13e674) [**0x53e674**]
|
|
||||||
|
|
||||||
echo info line ***0x53eaaa** | gdb -q /usr/bin/Xkasmvnc
|
|
||||||
(gdb) Line 223 of "/src/common/network/webudp/Wu.cpp" starts at address 0x53e674 <WuClientSendPendingDTLS(WuClient*, Wu const*, Wu const*)+68>
|
|
||||||
|
|
||||||
The following script will search the provide file for a backtrace and symbolize the entire backtrace.
|
|
||||||
|
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
FILENAME=$1
|
|
||||||
grep "(EE)" $FILENAME | while read -r line ; do
|
|
||||||
BACKTRACE=$(echo $line | grep -Po '\[[0-9a-f]x[a-f0-9]{1,}' | sed -r 's#\[##')
|
|
||||||
echo $line
|
|
||||||
if ! [ -z $BACKTRACE ] ; then
|
|
||||||
SYMBOLIZED=$(echo "info line *${BACKTRACE}" | gdb /usr/bin/Xkasmvnc | grep "(gdb)" | grep -vP "\(gdb\)\s*quit$")
|
|
||||||
echo " ${SYMBOLIZED}"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
Using this script on the above example backtrace produces the following output.
|
|
||||||
|
|
||||||
ubuntu@hostname-1:~$ bash symbolize.sh ~/.vnc/hostname-1\:10.log
|
|
||||||
(EE)
|
|
||||||
(EE) Backtrace:
|
|
||||||
(EE) 0: /usr/bin/Xvnc (xorg_backtrace+0x4d) [0x5e48dd]
|
|
||||||
(gdb) Line 130 of "backtrace.c" starts at address 0x5e48dd <xorg_backtrace+77> and ends at 0x5e4900 <xorg_backtrace+112>.
|
|
||||||
(EE) 1: /usr/bin/Xvnc (0x400000+0x1e8259) [0x5e8259]
|
|
||||||
(gdb) Line 138 of "osinit.c" starts at address 0x5e8259 <OsSigHandler+41> and ends at 0x5e8275 <OsSigHandler+69>.
|
|
||||||
(EE) 2: /lib/x86_64-linux-gnu/libpthread.so.0 (0x7f5a57ef6000+0x12980) [0x7f5a57f08980]
|
|
||||||
(gdb) No line number information available for address 0x7f5a57f08980
|
|
||||||
(EE) 3: /lib/x86_64-linux-gnu/libc.so.6 (epoll_wait+0x57) [0x7f5a552eca47]
|
|
||||||
(gdb) No line number information available for address 0x7f5a552eca47
|
|
||||||
(EE) 4: /usr/bin/Xvnc (ospoll_wait+0x37) [0x5e8d07]
|
|
||||||
(gdb) Line 643 of "ospoll.c" starts at address 0x5e8d07 <ospoll_wait+55> and ends at 0x5e8d09 <ospoll_wait+57>.
|
|
||||||
(EE) 5: /usr/bin/Xvnc (WaitForSomething+0x1c3) [0x5e2813]
|
|
||||||
(gdb) Line 210 of "WaitFor.c" starts at address 0x5e2813 <WaitForSomething+451> and ends at 0x5e2819 <WaitForSomething+457>.
|
|
||||||
(EE) 6: /usr/bin/Xvnc (Dispatch+0xa7) [0x597007]
|
|
||||||
(gdb) Line 421 of "dispatch.c" starts at address 0x596ffb <Dispatch+155> and ends at 0x59700b <Dispatch+171>.
|
|
||||||
(EE) 7: /usr/bin/Xvnc (dix_main+0x36e) [0x59b1fe]
|
|
||||||
(gdb) Line 278 of "main.c" starts at address 0x59b1fe <dix_main+878> and ends at 0x59b203 <dix_main+883>.
|
|
||||||
(EE) 8: /lib/x86_64-linux-gnu/libc.so.6 (__libc_start_main+0xe7) [0x7f5a551ecbf7]
|
|
||||||
(gdb) No line number information available for address 0x7f5a551ecbf7
|
|
||||||
(EE) 9: /usr/bin/Xvnc (_start+0x2a) [0x46048a]
|
|
||||||
(gdb) No line number information available for address 0x46048a <_start+42>
|
|
||||||
(EE)
|
|
||||||
(EE) Received signal 11 sent by process 17182, uid 0
|
|
||||||
(EE)
|
|
||||||
(EE) Caught signal 11 (Segmentation fault). Server aborting
|
|
||||||
(EE)
|
|
||||||
|
|
||||||
@@ -42,11 +42,10 @@ Future Goals:
|
|||||||
#### Debian-based
|
#### Debian-based
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
# Please choose the package for your distro here (under Assets):
|
wget -qO- https://github.com/kasmtech/KasmVNC/releases/download/v0.9.1-beta/kasmvncserver_0.9.1~beta-1_amd64.deb
|
||||||
# https://github.com/kasmtech/KasmVNC/releases
|
|
||||||
wget <package_url>
|
|
||||||
|
|
||||||
sudo apt-get install ./kasmvncserver_*.deb
|
sudo dpkg -i kasmvncserver_0.9.1~beta-1_amd64.deb
|
||||||
|
sudo apt-get -f install
|
||||||
|
|
||||||
# We provide an example script to run KasmVNC at #
|
# We provide an example script to run KasmVNC at #
|
||||||
# /usr/share/doc/kasmvncserver/examples/kasmvncserver-easy-start. It runs a VNC
|
# /usr/share/doc/kasmvncserver/examples/kasmvncserver-easy-start. It runs a VNC
|
||||||
|
|||||||
@@ -79,25 +79,6 @@ packages installed with XFCE.
|
|||||||
```
|
```
|
||||||
builder/test-deb-barebones ubuntu focal
|
builder/test-deb-barebones ubuntu focal
|
||||||
```
|
```
|
||||||
|
|
||||||
# Preparing a release
|
|
||||||
|
|
||||||
Deb and rpm packages need their versions bumped to the new release version. It
|
|
||||||
can be done with:
|
|
||||||
|
|
||||||
```
|
|
||||||
builder/bump-package-version 0.9.4-beta
|
|
||||||
```
|
|
||||||
|
|
||||||
This will update corresponding package files, use `git diff` to see changes.
|
|
||||||
|
|
||||||
If you've ran the command and curious about Debian version specifics, here's an
|
|
||||||
explanation:
|
|
||||||
Deb version will be `0.9.4~beta-1`. `~` (and not `-`) is required by packaging
|
|
||||||
guidelines, and `-1` is Debian package revision for `0.9.4` upstream release. If
|
|
||||||
a Debian-specific patch was later added on top of `0.9.4`, it'd be `-2` for the
|
|
||||||
next Debian version. Rpm has a corresponding revision in its .spec file.
|
|
||||||
|
|
||||||
# CI development
|
# CI development
|
||||||
|
|
||||||
S3 upload code is extracted to various files in `.ci`. It's possible to iterate
|
S3 upload code is extracted to various files in `.ci`. It's possible to iterate
|
||||||
@@ -109,33 +90,3 @@ bash -c '
|
|||||||
prepare_upload_filename "bionic/kasmvncserver_0.9.1~beta-1+libjpeg-turbo-latest_amd64.deb";
|
prepare_upload_filename "bionic/kasmvncserver_0.9.1~beta-1+libjpeg-turbo-latest_amd64.deb";
|
||||||
echo $upload_filename;'
|
echo $upload_filename;'
|
||||||
```
|
```
|
||||||
|
|
||||||
# ARM
|
|
||||||
|
|
||||||
KasmVNC is supported on ARM, however, the build process needs to be broken into two parts with one occuring on a x64 system and the other on an ARM system. All our testing and official builds are done on AWS Graviton instances.
|
|
||||||
|
|
||||||
### Build www code on x86 System
|
|
||||||
The www code is webpacked for performance and thus requires building. There are NPM packages, phantomjs, which do not have an ARM build. Therefore, this must be built on x86 and then copied over to the ARM system for final packaging.
|
|
||||||
|
|
||||||
```
|
|
||||||
cd ~/KasmVNC
|
|
||||||
mkdir builder/www
|
|
||||||
sudo docker build -t kasmweb/www -f builder/dockerfile.www.build .
|
|
||||||
sudo docker run --rm -v $PWD/builder/www:/build kasmweb/www:latest
|
|
||||||
cd builder
|
|
||||||
tar -zcvf /tmp/kasm_www.tar.gz www
|
|
||||||
```
|
|
||||||
|
|
||||||
Now transfer ```kasm_www.tar.gz``` to the ARM system.
|
|
||||||
|
|
||||||
### Build KasmVNC ARM
|
|
||||||
These instructions assume KasmVNC has been cloned at $HOME and ```kasm_www.tar.gz``` has been placed at $HOME as well, adjust for your environment.
|
|
||||||
|
|
||||||
```
|
|
||||||
cd ~
|
|
||||||
tar -zxf kasm_www.tar.gz -C KasmVNC/builder/
|
|
||||||
cd KasmVNC
|
|
||||||
sudo builder/build-package ubuntu bionic
|
|
||||||
```
|
|
||||||
The resulting deb package can be found under ~/KasmVNC/builder/build/bionic
|
|
||||||
Replace ```bionic``` with ```focal``` to build for Ubuntu 20.04LTS. At this time, only Ubuntu Bionic has been tested, however, other Debian based builds we support should also work.
|
|
||||||
|
|||||||
@@ -29,6 +29,5 @@ fi
|
|||||||
|
|
||||||
dpkg-buildpackage -us -uc -b
|
dpkg-buildpackage -us -uc -b
|
||||||
mkdir -p "$os_dir"
|
mkdir -p "$os_dir"
|
||||||
cp ../*dbgsym*deb "$os_dir"
|
|
||||||
cp ../*.deb "$os_dir"
|
cp ../*.deb "$os_dir"
|
||||||
lintian ../*.deb || true
|
lintian ../*.deb || true
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ prepare_build_env() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
copy_spec_and_tar_with_binaries() {
|
copy_spec_and_tar_with_binaries() {
|
||||||
cp /tmp/kasmvncserver.spec ~/rpmbuild/SPECS/
|
cp /src/centos/kasmvncserver.spec ~/rpmbuild/SPECS/
|
||||||
cp /src/builder/build/kasmvnc.${os}_${os_codename}.tar.gz \
|
cp /src/builder/build/kasmvnc.${os}_${os_codename}.tar.gz \
|
||||||
~/rpmbuild/SOURCES/
|
~/rpmbuild/SOURCES/
|
||||||
}
|
}
|
||||||
@@ -20,13 +20,8 @@ copy_rpm_to_build_dir() {
|
|||||||
|
|
||||||
cd "$(dirname "$0")/.."
|
cd "$(dirname "$0")/.."
|
||||||
|
|
||||||
if [ -z ${KASMVNC_BUILD_OS_CODENAME+x} ]; then
|
os=$(lsb_release -is | tr '[:upper:]' '[:lower:]')
|
||||||
os=$(lsb_release -is | tr '[:upper:]' '[:lower:]')
|
os_codename=$(lsb_release -cs | tr '[:upper:]' '[:lower:]')
|
||||||
os_codename=$(lsb_release -cs | tr '[:upper:]' '[:lower:]')
|
|
||||||
else
|
|
||||||
os=${KASMVNC_BUILD_OS}
|
|
||||||
os_codename=${KASMVNC_BUILD_OS_CODENAME}
|
|
||||||
fi
|
|
||||||
os_dir="build/${os}_${os_codename}"
|
os_dir="build/${os}_${os_codename}"
|
||||||
|
|
||||||
prepare_build_env
|
prepare_build_env
|
||||||
|
|||||||
@@ -31,7 +31,6 @@ docker build -t "$builder_image" \
|
|||||||
-f builder/dockerfile.${os}_${os_codename}${build_tag}.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 -e BUILD_TAG="$build_tag" \
|
||||||
-e KASMVNC_COMMIT_ID="$KASMVNC_COMMIT_ID" \
|
|
||||||
--rm "$builder_image"
|
--rm "$builder_image"
|
||||||
|
|
||||||
L_GID=$(id -g)
|
L_GID=$(id -g)
|
||||||
|
|||||||
@@ -7,12 +7,6 @@ detect_quilt() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
ensure_crashpad_can_fetch_line_number_by_address() {
|
|
||||||
if [ ! -f /etc/centos-release ]; then
|
|
||||||
export LDFLAGS="$LDFLAGS -no-pie"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# For build-dep to work, the apt sources need to have the source server
|
# For build-dep to work, the apt sources need to have the source server
|
||||||
#sudo apt-get build-dep xorg-server
|
#sudo apt-get build-dep xorg-server
|
||||||
|
|
||||||
@@ -36,36 +30,28 @@ sed -i -e '/find_package(FLTK/s@^@#@' \
|
|||||||
-e '/add_subdirectory(tests/s@^@#@' \
|
-e '/add_subdirectory(tests/s@^@#@' \
|
||||||
CMakeLists.txt
|
CMakeLists.txt
|
||||||
|
|
||||||
cmake -D CMAKE_BUILD_TYPE=RelWithDebInfo . -DBUILD_VIEWER:BOOL=OFF
|
cmake -D CMAKE_BUILD_TYPE=RelWithDebInfo .
|
||||||
make -j5
|
make -j5
|
||||||
|
|
||||||
tar -C unix/xserver -xf /tmp/xorg-server-${XORG_VER}.tar.bz2 --strip-components=1
|
tar -C unix/xserver -xvf /tmp/xorg-server-${XORG_VER}.tar.bz2 --strip-components=1
|
||||||
|
|
||||||
cd unix/xserver
|
cd unix/xserver
|
||||||
patch -Np1 -i ../xserver${XORG_PATCH}.patch
|
patch -Np1 -i ../xserver${XORG_PATCH}.patch
|
||||||
case "$XORG_VER" in
|
if [[ $XORG_VER =~ ^1\.20\..*$ ]]; then
|
||||||
1.20.*)
|
|
||||||
if [ -f ../xserver120.7.patch ]; then
|
|
||||||
patch -Np1 -i ../xserver120.7.patch
|
patch -Np1 -i ../xserver120.7.patch
|
||||||
fi ;;
|
fi
|
||||||
esac
|
|
||||||
|
|
||||||
autoreconf -i
|
autoreconf -i
|
||||||
# Configuring Xorg is long and has many distro-specific paths.
|
# Configuring Xorg is long and has many distro-specific paths.
|
||||||
# The distro paths start after prefix and end with the font path,
|
# The distro paths start after prefix and end with the font path,
|
||||||
# everything after that is based on BUILDING.txt to remove unneeded
|
# everything after that is based on BUILDING.txt to remove unneeded
|
||||||
# components.
|
# components.
|
||||||
ensure_crashpad_can_fetch_line_number_by_address
|
|
||||||
# remove gl check for opensuse
|
|
||||||
if [ "${KASMVNC_BUILD_OS}" == "opensuse" ]; then
|
|
||||||
sed -i 's/LIBGL="gl >= 7.1.0"/LIBGL="gl >= 1.1"/g' configure
|
|
||||||
fi
|
|
||||||
./configure --prefix=/opt/kasmweb \
|
./configure --prefix=/opt/kasmweb \
|
||||||
--with-xkb-path=/usr/share/X11/xkb \
|
--with-xkb-path=/usr/share/X11/xkb \
|
||||||
--with-xkb-output=/var/lib/xkb \
|
--with-xkb-output=/var/lib/xkb \
|
||||||
--with-xkb-bin-directory=/usr/bin \
|
--with-xkb-bin-directory=/usr/bin \
|
||||||
--with-default-font-path="/usr/share/fonts/X11/misc,/usr/share/fonts/X11/cyrillic,/usr/share/fonts/X11/100dpi/:unscaled,/usr/share/fonts/X11/75dpi/:unscaled,/usr/share/fonts/X11/Type1,/usr/share/fonts/X11/100dpi,/usr/share/fonts/X11/75dpi,built-ins" \
|
--with-default-font-path="/usr/share/fonts/X11/misc,/usr/share/fonts/X11/cyrillic,/usr/share/fonts/X11/100dpi/:unscaled,/usr/share/fonts/X11/75dpi/:unscaled,/usr/share/fonts/X11/Type1,/usr/share/fonts/X11/100dpi,/usr/share/fonts/X11/75dpi,built-ins" \
|
||||||
--without-dtrace --disable-dri \
|
--with-pic --without-dtrace --disable-dri \
|
||||||
--disable-static \
|
--disable-static \
|
||||||
--disable-xinerama --disable-xvfb --disable-xnest --disable-xorg \
|
--disable-xinerama --disable-xvfb --disable-xnest --disable-xorg \
|
||||||
--disable-dmx --disable-xwin --disable-xephyr --disable-kdrive \
|
--disable-dmx --disable-xwin --disable-xephyr --disable-kdrive \
|
||||||
@@ -86,8 +72,6 @@ mkdir lib
|
|||||||
cd lib
|
cd lib
|
||||||
if [ -d /usr/lib/x86_64-linux-gnu/dri ]; then
|
if [ -d /usr/lib/x86_64-linux-gnu/dri ]; then
|
||||||
ln -s /usr/lib/x86_64-linux-gnu/dri dri
|
ln -s /usr/lib/x86_64-linux-gnu/dri dri
|
||||||
elif [ -d /usr/lib/aarch64-linux-gnu/dri ]; then
|
|
||||||
ln -s /usr/lib/aarch64-linux-gnu/dri dri
|
|
||||||
else
|
else
|
||||||
ln -s /usr/lib64/dri dri
|
ln -s /usr/lib64/dri dri
|
||||||
fi
|
fi
|
||||||
@@ -96,9 +80,7 @@ cd /src
|
|||||||
detect_quilt
|
detect_quilt
|
||||||
if [ -n "$QUILT_PRESENT" ]; then
|
if [ -n "$QUILT_PRESENT" ]; then
|
||||||
quilt push -a
|
quilt push -a
|
||||||
echo 'Patches applied!'
|
|
||||||
fi
|
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
|
||||||
|
|||||||
@@ -15,3 +15,4 @@ cd /build
|
|||||||
rm *.md
|
rm *.md
|
||||||
rm AUTHORS
|
rm AUTHORS
|
||||||
rm vnc.html
|
rm vnc.html
|
||||||
|
rm vnc_lite.html
|
||||||
|
|||||||
@@ -1,29 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
set -eo pipefail
|
|
||||||
|
|
||||||
update_version_to_meet_packaging_standards() {
|
|
||||||
new_version=$(echo "$new_version" |
|
|
||||||
sed -e 's/\([0-9]\)-\([a-zA-Z]\)/\1~\2/')
|
|
||||||
}
|
|
||||||
|
|
||||||
bump_rpm() {
|
|
||||||
builder/bump-package-version-rpm "$new_version"
|
|
||||||
}
|
|
||||||
|
|
||||||
bump_deb() {
|
|
||||||
builder/bump-package-version-deb "$new_version"
|
|
||||||
}
|
|
||||||
|
|
||||||
new_version="$1"
|
|
||||||
|
|
||||||
if [[ -z "$new_version" ]]; then
|
|
||||||
echo >&2 "Usage: $(basename "$0") <new_version>"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
cd "$(dirname "$0")/.."
|
|
||||||
|
|
||||||
update_version_to_meet_packaging_standards
|
|
||||||
bump_rpm
|
|
||||||
bump_deb
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
set -eo pipefail
|
|
||||||
|
|
||||||
new_version="$1"
|
|
||||||
|
|
||||||
add_debian_revision_to_new_version() {
|
|
||||||
echo "$new_version-1"
|
|
||||||
}
|
|
||||||
|
|
||||||
bump_deb() {
|
|
||||||
local image="debbump_package_version:dev"
|
|
||||||
local L_UID=$(id -u)
|
|
||||||
local L_GID=$(id -g)
|
|
||||||
local debian_version=$(add_debian_revision_to_new_version)
|
|
||||||
|
|
||||||
docker build -t "$image" -f builder/dockerfile.bump-package-version .
|
|
||||||
docker run --rm -v "$PWD":/src --user "$L_UID:$L_GID" \
|
|
||||||
"$image" /bin/bash -c \
|
|
||||||
"cd /src && builder/bump-package-version-inside-docker-deb $debian_version"
|
|
||||||
}
|
|
||||||
|
|
||||||
bump_deb
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
set -euo pipefail
|
|
||||||
|
|
||||||
new_version="$1"
|
|
||||||
|
|
||||||
update_version() {
|
|
||||||
dch --newversion $new_version 'New upstream release.'
|
|
||||||
}
|
|
||||||
|
|
||||||
mark_as_released() {
|
|
||||||
dch --release ""
|
|
||||||
}
|
|
||||||
|
|
||||||
update_version
|
|
||||||
mark_as_released
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
set -eo pipefail
|
|
||||||
|
|
||||||
new_version="$1"
|
|
||||||
specs="centos/kasmvncserver.spec
|
|
||||||
oracle/kasmvncserver.spec
|
|
||||||
opensuse/kasmvncserver.spec"
|
|
||||||
|
|
||||||
bump_version() {
|
|
||||||
sed -i "s/^Version:.\+/Version: $new_version/" "$1"
|
|
||||||
}
|
|
||||||
|
|
||||||
detect_release_version() {
|
|
||||||
release_version=$(sed -ne 's/^Release:\s\+//p' "$1" | sed -e 's/%.\+$//')
|
|
||||||
}
|
|
||||||
|
|
||||||
bump_changelog() {
|
|
||||||
detect_release_version "$1"
|
|
||||||
|
|
||||||
local date=$(date +'%a %b %d %Y')
|
|
||||||
local changelog_version="$new_version-$release_version"
|
|
||||||
local new_changelog_entry="* $date KasmTech <info@kasmweb.com> - $changelog_version\n- Upstream release"
|
|
||||||
|
|
||||||
sed -i -e "s/%changelog/%changelog\n$new_changelog_entry/" "$1"
|
|
||||||
}
|
|
||||||
|
|
||||||
IFS=$'\n'
|
|
||||||
for spec_file in $specs; do
|
|
||||||
bump_version $spec_file
|
|
||||||
bump_changelog $spec_file
|
|
||||||
done
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
FROM debian:buster
|
|
||||||
|
|
||||||
ENV DEBEMAIL="Kasm Technologies LLC <info@kasmweb.com>"
|
|
||||||
|
|
||||||
RUN apt-get update && \
|
|
||||||
apt-get -y install vim devscripts
|
|
||||||
@@ -3,7 +3,6 @@ FROM centos:centos7
|
|||||||
ENV KASMVNC_BUILD_OS centos
|
ENV KASMVNC_BUILD_OS centos
|
||||||
ENV KASMVNC_BUILD_OS_CODENAME core
|
ENV KASMVNC_BUILD_OS_CODENAME core
|
||||||
|
|
||||||
RUN yum install -y ca-certificates
|
|
||||||
RUN yum install -y build-dep xorg-server libxfont-dev sudo
|
RUN yum install -y build-dep xorg-server libxfont-dev sudo
|
||||||
RUN yum install -y gcc cmake git libjpeg-dev libgnutls28-dev vim wget tightvncserver
|
RUN yum install -y gcc cmake git libjpeg-dev libgnutls28-dev vim wget tightvncserver
|
||||||
RUN yum install -y libjpeg-dev libpng-dev libtiff-dev libgif-dev libavcodec-dev openssl-devel
|
RUN yum install -y libjpeg-dev libpng-dev libtiff-dev libgif-dev libavcodec-dev openssl-devel
|
||||||
@@ -11,14 +10,12 @@ RUN yum install -y make
|
|||||||
RUN yum group install -y "Development Tools"
|
RUN yum group install -y "Development Tools"
|
||||||
RUN yum install -y xorg-x11-server-devel zlib-devel libjpeg-turbo-devel
|
RUN yum install -y xorg-x11-server-devel zlib-devel libjpeg-turbo-devel
|
||||||
RUN yum install -y libxkbfile-devel libXfont2-devel xorg-x11-font-utils \
|
RUN yum install -y libxkbfile-devel libXfont2-devel xorg-x11-font-utils \
|
||||||
xorg-x11-xtrans-devel xorg-x11-xkb-utils-devel libXrandr-devel pam-devel \
|
xorg-x11-xtrans-devel xorg-x11-xkb-utils-devel
|
||||||
gnutls-devel libX11-devel libXtst-devel libXcursor-devel
|
|
||||||
RUN yum install -y mesa-dri-drivers
|
RUN yum install -y mesa-dri-drivers
|
||||||
RUN yum install -y ca-certificates
|
|
||||||
|
|
||||||
# Additions for webp
|
# 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 && wget https://storage.googleapis.com/downloads.webmproject.org/releases/webp/libwebp-1.0.2.tar.gz
|
||||||
RUN cd /tmp && tar -xzf /tmp/libwebp-*
|
RUN cd /tmp && tar -xzvf /tmp/libwebp-*
|
||||||
RUN cd /tmp/libwebp-1.0.2 && \
|
RUN cd /tmp/libwebp-1.0.2 && \
|
||||||
./configure --enable-static --disable-shared && \
|
./configure --enable-static --disable-shared && \
|
||||||
make && make install
|
make && make install
|
||||||
|
|||||||
@@ -13,11 +13,11 @@ RUN apt-get update && \
|
|||||||
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends tzdata
|
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends tzdata
|
||||||
RUN apt-get update && apt-get -y build-dep xorg-server libxfont-dev
|
RUN apt-get update && apt-get -y build-dep xorg-server libxfont-dev
|
||||||
RUN apt-get update && apt-get -y install cmake git libjpeg-dev libgnutls28-dev vim wget tightvncserver
|
RUN apt-get update && apt-get -y install cmake git libjpeg-dev libgnutls28-dev vim wget tightvncserver
|
||||||
RUN apt-get update && apt-get -y install libpng-dev libtiff-dev libgif-dev libavcodec-dev libssl-dev libxrandr-dev libxcursor-dev
|
RUN apt-get update && apt-get -y install libjpeg-dev libpng-dev libtiff-dev libgif-dev libavcodec-dev libssl-dev
|
||||||
|
|
||||||
# Additions for webp
|
# 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 && wget https://storage.googleapis.com/downloads.webmproject.org/releases/webp/libwebp-1.0.2.tar.gz
|
||||||
RUN cd /tmp && tar -xzf /tmp/libwebp-*
|
RUN cd /tmp && tar -xzvf /tmp/libwebp-*
|
||||||
RUN cd /tmp/libwebp-1.0.2 && \
|
RUN cd /tmp/libwebp-1.0.2 && \
|
||||||
./configure --enable-static --disable-shared && \
|
./configure --enable-static --disable-shared && \
|
||||||
make && make install
|
make && make install
|
||||||
|
|||||||
@@ -13,11 +13,11 @@ RUN apt-get update && \
|
|||||||
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends tzdata
|
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends tzdata
|
||||||
RUN apt-get update && apt-get -y build-dep xorg-server libxfont-dev
|
RUN apt-get update && apt-get -y build-dep xorg-server libxfont-dev
|
||||||
RUN apt-get update && apt-get -y install cmake git libjpeg-dev libgnutls28-dev vim wget tightvncserver
|
RUN apt-get update && apt-get -y install cmake git libjpeg-dev libgnutls28-dev vim wget tightvncserver
|
||||||
RUN apt-get update && apt-get -y install libpng-dev libtiff-dev libgif-dev libavcodec-dev libssl-dev libxrandr-dev libxcursor-dev
|
RUN apt-get update && apt-get -y install libjpeg-dev libpng-dev libtiff-dev libgif-dev libavcodec-dev libssl-dev
|
||||||
|
|
||||||
# Additions for webp
|
# 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 && wget https://storage.googleapis.com/downloads.webmproject.org/releases/webp/libwebp-1.0.2.tar.gz
|
||||||
RUN cd /tmp && tar -xzf /tmp/libwebp-*
|
RUN cd /tmp && tar -xzvf /tmp/libwebp-*
|
||||||
RUN cd /tmp/libwebp-1.0.2 && \
|
RUN cd /tmp/libwebp-1.0.2 && \
|
||||||
./configure --enable-static --disable-shared && \
|
./configure --enable-static --disable-shared && \
|
||||||
make && make install
|
make && make install
|
||||||
|
|||||||
@@ -18,14 +18,13 @@ RUN dnf install -y make
|
|||||||
RUN dnf group install -y "Development Tools"
|
RUN dnf group install -y "Development Tools"
|
||||||
RUN dnf install -y xorg-x11-server-devel zlib-devel libjpeg-turbo-devel
|
RUN dnf install -y xorg-x11-server-devel zlib-devel libjpeg-turbo-devel
|
||||||
RUN dnf install -y libxkbfile-devel libXfont2-devel xorg-x11-font-utils \
|
RUN dnf install -y libxkbfile-devel libXfont2-devel xorg-x11-font-utils \
|
||||||
xorg-x11-xtrans-devel xorg-x11-xkb-utils-devel libXrandr-devel libXtst-devel \
|
xorg-x11-xtrans-devel xorg-x11-xkb-utils-devel
|
||||||
libXcursor-devel
|
|
||||||
RUN dnf install -y mesa-dri-drivers
|
RUN dnf install -y mesa-dri-drivers
|
||||||
RUN dnf install -y bzip2 redhat-lsb-core
|
RUN dnf install -y bzip2 redhat-lsb-core
|
||||||
|
|
||||||
# Additions for webp
|
# 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 && wget https://storage.googleapis.com/downloads.webmproject.org/releases/webp/libwebp-1.0.2.tar.gz
|
||||||
RUN cd /tmp && tar -xzf /tmp/libwebp-*
|
RUN cd /tmp && tar -xzvf /tmp/libwebp-*
|
||||||
RUN cd /tmp/libwebp-1.0.2 && \
|
RUN cd /tmp/libwebp-1.0.2 && \
|
||||||
./configure --enable-static --disable-shared && \
|
./configure --enable-static --disable-shared && \
|
||||||
make && make install
|
make && make install
|
||||||
|
|||||||
@@ -13,11 +13,11 @@ RUN apt-get update && \
|
|||||||
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends tzdata
|
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends tzdata
|
||||||
RUN apt-get update && apt-get -y build-dep xorg-server libxfont-dev
|
RUN apt-get update && apt-get -y build-dep xorg-server libxfont-dev
|
||||||
RUN apt-get update && apt-get -y install cmake git libjpeg-dev libgnutls28-dev vim wget tightvncserver
|
RUN apt-get update && apt-get -y install cmake git libjpeg-dev libgnutls28-dev vim wget tightvncserver
|
||||||
RUN apt-get update && apt-get -y install libpng-dev libtiff-dev libgif-dev libavcodec-dev libssl-dev libxrandr-dev libxcursor-dev
|
RUN apt-get update && apt-get -y install libjpeg-dev libpng-dev libtiff-dev libgif-dev libavcodec-dev libssl-dev
|
||||||
|
|
||||||
# Additions for webp
|
# 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 && wget https://storage.googleapis.com/downloads.webmproject.org/releases/webp/libwebp-1.0.2.tar.gz
|
||||||
RUN cd /tmp && tar -xzf /tmp/libwebp-*
|
RUN cd /tmp && tar -xzvf /tmp/libwebp-*
|
||||||
RUN cd /tmp/libwebp-1.0.2 && \
|
RUN cd /tmp/libwebp-1.0.2 && \
|
||||||
./configure --enable-static --disable-shared && \
|
./configure --enable-static --disable-shared && \
|
||||||
make && make install
|
make && make install
|
||||||
|
|||||||
@@ -1,39 +0,0 @@
|
|||||||
FROM opensuse/leap:15.3
|
|
||||||
|
|
||||||
# base tools
|
|
||||||
RUN zypper -n install -y \
|
|
||||||
less \
|
|
||||||
vim \
|
|
||||||
xterm
|
|
||||||
|
|
||||||
# deps and rpm install
|
|
||||||
RUN zypper -n install -y \
|
|
||||||
libglvnd \
|
|
||||||
libgnutls30 \
|
|
||||||
libgomp1 \
|
|
||||||
libjpeg8 \
|
|
||||||
libnettle6 \
|
|
||||||
libpixman-1-0 \
|
|
||||||
libXdmcp6 \
|
|
||||||
libXfont2-2 \
|
|
||||||
libxkbcommon-x11-0 \
|
|
||||||
openssl \
|
|
||||||
perl \
|
|
||||||
x11-tools \
|
|
||||||
xauth \
|
|
||||||
xkbcomp \
|
|
||||||
xkeyboard-config && \
|
|
||||||
mkdir -p /etc/pki/tls/private
|
|
||||||
|
|
||||||
ARG KASMVNC_PACKAGE_DIR
|
|
||||||
COPY $KASMVNC_PACKAGE_DIR/*.rpm /tmp
|
|
||||||
RUN zypper install -y --allow-unsigned-rpm /tmp/*.rpm
|
|
||||||
|
|
||||||
RUN useradd -m foo
|
|
||||||
|
|
||||||
USER foo:kasmvnc-cert
|
|
||||||
|
|
||||||
RUN mkdir ~/.vnc && echo '/usr/bin/xterm &' >> ~/.vnc/xstartup && \
|
|
||||||
chmod +x ~/.vnc/xstartup
|
|
||||||
|
|
||||||
ENTRYPOINT bash -c "echo -e \"$VNC_PW\n$VNC_PW\n\" | kasmvncpasswd -w -u \"$VNC_USER\" && vncserver :1 -interface 0.0.0.0 && vncserver -kill :1 && vncserver :1 -depth 24 -geometry 1280x1050 -websocketPort 6901 -cert /etc/pki/tls/private/kasmvnc.pem -sslOnly -FrameRate=24 -interface 0.0.0.0 -httpd /usr/share/kasmvnc/www && tail -f $HOME/.vnc/*.log "
|
|
||||||
@@ -1,59 +0,0 @@
|
|||||||
FROM opensuse/leap:15.3
|
|
||||||
|
|
||||||
ENV KASMVNC_BUILD_OS opensuse
|
|
||||||
ENV KASMVNC_BUILD_OS_CODENAME 15
|
|
||||||
ENV XORG_VER 1.20.3
|
|
||||||
|
|
||||||
# Install depends
|
|
||||||
RUN zypper install -ny \
|
|
||||||
bdftopcf \
|
|
||||||
bigreqsproto-devel \
|
|
||||||
cmake \
|
|
||||||
ffmpeg-4-libavcodec-devel \
|
|
||||||
fonttosfnt \
|
|
||||||
font-util \
|
|
||||||
gcc \
|
|
||||||
gcc-c++ \
|
|
||||||
giflib-devel \
|
|
||||||
git \
|
|
||||||
gzip \
|
|
||||||
lbzip2 \
|
|
||||||
libbz2-devel \
|
|
||||||
libGLw-devel \
|
|
||||||
libgnutls-devel \
|
|
||||||
libjpeg8-devel \
|
|
||||||
libopenssl-devel \
|
|
||||||
libpng16-devel \
|
|
||||||
libtiff-devel \
|
|
||||||
libXfont2-devel \
|
|
||||||
libxkbcommon-x11-devel \
|
|
||||||
make \
|
|
||||||
Mesa-dri \
|
|
||||||
Mesa-libglapi-devel \
|
|
||||||
mkfontdir \
|
|
||||||
mkfontscale \
|
|
||||||
patch \
|
|
||||||
tigervnc \
|
|
||||||
wget \
|
|
||||||
xcmiscproto-devel \
|
|
||||||
xorg-x11-devel \
|
|
||||||
xorg-x11-server-sdk \
|
|
||||||
xorg-x11-util-devel \
|
|
||||||
zlib-devel
|
|
||||||
|
|
||||||
# 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 -xzf /tmp/libwebp-*
|
|
||||||
RUN cd /tmp/libwebp-1.0.2 && \
|
|
||||||
./configure --enable-static --disable-shared && \
|
|
||||||
make && make install
|
|
||||||
|
|
||||||
RUN useradd -u 1000 docker && \
|
|
||||||
groupadd -g 1000 docker && \
|
|
||||||
usermod -a -G docker docker
|
|
||||||
|
|
||||||
COPY --chown=docker:docker . /src/
|
|
||||||
|
|
||||||
|
|
||||||
USER docker
|
|
||||||
ENTRYPOINT ["/src/builder/build.sh"]
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
FROM opensuse/leap:15.3
|
|
||||||
|
|
||||||
ENV KASMVNC_BUILD_OS opensuse
|
|
||||||
ENV KASMVNC_BUILD_OS_CODENAME 15
|
|
||||||
|
|
||||||
RUN zypper -n install -y \
|
|
||||||
gpg* \
|
|
||||||
less \
|
|
||||||
lsb-release \
|
|
||||||
rng-tools \
|
|
||||||
rpm-build \
|
|
||||||
rpmdevtools \
|
|
||||||
rpmlint \
|
|
||||||
tree \
|
|
||||||
vim
|
|
||||||
|
|
||||||
COPY opensuse/*.spec /tmp
|
|
||||||
RUN zypper -n install $(grep BuildRequires /tmp/*.spec | cut -d' ' -f2 | xargs)
|
|
||||||
|
|
||||||
RUN useradd -u 1000 -m -d /home/docker docker && \
|
|
||||||
groupadd -g 1000 docker && \
|
|
||||||
usermod -a -G docker docker
|
|
||||||
|
|
||||||
USER docker
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
FROM oraclelinux:8
|
|
||||||
|
|
||||||
RUN dnf install -y \
|
|
||||||
less \
|
|
||||||
redhat-lsb-core \
|
|
||||||
vim \
|
|
||||||
xterm
|
|
||||||
|
|
||||||
ARG KASMVNC_PACKAGE_DIR
|
|
||||||
COPY $KASMVNC_PACKAGE_DIR/*.rpm /tmp
|
|
||||||
RUN dnf localinstall -y /tmp/*.rpm
|
|
||||||
|
|
||||||
RUN useradd -m foo
|
|
||||||
|
|
||||||
USER foo:kasmvnc-cert
|
|
||||||
|
|
||||||
RUN mkdir ~/.vnc && echo '/usr/bin/xterm &' >> ~/.vnc/xstartup && \
|
|
||||||
chmod +x ~/.vnc/xstartup
|
|
||||||
|
|
||||||
ENTRYPOINT bash -c "echo -e \"$VNC_PW\n$VNC_PW\n\" | kasmvncpasswd -w -u \"$VNC_USER\" && vncserver :1 -interface 0.0.0.0 && vncserver -kill :1 && vncserver :1 -depth 24 -geometry 1280x1050 -websocketPort 8443 -cert /etc/pki/tls/private/kasmvnc.pem -sslOnly -FrameRate=24 -interface 0.0.0.0 -httpd /usr/share/kasmvnc/www && tail -f $HOME/.vnc/*.log "
|
|
||||||
@@ -1,61 +0,0 @@
|
|||||||
FROM oraclelinux:8
|
|
||||||
|
|
||||||
ENV KASMVNC_BUILD_OS oracle
|
|
||||||
ENV KASMVNC_BUILD_OS_CODENAME 8
|
|
||||||
ENV XORG_VER 1.20.10
|
|
||||||
|
|
||||||
# Install from stock repos
|
|
||||||
RUN dnf install -y \
|
|
||||||
bzip2-devel \
|
|
||||||
ca-certificates \
|
|
||||||
cmake \
|
|
||||||
dnf-plugins-core \
|
|
||||||
gcc \
|
|
||||||
gcc-c++ \
|
|
||||||
git \
|
|
||||||
gnutls-devel \
|
|
||||||
libjpeg-turbo-devel \
|
|
||||||
libpng-devel \
|
|
||||||
libtiff-devel \
|
|
||||||
make \
|
|
||||||
mesa-dri-drivers \
|
|
||||||
openssl-devel \
|
|
||||||
openssl-devel \
|
|
||||||
patch \
|
|
||||||
tigervnc-server \
|
|
||||||
wget \
|
|
||||||
xorg-x11-font-utils \
|
|
||||||
zlib-devel
|
|
||||||
|
|
||||||
# Enable additional repos (epel, powertools, and fusion)
|
|
||||||
RUN dnf config-manager --set-enabled ol8_codeready_builder
|
|
||||||
RUN dnf install -y oracle-epel-release-el8
|
|
||||||
RUN dnf install -y --nogpgcheck https://mirrors.rpmfusion.org/free/el/rpmfusion-free-release-8.noarch.rpm
|
|
||||||
|
|
||||||
# Install from new repos
|
|
||||||
RUN dnf install -y \
|
|
||||||
ffmpeg-devel \
|
|
||||||
giflib-devel \
|
|
||||||
lbzip2 \
|
|
||||||
libXfont2-devel \
|
|
||||||
libxkbfile-devel \
|
|
||||||
xorg-x11-server-devel \
|
|
||||||
xorg-x11-xkb-utils-devel \
|
|
||||||
xorg-x11-xtrans-devel \
|
|
||||||
libXrandr-devel \
|
|
||||||
libXtst-devel \
|
|
||||||
libXcursor-devel
|
|
||||||
|
|
||||||
# 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 -xzf /tmp/libwebp-*
|
|
||||||
RUN cd /tmp/libwebp-1.0.2 && \
|
|
||||||
./configure --enable-static --disable-shared && \
|
|
||||||
make && make install
|
|
||||||
|
|
||||||
RUN useradd -m docker && echo "docker:docker" | chpasswd
|
|
||||||
|
|
||||||
COPY --chown=docker:docker . /src/
|
|
||||||
|
|
||||||
USER docker
|
|
||||||
ENTRYPOINT ["/src/builder/build.sh"]
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
FROM oraclelinux:8
|
|
||||||
|
|
||||||
ENV KASMVNC_BUILD_OS oracle
|
|
||||||
ENV KASMVNC_BUILD_OS_CODENAME 8
|
|
||||||
|
|
||||||
RUN dnf install -y \
|
|
||||||
gpg* \
|
|
||||||
less \
|
|
||||||
redhat-lsb-core \
|
|
||||||
rng-tools \
|
|
||||||
rpm* \
|
|
||||||
rpmlint \
|
|
||||||
tree \
|
|
||||||
vim
|
|
||||||
|
|
||||||
COPY oracle/*.spec /tmp
|
|
||||||
RUN dnf builddep -y /tmp/*.spec
|
|
||||||
|
|
||||||
RUN useradd -m docker && echo "docker:docker" | chpasswd
|
|
||||||
|
|
||||||
USER docker
|
|
||||||
@@ -11,7 +11,7 @@ RUN apt-get update && \
|
|||||||
|
|
||||||
RUN apt-get update && apt-get -y build-dep xorg-server libxfont-dev
|
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 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 libxrandr-dev libxcursor-dev
|
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 apt-get update && apt-get install -y cmake nasm gcc
|
||||||
RUN git clone https://github.com/libjpeg-turbo/libjpeg-turbo.git
|
RUN git clone https://github.com/libjpeg-turbo/libjpeg-turbo.git
|
||||||
@@ -20,7 +20,7 @@ RUN export MAKEFLAGS=-j`nproc`; cd libjpeg-turbo && cmake -DCMAKE_INSTALL_PREFIX
|
|||||||
|
|
||||||
# Additions for webp
|
# 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 && wget https://storage.googleapis.com/downloads.webmproject.org/releases/webp/libwebp-1.0.2.tar.gz
|
||||||
RUN cd /tmp && tar -xzf /tmp/libwebp-*
|
RUN cd /tmp && tar -xzvf /tmp/libwebp-*
|
||||||
RUN cd /tmp/libwebp-1.0.2 && \
|
RUN cd /tmp/libwebp-1.0.2 && \
|
||||||
./configure --enable-static --disable-shared && \
|
./configure --enable-static --disable-shared && \
|
||||||
make && make install
|
make && make install
|
||||||
|
|||||||
@@ -11,11 +11,11 @@ RUN apt-get update && \
|
|||||||
|
|
||||||
RUN apt-get update && apt-get -y build-dep xorg-server libxfont-dev
|
RUN apt-get update && apt-get -y build-dep xorg-server libxfont-dev
|
||||||
RUN apt-get update && apt-get -y install cmake git libjpeg-dev libgnutls28-dev vim wget tightvncserver
|
RUN apt-get update && apt-get -y install cmake git libjpeg-dev libgnutls28-dev vim wget tightvncserver
|
||||||
RUN apt-get update && apt-get -y install libpng-dev libtiff-dev libgif-dev libavcodec-dev libssl-dev libxrandr-dev libxcursor-dev
|
RUN apt-get update && apt-get -y install libjpeg-dev libpng-dev libtiff-dev libgif-dev libavcodec-dev libssl-dev
|
||||||
|
|
||||||
# Additions for webp
|
# 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 && wget https://storage.googleapis.com/downloads.webmproject.org/releases/webp/libwebp-1.0.2.tar.gz
|
||||||
RUN cd /tmp && tar -xzf /tmp/libwebp-*
|
RUN cd /tmp && tar -xzvf /tmp/libwebp-*
|
||||||
RUN cd /tmp/libwebp-1.0.2 && \
|
RUN cd /tmp/libwebp-1.0.2 && \
|
||||||
./configure --enable-static --disable-shared && \
|
./configure --enable-static --disable-shared && \
|
||||||
make && make install
|
make && make install
|
||||||
|
|||||||
@@ -13,11 +13,11 @@ RUN apt-get update && \
|
|||||||
RUN apt-get update && apt-get install -y --no-install-recommends tzdata
|
RUN apt-get update && apt-get install -y --no-install-recommends tzdata
|
||||||
RUN apt-get update && apt-get -y build-dep xorg-server libxfont-dev
|
RUN apt-get update && apt-get -y build-dep xorg-server libxfont-dev
|
||||||
RUN apt-get update && apt-get -y install cmake git libjpeg-dev libgnutls28-dev vim wget tightvncserver
|
RUN apt-get update && apt-get -y install cmake git libjpeg-dev libgnutls28-dev vim wget tightvncserver
|
||||||
RUN apt-get update && apt-get -y install libpng-dev libtiff-dev libgif-dev libavcodec-dev libssl-dev libxrandr-dev libxcursor-dev
|
RUN apt-get update && apt-get -y install libjpeg-dev libpng-dev libtiff-dev libgif-dev libavcodec-dev libssl-dev
|
||||||
|
|
||||||
# Additions for webp
|
# 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 && wget https://storage.googleapis.com/downloads.webmproject.org/releases/webp/libwebp-1.0.2.tar.gz
|
||||||
RUN cd /tmp && tar -xzf /tmp/libwebp-*
|
RUN cd /tmp && tar -xzvf /tmp/libwebp-*
|
||||||
RUN cd /tmp/libwebp-1.0.2 && \
|
RUN cd /tmp/libwebp-1.0.2 && \
|
||||||
./configure --enable-static --disable-shared && \
|
./configure --enable-static --disable-shared && \
|
||||||
make && make install
|
make && make install
|
||||||
|
|||||||
@@ -1,30 +0,0 @@
|
|||||||
FROM ubuntu:jammy
|
|
||||||
|
|
||||||
ENV KASMVNC_BUILD_OS ubuntu
|
|
||||||
ENV KASMVNC_BUILD_OS_CODENAME jammy
|
|
||||||
ENV XORG_VER 1.20.8
|
|
||||||
ENV DEBIAN_FRONTEND noninteractive
|
|
||||||
|
|
||||||
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 install -y --no-install-recommends tzdata
|
|
||||||
RUN apt-get update && apt-get -y build-dep xorg-server libxfont-dev
|
|
||||||
RUN apt-get update && apt-get -y install cmake git libjpeg-dev libgnutls28-dev vim wget tightvncserver
|
|
||||||
RUN apt-get update && apt-get -y install libpng-dev libtiff-dev libgif-dev libavcodec-dev libssl-dev libxrandr-dev libxcursor-dev
|
|
||||||
|
|
||||||
# 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 -xzf /tmp/libwebp-*
|
|
||||||
RUN cd /tmp/libwebp-1.0.2 && \
|
|
||||||
./configure --enable-static --disable-shared && \
|
|
||||||
make && make install
|
|
||||||
|
|
||||||
RUN useradd -m docker && echo "docker:docker" | chpasswd && adduser docker sudo
|
|
||||||
|
|
||||||
COPY --chown=docker:docker . /src/
|
|
||||||
|
|
||||||
USER docker
|
|
||||||
ENTRYPOINT ["/src/builder/build.sh"]
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
FROM ubuntu:jammy
|
|
||||||
|
|
||||||
ENV DEBIAN_FRONTEND noninteractive
|
|
||||||
|
|
||||||
RUN apt-get update && \
|
|
||||||
apt-get -y install vim build-essential devscripts equivs
|
|
||||||
|
|
||||||
# Install build-deps for the package.
|
|
||||||
COPY ./debian/control /tmp
|
|
||||||
RUN apt-get update && echo YYY | mk-build-deps --install --remove /tmp/control
|
|
||||||
|
|
||||||
ARG L_UID
|
|
||||||
RUN if [ "$L_UID" -eq 0 ]; then \
|
|
||||||
useradd -m docker; \
|
|
||||||
else \
|
|
||||||
useradd -m docker -u $L_UID;\
|
|
||||||
fi
|
|
||||||
|
|
||||||
USER docker
|
|
||||||
@@ -1,57 +0,0 @@
|
|||||||
FROM ubuntu:jammy
|
|
||||||
|
|
||||||
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=/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/kasmvncserver_*.deb /tmp/
|
|
||||||
RUN rm -f /tmp/kasmvncserver_*+*.deb; dpkg -i /tmp/*.deb; apt-get -yf install
|
|
||||||
|
|
||||||
RUN mkdir ~/.vnc && echo '/usr/bin/xfce4-session &' >> ~/.vnc/xstartup && \
|
|
||||||
chmod +x ~/.vnc/xstartup
|
|
||||||
|
|
||||||
### END CUSTOM STUFF ###
|
|
||||||
|
|
||||||
RUN chown -R 1000:0 $HOME
|
|
||||||
USER 1000:ssl-cert
|
|
||||||
WORKDIR $HOME
|
|
||||||
|
|
||||||
ENTRYPOINT [ "/dockerstartup/vnc_startup.sh" ]
|
|
||||||
@@ -1,51 +0,0 @@
|
|||||||
FROM ubuntu:jammy
|
|
||||||
|
|
||||||
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=/usr/local/lib/ \
|
|
||||||
OMP_WAIT_POLICY=PASSIVE \
|
|
||||||
SHELL=/bin/bash \
|
|
||||||
SINGLE_APPLICATION=0 \
|
|
||||||
KASMVNC_BUILD_OS=ubuntu \
|
|
||||||
KASMVNC_BUILD_OS_CODENAME=jammy
|
|
||||||
|
|
||||||
EXPOSE $VNC_PORT
|
|
||||||
|
|
||||||
WORKDIR $HOME
|
|
||||||
|
|
||||||
### REQUIRED STUFF ###
|
|
||||||
|
|
||||||
RUN apt-get update && apt-get install -y supervisor xfce4 xfce4-terminal xterm libnss-wrapper gettext libjpeg-dev wget
|
|
||||||
RUN apt-get purge -y pm-utils xscreensaver*
|
|
||||||
|
|
||||||
RUN echo 'source $STARTUPDIR/generate_container_user' >> $HOME/.bashrc
|
|
||||||
|
|
||||||
RUN mkdir -p $STARTUPDIR
|
|
||||||
COPY startup/ $STARTUPDIR
|
|
||||||
|
|
||||||
### START CUSTOM STUFF ####
|
|
||||||
|
|
||||||
COPY build/kasmvnc.${KASMVNC_BUILD_OS}_${KASMVNC_BUILD_OS_CODENAME}.tar.gz /tmp/
|
|
||||||
RUN tar -xzvf /tmp/kasmvnc.${KASMVNC_BUILD_OS}_${KASMVNC_BUILD_OS_CODENAME}.tar.gz --strip 1 -C /
|
|
||||||
|
|
||||||
### END CUSTOM STUFF ###
|
|
||||||
|
|
||||||
RUN chown -R 1000:0 $HOME
|
|
||||||
USER 1000
|
|
||||||
WORKDIR $HOME
|
|
||||||
|
|
||||||
ENTRYPOINT [ "/dockerstartup/vnc_startup.sh" ]
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
Name: kasmvncserver
|
Name: kasmvncserver
|
||||||
Version: 0.9.3~beta
|
Version: 0.9.1~beta
|
||||||
Release: 1%{?dist}
|
Release: 1%{?dist}
|
||||||
Summary: VNC server accessible from a web browser
|
Summary: VNC server accessible from a web browser
|
||||||
|
|
||||||
@@ -53,7 +53,6 @@ cp $SRC_BIN/Xvnc $DESTDIR/usr/bin;
|
|||||||
cp $SRC_BIN/vncserver $DESTDIR/usr/bin;
|
cp $SRC_BIN/vncserver $DESTDIR/usr/bin;
|
||||||
cp $SRC_BIN/vncconfig $DESTDIR/usr/bin;
|
cp $SRC_BIN/vncconfig $DESTDIR/usr/bin;
|
||||||
cp $SRC_BIN/kasmvncpasswd $DESTDIR/usr/bin;
|
cp $SRC_BIN/kasmvncpasswd $DESTDIR/usr/bin;
|
||||||
cp $SRC_BIN/kasmxproxy $DESTDIR/usr/bin;
|
|
||||||
cd $DESTDIR/usr/bin && ln -s kasmvncpasswd vncpasswd;
|
cd $DESTDIR/usr/bin && ln -s kasmvncpasswd vncpasswd;
|
||||||
cp -r $SRC/share/doc/kasmvnc*/* $DESTDIR/usr/share/doc/kasmvncserver/
|
cp -r $SRC/share/doc/kasmvnc*/* $DESTDIR/usr/share/doc/kasmvncserver/
|
||||||
rsync -r --exclude '.git*' --exclude po2js --exclude xgettext-html \
|
rsync -r --exclude '.git*' --exclude po2js --exclude xgettext-html \
|
||||||
@@ -63,10 +62,8 @@ cp $SRC/man/man1/Xvnc.1 $DESTDIR/usr/share/man/man1/;
|
|||||||
cp $SRC/share/man/man1/vncserver.1 $DST_MAN;
|
cp $SRC/share/man/man1/vncserver.1 $DST_MAN;
|
||||||
cp $SRC/share/man/man1/vncconfig.1 $DST_MAN;
|
cp $SRC/share/man/man1/vncconfig.1 $DST_MAN;
|
||||||
cp $SRC/share/man/man1/vncpasswd.1 $DST_MAN;
|
cp $SRC/share/man/man1/vncpasswd.1 $DST_MAN;
|
||||||
cp $SRC/share/man/man1/kasmxproxy.1 $DST_MAN;
|
|
||||||
cd $DST_MAN && ln -s vncpasswd.1 kasmvncpasswd.1;
|
cd $DST_MAN && ln -s vncpasswd.1 kasmvncpasswd.1;
|
||||||
|
|
||||||
|
|
||||||
%files
|
%files
|
||||||
/usr/bin/*
|
/usr/bin/*
|
||||||
/usr/share/man/man1/*
|
/usr/share/man/man1/*
|
||||||
@@ -76,7 +73,6 @@ cd $DST_MAN && ln -s vncpasswd.1 kasmvncpasswd.1;
|
|||||||
%doc /usr/share/doc/kasmvncserver/README.md
|
%doc /usr/share/doc/kasmvncserver/README.md
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
* Tue Mar 22 2022 KasmTech <info@kasmweb.com> - 0.9.3~beta-1
|
|
||||||
* Fri Feb 12 2021 KasmTech <info@kasmweb.com> - 0.9.1~beta-1
|
* Fri Feb 12 2021 KasmTech <info@kasmweb.com> - 0.9.1~beta-1
|
||||||
- Initial release of the rpm package.
|
- Initial release of the rpm package.
|
||||||
|
|
||||||
|
|||||||
@@ -1,85 +0,0 @@
|
|||||||
/* Copyright (C) 2021 Kasm
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
|
||||||
#include <config.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <arpa/inet.h>
|
|
||||||
#include <errno.h>
|
|
||||||
#include <netinet/tcp.h>
|
|
||||||
#include <netdb.h>
|
|
||||||
#include <pthread.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <time.h>
|
|
||||||
|
|
||||||
#include <map>
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
#include <network/Blacklist.h>
|
|
||||||
#include <rfb/Blacklist.h>
|
|
||||||
|
|
||||||
static std::map<std::string, unsigned> hits;
|
|
||||||
static std::map<std::string, time_t> blacklist;
|
|
||||||
|
|
||||||
static pthread_mutex_t hitmutex = PTHREAD_MUTEX_INITIALIZER;
|
|
||||||
static pthread_mutex_t blmutex = PTHREAD_MUTEX_INITIALIZER;
|
|
||||||
|
|
||||||
unsigned char bl_isBlacklisted(const char *addr) {
|
|
||||||
const unsigned char count = blacklist.count(addr);
|
|
||||||
if (!count)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
const time_t now = time(NULL);
|
|
||||||
const unsigned timeout = rfb::Blacklist::initialTimeout;
|
|
||||||
|
|
||||||
if (pthread_mutex_lock(&blmutex))
|
|
||||||
abort();
|
|
||||||
|
|
||||||
if (now - timeout > blacklist[addr]) {
|
|
||||||
blacklist.erase(addr);
|
|
||||||
pthread_mutex_unlock(&blmutex);
|
|
||||||
|
|
||||||
if (pthread_mutex_lock(&hitmutex))
|
|
||||||
abort();
|
|
||||||
hits.erase(addr);
|
|
||||||
pthread_mutex_unlock(&hitmutex);
|
|
||||||
return 0;
|
|
||||||
} else {
|
|
||||||
blacklist[addr] = now;
|
|
||||||
pthread_mutex_unlock(&blmutex);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void bl_addFailure(const char *addr) {
|
|
||||||
if (!rfb::Blacklist::threshold)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (pthread_mutex_lock(&hitmutex))
|
|
||||||
abort();
|
|
||||||
const unsigned num = ++hits[addr];
|
|
||||||
pthread_mutex_unlock(&hitmutex);
|
|
||||||
|
|
||||||
if (num >= (unsigned) rfb::Blacklist::threshold) {
|
|
||||||
if (pthread_mutex_lock(&blmutex))
|
|
||||||
abort();
|
|
||||||
blacklist[addr] = time(NULL);
|
|
||||||
pthread_mutex_unlock(&blmutex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
/* Copyright (C) 2021 Kasm
|
|
||||||
*
|
|
||||||
* 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 __NETWORK_BLACKLIST_H__
|
|
||||||
#define __NETWORK_BLACKLIST_H__
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
unsigned char bl_isBlacklisted(const char *);
|
|
||||||
void bl_addFailure(const char *);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
} // extern C
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif // __NETWORK_TCP_SOCKET_H__
|
|
||||||
@@ -2,11 +2,8 @@ include_directories(${CMAKE_SOURCE_DIR}/common ${CMAKE_SOURCE_DIR}/unix/kasmvncp
|
|||||||
|
|
||||||
set(NETWORK_SOURCES
|
set(NETWORK_SOURCES
|
||||||
GetAPIMessager.cxx
|
GetAPIMessager.cxx
|
||||||
Blacklist.cxx
|
|
||||||
Socket.cxx
|
Socket.cxx
|
||||||
TcpSocket.cxx
|
TcpSocket.cxx
|
||||||
cJSON.c
|
|
||||||
jsonescape.c
|
|
||||||
websocket.c
|
websocket.c
|
||||||
websockify.c
|
websockify.c
|
||||||
${CMAKE_SOURCE_DIR}/unix/kasmvncpasswd/kasmpasswd.c)
|
${CMAKE_SOURCE_DIR}/unix/kasmvncpasswd/kasmpasswd.c)
|
||||||
|
|||||||
@@ -21,7 +21,6 @@
|
|||||||
|
|
||||||
#include <kasmpasswd.h>
|
#include <kasmpasswd.h>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include <network/GetAPIEnums.h>
|
|
||||||
#include <rfb/PixelBuffer.h>
|
#include <rfb/PixelBuffer.h>
|
||||||
#include <rfb/PixelFormat.h>
|
#include <rfb/PixelFormat.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
@@ -53,21 +52,17 @@ namespace network {
|
|||||||
uint8_t *netGetScreenshot(uint16_t w, uint16_t h,
|
uint8_t *netGetScreenshot(uint16_t w, uint16_t h,
|
||||||
const uint8_t q, const bool dedup,
|
const uint8_t q, const bool dedup,
|
||||||
uint32_t &len, uint8_t *staging);
|
uint32_t &len, uint8_t *staging);
|
||||||
uint8_t netAddUser(const char name[], const char pw[],
|
uint8_t netAddUser(const char name[], const char pw[], const bool write);
|
||||||
const bool read, const bool write, const bool owner);
|
|
||||||
uint8_t netRemoveUser(const char name[]);
|
uint8_t netRemoveUser(const char name[]);
|
||||||
uint8_t netUpdateUser(const char name[], const uint64_t mask,
|
uint8_t netGiveControlTo(const char name[]);
|
||||||
const char password[],
|
|
||||||
const bool read, const bool write, const bool owner);
|
|
||||||
uint8_t netAddOrUpdateUser(const struct kasmpasswd_entry_t *entry);
|
|
||||||
void netGetUsers(const char **ptr);
|
|
||||||
void netGetBottleneckStats(char *buf, uint32_t len);
|
void netGetBottleneckStats(char *buf, uint32_t len);
|
||||||
void netGetFrameStats(char *buf, uint32_t len);
|
void netGetFrameStats(char *buf, uint32_t len);
|
||||||
void netResetFrameStatsCall();
|
|
||||||
uint8_t netServerFrameStatsReady();
|
uint8_t netServerFrameStatsReady();
|
||||||
|
|
||||||
enum USER_ACTION {
|
enum USER_ACTION {
|
||||||
NONE,
|
//USER_ADD, - handled locally for interactivity
|
||||||
|
USER_REMOVE,
|
||||||
|
USER_GIVE_CONTROL,
|
||||||
WANT_FRAME_STATS_SERVERONLY,
|
WANT_FRAME_STATS_SERVERONLY,
|
||||||
WANT_FRAME_STATS_ALL,
|
WANT_FRAME_STATS_ALL,
|
||||||
WANT_FRAME_STATS_OWNER,
|
WANT_FRAME_STATS_OWNER,
|
||||||
|
|||||||
@@ -1,30 +0,0 @@
|
|||||||
/* Copyright (C) 2021 Kasm
|
|
||||||
*
|
|
||||||
* 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 __NETWORK_GET_API_ENUMS_H__
|
|
||||||
#define __NETWORK_GET_API_ENUMS_H__
|
|
||||||
|
|
||||||
// Enums that need accessibility from both C and C++.
|
|
||||||
enum USER_UPDATE_MASK {
|
|
||||||
USER_UPDATE_WRITE_MASK = 1 << 0,
|
|
||||||
USER_UPDATE_OWNER_MASK = 1 << 1,
|
|
||||||
USER_UPDATE_PASSWORD_MASK = 1 << 2,
|
|
||||||
USER_UPDATE_READ_MASK = 1 << 3,
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -20,7 +20,6 @@
|
|||||||
|
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <network/GetAPI.h>
|
#include <network/GetAPI.h>
|
||||||
#include <network/jsonescape.h>
|
|
||||||
#include <rfb/ConnParams.h>
|
#include <rfb/ConnParams.h>
|
||||||
#include <rfb/EncodeManager.h>
|
#include <rfb/EncodeManager.h>
|
||||||
#include <rfb/LogWriter.h>
|
#include <rfb/LogWriter.h>
|
||||||
@@ -264,9 +263,10 @@ uint8_t *GetAPIMessager::netGetScreenshot(uint16_t w, uint16_t h,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t GetAPIMessager::netAddUser(const char name[], const char pw[],
|
#define USERNAME_LEN sizeof(((struct kasmpasswd_entry_t *)0)->user)
|
||||||
const bool read, const bool write,
|
#define PASSWORD_LEN sizeof(((struct kasmpasswd_entry_t *)0)->password)
|
||||||
const bool owner) {
|
|
||||||
|
uint8_t GetAPIMessager::netAddUser(const char name[], const char pw[], const bool write) {
|
||||||
if (strlen(name) >= USERNAME_LEN) {
|
if (strlen(name) >= USERNAME_LEN) {
|
||||||
vlog.error("Username too long");
|
vlog.error("Username too long");
|
||||||
return 0;
|
return 0;
|
||||||
@@ -280,17 +280,14 @@ uint8_t GetAPIMessager::netAddUser(const char name[], const char pw[],
|
|||||||
if (!passwdfile)
|
if (!passwdfile)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
uint8_t ret = 1;
|
|
||||||
|
|
||||||
action_data act;
|
action_data act;
|
||||||
|
|
||||||
memcpy(act.data.user, name, USERNAME_LEN);
|
memcpy(act.data.user, name, USERNAME_LEN);
|
||||||
act.data.user[USERNAME_LEN - 1] = '\0';
|
act.data.user[USERNAME_LEN - 1] = '\0';
|
||||||
memcpy(act.data.password, pw, PASSWORD_LEN);
|
memcpy(act.data.password, pw, PASSWORD_LEN);
|
||||||
act.data.password[PASSWORD_LEN - 1] = '\0';
|
act.data.password[PASSWORD_LEN - 1] = '\0';
|
||||||
act.data.owner = owner;
|
act.data.owner = 0;
|
||||||
act.data.write = write;
|
act.data.write = write;
|
||||||
act.data.read = read;
|
|
||||||
|
|
||||||
if (pthread_mutex_lock(&userMutex))
|
if (pthread_mutex_lock(&userMutex))
|
||||||
return 0;
|
return 0;
|
||||||
@@ -302,9 +299,8 @@ uint8_t GetAPIMessager::netAddUser(const char name[], const char pw[],
|
|||||||
struct kasmpasswd_t *set = readkasmpasswd(passwdfile);
|
struct kasmpasswd_t *set = readkasmpasswd(passwdfile);
|
||||||
unsigned s;
|
unsigned s;
|
||||||
for (s = 0; s < set->num; s++) {
|
for (s = 0; s < set->num; s++) {
|
||||||
if (!strcmp(set->entries[s].user, name)) {
|
if (!strcmp(set->entries[s].user, act.data.user)) {
|
||||||
vlog.error("Can't create user %s, already exists", name);
|
vlog.error("Can't create user %s, already exists", act.data.user);
|
||||||
ret = 0;
|
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -315,14 +311,11 @@ uint8_t GetAPIMessager::netAddUser(const char name[], const char pw[],
|
|||||||
set->entries[s] = act.data;
|
set->entries[s] = act.data;
|
||||||
|
|
||||||
writekasmpasswd(passwdfile, set);
|
writekasmpasswd(passwdfile, set);
|
||||||
vlog.info("User %s created", name);
|
vlog.info("User %s created", act.data.user);
|
||||||
out:
|
out:
|
||||||
pthread_mutex_unlock(&userMutex);
|
pthread_mutex_unlock(&userMutex);
|
||||||
|
|
||||||
free(set->entries);
|
return 1;
|
||||||
free(set);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t GetAPIMessager::netRemoveUser(const char name[]) {
|
uint8_t GetAPIMessager::netRemoveUser(const char name[]) {
|
||||||
@@ -331,189 +324,44 @@ uint8_t GetAPIMessager::netRemoveUser(const char name[]) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
action_data act;
|
||||||
|
act.action = USER_REMOVE;
|
||||||
|
|
||||||
|
memcpy(act.data.user, name, USERNAME_LEN);
|
||||||
|
act.data.user[USERNAME_LEN - 1] = '\0';
|
||||||
|
|
||||||
if (pthread_mutex_lock(&userMutex))
|
if (pthread_mutex_lock(&userMutex))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
struct kasmpasswd_t *set = readkasmpasswd(passwdfile);
|
actionQueue.push_back(act);
|
||||||
bool found = false;
|
|
||||||
unsigned s;
|
|
||||||
for (s = 0; s < set->num; s++) {
|
|
||||||
if (!strcmp(set->entries[s].user, name)) {
|
|
||||||
set->entries[s].user[0] = '\0';
|
|
||||||
found = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (found) {
|
|
||||||
writekasmpasswd(passwdfile, set);
|
|
||||||
vlog.info("User %s removed", name);
|
|
||||||
} else {
|
|
||||||
vlog.error("Tried to remove nonexistent user %s", name);
|
|
||||||
|
|
||||||
pthread_mutex_unlock(&userMutex);
|
pthread_mutex_unlock(&userMutex);
|
||||||
|
|
||||||
free(set->entries);
|
|
||||||
free(set);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
pthread_mutex_unlock(&userMutex);
|
|
||||||
|
|
||||||
free(set->entries);
|
|
||||||
free(set);
|
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t GetAPIMessager::netUpdateUser(const char name[], const uint64_t mask,
|
uint8_t GetAPIMessager::netGiveControlTo(const char name[]) {
|
||||||
const char password[],
|
|
||||||
const bool read, const bool write, const bool owner) {
|
|
||||||
if (strlen(name) >= USERNAME_LEN) {
|
if (strlen(name) >= USERNAME_LEN) {
|
||||||
vlog.error("Username too long");
|
vlog.error("Username too long");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strlen(password) >= PASSWORD_LEN) {
|
action_data act;
|
||||||
vlog.error("Password too long");
|
act.action = USER_GIVE_CONTROL;
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!mask) {
|
memcpy(act.data.user, name, USERNAME_LEN);
|
||||||
vlog.error("Update_user without any updates?");
|
act.data.user[USERNAME_LEN - 1] = '\0';
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pthread_mutex_lock(&userMutex))
|
if (pthread_mutex_lock(&userMutex))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
struct kasmpasswd_t *set = readkasmpasswd(passwdfile);
|
actionQueue.push_back(act);
|
||||||
bool found = false;
|
|
||||||
unsigned s;
|
|
||||||
for (s = 0; s < set->num; s++) {
|
|
||||||
if (!strcmp(set->entries[s].user, name)) {
|
|
||||||
if (mask & USER_UPDATE_READ_MASK)
|
|
||||||
set->entries[s].read = read;
|
|
||||||
if (mask & USER_UPDATE_WRITE_MASK)
|
|
||||||
set->entries[s].write = write;
|
|
||||||
if (mask & USER_UPDATE_OWNER_MASK)
|
|
||||||
set->entries[s].owner = owner;
|
|
||||||
|
|
||||||
if (mask & USER_UPDATE_PASSWORD_MASK)
|
|
||||||
strcpy(set->entries[s].password, password);
|
|
||||||
found = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (found) {
|
|
||||||
writekasmpasswd(passwdfile, set);
|
|
||||||
vlog.info("User %s permissions updated", name);
|
|
||||||
} else {
|
|
||||||
vlog.error("Tried to update nonexistent user %s", name);
|
|
||||||
|
|
||||||
pthread_mutex_unlock(&userMutex);
|
pthread_mutex_unlock(&userMutex);
|
||||||
|
|
||||||
free(set->entries);
|
|
||||||
free(set);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
pthread_mutex_unlock(&userMutex);
|
|
||||||
|
|
||||||
free(set->entries);
|
|
||||||
free(set);
|
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t GetAPIMessager::netAddOrUpdateUser(const struct kasmpasswd_entry_t *entry) {
|
|
||||||
|
|
||||||
if (pthread_mutex_lock(&userMutex))
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
struct kasmpasswd_t *set = readkasmpasswd(passwdfile);
|
|
||||||
unsigned s;
|
|
||||||
bool updated = false;
|
|
||||||
for (s = 0; s < set->num; s++) {
|
|
||||||
if (!strcmp(set->entries[s].user, entry->user)) {
|
|
||||||
set->entries[s] = *entry;
|
|
||||||
updated = true;
|
|
||||||
vlog.info("User %s updated", entry->user);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!updated) {
|
|
||||||
s = set->num++;
|
|
||||||
set->entries = (struct kasmpasswd_entry_t *) realloc(set->entries,
|
|
||||||
set->num * sizeof(struct kasmpasswd_entry_t));
|
|
||||||
set->entries[s] = *entry;
|
|
||||||
vlog.info("User %s created", entry->user);
|
|
||||||
}
|
|
||||||
|
|
||||||
writekasmpasswd(passwdfile, set);
|
|
||||||
|
|
||||||
pthread_mutex_unlock(&userMutex);
|
|
||||||
|
|
||||||
free(set->entries);
|
|
||||||
free(set);
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void GetAPIMessager::netGetUsers(const char **outptr) {
|
|
||||||
/*
|
|
||||||
[
|
|
||||||
{ "user": "username", "write": true, "owner": true },
|
|
||||||
{ "user": "username", "write": true, "owner": true }
|
|
||||||
]
|
|
||||||
*/
|
|
||||||
char *buf;
|
|
||||||
char escapeduser[USERNAME_LEN * 2];
|
|
||||||
|
|
||||||
if (pthread_mutex_lock(&userMutex)) {
|
|
||||||
*outptr = (char *) calloc(1, 1);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct kasmpasswd_t *set = readkasmpasswd(passwdfile);
|
|
||||||
|
|
||||||
buf = (char *) calloc(set->num, 80);
|
|
||||||
FILE *f = fmemopen(buf, set->num * 80, "w");
|
|
||||||
|
|
||||||
fprintf(f, "[\n");
|
|
||||||
|
|
||||||
unsigned s;
|
|
||||||
for (s = 0; s < set->num; s++) {
|
|
||||||
JSON_escape(set->entries[s].user, escapeduser);
|
|
||||||
|
|
||||||
fprintf(f, " { \"user\": \"%s\", \"read\": %s, \"write\": %s, \"owner\": %s }",
|
|
||||||
escapeduser,
|
|
||||||
set->entries[s].read ? "true" : "false",
|
|
||||||
set->entries[s].write ? "true" : "false",
|
|
||||||
set->entries[s].owner ? "true" : "false");
|
|
||||||
|
|
||||||
if (s == set->num - 1)
|
|
||||||
fprintf(f, "\n");
|
|
||||||
else
|
|
||||||
fprintf(f, ",\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
free(set->entries);
|
|
||||||
free(set);
|
|
||||||
|
|
||||||
fprintf(f, "]\n");
|
|
||||||
|
|
||||||
fclose(f);
|
|
||||||
|
|
||||||
pthread_mutex_unlock(&userMutex);
|
|
||||||
*outptr = buf;
|
|
||||||
}
|
|
||||||
|
|
||||||
void GetAPIMessager::netGetBottleneckStats(char *buf, uint32_t len) {
|
void GetAPIMessager::netGetBottleneckStats(char *buf, uint32_t len) {
|
||||||
/*
|
/*
|
||||||
{
|
{
|
||||||
@@ -692,15 +540,6 @@ out:
|
|||||||
pthread_mutex_unlock(&frameStatMutex);
|
pthread_mutex_unlock(&frameStatMutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GetAPIMessager::netResetFrameStatsCall() {
|
|
||||||
if (pthread_mutex_lock(&frameStatMutex))
|
|
||||||
return;
|
|
||||||
|
|
||||||
serverFrameStats.inprogress = 0;
|
|
||||||
|
|
||||||
pthread_mutex_unlock(&frameStatMutex);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t GetAPIMessager::netRequestFrameStats(USER_ACTION what, const char *client) {
|
uint8_t GetAPIMessager::netRequestFrameStats(USER_ACTION what, const char *client) {
|
||||||
// Return 1 for success
|
// Return 1 for success
|
||||||
action_data act;
|
action_data act;
|
||||||
|
|||||||
@@ -443,10 +443,10 @@ static uint8_t *screenshotCb(void *messager, uint16_t w, uint16_t h, const uint8
|
|||||||
}
|
}
|
||||||
|
|
||||||
static uint8_t adduserCb(void *messager, const char name[], const char pw[],
|
static uint8_t adduserCb(void *messager, const char name[], const char pw[],
|
||||||
const uint8_t read, const uint8_t write, const uint8_t owner)
|
const uint8_t write)
|
||||||
{
|
{
|
||||||
GetAPIMessager *msgr = (GetAPIMessager *) messager;
|
GetAPIMessager *msgr = (GetAPIMessager *) messager;
|
||||||
return msgr->netAddUser(name, pw, read, write, owner);
|
return msgr->netAddUser(name, pw, write);
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint8_t removeCb(void *messager, const char name[])
|
static uint8_t removeCb(void *messager, const char name[])
|
||||||
@@ -455,24 +455,10 @@ static uint8_t removeCb(void *messager, const char name[])
|
|||||||
return msgr->netRemoveUser(name);
|
return msgr->netRemoveUser(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint8_t updateUserCb(void *messager, const char name[], const uint64_t mask,
|
static uint8_t givecontrolCb(void *messager, const char name[])
|
||||||
const char password[],
|
|
||||||
const uint8_t read, const uint8_t write, const uint8_t owner)
|
|
||||||
{
|
{
|
||||||
GetAPIMessager *msgr = (GetAPIMessager *) messager;
|
GetAPIMessager *msgr = (GetAPIMessager *) messager;
|
||||||
return msgr->netUpdateUser(name, mask, password, read, write, owner);
|
return msgr->netGiveControlTo(name);
|
||||||
}
|
|
||||||
|
|
||||||
static uint8_t addOrUpdateUserCb(void *messager, const struct kasmpasswd_entry_t *entry)
|
|
||||||
{
|
|
||||||
GetAPIMessager *msgr = (GetAPIMessager *) messager;
|
|
||||||
return msgr->netAddOrUpdateUser(entry);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void getUsersCb(void *messager, const char **ptr)
|
|
||||||
{
|
|
||||||
GetAPIMessager *msgr = (GetAPIMessager *) messager;
|
|
||||||
msgr->netGetUsers(ptr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void bottleneckStatsCb(void *messager, char *buf, uint32_t len)
|
static void bottleneckStatsCb(void *messager, char *buf, uint32_t len)
|
||||||
@@ -487,12 +473,6 @@ static void frameStatsCb(void *messager, char *buf, uint32_t len)
|
|||||||
msgr->netGetFrameStats(buf, len);
|
msgr->netGetFrameStats(buf, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void resetFrameStatsCb(void *messager)
|
|
||||||
{
|
|
||||||
GetAPIMessager *msgr = (GetAPIMessager *) messager;
|
|
||||||
msgr->netResetFrameStatsCall();
|
|
||||||
}
|
|
||||||
|
|
||||||
static uint8_t requestFrameStatsNoneCb(void *messager)
|
static uint8_t requestFrameStatsNoneCb(void *messager)
|
||||||
{
|
{
|
||||||
GetAPIMessager *msgr = (GetAPIMessager *) messager;
|
GetAPIMessager *msgr = (GetAPIMessager *) messager;
|
||||||
@@ -633,12 +613,9 @@ WebsocketListener::WebsocketListener(const struct sockaddr *listenaddr,
|
|||||||
settings.screenshotCb = screenshotCb;
|
settings.screenshotCb = screenshotCb;
|
||||||
settings.adduserCb = adduserCb;
|
settings.adduserCb = adduserCb;
|
||||||
settings.removeCb = removeCb;
|
settings.removeCb = removeCb;
|
||||||
settings.updateUserCb = updateUserCb;
|
settings.givecontrolCb = givecontrolCb;
|
||||||
settings.addOrUpdateUserCb = addOrUpdateUserCb;
|
|
||||||
settings.getUsersCb = getUsersCb;
|
|
||||||
settings.bottleneckStatsCb = bottleneckStatsCb;
|
settings.bottleneckStatsCb = bottleneckStatsCb;
|
||||||
settings.frameStatsCb = frameStatsCb;
|
settings.frameStatsCb = frameStatsCb;
|
||||||
settings.resetFrameStatsCb = resetFrameStatsCb;
|
|
||||||
|
|
||||||
settings.requestFrameStatsNoneCb = requestFrameStatsNoneCb;
|
settings.requestFrameStatsNoneCb = requestFrameStatsNoneCb;
|
||||||
settings.requestFrameStatsOwnerCb = requestFrameStatsOwnerCb;
|
settings.requestFrameStatsOwnerCb = requestFrameStatsOwnerCb;
|
||||||
@@ -931,8 +908,6 @@ void network::createWebsocketListeners(std::list<SocketListener*> *listeners,
|
|||||||
freeaddrinfo(ai);
|
freeaddrinfo(ai);
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
|
|
||||||
freeaddrinfo(ai);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -1,295 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright (c) 2009-2017 Dave Gamble and cJSON contributors
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
|
||||||
in the Software without restriction, including without limitation the rights
|
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
copies of the Software, and to permit persons to whom the Software is
|
|
||||||
furnished to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in
|
|
||||||
all copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
||||||
THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
// 2fc55f6 from Jan 20, 2022
|
|
||||||
|
|
||||||
#ifndef cJSON__h
|
|
||||||
#define cJSON__h
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C"
|
|
||||||
{
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if !defined(__WINDOWS__) && (defined(WIN32) || defined(WIN64) || defined(_MSC_VER) || defined(_WIN32))
|
|
||||||
#define __WINDOWS__
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __WINDOWS__
|
|
||||||
|
|
||||||
/* When compiling for windows, we specify a specific calling convention to avoid issues where we are being called from a project with a different default calling convention. For windows you have 3 define options:
|
|
||||||
|
|
||||||
CJSON_HIDE_SYMBOLS - Define this in the case where you don't want to ever dllexport symbols
|
|
||||||
CJSON_EXPORT_SYMBOLS - Define this on library build when you want to dllexport symbols (default)
|
|
||||||
CJSON_IMPORT_SYMBOLS - Define this if you want to dllimport symbol
|
|
||||||
|
|
||||||
For *nix builds that support visibility attribute, you can define similar behavior by
|
|
||||||
|
|
||||||
setting default visibility to hidden by adding
|
|
||||||
-fvisibility=hidden (for gcc)
|
|
||||||
or
|
|
||||||
-xldscope=hidden (for sun cc)
|
|
||||||
to CFLAGS
|
|
||||||
|
|
||||||
then using the CJSON_API_VISIBILITY flag to "export" the same symbols the way CJSON_EXPORT_SYMBOLS does
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define CJSON_CDECL __cdecl
|
|
||||||
#define CJSON_STDCALL __stdcall
|
|
||||||
|
|
||||||
/* export symbols by default, this is necessary for copy pasting the C and header file */
|
|
||||||
#if !defined(CJSON_HIDE_SYMBOLS) && !defined(CJSON_IMPORT_SYMBOLS) && !defined(CJSON_EXPORT_SYMBOLS)
|
|
||||||
#define CJSON_EXPORT_SYMBOLS
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(CJSON_HIDE_SYMBOLS)
|
|
||||||
#define CJSON_PUBLIC(type) type CJSON_STDCALL
|
|
||||||
#elif defined(CJSON_EXPORT_SYMBOLS)
|
|
||||||
#define CJSON_PUBLIC(type) __declspec(dllexport) type CJSON_STDCALL
|
|
||||||
#elif defined(CJSON_IMPORT_SYMBOLS)
|
|
||||||
#define CJSON_PUBLIC(type) __declspec(dllimport) type CJSON_STDCALL
|
|
||||||
#endif
|
|
||||||
#else /* !__WINDOWS__ */
|
|
||||||
#define CJSON_CDECL
|
|
||||||
#define CJSON_STDCALL
|
|
||||||
|
|
||||||
#if (defined(__GNUC__) || defined(__SUNPRO_CC) || defined (__SUNPRO_C)) && defined(CJSON_API_VISIBILITY)
|
|
||||||
#define CJSON_PUBLIC(type) __attribute__((visibility("default"))) type
|
|
||||||
#else
|
|
||||||
#define CJSON_PUBLIC(type) type
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* project version */
|
|
||||||
#define CJSON_VERSION_MAJOR 1
|
|
||||||
#define CJSON_VERSION_MINOR 7
|
|
||||||
#define CJSON_VERSION_PATCH 15
|
|
||||||
|
|
||||||
#include <stddef.h>
|
|
||||||
|
|
||||||
/* cJSON Types: */
|
|
||||||
#define cJSON_Invalid (0)
|
|
||||||
#define cJSON_False (1 << 0)
|
|
||||||
#define cJSON_True (1 << 1)
|
|
||||||
#define cJSON_NULL (1 << 2)
|
|
||||||
#define cJSON_Number (1 << 3)
|
|
||||||
#define cJSON_String (1 << 4)
|
|
||||||
#define cJSON_Array (1 << 5)
|
|
||||||
#define cJSON_Object (1 << 6)
|
|
||||||
#define cJSON_Raw (1 << 7) /* raw json */
|
|
||||||
|
|
||||||
#define cJSON_IsReference 256
|
|
||||||
#define cJSON_StringIsConst 512
|
|
||||||
|
|
||||||
/* The cJSON structure: */
|
|
||||||
typedef struct cJSON
|
|
||||||
{
|
|
||||||
/* next/prev allow you to walk array/object chains. Alternatively, use GetArraySize/GetArrayItem/GetObjectItem */
|
|
||||||
struct cJSON *next;
|
|
||||||
struct cJSON *prev;
|
|
||||||
/* An array or object item will have a child pointer pointing to a chain of the items in the array/object. */
|
|
||||||
struct cJSON *child;
|
|
||||||
|
|
||||||
/* The type of the item, as above. */
|
|
||||||
int type;
|
|
||||||
|
|
||||||
/* The item's string, if type==cJSON_String and type == cJSON_Raw */
|
|
||||||
char *valuestring;
|
|
||||||
/* writing to valueint is DEPRECATED, use cJSON_SetNumberValue instead */
|
|
||||||
int valueint;
|
|
||||||
/* The item's number, if type==cJSON_Number */
|
|
||||||
double valuedouble;
|
|
||||||
|
|
||||||
/* The item's name string, if this item is the child of, or is in the list of subitems of an object. */
|
|
||||||
char *string;
|
|
||||||
} cJSON;
|
|
||||||
|
|
||||||
typedef struct cJSON_Hooks
|
|
||||||
{
|
|
||||||
/* malloc/free are CDECL on Windows regardless of the default calling convention of the compiler, so ensure the hooks allow passing those functions directly. */
|
|
||||||
void *(CJSON_CDECL *malloc_fn)(size_t sz);
|
|
||||||
void (CJSON_CDECL *free_fn)(void *ptr);
|
|
||||||
} cJSON_Hooks;
|
|
||||||
|
|
||||||
typedef int cJSON_bool;
|
|
||||||
|
|
||||||
/* Limits how deeply nested arrays/objects can be before cJSON rejects to parse them.
|
|
||||||
* This is to prevent stack overflows. */
|
|
||||||
#ifndef CJSON_NESTING_LIMIT
|
|
||||||
#define CJSON_NESTING_LIMIT 1000
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* returns the version of cJSON as a string */
|
|
||||||
CJSON_PUBLIC(const char*) cJSON_Version(void);
|
|
||||||
|
|
||||||
/* Supply malloc, realloc and free functions to cJSON */
|
|
||||||
CJSON_PUBLIC(void) cJSON_InitHooks(cJSON_Hooks* hooks);
|
|
||||||
|
|
||||||
/* Memory Management: the caller is always responsible to free the results from all variants of cJSON_Parse (with cJSON_Delete) and cJSON_Print (with stdlib free, cJSON_Hooks.free_fn, or cJSON_free as appropriate). The exception is cJSON_PrintPreallocated, where the caller has full responsibility of the buffer. */
|
|
||||||
/* Supply a block of JSON, and this returns a cJSON object you can interrogate. */
|
|
||||||
CJSON_PUBLIC(cJSON *) cJSON_Parse(const char *value);
|
|
||||||
CJSON_PUBLIC(cJSON *) cJSON_ParseWithLength(const char *value, size_t buffer_length);
|
|
||||||
/* ParseWithOpts allows you to require (and check) that the JSON is null terminated, and to retrieve the pointer to the final byte parsed. */
|
|
||||||
/* If you supply a ptr in return_parse_end and parsing fails, then return_parse_end will contain a pointer to the error so will match cJSON_GetErrorPtr(). */
|
|
||||||
CJSON_PUBLIC(cJSON *) cJSON_ParseWithOpts(const char *value, const char **return_parse_end, cJSON_bool require_null_terminated);
|
|
||||||
CJSON_PUBLIC(cJSON *) cJSON_ParseWithLengthOpts(const char *value, size_t buffer_length, const char **return_parse_end, cJSON_bool require_null_terminated);
|
|
||||||
|
|
||||||
/* Render a cJSON entity to text for transfer/storage. */
|
|
||||||
CJSON_PUBLIC(char *) cJSON_Print(const cJSON *item);
|
|
||||||
/* Render a cJSON entity to text for transfer/storage without any formatting. */
|
|
||||||
CJSON_PUBLIC(char *) cJSON_PrintUnformatted(const cJSON *item);
|
|
||||||
/* Render a cJSON entity to text using a buffered strategy. prebuffer is a guess at the final size. guessing well reduces reallocation. fmt=0 gives unformatted, =1 gives formatted */
|
|
||||||
CJSON_PUBLIC(char *) cJSON_PrintBuffered(const cJSON *item, int prebuffer, cJSON_bool fmt);
|
|
||||||
/* Render a cJSON entity to text using a buffer already allocated in memory with given length. Returns 1 on success and 0 on failure. */
|
|
||||||
/* NOTE: cJSON is not always 100% accurate in estimating how much memory it will use, so to be safe allocate 5 bytes more than you actually need */
|
|
||||||
CJSON_PUBLIC(cJSON_bool) cJSON_PrintPreallocated(cJSON *item, char *buffer, const int length, const cJSON_bool format);
|
|
||||||
/* Delete a cJSON entity and all subentities. */
|
|
||||||
CJSON_PUBLIC(void) cJSON_Delete(cJSON *item);
|
|
||||||
|
|
||||||
/* Returns the number of items in an array (or object). */
|
|
||||||
CJSON_PUBLIC(int) cJSON_GetArraySize(const cJSON *array);
|
|
||||||
/* Retrieve item number "index" from array "array". Returns NULL if unsuccessful. */
|
|
||||||
CJSON_PUBLIC(cJSON *) cJSON_GetArrayItem(const cJSON *array, int index);
|
|
||||||
/* Get item "string" from object. Case insensitive. */
|
|
||||||
CJSON_PUBLIC(cJSON *) cJSON_GetObjectItem(const cJSON * const object, const char * const string);
|
|
||||||
CJSON_PUBLIC(cJSON *) cJSON_GetObjectItemCaseSensitive(const cJSON * const object, const char * const string);
|
|
||||||
CJSON_PUBLIC(cJSON_bool) cJSON_HasObjectItem(const cJSON *object, const char *string);
|
|
||||||
/* For analysing failed parses. This returns a pointer to the parse error. You'll probably need to look a few chars back to make sense of it. Defined when cJSON_Parse() returns 0. 0 when cJSON_Parse() succeeds. */
|
|
||||||
CJSON_PUBLIC(const char *) cJSON_GetErrorPtr(void);
|
|
||||||
|
|
||||||
/* Check item type and return its value */
|
|
||||||
CJSON_PUBLIC(char *) cJSON_GetStringValue(const cJSON * const item);
|
|
||||||
CJSON_PUBLIC(double) cJSON_GetNumberValue(const cJSON * const item);
|
|
||||||
|
|
||||||
/* These functions check the type of an item */
|
|
||||||
CJSON_PUBLIC(cJSON_bool) cJSON_IsInvalid(const cJSON * const item);
|
|
||||||
CJSON_PUBLIC(cJSON_bool) cJSON_IsFalse(const cJSON * const item);
|
|
||||||
CJSON_PUBLIC(cJSON_bool) cJSON_IsTrue(const cJSON * const item);
|
|
||||||
CJSON_PUBLIC(cJSON_bool) cJSON_IsBool(const cJSON * const item);
|
|
||||||
CJSON_PUBLIC(cJSON_bool) cJSON_IsNull(const cJSON * const item);
|
|
||||||
CJSON_PUBLIC(cJSON_bool) cJSON_IsNumber(const cJSON * const item);
|
|
||||||
CJSON_PUBLIC(cJSON_bool) cJSON_IsString(const cJSON * const item);
|
|
||||||
CJSON_PUBLIC(cJSON_bool) cJSON_IsArray(const cJSON * const item);
|
|
||||||
CJSON_PUBLIC(cJSON_bool) cJSON_IsObject(const cJSON * const item);
|
|
||||||
CJSON_PUBLIC(cJSON_bool) cJSON_IsRaw(const cJSON * const item);
|
|
||||||
|
|
||||||
/* These calls create a cJSON item of the appropriate type. */
|
|
||||||
CJSON_PUBLIC(cJSON *) cJSON_CreateNull(void);
|
|
||||||
CJSON_PUBLIC(cJSON *) cJSON_CreateTrue(void);
|
|
||||||
CJSON_PUBLIC(cJSON *) cJSON_CreateFalse(void);
|
|
||||||
CJSON_PUBLIC(cJSON *) cJSON_CreateBool(cJSON_bool boolean);
|
|
||||||
CJSON_PUBLIC(cJSON *) cJSON_CreateNumber(double num);
|
|
||||||
CJSON_PUBLIC(cJSON *) cJSON_CreateString(const char *string);
|
|
||||||
/* raw json */
|
|
||||||
CJSON_PUBLIC(cJSON *) cJSON_CreateRaw(const char *raw);
|
|
||||||
CJSON_PUBLIC(cJSON *) cJSON_CreateArray(void);
|
|
||||||
CJSON_PUBLIC(cJSON *) cJSON_CreateObject(void);
|
|
||||||
|
|
||||||
/* Create a string where valuestring references a string so
|
|
||||||
* it will not be freed by cJSON_Delete */
|
|
||||||
CJSON_PUBLIC(cJSON *) cJSON_CreateStringReference(const char *string);
|
|
||||||
/* Create an object/array that only references it's elements so
|
|
||||||
* they will not be freed by cJSON_Delete */
|
|
||||||
CJSON_PUBLIC(cJSON *) cJSON_CreateObjectReference(const cJSON *child);
|
|
||||||
CJSON_PUBLIC(cJSON *) cJSON_CreateArrayReference(const cJSON *child);
|
|
||||||
|
|
||||||
/* These utilities create an Array of count items.
|
|
||||||
* The parameter count cannot be greater than the number of elements in the number array, otherwise array access will be out of bounds.*/
|
|
||||||
CJSON_PUBLIC(cJSON *) cJSON_CreateIntArray(const int *numbers, int count);
|
|
||||||
CJSON_PUBLIC(cJSON *) cJSON_CreateFloatArray(const float *numbers, int count);
|
|
||||||
CJSON_PUBLIC(cJSON *) cJSON_CreateDoubleArray(const double *numbers, int count);
|
|
||||||
CJSON_PUBLIC(cJSON *) cJSON_CreateStringArray(const char *const *strings, int count);
|
|
||||||
|
|
||||||
/* Append item to the specified array/object. */
|
|
||||||
CJSON_PUBLIC(cJSON_bool) cJSON_AddItemToArray(cJSON *array, cJSON *item);
|
|
||||||
CJSON_PUBLIC(cJSON_bool) cJSON_AddItemToObject(cJSON *object, const char *string, cJSON *item);
|
|
||||||
/* Use this when string is definitely const (i.e. a literal, or as good as), and will definitely survive the cJSON object.
|
|
||||||
* WARNING: When this function was used, make sure to always check that (item->type & cJSON_StringIsConst) is zero before
|
|
||||||
* writing to `item->string` */
|
|
||||||
CJSON_PUBLIC(cJSON_bool) cJSON_AddItemToObjectCS(cJSON *object, const char *string, cJSON *item);
|
|
||||||
/* Append reference to item to the specified array/object. Use this when you want to add an existing cJSON to a new cJSON, but don't want to corrupt your existing cJSON. */
|
|
||||||
CJSON_PUBLIC(cJSON_bool) cJSON_AddItemReferenceToArray(cJSON *array, cJSON *item);
|
|
||||||
CJSON_PUBLIC(cJSON_bool) cJSON_AddItemReferenceToObject(cJSON *object, const char *string, cJSON *item);
|
|
||||||
|
|
||||||
/* Remove/Detach items from Arrays/Objects. */
|
|
||||||
CJSON_PUBLIC(cJSON *) cJSON_DetachItemViaPointer(cJSON *parent, cJSON * const item);
|
|
||||||
CJSON_PUBLIC(cJSON *) cJSON_DetachItemFromArray(cJSON *array, int which);
|
|
||||||
CJSON_PUBLIC(void) cJSON_DeleteItemFromArray(cJSON *array, int which);
|
|
||||||
CJSON_PUBLIC(cJSON *) cJSON_DetachItemFromObject(cJSON *object, const char *string);
|
|
||||||
CJSON_PUBLIC(cJSON *) cJSON_DetachItemFromObjectCaseSensitive(cJSON *object, const char *string);
|
|
||||||
CJSON_PUBLIC(void) cJSON_DeleteItemFromObject(cJSON *object, const char *string);
|
|
||||||
CJSON_PUBLIC(void) cJSON_DeleteItemFromObjectCaseSensitive(cJSON *object, const char *string);
|
|
||||||
|
|
||||||
/* Update array items. */
|
|
||||||
CJSON_PUBLIC(cJSON_bool) cJSON_InsertItemInArray(cJSON *array, int which, cJSON *newitem); /* Shifts pre-existing items to the right. */
|
|
||||||
CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemViaPointer(cJSON * const parent, cJSON * const item, cJSON * replacement);
|
|
||||||
CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemInArray(cJSON *array, int which, cJSON *newitem);
|
|
||||||
CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemInObject(cJSON *object,const char *string,cJSON *newitem);
|
|
||||||
CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemInObjectCaseSensitive(cJSON *object,const char *string,cJSON *newitem);
|
|
||||||
|
|
||||||
/* Duplicate a cJSON item */
|
|
||||||
CJSON_PUBLIC(cJSON *) cJSON_Duplicate(const cJSON *item, cJSON_bool recurse);
|
|
||||||
/* Duplicate will create a new, identical cJSON item to the one you pass, in new memory that will
|
|
||||||
* need to be released. With recurse!=0, it will duplicate any children connected to the item.
|
|
||||||
* The item->next and ->prev pointers are always zero on return from Duplicate. */
|
|
||||||
/* Recursively compare two cJSON items for equality. If either a or b is NULL or invalid, they will be considered unequal.
|
|
||||||
* case_sensitive determines if object keys are treated case sensitive (1) or case insensitive (0) */
|
|
||||||
CJSON_PUBLIC(cJSON_bool) cJSON_Compare(const cJSON * const a, const cJSON * const b, const cJSON_bool case_sensitive);
|
|
||||||
|
|
||||||
/* Minify a strings, remove blank characters(such as ' ', '\t', '\r', '\n') from strings.
|
|
||||||
* The input pointer json cannot point to a read-only address area, such as a string constant,
|
|
||||||
* but should point to a readable and writable address area. */
|
|
||||||
CJSON_PUBLIC(void) cJSON_Minify(char *json);
|
|
||||||
|
|
||||||
/* Helper functions for creating and adding items to an object at the same time.
|
|
||||||
* They return the added item or NULL on failure. */
|
|
||||||
CJSON_PUBLIC(cJSON*) cJSON_AddNullToObject(cJSON * const object, const char * const name);
|
|
||||||
CJSON_PUBLIC(cJSON*) cJSON_AddTrueToObject(cJSON * const object, const char * const name);
|
|
||||||
CJSON_PUBLIC(cJSON*) cJSON_AddFalseToObject(cJSON * const object, const char * const name);
|
|
||||||
CJSON_PUBLIC(cJSON*) cJSON_AddBoolToObject(cJSON * const object, const char * const name, const cJSON_bool boolean);
|
|
||||||
CJSON_PUBLIC(cJSON*) cJSON_AddNumberToObject(cJSON * const object, const char * const name, const double number);
|
|
||||||
CJSON_PUBLIC(cJSON*) cJSON_AddStringToObject(cJSON * const object, const char * const name, const char * const string);
|
|
||||||
CJSON_PUBLIC(cJSON*) cJSON_AddRawToObject(cJSON * const object, const char * const name, const char * const raw);
|
|
||||||
CJSON_PUBLIC(cJSON*) cJSON_AddObjectToObject(cJSON * const object, const char * const name);
|
|
||||||
CJSON_PUBLIC(cJSON*) cJSON_AddArrayToObject(cJSON * const object, const char * const name);
|
|
||||||
|
|
||||||
/* When assigning an integer value, it needs to be propagated to valuedouble too. */
|
|
||||||
#define cJSON_SetIntValue(object, number) ((object) ? (object)->valueint = (object)->valuedouble = (number) : (number))
|
|
||||||
/* helper for the cJSON_SetNumberValue macro */
|
|
||||||
CJSON_PUBLIC(double) cJSON_SetNumberHelper(cJSON *object, double number);
|
|
||||||
#define cJSON_SetNumberValue(object, number) ((object != NULL) ? cJSON_SetNumberHelper(object, (double)number) : (number))
|
|
||||||
/* Change the valuestring of a cJSON_String object, only takes effect when type of object is cJSON_String */
|
|
||||||
CJSON_PUBLIC(char*) cJSON_SetValuestring(cJSON *object, const char *valuestring);
|
|
||||||
|
|
||||||
/* Macro for iterating over an array or object */
|
|
||||||
#define cJSON_ArrayForEach(element, array) for(element = (array != NULL) ? (array)->child : NULL; element != NULL; element = element->next)
|
|
||||||
|
|
||||||
/* malloc/free objects using the malloc/free functions that have been set with cJSON_InitHooks */
|
|
||||||
CJSON_PUBLIC(void *) cJSON_malloc(size_t size);
|
|
||||||
CJSON_PUBLIC(void) cJSON_free(void *object);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
/* Copyright (C) 2022 Kasm
|
|
||||||
*
|
|
||||||
* 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 NETWORK_DATELOG_H
|
|
||||||
#define NETWORK_DATELOG_H
|
|
||||||
|
|
||||||
// 2022-05-18 19:51:26
|
|
||||||
#define DATELOGFMT "%Y-%m-%d %H:%M:%S"
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,179 +0,0 @@
|
|||||||
/* Copyright (C) 2022 Kasm
|
|
||||||
*
|
|
||||||
* 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 <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#include "jsonescape.h"
|
|
||||||
#include "cJSON.h"
|
|
||||||
|
|
||||||
void JSON_escape(const char *in, char *out) {
|
|
||||||
for (; *in; in++) {
|
|
||||||
if (in[0] == '\b') {
|
|
||||||
*out++ = '\\';
|
|
||||||
*out++ = 'b';
|
|
||||||
} else if (in[0] == '\f') {
|
|
||||||
*out++ = '\\';
|
|
||||||
*out++ = 'f';
|
|
||||||
} else if (in[0] == '\n') {
|
|
||||||
*out++ = '\\';
|
|
||||||
*out++ = 'n';
|
|
||||||
} else if (in[0] == '\r') {
|
|
||||||
*out++ = '\\';
|
|
||||||
*out++ = 'r';
|
|
||||||
} else if (in[0] == '\t') {
|
|
||||||
*out++ = '\\';
|
|
||||||
*out++ = 't';
|
|
||||||
} else if (in[0] == '"') {
|
|
||||||
*out++ = '\\';
|
|
||||||
*out++ = '"';
|
|
||||||
} else if (in[0] == '\\') {
|
|
||||||
*out++ = '\\';
|
|
||||||
*out++ = '\\';
|
|
||||||
} else {
|
|
||||||
*out++ = *in;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
*out = '\0';
|
|
||||||
}
|
|
||||||
|
|
||||||
void JSON_unescape(const char *in, char *out) {
|
|
||||||
for (; *in; in++) {
|
|
||||||
if (in[0] == '\\' && in[1] == 'b') {
|
|
||||||
*out++ = '\b';
|
|
||||||
in++;
|
|
||||||
} else if (in[0] == '\\' && in[1] == 'f') {
|
|
||||||
*out++ = '\f';
|
|
||||||
in++;
|
|
||||||
} else if (in[0] == '\\' && in[1] == 'n') {
|
|
||||||
*out++ = '\n';
|
|
||||||
in++;
|
|
||||||
} else if (in[0] == '\\' && in[1] == 'r') {
|
|
||||||
*out++ = '\r';
|
|
||||||
in++;
|
|
||||||
} else if (in[0] == '\\' && in[1] == 't') {
|
|
||||||
*out++ = '\t';
|
|
||||||
in++;
|
|
||||||
} else if (in[0] == '\\' && in[1] == '"') {
|
|
||||||
*out++ = '"';
|
|
||||||
in++;
|
|
||||||
} else if (in[0] == '\\' && in[1] == '\\') {
|
|
||||||
*out++ = '\\';
|
|
||||||
in++;
|
|
||||||
} else {
|
|
||||||
*out++ = *in;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
*out = '\0';
|
|
||||||
}
|
|
||||||
|
|
||||||
struct kasmpasswd_t *parseJsonUsers(const char *data) {
|
|
||||||
|
|
||||||
cJSON *json = cJSON_Parse(data);
|
|
||||||
if (!json)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
if (!(json->type & cJSON_Array))
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
struct kasmpasswd_t *set = calloc(sizeof(struct kasmpasswd_t), 1);
|
|
||||||
set->num = cJSON_GetArraySize(json);
|
|
||||||
set->entries = calloc(sizeof(struct kasmpasswd_entry_t), set->num);
|
|
||||||
|
|
||||||
cJSON *cur;
|
|
||||||
unsigned s, len;
|
|
||||||
for (cur = json->child, s = 0; cur; cur = cur->next, s++) {
|
|
||||||
if (!(cur->type & cJSON_Object))
|
|
||||||
goto fail;
|
|
||||||
|
|
||||||
cJSON *e;
|
|
||||||
struct kasmpasswd_entry_t * const entry = &set->entries[s];
|
|
||||||
|
|
||||||
entry->user[0] = '\0';
|
|
||||||
entry->password[0] = '\0';
|
|
||||||
entry->write = entry->owner = 0;
|
|
||||||
|
|
||||||
for (e = cur->child; e; e = e->next) {
|
|
||||||
#define field(x) if (!strcmp(x, e->string))
|
|
||||||
|
|
||||||
field("user") {
|
|
||||||
if (!(e->type & cJSON_String))
|
|
||||||
goto fail;
|
|
||||||
len = strlen(e->valuestring);
|
|
||||||
|
|
||||||
//printf("Val '%.*s'\n", len, start);
|
|
||||||
|
|
||||||
if (len >= USERNAME_LEN)
|
|
||||||
goto fail;
|
|
||||||
|
|
||||||
memcpy(entry->user, e->valuestring, len);
|
|
||||||
entry->user[len] = '\0';
|
|
||||||
} else field("password") {
|
|
||||||
if (!(e->type & cJSON_String))
|
|
||||||
goto fail;
|
|
||||||
len = strlen(e->valuestring);
|
|
||||||
|
|
||||||
//printf("Val '%.*s'\n", len, start);
|
|
||||||
|
|
||||||
if (len >= PASSWORD_LEN)
|
|
||||||
goto fail;
|
|
||||||
|
|
||||||
memcpy(entry->password, e->valuestring, len);
|
|
||||||
entry->password[len] = '\0';
|
|
||||||
} else field("write") {
|
|
||||||
if (!(e->type & (cJSON_False | cJSON_True)))
|
|
||||||
goto fail;
|
|
||||||
|
|
||||||
if (e->type & cJSON_True)
|
|
||||||
entry->write = 1;
|
|
||||||
} else field("owner") {
|
|
||||||
if (!(e->type & (cJSON_False | cJSON_True)))
|
|
||||||
goto fail;
|
|
||||||
|
|
||||||
if (e->type & cJSON_True)
|
|
||||||
entry->owner = 1;
|
|
||||||
} else field("read") {
|
|
||||||
if (!(e->type & (cJSON_False | cJSON_True)))
|
|
||||||
goto fail;
|
|
||||||
|
|
||||||
if (e->type & cJSON_True)
|
|
||||||
entry->read = 1;
|
|
||||||
|
|
||||||
} else {
|
|
||||||
//printf("Unknown field '%.*s'\n", len, start);
|
|
||||||
goto fail;
|
|
||||||
}
|
|
||||||
|
|
||||||
#undef field
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
cJSON_Delete(json);
|
|
||||||
|
|
||||||
return set;
|
|
||||||
fail:
|
|
||||||
free(set->entries);
|
|
||||||
free(set);
|
|
||||||
|
|
||||||
cJSON_Delete(json);
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
/* Copyright (C) 2022 Kasm
|
|
||||||
*
|
|
||||||
* 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 __NETWORK_JSON_ESCAPE_H__
|
|
||||||
#define __NETWORK_JSON_ESCAPE_H__
|
|
||||||
|
|
||||||
#include <kasmpasswd.h>
|
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void JSON_escape(const char *in, char *out);
|
|
||||||
void JSON_unescape(const char *in, char *out);
|
|
||||||
|
|
||||||
struct kasmpasswd_t *parseJsonUsers(const char *data);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
} // extern C
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -1,7 +1,5 @@
|
|||||||
#include <openssl/ssl.h>
|
#include <openssl/ssl.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include "GetAPIEnums.h"
|
|
||||||
#include "datelog.h"
|
|
||||||
|
|
||||||
#define BUFSIZE 65536
|
#define BUFSIZE 65536
|
||||||
#define DBUFSIZE (BUFSIZE * 3) / 4 - 20
|
#define DBUFSIZE (BUFSIZE * 3) / 4 - 20
|
||||||
@@ -67,8 +65,6 @@ struct wspass_t {
|
|||||||
char ip[64];
|
char ip[64];
|
||||||
};
|
};
|
||||||
|
|
||||||
struct kasmpasswd_entry_t;
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int verbose;
|
int verbose;
|
||||||
int listen_sock;
|
int listen_sock;
|
||||||
@@ -85,15 +81,11 @@ typedef struct {
|
|||||||
const uint8_t dedup,
|
const uint8_t dedup,
|
||||||
uint32_t *len, uint8_t *staging);
|
uint32_t *len, uint8_t *staging);
|
||||||
uint8_t (*adduserCb)(void *messager, const char name[], const char pw[],
|
uint8_t (*adduserCb)(void *messager, const char name[], const char pw[],
|
||||||
const uint8_t read, const uint8_t write, const uint8_t owner);
|
const uint8_t write);
|
||||||
uint8_t (*removeCb)(void *messager, const char name[]);
|
uint8_t (*removeCb)(void *messager, const char name[]);
|
||||||
uint8_t (*updateUserCb)(void *messager, const char name[], const uint64_t mask,
|
uint8_t (*givecontrolCb)(void *messager, const char name[]);
|
||||||
const char password[],
|
|
||||||
const uint8_t read, const uint8_t write, const uint8_t owner);
|
|
||||||
uint8_t (*addOrUpdateUserCb)(void *messager, const struct kasmpasswd_entry_t *entry);
|
|
||||||
void (*bottleneckStatsCb)(void *messager, char *buf, uint32_t len);
|
void (*bottleneckStatsCb)(void *messager, char *buf, uint32_t len);
|
||||||
void (*frameStatsCb)(void *messager, char *buf, uint32_t len);
|
void (*frameStatsCb)(void *messager, char *buf, uint32_t len);
|
||||||
void (*resetFrameStatsCb)(void *messager);
|
|
||||||
|
|
||||||
uint8_t (*requestFrameStatsNoneCb)(void *messager);
|
uint8_t (*requestFrameStatsNoneCb)(void *messager);
|
||||||
uint8_t (*requestFrameStatsOwnerCb)(void *messager);
|
uint8_t (*requestFrameStatsOwnerCb)(void *messager);
|
||||||
@@ -102,7 +94,6 @@ typedef struct {
|
|||||||
|
|
||||||
uint8_t (*ownerConnectedCb)(void *messager);
|
uint8_t (*ownerConnectedCb)(void *messager);
|
||||||
uint8_t (*numActiveUsersCb)(void *messager);
|
uint8_t (*numActiveUsersCb)(void *messager);
|
||||||
void (*getUsersCb)(void *messager, const char **buf);
|
|
||||||
uint8_t (*getClientFrameStatsNumCb)(void *messager);
|
uint8_t (*getClientFrameStatsNumCb)(void *messager);
|
||||||
uint8_t (*serverFrameStatsReadyCb)(void *messager);
|
uint8_t (*serverFrameStatsReadyCb)(void *messager);
|
||||||
} settings_t;
|
} settings_t;
|
||||||
@@ -121,24 +112,18 @@ ssize_t ws_send(ws_ctx_t *ctx, const void *buf, size_t len);
|
|||||||
//int b64_ntop(u_char const *src, size_t srclength, char *target, size_t targsize);
|
//int b64_ntop(u_char const *src, size_t srclength, char *target, size_t targsize);
|
||||||
//int b64_pton(char const *src, u_char *target, size_t targsize);
|
//int b64_pton(char const *src, u_char *target, size_t targsize);
|
||||||
|
|
||||||
void wslog(char *logbuf, const unsigned websocket, const uint8_t debug);
|
|
||||||
|
|
||||||
extern __thread unsigned wsthread_handler_id;
|
extern __thread unsigned wsthread_handler_id;
|
||||||
|
|
||||||
#define gen_handler_msg(stream, ...) \
|
#define gen_handler_msg(stream, ...) \
|
||||||
if (settings.verbose) { \
|
if (settings.verbose) { \
|
||||||
char logbuf[2][1024]; \
|
fprintf(stream, " websocket %d: ", wsthread_handler_id); \
|
||||||
wslog(logbuf[0], wsthread_handler_id, 1); \
|
fprintf(stream, __VA_ARGS__); \
|
||||||
sprintf(logbuf[1], __VA_ARGS__); \
|
|
||||||
fprintf(stream, "%s%s", logbuf[0], logbuf[1]); \
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#define wserr(...) \
|
#define wserr(...) \
|
||||||
{ \
|
{ \
|
||||||
char logbuf[2][1024]; \
|
fprintf(stderr, " websocket %d: ", wsthread_handler_id); \
|
||||||
wslog(logbuf[0], wsthread_handler_id, 0); \
|
fprintf(stderr, __VA_ARGS__); \
|
||||||
sprintf(logbuf[1], __VA_ARGS__); \
|
|
||||||
fprintf(stderr, "%s%s", logbuf[0], logbuf[1]); \
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#define handler_msg(...) gen_handler_msg(stderr, __VA_ARGS__);
|
#define handler_msg(...) gen_handler_msg(stderr, __VA_ARGS__);
|
||||||
|
|||||||
@@ -44,11 +44,11 @@ static void do_proxy(ws_ctx_t *ws_ctx, int target) {
|
|||||||
int maxfd, client = ws_ctx->sockfd;
|
int maxfd, client = ws_ctx->sockfd;
|
||||||
unsigned int opcode, left, ret;
|
unsigned int opcode, left, ret;
|
||||||
unsigned int tout_start, tout_end, cout_start, cout_end;
|
unsigned int tout_start, tout_end, cout_start, cout_end;
|
||||||
unsigned int tin_end;
|
unsigned int tin_start, tin_end;
|
||||||
ssize_t len, bytes;
|
ssize_t len, bytes;
|
||||||
|
|
||||||
tout_start = tout_end = cout_start = cout_end =
|
tout_start = tout_end = cout_start = cout_end =
|
||||||
tin_end = 0;
|
tin_start = tin_end = 0;
|
||||||
maxfd = client > target ? client+1 : target+1;
|
maxfd = client > target ? client+1 : target+1;
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
@@ -165,7 +165,7 @@ static void do_proxy(ws_ctx_t *ws_ctx, int target) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (FD_ISSET(client, &rlist)) {
|
if (FD_ISSET(client, &rlist)) {
|
||||||
bytes = ws_recv(ws_ctx, ws_ctx->tin_buf + tin_end, BUFSIZE-1-tin_end);
|
bytes = ws_recv(ws_ctx, ws_ctx->tin_buf + tin_end, BUFSIZE-1);
|
||||||
if (pipe_error) { break; }
|
if (pipe_error) { break; }
|
||||||
if (bytes <= 0) {
|
if (bytes <= 0) {
|
||||||
handler_emsg("client closed connection\n");
|
handler_emsg("client closed connection\n");
|
||||||
@@ -180,13 +180,13 @@ static void do_proxy(ws_ctx_t *ws_ctx, int target) {
|
|||||||
printf("\n");
|
printf("\n");
|
||||||
*/
|
*/
|
||||||
if (ws_ctx->hybi) {
|
if (ws_ctx->hybi) {
|
||||||
len = decode_hybi(ws_ctx->tin_buf,
|
len = decode_hybi(ws_ctx->tin_buf + tin_start,
|
||||||
tin_end,
|
tin_end-tin_start,
|
||||||
ws_ctx->tout_buf, BUFSIZE-1,
|
ws_ctx->tout_buf, BUFSIZE-1,
|
||||||
&opcode, &left);
|
&opcode, &left);
|
||||||
} else {
|
} else {
|
||||||
len = decode_hixie(ws_ctx->tin_buf,
|
len = decode_hixie(ws_ctx->tin_buf + tin_start,
|
||||||
tin_end,
|
tin_end-tin_start,
|
||||||
ws_ctx->tout_buf, BUFSIZE-1,
|
ws_ctx->tout_buf, BUFSIZE-1,
|
||||||
&opcode, &left);
|
&opcode, &left);
|
||||||
}
|
}
|
||||||
@@ -208,13 +208,10 @@ static void do_proxy(ws_ctx_t *ws_ctx, int target) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (left) {
|
if (left) {
|
||||||
const unsigned tin_start = tin_end - left;
|
tin_start = tin_end - left;
|
||||||
//handler_emsg("partial frame from client, %u left, start %u end %u, lens %lu %lu\n",
|
//printf("partial frame from client");
|
||||||
// left, tin_start, tin_end, bytes, len);
|
|
||||||
memmove(ws_ctx->tin_buf, ws_ctx->tin_buf + tin_start, left);
|
|
||||||
tin_end = left;
|
|
||||||
} else {
|
} else {
|
||||||
//handler_emsg("handled %lu/%lu bytes\n", bytes, len);
|
tin_start = 0;
|
||||||
tin_end = 0;
|
tin_end = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1024,7 +1024,7 @@ PixelBuffer *rfb::progressiveBilinearScale(const PixelBuffer *pb,
|
|||||||
rdr::U8 *newpx = ((ManagedPixelBuffer *) newpb)->getBufferRW(newpb->getRect(),
|
rdr::U8 *newpx = ((ManagedPixelBuffer *) newpb)->getBufferRW(newpb->getRect(),
|
||||||
&newstride);
|
&newstride);
|
||||||
|
|
||||||
SSE2_scale(oldpx, tgtw, tgth, newpx, oldstride, newstride, tgtw / (float) oldw);
|
SSE2_scale(oldpx, tgtw, tgth, newpx, oldstride, newstride, tgtdiff);
|
||||||
if (del)
|
if (del)
|
||||||
delete pb;
|
delete pb;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,12 +36,9 @@ namespace rfb {
|
|||||||
rdr::U32 __unused_attr keycode,
|
rdr::U32 __unused_attr keycode,
|
||||||
bool __unused_attr down) { }
|
bool __unused_attr down) { }
|
||||||
virtual void pointerEvent(const Point& __unused_attr pos,
|
virtual void pointerEvent(const Point& __unused_attr pos,
|
||||||
const Point& __unused_attr abspos,
|
|
||||||
int __unused_attr buttonMask,
|
int __unused_attr buttonMask,
|
||||||
const bool __unused_attr skipClick,
|
const bool __unused_attr skipClick,
|
||||||
const bool __unused_attr skipRelease,
|
const bool __unused_attr skipRelease) { }
|
||||||
int scrollX,
|
|
||||||
int scrollY) { }
|
|
||||||
virtual void clientCutText(const char* __unused_attr str,
|
virtual void clientCutText(const char* __unused_attr str,
|
||||||
int __unused_attr len) { }
|
int __unused_attr len) { }
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -20,14 +20,11 @@
|
|||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sys/time.h>
|
|
||||||
|
|
||||||
#include <os/Mutex.h>
|
#include <os/Mutex.h>
|
||||||
|
|
||||||
#include <network/datelog.h>
|
|
||||||
#include <rfb/util.h>
|
#include <rfb/util.h>
|
||||||
#include <rfb/Logger_file.h>
|
#include <rfb/Logger_file.h>
|
||||||
#include <rfb/LogWriter.h>
|
|
||||||
|
|
||||||
using namespace rfb;
|
using namespace rfb;
|
||||||
|
|
||||||
@@ -58,28 +55,14 @@ void Logger_File::write(int level, const char *logname, const char *message)
|
|||||||
if (!m_file) return;
|
if (!m_file) return;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct timeval tv;
|
time_t current = time(0);
|
||||||
gettimeofday(&tv, NULL);
|
if (current != m_lastLogTime) {
|
||||||
|
m_lastLogTime = current;
|
||||||
if (tv.tv_sec != m_lastLogTime) {
|
|
||||||
m_lastLogTime = tv.tv_sec;
|
|
||||||
// fprintf(m_file, "\n%s", ctime(&m_lastLogTime));
|
// fprintf(m_file, "\n%s", ctime(&m_lastLogTime));
|
||||||
}
|
}
|
||||||
|
|
||||||
char timebuf[128];
|
fprintf(m_file," %s:", logname);
|
||||||
struct tm local;
|
int column = strlen(logname) + 2;
|
||||||
localtime_r(&tv.tv_sec, &local);
|
|
||||||
strftime(timebuf, sizeof(timebuf), DATELOGFMT, &local);
|
|
||||||
|
|
||||||
const unsigned msec = tv.tv_usec / 1000;
|
|
||||||
const char *levelname = "PRIO";
|
|
||||||
if (level >= LogWriter::LEVEL_INFO)
|
|
||||||
levelname = "INFO";
|
|
||||||
if (level >= LogWriter::LEVEL_DEBUG)
|
|
||||||
levelname = "DEBUG";
|
|
||||||
|
|
||||||
int column = fprintf(m_file, " %s,%03u [%s] %s:", timebuf, msec, levelname, logname);
|
|
||||||
|
|
||||||
if (column < indent) {
|
if (column < indent) {
|
||||||
fprintf(m_file,"%*s",indent-column,"");
|
fprintf(m_file,"%*s",indent-column,"");
|
||||||
column = indent;
|
column = indent;
|
||||||
|
|||||||
@@ -216,7 +216,7 @@ void SConnection::processSecurityMsg()
|
|||||||
bool done = ssecurity->processMsg(this);
|
bool done = ssecurity->processMsg(this);
|
||||||
if (done) {
|
if (done) {
|
||||||
state_ = RFBSTATE_QUERYING;
|
state_ = RFBSTATE_QUERYING;
|
||||||
//setAccessRights(ssecurity->getAccessRights());
|
setAccessRights(ssecurity->getAccessRights());
|
||||||
queryConnection(ssecurity->getUserName());
|
queryConnection(ssecurity->getUserName());
|
||||||
}
|
}
|
||||||
} catch (AuthFailureException& e) {
|
} catch (AuthFailureException& e) {
|
||||||
@@ -284,28 +284,74 @@ void SConnection::setEncodings(int nEncodings, const rdr::S32* encodings)
|
|||||||
}
|
}
|
||||||
|
|
||||||
SMsgHandler::setEncodings(nEncodings, encodings);
|
SMsgHandler::setEncodings(nEncodings, encodings);
|
||||||
|
|
||||||
|
if (cp.supportsExtendedClipboard) {
|
||||||
|
rdr::U32 sizes[] = { 0 };
|
||||||
|
writer()->writeClipboardCaps(rfb::clipboardUTF8 |
|
||||||
|
rfb::clipboardRequest |
|
||||||
|
rfb::clipboardPeek |
|
||||||
|
rfb::clipboardNotify |
|
||||||
|
rfb::clipboardProvide,
|
||||||
|
sizes);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SConnection::clearBinaryClipboard()
|
void SConnection::clientCutText(const char* str, int len)
|
||||||
{
|
{
|
||||||
binaryClipboard.clear();
|
hasLocalClipboard = false;
|
||||||
|
|
||||||
|
strFree(clientClipboard);
|
||||||
|
clientClipboard = NULL;
|
||||||
|
|
||||||
|
clientClipboard = latin1ToUTF8(str);
|
||||||
|
|
||||||
|
handleClipboardAnnounce(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SConnection::addBinaryClipboard(const char mime[], const rdr::U8 *data,
|
void SConnection::handleClipboardRequest(rdr::U32 flags)
|
||||||
const rdr::U32 len, const rdr::U32 id)
|
|
||||||
{
|
{
|
||||||
binaryClipboard_t bin;
|
if (!(flags & rfb::clipboardUTF8))
|
||||||
strncpy(bin.mime, mime, sizeof(bin.mime));
|
return;
|
||||||
bin.mime[sizeof(bin.mime) - 1] = '\0';
|
if (!hasLocalClipboard)
|
||||||
|
return;
|
||||||
bin.data.resize(len);
|
handleClipboardRequest();
|
||||||
memcpy(&bin.data[0], data, len);
|
|
||||||
|
|
||||||
bin.id = id;
|
|
||||||
|
|
||||||
binaryClipboard.push_back(bin);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SConnection::handleClipboardPeek(rdr::U32 flags)
|
||||||
|
{
|
||||||
|
if (!hasLocalClipboard)
|
||||||
|
return;
|
||||||
|
if (cp.clipboardFlags() & rfb::clipboardNotify)
|
||||||
|
writer()->writeClipboardNotify(rfb::clipboardUTF8);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SConnection::handleClipboardNotify(rdr::U32 flags)
|
||||||
|
{
|
||||||
|
strFree(clientClipboard);
|
||||||
|
clientClipboard = NULL;
|
||||||
|
|
||||||
|
if (flags & rfb::clipboardUTF8) {
|
||||||
|
handleClipboardAnnounce(true);
|
||||||
|
hasLocalClipboard = false;
|
||||||
|
} else {
|
||||||
|
handleClipboardAnnounce(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SConnection::handleClipboardProvide(rdr::U32 flags,
|
||||||
|
const size_t* lengths,
|
||||||
|
const rdr::U8* const* data)
|
||||||
|
{
|
||||||
|
if (!(flags & rfb::clipboardUTF8))
|
||||||
|
return;
|
||||||
|
|
||||||
|
strFree(clientClipboard);
|
||||||
|
clientClipboard = NULL;
|
||||||
|
|
||||||
|
clientClipboard = convertLF((const char*)data[0], lengths[0]);
|
||||||
|
|
||||||
|
handleClipboardData(clientClipboard, strlen(clientClipboard));
|
||||||
|
}
|
||||||
|
|
||||||
void SConnection::supportsQEMUKeyEvent()
|
void SConnection::supportsQEMUKeyEvent()
|
||||||
{
|
{
|
||||||
@@ -399,13 +445,56 @@ void SConnection::enableContinuousUpdates(bool enable,
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SConnection::handleClipboardRequest()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
void SConnection::handleClipboardAnnounce(bool available)
|
void SConnection::handleClipboardAnnounce(bool available)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SConnection::handleClipboardData(const char* data, int len)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void SConnection::requestClipboard()
|
||||||
|
{
|
||||||
|
if (clientClipboard != NULL) {
|
||||||
|
handleClipboardData(clientClipboard, strlen(clientClipboard));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cp.supportsExtendedClipboard &&
|
||||||
|
(cp.clipboardFlags() & rfb::clipboardRequest))
|
||||||
|
writer()->writeClipboardRequest(rfb::clipboardUTF8);
|
||||||
|
}
|
||||||
|
|
||||||
void SConnection::announceClipboard(bool available)
|
void SConnection::announceClipboard(bool available)
|
||||||
{
|
{
|
||||||
hasLocalClipboard = available;
|
hasLocalClipboard = available;
|
||||||
|
|
||||||
|
if (cp.supportsExtendedClipboard &&
|
||||||
|
(cp.clipboardFlags() & rfb::clipboardNotify))
|
||||||
|
writer()->writeClipboardNotify(available ? rfb::clipboardUTF8 : 0);
|
||||||
|
else {
|
||||||
|
if (available)
|
||||||
|
handleClipboardRequest();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SConnection::sendClipboardData(const char* data, int len)
|
||||||
|
{
|
||||||
|
if (cp.supportsExtendedClipboard &&
|
||||||
|
(cp.clipboardFlags() & rfb::clipboardProvide)) {
|
||||||
|
CharArray filtered(convertCRLF(data));
|
||||||
|
size_t sizes[1] = { strlen(filtered.buf) + 1 };
|
||||||
|
const rdr::U8* data[1] = { (const rdr::U8*)filtered.buf };
|
||||||
|
writer()->writeClipboardProvide(rfb::clipboardUTF8, sizes, data);
|
||||||
|
} else {
|
||||||
|
CharArray latin1(utf8ToLatin1(data));
|
||||||
|
|
||||||
|
writer()->writeServerCutText(latin1.buf, strlen(latin1.buf));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SConnection::writeFakeColourMap(void)
|
void SConnection::writeFakeColourMap(void)
|
||||||
|
|||||||
@@ -28,7 +28,6 @@
|
|||||||
#include <rdr/OutStream.h>
|
#include <rdr/OutStream.h>
|
||||||
#include <rfb/SMsgHandler.h>
|
#include <rfb/SMsgHandler.h>
|
||||||
#include <rfb/SecurityServer.h>
|
#include <rfb/SecurityServer.h>
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
namespace rfb {
|
namespace rfb {
|
||||||
|
|
||||||
@@ -74,9 +73,14 @@ namespace rfb {
|
|||||||
|
|
||||||
virtual void setEncodings(int nEncodings, const rdr::S32* encodings);
|
virtual void setEncodings(int nEncodings, const rdr::S32* encodings);
|
||||||
|
|
||||||
virtual void clearBinaryClipboard();
|
virtual void clientCutText(const char* str, int len);
|
||||||
virtual void addBinaryClipboard(const char mime[], const rdr::U8 *data,
|
|
||||||
const rdr::U32 len, const rdr::U32 id);
|
virtual void handleClipboardRequest(rdr::U32 flags);
|
||||||
|
virtual void handleClipboardPeek(rdr::U32 flags);
|
||||||
|
virtual void handleClipboardNotify(rdr::U32 flags);
|
||||||
|
virtual void handleClipboardProvide(rdr::U32 flags,
|
||||||
|
const size_t* lengths,
|
||||||
|
const rdr::U8* const* data);
|
||||||
|
|
||||||
virtual void supportsQEMUKeyEvent();
|
virtual void supportsQEMUKeyEvent();
|
||||||
|
|
||||||
@@ -123,11 +127,25 @@ namespace rfb {
|
|||||||
virtual void enableContinuousUpdates(bool enable,
|
virtual void enableContinuousUpdates(bool enable,
|
||||||
int x, int y, int w, int h);
|
int x, int y, int w, int h);
|
||||||
|
|
||||||
|
// handleClipboardRequest() is called whenever the client requests
|
||||||
|
// the server to send over its clipboard data. It will only be
|
||||||
|
// called after the server has first announced a clipboard change
|
||||||
|
// via announceClipboard().
|
||||||
|
virtual void handleClipboardRequest();
|
||||||
|
|
||||||
// handleClipboardAnnounce() is called to indicate a change in the
|
// handleClipboardAnnounce() is called to indicate a change in the
|
||||||
// clipboard on the client. Call requestClipboard() to access the
|
// clipboard on the client. Call requestClipboard() to access the
|
||||||
// actual data.
|
// actual data.
|
||||||
virtual void handleClipboardAnnounce(bool available);
|
virtual void handleClipboardAnnounce(bool available);
|
||||||
|
|
||||||
|
// handleClipboardData() is called when the client has sent over
|
||||||
|
// the clipboard data as a result of a previous call to
|
||||||
|
// requestClipboard(). Note that this function might never be
|
||||||
|
// called if the clipboard data was no longer available when the
|
||||||
|
// client received the request.
|
||||||
|
virtual void handleClipboardData(const char* data, int len);
|
||||||
|
|
||||||
|
|
||||||
virtual void add_changed_all() {}
|
virtual void add_changed_all() {}
|
||||||
|
|
||||||
// setAccessRights() allows a security package to limit the access rights
|
// setAccessRights() allows a security package to limit the access rights
|
||||||
@@ -144,14 +162,26 @@ namespace rfb {
|
|||||||
static const AccessRights AccessDefault; // The default rights, INCLUDING FUTURE ONES
|
static const AccessRights AccessDefault; // The default rights, INCLUDING FUTURE ONES
|
||||||
static const AccessRights AccessNoQuery; // Connect without local user accepting
|
static const AccessRights AccessNoQuery; // Connect without local user accepting
|
||||||
static const AccessRights AccessFull; // All of the available AND FUTURE rights
|
static const AccessRights AccessFull; // All of the available AND FUTURE rights
|
||||||
|
virtual void setAccessRights(AccessRights ar) = 0;
|
||||||
|
|
||||||
// Other methods
|
// Other methods
|
||||||
|
|
||||||
|
// requestClipboard() will result in a request to the client to
|
||||||
|
// transfer its clipboard data. A call to handleClipboardData()
|
||||||
|
// will be made once the data is available.
|
||||||
|
virtual void requestClipboard();
|
||||||
|
|
||||||
// announceClipboard() informs the client of changes to the
|
// announceClipboard() informs the client of changes to the
|
||||||
// clipboard on the server. The client may later request the
|
// clipboard on the server. The client may later request the
|
||||||
// clipboard data via handleClipboardRequest().
|
// clipboard data via handleClipboardRequest().
|
||||||
virtual void announceClipboard(bool available);
|
virtual void announceClipboard(bool available);
|
||||||
|
|
||||||
|
// sendClipboardData() transfers the clipboard data to the client
|
||||||
|
// and should be called whenever the client has requested the
|
||||||
|
// clipboard via handleClipboardRequest().
|
||||||
|
virtual void sendClipboardData(const char* data, int len);
|
||||||
|
|
||||||
|
|
||||||
// authenticated() returns true if the client has authenticated
|
// authenticated() returns true if the client has authenticated
|
||||||
// successfully.
|
// successfully.
|
||||||
bool authenticated() { return (state_ == RFBSTATE_INITIALISATION ||
|
bool authenticated() { return (state_ == RFBSTATE_INITIALISATION ||
|
||||||
@@ -191,20 +221,12 @@ namespace rfb {
|
|||||||
|
|
||||||
rdr::S32 getPreferredEncoding() { return preferredEncoding; }
|
rdr::S32 getPreferredEncoding() { return preferredEncoding; }
|
||||||
|
|
||||||
struct binaryClipboard_t {
|
|
||||||
char mime[32];
|
|
||||||
rdr::U32 id;
|
|
||||||
std::vector<unsigned char> data;
|
|
||||||
};
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void setState(stateEnum s) { state_ = s; }
|
void setState(stateEnum s) { state_ = s; }
|
||||||
|
|
||||||
void setReader(SMsgReader *r) { reader_ = r; }
|
void setReader(SMsgReader *r) { reader_ = r; }
|
||||||
void setWriter(SMsgWriter *w) { writer_ = w; }
|
void setWriter(SMsgWriter *w) { writer_ = w; }
|
||||||
|
|
||||||
std::vector<binaryClipboard_t> binaryClipboard;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void writeFakeColourMap(void);
|
void writeFakeColourMap(void);
|
||||||
|
|
||||||
|
|||||||
@@ -78,13 +78,23 @@ namespace rfb {
|
|||||||
// the relevant RFB protocol messages from clients.
|
// the relevant RFB protocol messages from clients.
|
||||||
// See InputHandler for method signatures.
|
// See InputHandler for method signatures.
|
||||||
|
|
||||||
|
// handleClipboardRequest() is called whenever a client requests
|
||||||
|
// the server to send over its clipboard data. It will only be
|
||||||
|
// called after the server has first announced a clipboard change
|
||||||
|
// via VNCServer::announceClipboard().
|
||||||
|
virtual void handleClipboardRequest() {}
|
||||||
|
|
||||||
// handleClipboardAnnounce() is called to indicate a change in the
|
// handleClipboardAnnounce() is called to indicate a change in the
|
||||||
// clipboard on a client. Call VNCServer::requestClipboard() to
|
// clipboard on a client. Call VNCServer::requestClipboard() to
|
||||||
// access the actual data.
|
// access the actual data.
|
||||||
virtual void handleClipboardAnnounce(bool __unused_attr available) {}
|
virtual void handleClipboardAnnounce(bool __unused_attr available) {}
|
||||||
|
|
||||||
virtual void handleClipboardAnnounceBinary(const unsigned __unused_attr num,
|
// handleClipboardData() is called when a client has sent over
|
||||||
const char __unused_attr mimes[][32]) {}
|
// the clipboard data as a result of a previous call to
|
||||||
|
// VNCServer::requestClipboard(). Note that this function might
|
||||||
|
// never be called if the clipboard data was no longer available
|
||||||
|
// when the client received the request.
|
||||||
|
virtual void handleClipboardData(const char* __unused_attr data, int len __unused_attr) {}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual ~SDesktop() {}
|
virtual ~SDesktop() {}
|
||||||
|
|||||||
@@ -64,16 +64,26 @@ void SMsgHandler::setEncodings(int nEncodings, const rdr::S32* encodings)
|
|||||||
supportsQEMUKeyEvent();
|
supportsQEMUKeyEvent();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SMsgHandler::handleClipboardAnnounceBinary(const unsigned, const char mimes[][32])
|
void SMsgHandler::handleClipboardCaps(rdr::U32 flags, const rdr::U32* lengths)
|
||||||
|
{
|
||||||
|
cp.setClipboardCaps(flags, lengths);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SMsgHandler::handleClipboardRequest(rdr::U32 flags)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void SMsgHandler::clearBinaryClipboard()
|
void SMsgHandler::handleClipboardPeek(rdr::U32 flags)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void SMsgHandler::addBinaryClipboard(const char mime[], const rdr::U8 *data,
|
void SMsgHandler::handleClipboardNotify(rdr::U32 flags)
|
||||||
const rdr::U32 len, const rdr::U32 id)
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void SMsgHandler::handleClipboardProvide(rdr::U32 flags,
|
||||||
|
const size_t* lengths,
|
||||||
|
const rdr::U8* const* data)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -54,10 +54,14 @@ namespace rfb {
|
|||||||
virtual void enableContinuousUpdates(bool enable,
|
virtual void enableContinuousUpdates(bool enable,
|
||||||
int x, int y, int w, int h) = 0;
|
int x, int y, int w, int h) = 0;
|
||||||
|
|
||||||
virtual void handleClipboardAnnounceBinary(const unsigned num, const char mimes[][32]);
|
virtual void handleClipboardCaps(rdr::U32 flags,
|
||||||
virtual void clearBinaryClipboard();
|
const rdr::U32* lengths);
|
||||||
virtual void addBinaryClipboard(const char mime[], const rdr::U8 *data,
|
virtual void handleClipboardRequest(rdr::U32 flags);
|
||||||
const rdr::U32 len, const rdr::U32 id);
|
virtual void handleClipboardPeek(rdr::U32 flags);
|
||||||
|
virtual void handleClipboardNotify(rdr::U32 flags);
|
||||||
|
virtual void handleClipboardProvide(rdr::U32 flags,
|
||||||
|
const size_t* lengths,
|
||||||
|
const rdr::U8* const* data);
|
||||||
|
|
||||||
virtual void sendStats(const bool toClient = true) = 0;
|
virtual void sendStats(const bool toClient = true) = 0;
|
||||||
virtual void handleFrameStats(rdr::U32 all, rdr::U32 render) = 0;
|
virtual void handleFrameStats(rdr::U32 all, rdr::U32 render) = 0;
|
||||||
|
|||||||
@@ -35,6 +35,8 @@ using namespace rfb;
|
|||||||
|
|
||||||
static LogWriter vlog("SMsgReader");
|
static LogWriter vlog("SMsgReader");
|
||||||
|
|
||||||
|
static IntParameter maxCutText("MaxCutText", "Maximum permitted length of an incoming clipboard update", 256*1024);
|
||||||
|
|
||||||
SMsgReader::SMsgReader(SMsgHandler* handler_, rdr::InStream* is_)
|
SMsgReader::SMsgReader(SMsgHandler* handler_, rdr::InStream* is_)
|
||||||
: handler(handler_), is(is_)
|
: handler(handler_), is(is_)
|
||||||
{
|
{
|
||||||
@@ -81,9 +83,6 @@ void SMsgReader::readMsg()
|
|||||||
case msgTypeFrameStats:
|
case msgTypeFrameStats:
|
||||||
readFrameStats();
|
readFrameStats();
|
||||||
break;
|
break;
|
||||||
case msgTypeBinaryClipboard:
|
|
||||||
readBinaryClipboard();
|
|
||||||
break;
|
|
||||||
case msgTypeKeyEvent:
|
case msgTypeKeyEvent:
|
||||||
readKeyEvent();
|
readKeyEvent();
|
||||||
break;
|
break;
|
||||||
@@ -224,10 +223,7 @@ void SMsgReader::readPointerEvent()
|
|||||||
int mask = is->readU8();
|
int mask = is->readU8();
|
||||||
int x = is->readU16();
|
int x = is->readU16();
|
||||||
int y = is->readU16();
|
int y = is->readU16();
|
||||||
int scrollX = is->readS16();
|
handler->pointerEvent(Point(x, y), mask, false, false);
|
||||||
int scrollY = is->readS16();
|
|
||||||
|
|
||||||
handler->pointerEvent(Point(x, y), Point(0, 0), mask, false, false, scrollX, scrollY);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -242,54 +238,109 @@ void SMsgReader::readClientCutText()
|
|||||||
readExtendedClipboard(slen);
|
readExtendedClipboard(slen);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (len > (size_t)maxCutText) {
|
||||||
is->skip(len);
|
is->skip(len);
|
||||||
vlog.error("Client sent old cuttext msg, ignoring");
|
vlog.error("Cut text too long (%d bytes) - ignoring", len);
|
||||||
}
|
return;
|
||||||
|
|
||||||
void SMsgReader::readBinaryClipboard()
|
|
||||||
{
|
|
||||||
const rdr::U8 num = is->readU8();
|
|
||||||
rdr::U8 i, valid = 0;
|
|
||||||
char tmpmimes[num][32];
|
|
||||||
|
|
||||||
handler->clearBinaryClipboard();
|
|
||||||
for (i = 0; i < num; i++) {
|
|
||||||
const rdr::U8 mimelen = is->readU8();
|
|
||||||
if (mimelen > 32 - 1) {
|
|
||||||
vlog.error("Mime too long (%u)", mimelen);
|
|
||||||
}
|
}
|
||||||
|
CharArray ca(len+1);
|
||||||
char mime[mimelen + 1];
|
ca.buf[len] = 0;
|
||||||
mime[mimelen] = '\0';
|
|
||||||
is->readBytes(mime, mimelen);
|
|
||||||
|
|
||||||
strncpy(tmpmimes[valid], mime, 32);
|
|
||||||
tmpmimes[valid][31] = '\0';
|
|
||||||
|
|
||||||
const rdr::U32 len = is->readU32();
|
|
||||||
CharArray ca(len);
|
|
||||||
is->readBytes(ca.buf, len);
|
is->readBytes(ca.buf, len);
|
||||||
|
handler->clientCutText(ca.buf, len);
|
||||||
if (rfb::Server::DLP_ClipAcceptMax && len > (unsigned) rfb::Server::DLP_ClipAcceptMax) {
|
|
||||||
vlog.info("DLP: refused to receive binary clipboard, too large");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
vlog.debug("Received binary clipboard, type %s, %u bytes", mime, len);
|
|
||||||
|
|
||||||
handler->addBinaryClipboard(mime, (rdr::U8 *) ca.buf, len, 0);
|
|
||||||
valid++;
|
|
||||||
}
|
|
||||||
|
|
||||||
handler->handleClipboardAnnounceBinary(valid, tmpmimes);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SMsgReader::readExtendedClipboard(rdr::S32 len)
|
void SMsgReader::readExtendedClipboard(rdr::S32 len)
|
||||||
{
|
{
|
||||||
|
rdr::U32 flags;
|
||||||
|
rdr::U32 action;
|
||||||
|
|
||||||
if (len < 4)
|
if (len < 4)
|
||||||
throw Exception("Invalid extended clipboard message");
|
throw Exception("Invalid extended clipboard message");
|
||||||
vlog.error("Client sent old cuttext msg, ignoring");
|
if (len > maxCutText) {
|
||||||
|
vlog.error("Extended clipboard message too long (%d bytes) - ignoring", len);
|
||||||
is->skip(len);
|
is->skip(len);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
flags = is->readU32();
|
||||||
|
action = flags & clipboardActionMask;
|
||||||
|
|
||||||
|
if (action & clipboardCaps) {
|
||||||
|
int i;
|
||||||
|
size_t num;
|
||||||
|
rdr::U32 lengths[16];
|
||||||
|
|
||||||
|
num = 0;
|
||||||
|
for (i = 0;i < 16;i++) {
|
||||||
|
if (flags & (1 << i))
|
||||||
|
num++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (len < (rdr::S32)(4 + 4*num))
|
||||||
|
throw Exception("Invalid extended clipboard message");
|
||||||
|
|
||||||
|
num = 0;
|
||||||
|
for (i = 0;i < 16;i++) {
|
||||||
|
if (flags & (1 << i))
|
||||||
|
lengths[num++] = is->readU32();
|
||||||
|
}
|
||||||
|
|
||||||
|
handler->handleClipboardCaps(flags, lengths);
|
||||||
|
} else if (action == clipboardProvide) {
|
||||||
|
rdr::ZlibInStream zis;
|
||||||
|
|
||||||
|
int i;
|
||||||
|
size_t num;
|
||||||
|
size_t lengths[16];
|
||||||
|
rdr::U8* buffers[16];
|
||||||
|
|
||||||
|
zis.setUnderlying(is, len - 4);
|
||||||
|
|
||||||
|
num = 0;
|
||||||
|
for (i = 0;i < 16;i++) {
|
||||||
|
if (!(flags & 1 << i))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
lengths[num] = zis.readU32();
|
||||||
|
if (lengths[num] > (size_t)maxCutText) {
|
||||||
|
vlog.error("Extended clipboard data too long (%d bytes) - ignoring",
|
||||||
|
(unsigned)lengths[num]);
|
||||||
|
zis.skip(lengths[num]);
|
||||||
|
flags &= ~(1 << i);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
buffers[num] = new rdr::U8[lengths[num]];
|
||||||
|
zis.readBytes(buffers[num], lengths[num]);
|
||||||
|
num++;
|
||||||
|
}
|
||||||
|
|
||||||
|
zis.flushUnderlying();
|
||||||
|
zis.setUnderlying(NULL, 0);
|
||||||
|
|
||||||
|
handler->handleClipboardProvide(flags, lengths, buffers);
|
||||||
|
|
||||||
|
num = 0;
|
||||||
|
for (i = 0;i < 16;i++) {
|
||||||
|
if (!(flags & 1 << i))
|
||||||
|
continue;
|
||||||
|
delete [] buffers[num++];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
switch (action) {
|
||||||
|
case clipboardRequest:
|
||||||
|
handler->handleClipboardRequest(flags);
|
||||||
|
break;
|
||||||
|
case clipboardPeek:
|
||||||
|
handler->handleClipboardPeek(flags);
|
||||||
|
break;
|
||||||
|
case clipboardNotify:
|
||||||
|
handler->handleClipboardNotify(flags);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw Exception("Invalid extended clipboard action");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SMsgReader::readRequestStats()
|
void SMsgReader::readRequestStats()
|
||||||
|
|||||||
@@ -58,7 +58,6 @@ namespace rfb {
|
|||||||
void readExtendedClipboard(rdr::S32 len);
|
void readExtendedClipboard(rdr::S32 len);
|
||||||
void readRequestStats();
|
void readRequestStats();
|
||||||
void readFrameStats();
|
void readFrameStats();
|
||||||
void readBinaryClipboard();
|
|
||||||
|
|
||||||
void readQEMUMessage();
|
void readQEMUMessage();
|
||||||
void readQEMUKeyEvent();
|
void readQEMUKeyEvent();
|
||||||
|
|||||||
@@ -85,24 +85,118 @@ void SMsgWriter::writeBell()
|
|||||||
endMsg();
|
endMsg();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SMsgWriter::writeBinaryClipboard(const std::vector<SConnection::binaryClipboard_t> &b)
|
void SMsgWriter::writeServerCutText(const char* str, int len)
|
||||||
{
|
{
|
||||||
startMsg(msgTypeBinaryClipboard);
|
startMsg(msgTypeServerCutText);
|
||||||
|
os->pad(3);
|
||||||
|
os->writeU32(len);
|
||||||
|
os->writeBytes(str, len);
|
||||||
|
endMsg();
|
||||||
|
}
|
||||||
|
|
||||||
os->writeU8(b.size());
|
void SMsgWriter::writeClipboardCaps(rdr::U32 caps,
|
||||||
rdr::U8 i;
|
const rdr::U32* lengths)
|
||||||
for (i = 0; i < b.size(); i++) {
|
{
|
||||||
const rdr::U32 id = b[i].id;
|
size_t i, count;
|
||||||
os->writeU32(id);
|
|
||||||
|
|
||||||
const rdr::U8 mimelen = strlen(b[i].mime);
|
if (!cp->supportsExtendedClipboard)
|
||||||
os->writeU8(mimelen);
|
throw Exception("Client does not support extended clipboard");
|
||||||
os->writeBytes(b[i].mime, mimelen);
|
|
||||||
|
|
||||||
os->writeU32(b[i].data.size());
|
count = 0;
|
||||||
os->writeBytes(&b[i].data[0], b[i].data.size());
|
for (i = 0;i < 16;i++) {
|
||||||
|
if (caps & (1 << i))
|
||||||
|
count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
startMsg(msgTypeServerCutText);
|
||||||
|
os->pad(3);
|
||||||
|
os->writeS32(-(4 + 4 * count));
|
||||||
|
|
||||||
|
os->writeU32(caps | clipboardCaps);
|
||||||
|
|
||||||
|
count = 0;
|
||||||
|
for (i = 0;i < 16;i++) {
|
||||||
|
if (caps & (1 << i))
|
||||||
|
os->writeU32(lengths[count++]);
|
||||||
|
}
|
||||||
|
|
||||||
|
endMsg();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SMsgWriter::writeClipboardRequest(rdr::U32 flags)
|
||||||
|
{
|
||||||
|
if (!cp->supportsExtendedClipboard)
|
||||||
|
throw Exception("Client does not support extended clipboard");
|
||||||
|
if (!(cp->clipboardFlags() & clipboardRequest))
|
||||||
|
throw Exception("Client does not support clipboard \"request\" action");
|
||||||
|
|
||||||
|
startMsg(msgTypeServerCutText);
|
||||||
|
os->pad(3);
|
||||||
|
os->writeS32(-4);
|
||||||
|
os->writeU32(flags | clipboardRequest);
|
||||||
|
endMsg();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SMsgWriter::writeClipboardPeek(rdr::U32 flags)
|
||||||
|
{
|
||||||
|
if (!cp->supportsExtendedClipboard)
|
||||||
|
throw Exception("Client does not support extended clipboard");
|
||||||
|
if (!(cp->clipboardFlags() & clipboardPeek))
|
||||||
|
throw Exception("Client does not support clipboard \"peek\" action");
|
||||||
|
|
||||||
|
startMsg(msgTypeServerCutText);
|
||||||
|
os->pad(3);
|
||||||
|
os->writeS32(-4);
|
||||||
|
os->writeU32(flags | clipboardPeek);
|
||||||
|
endMsg();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SMsgWriter::writeClipboardNotify(rdr::U32 flags)
|
||||||
|
{
|
||||||
|
if (!cp->supportsExtendedClipboard)
|
||||||
|
throw Exception("Client does not support extended clipboard");
|
||||||
|
if (!(cp->clipboardFlags() & clipboardNotify))
|
||||||
|
throw Exception("Client does not support clipboard \"notify\" action");
|
||||||
|
|
||||||
|
startMsg(msgTypeServerCutText);
|
||||||
|
os->pad(3);
|
||||||
|
os->writeS32(-4);
|
||||||
|
os->writeU32(flags | clipboardNotify);
|
||||||
|
endMsg();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SMsgWriter::writeClipboardProvide(rdr::U32 flags,
|
||||||
|
const size_t* lengths,
|
||||||
|
const rdr::U8* const* data)
|
||||||
|
{
|
||||||
|
rdr::MemOutStream mos;
|
||||||
|
rdr::ZlibOutStream zos;
|
||||||
|
|
||||||
|
int i, count;
|
||||||
|
|
||||||
|
if (!cp->supportsExtendedClipboard)
|
||||||
|
throw Exception("Client does not support extended clipboard");
|
||||||
|
if (!(cp->clipboardFlags() & clipboardProvide))
|
||||||
|
throw Exception("Client does not support clipboard \"provide\" action");
|
||||||
|
|
||||||
|
zos.setUnderlying(&mos);
|
||||||
|
|
||||||
|
count = 0;
|
||||||
|
for (i = 0;i < 16;i++) {
|
||||||
|
if (!(flags & (1 << i)))
|
||||||
|
continue;
|
||||||
|
zos.writeU32(lengths[count]);
|
||||||
|
zos.writeBytes(data[count], lengths[count]);
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
|
||||||
|
zos.flush();
|
||||||
|
|
||||||
|
startMsg(msgTypeServerCutText);
|
||||||
|
os->pad(3);
|
||||||
|
os->writeS32(-(4 + mos.length()));
|
||||||
|
os->writeU32(flags | clipboardProvide);
|
||||||
|
os->writeBytes(mos.data(), mos.length());
|
||||||
endMsg();
|
endMsg();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -26,8 +26,6 @@
|
|||||||
#include <rdr/types.h>
|
#include <rdr/types.h>
|
||||||
#include <rfb/encodings.h>
|
#include <rfb/encodings.h>
|
||||||
#include <rfb/ScreenSet.h>
|
#include <rfb/ScreenSet.h>
|
||||||
#include <rfb/SConnection.h>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
namespace rdr { class OutStream; }
|
namespace rdr { class OutStream; }
|
||||||
|
|
||||||
@@ -56,8 +54,14 @@ namespace rfb {
|
|||||||
|
|
||||||
// writeBell() and writeServerCutText() do the obvious thing.
|
// writeBell() and writeServerCutText() do the obvious thing.
|
||||||
void writeBell();
|
void writeBell();
|
||||||
|
void writeServerCutText(const char* str, int len);
|
||||||
|
|
||||||
void writeBinaryClipboard(const std::vector<SConnection::binaryClipboard_t> &b);
|
void writeClipboardCaps(rdr::U32 caps, const rdr::U32* lengths);
|
||||||
|
void writeClipboardRequest(rdr::U32 flags);
|
||||||
|
void writeClipboardPeek(rdr::U32 flags);
|
||||||
|
void writeClipboardNotify(rdr::U32 flags);
|
||||||
|
void writeClipboardProvide(rdr::U32 flags, const size_t* lengths,
|
||||||
|
const rdr::U8* const* data);
|
||||||
|
|
||||||
void writeStats(const char* str, int len);
|
void writeStats(const char* str, int len);
|
||||||
|
|
||||||
|
|||||||
@@ -149,15 +149,15 @@ rfb::IntParameter rfb::Server::webpVideoQuality
|
|||||||
rfb::IntParameter rfb::Server::DLP_ClipSendMax
|
rfb::IntParameter rfb::Server::DLP_ClipSendMax
|
||||||
("DLP_ClipSendMax",
|
("DLP_ClipSendMax",
|
||||||
"Limit clipboard bytes to send to clients in one transaction",
|
"Limit clipboard bytes to send to clients in one transaction",
|
||||||
0, 0, INT_MAX);
|
10000, 0, INT_MAX);
|
||||||
rfb::IntParameter rfb::Server::DLP_ClipAcceptMax
|
rfb::IntParameter rfb::Server::DLP_ClipAcceptMax
|
||||||
("DLP_ClipAcceptMax",
|
("DLP_ClipAcceptMax",
|
||||||
"Limit clipboard bytes to receive from clients in one transaction",
|
"Limit clipboard bytes to receive from clients in one transaction",
|
||||||
0, 0, INT_MAX);
|
10000, 0, INT_MAX);
|
||||||
rfb::IntParameter rfb::Server::DLP_ClipDelay
|
rfb::IntParameter rfb::Server::DLP_ClipDelay
|
||||||
("DLP_ClipDelay",
|
("DLP_ClipDelay",
|
||||||
"This many milliseconds must pass between clipboard actions",
|
"This many milliseconds must pass between clipboard actions",
|
||||||
0, 0, INT_MAX);
|
1000, 0, INT_MAX);
|
||||||
rfb::IntParameter rfb::Server::DLP_KeyRateLimit
|
rfb::IntParameter rfb::Server::DLP_KeyRateLimit
|
||||||
("DLP_KeyRateLimit",
|
("DLP_KeyRateLimit",
|
||||||
"Reject keyboard presses over this many per second",
|
"Reject keyboard presses over this many per second",
|
||||||
@@ -171,10 +171,6 @@ rfb::StringParameter rfb::Server::DLP_Region
|
|||||||
("DLP_Region",
|
("DLP_Region",
|
||||||
"Black out anything outside this region",
|
"Black out anything outside this region",
|
||||||
"");
|
"");
|
||||||
rfb::StringParameter rfb::Server::DLP_Clip_Types
|
|
||||||
("DLP_ClipTypes",
|
|
||||||
"Allowed binary clipboard mimetypes",
|
|
||||||
"text/html,image/png");
|
|
||||||
|
|
||||||
rfb::BoolParameter rfb::Server::DLP_RegionAllowClick
|
rfb::BoolParameter rfb::Server::DLP_RegionAllowClick
|
||||||
("DLP_RegionAllowClick",
|
("DLP_RegionAllowClick",
|
||||||
|
|||||||
@@ -50,7 +50,6 @@ namespace rfb {
|
|||||||
static IntParameter DLP_KeyRateLimit;
|
static IntParameter DLP_KeyRateLimit;
|
||||||
static StringParameter DLP_ClipLog;
|
static StringParameter DLP_ClipLog;
|
||||||
static StringParameter DLP_Region;
|
static StringParameter DLP_Region;
|
||||||
static StringParameter DLP_Clip_Types;
|
|
||||||
static BoolParameter DLP_RegionAllowClick;
|
static BoolParameter DLP_RegionAllowClick;
|
||||||
static BoolParameter DLP_RegionAllowRelease;
|
static BoolParameter DLP_RegionAllowRelease;
|
||||||
static IntParameter jpegVideoQuality;
|
static IntParameter jpegVideoQuality;
|
||||||
@@ -77,6 +76,7 @@ namespace rfb {
|
|||||||
static BoolParameter ignoreClientSettingsKasm;
|
static BoolParameter ignoreClientSettingsKasm;
|
||||||
static BoolParameter selfBench;
|
static BoolParameter selfBench;
|
||||||
static PresetParameter preferBandwidth;
|
static PresetParameter preferBandwidth;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -71,12 +71,12 @@ static const struct TightWEBPConfiguration conf[10] = {
|
|||||||
{ 24, 0 }, // 1
|
{ 24, 0 }, // 1
|
||||||
{ 30, 0 }, // 2
|
{ 30, 0 }, // 2
|
||||||
{ 37, 0 }, // 3
|
{ 37, 0 }, // 3
|
||||||
{ 42, 0 }, // 4
|
{ 42, 1 }, // 4
|
||||||
{ 65, 0 }, // 5
|
{ 65, 1 }, // 5
|
||||||
{ 78, 0 }, // 6
|
{ 78, 1 }, // 6
|
||||||
{ 85, 0 }, // 7
|
{ 85, 2 }, // 7
|
||||||
{ 88, 0 }, // 8
|
{ 88, 3 }, // 8
|
||||||
{ 100, 0 } // 9
|
{ 100, 4 } // 9
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -143,7 +143,7 @@ void TightWEBPEncoder::compressOnly(const PixelBuffer* pb, const uint8_t quality
|
|||||||
method = conf[qualityIn].method;
|
method = conf[qualityIn].method;
|
||||||
} else {
|
} else {
|
||||||
quality = 8;
|
quality = 8;
|
||||||
method = 0;
|
method = 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
WebPConfigInit(&cfg);
|
WebPConfigInit(&cfg);
|
||||||
@@ -214,7 +214,7 @@ void TightWEBPEncoder::writeRect(const PixelBuffer* pb, const Palette& palette)
|
|||||||
method = conf[qualityLevel].method;
|
method = conf[qualityLevel].method;
|
||||||
} else {
|
} else {
|
||||||
quality = 8;
|
quality = 8;
|
||||||
method = 0;
|
method = 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
WebPConfigInit(&cfg);
|
WebPConfigInit(&cfg);
|
||||||
@@ -265,7 +265,7 @@ rdr::U32 TightWEBPEncoder::benchmark() const
|
|||||||
rdr::U8* buffer;
|
rdr::U8* buffer;
|
||||||
struct timeval start;
|
struct timeval start;
|
||||||
int stride, i;
|
int stride, i;
|
||||||
const uint8_t quality = 8, method = 2;
|
const uint8_t quality = 8, method = 4;
|
||||||
WebPConfig cfg;
|
WebPConfig cfg;
|
||||||
WebPPicture pic;
|
WebPPicture pic;
|
||||||
WebPMemoryWriter wrt;
|
WebPMemoryWriter wrt;
|
||||||
|
|||||||
@@ -57,8 +57,7 @@ VNCSConnectionST::VNCSConnectionST(VNCServerST* server_, network::Socket *s,
|
|||||||
inProcessMessages(false),
|
inProcessMessages(false),
|
||||||
pendingSyncFence(false), syncFence(false), fenceFlags(0),
|
pendingSyncFence(false), syncFence(false), fenceFlags(0),
|
||||||
fenceDataLen(0), fenceData(NULL), congestionTimer(this),
|
fenceDataLen(0), fenceData(NULL), congestionTimer(this),
|
||||||
losslessTimer(this), kbdLogTimer(this), binclipTimer(this),
|
losslessTimer(this), kbdLogTimer(this), server(server_), updates(false),
|
||||||
server(server_), updates(false),
|
|
||||||
updateRenderedCursor(false), removeRenderedCursor(false),
|
updateRenderedCursor(false), removeRenderedCursor(false),
|
||||||
continuousUpdates(false), encodeManager(this, &server_->encCache),
|
continuousUpdates(false), encodeManager(this, &server_->encCache),
|
||||||
needsPermCheck(false), pointerEventTime(0),
|
needsPermCheck(false), pointerEventTime(0),
|
||||||
@@ -87,16 +86,10 @@ VNCSConnectionST::VNCSConnectionST(VNCServerST* server_, network::Socket *s,
|
|||||||
user[at - peerEndpoint.buf] = '\0';
|
user[at - peerEndpoint.buf] = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
bool read, write, owner;
|
bool write, owner;
|
||||||
if (!getPerms(read, write, owner)) {
|
if (!getPerms(write, owner) || !write) {
|
||||||
accessRights &= ~(WRITER_PERMS | AccessView);
|
|
||||||
}
|
|
||||||
if (!write) {
|
|
||||||
accessRights &= ~WRITER_PERMS;
|
accessRights &= ~WRITER_PERMS;
|
||||||
}
|
}
|
||||||
if (!read) {
|
|
||||||
accessRights &= ~AccessView;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Configure the socket
|
// Configure the socket
|
||||||
setSocketTimeouts();
|
setSocketTimeouts();
|
||||||
@@ -367,18 +360,17 @@ char *percentEncode4(const uint16_t *str, const unsigned len) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void cliplog(const char *str, const int len, const int origlen,
|
static void cliplog(const char *str, const int len, const int origlen,
|
||||||
const char *dir, const char *client, const unsigned id) {
|
const char *dir, const char *client) {
|
||||||
if (Server::DLP_ClipLog[0] == 'o')
|
if (Server::DLP_ClipLog[0] == 'o')
|
||||||
return;
|
return;
|
||||||
if (Server::DLP_ClipLog[0] == 'i') {
|
if (Server::DLP_ClipLog[0] == 'i') {
|
||||||
vlog.info("DLP: client %s: %s %u (%u requested) clipboard bytes, id %u", client, dir,
|
vlog.info("DLP: client %s: %s %u (%u requested) clipboard bytes", client, dir, len, origlen);
|
||||||
len, origlen, id);
|
|
||||||
} else {
|
} else {
|
||||||
// URL-encode it
|
// URL-encode it
|
||||||
char *enc = percentEncode(str, len);
|
char *enc = percentEncode(str, len);
|
||||||
|
|
||||||
vlog.info("DLP: client %s: %s %u (%u requested) clipboard bytes, id %u: '%s'",
|
vlog.info("DLP: client %s: %s %u (%u requested) clipboard bytes: '%s'",
|
||||||
client, dir, len, origlen, id, enc);
|
client, dir, len, origlen, enc);
|
||||||
free(enc);
|
free(enc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -421,6 +413,18 @@ static void keylog(unsigned keysym, const char *client) {
|
|||||||
flushKeylog(client);
|
flushKeylog(client);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void VNCSConnectionST::requestClipboardOrClose()
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
if (!(accessRights & AccessCutText)) return;
|
||||||
|
if (!rfb::Server::acceptCutText) return;
|
||||||
|
if (state() != RFBSTATE_NORMAL) return;
|
||||||
|
requestClipboard();
|
||||||
|
} catch(rdr::Exception& e) {
|
||||||
|
close(e.str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void VNCSConnectionST::announceClipboardOrClose(bool available)
|
void VNCSConnectionST::announceClipboardOrClose(bool available)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
@@ -433,53 +437,29 @@ void VNCSConnectionST::announceClipboardOrClose(bool available)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void VNCSConnectionST::clearBinaryClipboardData()
|
void VNCSConnectionST::sendClipboardDataOrClose(const char* data)
|
||||||
{
|
|
||||||
clearBinaryClipboard();
|
|
||||||
}
|
|
||||||
|
|
||||||
void VNCSConnectionST::sendBinaryClipboardDataOrClose(const char* mime,
|
|
||||||
const unsigned char *data,
|
|
||||||
const unsigned len,
|
|
||||||
const unsigned id)
|
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
if (!(accessRights & AccessCutText)) return;
|
if (!(accessRights & AccessCutText)) return;
|
||||||
if (!rfb::Server::sendCutText) return;
|
if (!rfb::Server::sendCutText) return;
|
||||||
if (rfb::Server::DLP_ClipSendMax && len > (unsigned) rfb::Server::DLP_ClipSendMax) {
|
if (msSince(&lastClipboardOp) < (unsigned) rfb::Server::DLP_ClipDelay) {
|
||||||
vlog.info("DLP: client %s: refused to send binary clipboard, too large",
|
vlog.info("DLP: client %s: refused to send clipboard, too soon",
|
||||||
sock->getPeerAddress());
|
sock->getPeerAddress());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
int len = strlen(data);
|
||||||
cliplog((const char *) data, len, len, "sent", sock->getPeerAddress(),
|
const int origlen = len;
|
||||||
id);
|
if (rfb::Server::DLP_ClipSendMax && len > rfb::Server::DLP_ClipSendMax)
|
||||||
|
len = rfb::Server::DLP_ClipSendMax;
|
||||||
|
cliplog(data, len, origlen, "sent", sock->getPeerAddress());
|
||||||
if (state() != RFBSTATE_NORMAL) return;
|
if (state() != RFBSTATE_NORMAL) return;
|
||||||
|
sendClipboardData(data, len);
|
||||||
addBinaryClipboard(mime, data, len, id);
|
gettimeofday(&lastClipboardOp, NULL);
|
||||||
binclipTimer.start(100);
|
|
||||||
} catch(rdr::Exception& e) {
|
} catch(rdr::Exception& e) {
|
||||||
close(e.str());
|
close(e.str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void VNCSConnectionST::getBinaryClipboardData(const char* mime, const unsigned char **data,
|
|
||||||
unsigned *len)
|
|
||||||
{
|
|
||||||
unsigned i;
|
|
||||||
for (i = 0; i < binaryClipboard.size(); i++) {
|
|
||||||
if (!strcmp(binaryClipboard[i].mime, mime)) {
|
|
||||||
*data = &binaryClipboard[i].data[0];
|
|
||||||
*len = binaryClipboard[i].data.size();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
vlog.error("Binary clipboard data for mime %s not found", mime);
|
|
||||||
*data = (const unsigned char *) "";
|
|
||||||
*len = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
void VNCSConnectionST::setDesktopNameOrClose(const char *name)
|
void VNCSConnectionST::setDesktopNameOrClose(const char *name)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
@@ -712,58 +692,14 @@ void VNCSConnectionST::setPixelFormat(const PixelFormat& pf)
|
|||||||
setCursor();
|
setCursor();
|
||||||
}
|
}
|
||||||
|
|
||||||
void VNCSConnectionST::pointerEvent(const Point& pos, const Point& abspos, int buttonMask, const bool skipClick, const bool skipRelease, int scrollX, int scrollY)
|
void VNCSConnectionST::pointerEvent(const Point& pos, int buttonMask, const bool skipClick, const bool skipRelease)
|
||||||
{
|
{
|
||||||
pointerEventTime = lastEventTime = time(0);
|
pointerEventTime = lastEventTime = time(0);
|
||||||
server->lastUserInputTime = lastEventTime;
|
server->lastUserInputTime = lastEventTime;
|
||||||
if (!(accessRights & AccessPtrEvents)) {
|
if (!(accessRights & AccessPtrEvents)) return;
|
||||||
// This particular event is lost, but it's a corner case - you removed write access
|
|
||||||
// from yourself, then added it back. The intended use is for multiple clients,
|
|
||||||
// where the leader removes and adds back access for others, not himself.
|
|
||||||
recheckPerms();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!rfb::Server::acceptPointerEvents) return;
|
if (!rfb::Server::acceptPointerEvents) return;
|
||||||
if (!server->pointerClient || server->pointerClient == this) {
|
if (!server->pointerClient || server->pointerClient == this) {
|
||||||
Point newpos = pos;
|
|
||||||
if (pos.x & 0x4000) {
|
|
||||||
newpos.x &= ~0x4000;
|
|
||||||
newpos.y &= ~0x4000;
|
|
||||||
|
|
||||||
if (newpos.x & 0x8000) {
|
|
||||||
newpos.x &= ~0x8000;
|
|
||||||
newpos.x = -newpos.x;
|
|
||||||
}
|
|
||||||
if (newpos.y & 0x8000) {
|
|
||||||
newpos.y &= ~0x8000;
|
|
||||||
newpos.y = -newpos.y;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (newpos.x < 0) {
|
|
||||||
if (pointerEventPos.x + newpos.x >= 0)
|
|
||||||
pointerEventPos.x += newpos.x;
|
|
||||||
else
|
|
||||||
pointerEventPos.x = 0;
|
|
||||||
} else {
|
|
||||||
pointerEventPos.x += newpos.x;
|
|
||||||
if (pointerEventPos.x >= cp.width)
|
|
||||||
pointerEventPos.x = cp.width;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (newpos.y < 0) {
|
|
||||||
if (pointerEventPos.y + newpos.y >= 0)
|
|
||||||
pointerEventPos.y += newpos.y;
|
|
||||||
else
|
|
||||||
pointerEventPos.y = 0;
|
|
||||||
} else {
|
|
||||||
pointerEventPos.y += newpos.y;
|
|
||||||
if (pointerEventPos.y >= cp.height)
|
|
||||||
pointerEventPos.y = cp.height;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
pointerEventPos = pos;
|
pointerEventPos = pos;
|
||||||
}
|
|
||||||
|
|
||||||
if (buttonMask)
|
if (buttonMask)
|
||||||
server->pointerClient = this;
|
server->pointerClient = this;
|
||||||
else
|
else
|
||||||
@@ -784,7 +720,7 @@ void VNCSConnectionST::pointerEvent(const Point& pos, const Point& abspos, int b
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
server->desktop->pointerEvent(newpos, pointerEventPos, buttonMask, skipclick, skiprelease, scrollX, scrollY);
|
server->desktop->pointerEvent(pointerEventPos, buttonMask, skipclick, skiprelease);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1078,6 +1014,12 @@ void VNCSConnectionST::enableContinuousUpdates(bool enable,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void VNCSConnectionST::handleClipboardRequest()
|
||||||
|
{
|
||||||
|
if (!(accessRights & AccessCutText)) return;
|
||||||
|
server->handleClipboardRequest(this);
|
||||||
|
}
|
||||||
|
|
||||||
void VNCSConnectionST::handleClipboardAnnounce(bool available)
|
void VNCSConnectionST::handleClipboardAnnounce(bool available)
|
||||||
{
|
{
|
||||||
if (!(accessRights & AccessCutText)) return;
|
if (!(accessRights & AccessCutText)) return;
|
||||||
@@ -1085,21 +1027,25 @@ void VNCSConnectionST::handleClipboardAnnounce(bool available)
|
|||||||
server->handleClipboardAnnounce(this, available);
|
server->handleClipboardAnnounce(this, available);
|
||||||
}
|
}
|
||||||
|
|
||||||
void VNCSConnectionST::handleClipboardAnnounceBinary(const unsigned num, const char mimes[][32])
|
void VNCSConnectionST::handleClipboardData(const char* data, int len)
|
||||||
{
|
{
|
||||||
if (!(accessRights & AccessCutText)) return;
|
if (!(accessRights & AccessCutText)) return;
|
||||||
if (!rfb::Server::acceptCutText) return;
|
if (!rfb::Server::acceptCutText) return;
|
||||||
server->handleClipboardAnnounceBinary(this, num, mimes);
|
if (msSince(&lastClipboardOp) < (unsigned) rfb::Server::DLP_ClipDelay) {
|
||||||
|
vlog.info("DLP: client %s: refused to receive clipboard, too soon",
|
||||||
const unsigned tolog = server->clipboardId++;
|
sock->getPeerAddress());
|
||||||
|
|
||||||
if (Server::DLP_ClipLog[0] == 'o')
|
|
||||||
return;
|
return;
|
||||||
vlog.info("DLP: client %s: %s %u clipboard mimes, id %u",
|
}
|
||||||
sock->getPeerAddress(), "received",
|
const int origlen = len;
|
||||||
num, tolog);
|
if (rfb::Server::DLP_ClipAcceptMax && len > rfb::Server::DLP_ClipAcceptMax)
|
||||||
|
len = rfb::Server::DLP_ClipAcceptMax;
|
||||||
|
cliplog(data, len, origlen, "received", sock->getPeerAddress());
|
||||||
|
|
||||||
|
gettimeofday(&lastClipboardOp, NULL);
|
||||||
|
server->handleClipboardData(this, data, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// supportsLocalCursor() is called whenever the status of
|
// supportsLocalCursor() is called whenever the status of
|
||||||
// cp.supportsLocalCursor has changed. If the client does now support local
|
// cp.supportsLocalCursor has changed. If the client does now support local
|
||||||
// cursor, we make sure that the old server-side rendered cursor is cleaned up
|
// cursor, we make sure that the old server-side rendered cursor is cleaned up
|
||||||
@@ -1143,8 +1089,6 @@ bool VNCSConnectionST::handleTimeout(Timer* t)
|
|||||||
writeFramebufferUpdate();
|
writeFramebufferUpdate();
|
||||||
else if (t == &kbdLogTimer)
|
else if (t == &kbdLogTimer)
|
||||||
flushKeylog(sock->getPeerAddress());
|
flushKeylog(sock->getPeerAddress());
|
||||||
else if (t == &binclipTimer)
|
|
||||||
writeBinaryClipboard();
|
|
||||||
} catch (rdr::Exception& e) {
|
} catch (rdr::Exception& e) {
|
||||||
close(e.str());
|
close(e.str());
|
||||||
}
|
}
|
||||||
@@ -1166,12 +1110,11 @@ bool VNCSConnectionST::isShiftPressed()
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool VNCSConnectionST::getPerms(bool &read, bool &write, bool &owner) const
|
bool VNCSConnectionST::getPerms(bool &write, bool &owner) const
|
||||||
{
|
{
|
||||||
bool found = false;
|
bool found = false;
|
||||||
if (disablebasicauth) {
|
if (disablebasicauth) {
|
||||||
// We're running without basicauth
|
// We're running without basicauth
|
||||||
read = true;
|
|
||||||
write = true;
|
write = true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -1180,14 +1123,8 @@ bool VNCSConnectionST::getPerms(bool &read, bool &write, bool &owner) const
|
|||||||
unsigned i;
|
unsigned i;
|
||||||
for (i = 0; i < set->num; i++) {
|
for (i = 0; i < set->num; i++) {
|
||||||
if (!strcmp(set->entries[i].user, user)) {
|
if (!strcmp(set->entries[i].user, user)) {
|
||||||
read = set->entries[i].read;
|
|
||||||
write = set->entries[i].write;
|
write = set->entries[i].write;
|
||||||
owner = set->entries[i].owner;
|
owner = set->entries[i].owner;
|
||||||
|
|
||||||
// Writer can always read
|
|
||||||
if (write)
|
|
||||||
read = true;
|
|
||||||
|
|
||||||
found = true;
|
found = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -1285,28 +1222,17 @@ void VNCSConnectionST::writeFramebufferUpdate()
|
|||||||
if (needsPermCheck) {
|
if (needsPermCheck) {
|
||||||
needsPermCheck = false;
|
needsPermCheck = false;
|
||||||
|
|
||||||
bool read, write, owner, ret;
|
bool write, owner, ret;
|
||||||
ret = getPerms(read, write, owner);
|
ret = getPerms(write, owner);
|
||||||
if (!ret) {
|
if (!ret) {
|
||||||
close("User was deleted");
|
close("User was deleted");
|
||||||
return;
|
return;
|
||||||
}
|
} else if (!write) {
|
||||||
|
|
||||||
if (!write) {
|
|
||||||
accessRights &= ~WRITER_PERMS;
|
accessRights &= ~WRITER_PERMS;
|
||||||
} else {
|
} else {
|
||||||
accessRights |= WRITER_PERMS;
|
accessRights |= WRITER_PERMS;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!read) {
|
|
||||||
accessRights &= ~AccessView;
|
|
||||||
} else {
|
|
||||||
accessRights |= AccessView;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (!(accessRights & AccessView))
|
|
||||||
return;
|
|
||||||
|
|
||||||
// Updates often consists of many small writes, and in continuous
|
// Updates often consists of many small writes, and in continuous
|
||||||
// mode, we will also have small fence messages around the update. We
|
// mode, we will also have small fence messages around the update. We
|
||||||
@@ -1520,18 +1446,6 @@ void VNCSConnectionST::writeDataUpdate()
|
|||||||
requested.clear();
|
requested.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void VNCSConnectionST::writeBinaryClipboard()
|
|
||||||
{
|
|
||||||
if (msSince(&lastClipboardOp) < (unsigned) rfb::Server::DLP_ClipDelay) {
|
|
||||||
vlog.info("DLP: client %s: refused to send binary clipboard, too soon",
|
|
||||||
sock->getPeerAddress());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
writer()->writeBinaryClipboard(binaryClipboard);
|
|
||||||
|
|
||||||
gettimeofday(&lastClipboardOp, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
void VNCSConnectionST::screenLayoutChange(rdr::U16 reason)
|
void VNCSConnectionST::screenLayoutChange(rdr::U16 reason)
|
||||||
{
|
{
|
||||||
@@ -1738,8 +1652,8 @@ bool VNCSConnectionST::checkOwnerConn() const
|
|||||||
std::list<VNCSConnectionST*>::const_iterator it;
|
std::list<VNCSConnectionST*>::const_iterator it;
|
||||||
|
|
||||||
for (it = server->clients.begin(); it != server->clients.end(); it++) {
|
for (it = server->clients.begin(); it != server->clients.end(); it++) {
|
||||||
bool read, write, owner;
|
bool write, owner;
|
||||||
if ((*it)->getPerms(read, write, owner) && owner)
|
if ((*it)->getPerms(write, owner) && owner)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -77,12 +77,9 @@ namespace rfb {
|
|||||||
void bellOrClose();
|
void bellOrClose();
|
||||||
void setDesktopNameOrClose(const char *name);
|
void setDesktopNameOrClose(const char *name);
|
||||||
void setLEDStateOrClose(unsigned int state);
|
void setLEDStateOrClose(unsigned int state);
|
||||||
|
void requestClipboardOrClose();
|
||||||
void announceClipboardOrClose(bool available);
|
void announceClipboardOrClose(bool available);
|
||||||
void clearBinaryClipboardData();
|
void sendClipboardDataOrClose(const char* data);
|
||||||
void sendBinaryClipboardDataOrClose(const char* mime, const unsigned char *data,
|
|
||||||
const unsigned len, const unsigned id);
|
|
||||||
void getBinaryClipboardData(const char* mime, const unsigned char **data,
|
|
||||||
unsigned *len);
|
|
||||||
|
|
||||||
// checkIdleTimeout() returns the number of milliseconds left until the
|
// checkIdleTimeout() returns the number of milliseconds left until the
|
||||||
// idle timeout expires. If it has expired, the connection is closed and
|
// idle timeout expires. If it has expired, the connection is closed and
|
||||||
@@ -171,8 +168,8 @@ namespace rfb {
|
|||||||
virtual void handleFrameStats(rdr::U32 all, rdr::U32 render);
|
virtual void handleFrameStats(rdr::U32 all, rdr::U32 render);
|
||||||
|
|
||||||
bool is_owner() const {
|
bool is_owner() const {
|
||||||
bool read, write, owner;
|
bool write, owner;
|
||||||
if (getPerms(read, write, owner) && owner)
|
if (getPerms(write, owner) && owner)
|
||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -207,7 +204,7 @@ namespace rfb {
|
|||||||
virtual void queryConnection(const char* userName);
|
virtual void queryConnection(const char* userName);
|
||||||
virtual void clientInit(bool shared);
|
virtual void clientInit(bool shared);
|
||||||
virtual void setPixelFormat(const PixelFormat& pf);
|
virtual void setPixelFormat(const PixelFormat& pf);
|
||||||
virtual void pointerEvent(const Point& pos, const Point& abspos,int buttonMask, const bool skipClick, const bool skipRelease, int scrollX, int scrollY);
|
virtual void pointerEvent(const Point& pos, int buttonMask, const bool skipClick, const bool skipRelease);
|
||||||
virtual void keyEvent(rdr::U32 keysym, rdr::U32 keycode, bool down);
|
virtual void keyEvent(rdr::U32 keysym, rdr::U32 keycode, bool down);
|
||||||
virtual void framebufferUpdateRequest(const Rect& r, bool incremental);
|
virtual void framebufferUpdateRequest(const Rect& r, bool incremental);
|
||||||
virtual void setDesktopSize(int fb_width, int fb_height,
|
virtual void setDesktopSize(int fb_width, int fb_height,
|
||||||
@@ -215,8 +212,9 @@ namespace rfb {
|
|||||||
virtual void fence(rdr::U32 flags, unsigned len, const char data[]);
|
virtual void fence(rdr::U32 flags, unsigned len, const char data[]);
|
||||||
virtual void enableContinuousUpdates(bool enable,
|
virtual void enableContinuousUpdates(bool enable,
|
||||||
int x, int y, int w, int h);
|
int x, int y, int w, int h);
|
||||||
|
virtual void handleClipboardRequest();
|
||||||
virtual void handleClipboardAnnounce(bool available);
|
virtual void handleClipboardAnnounce(bool available);
|
||||||
virtual void handleClipboardAnnounceBinary(const unsigned num, const char mimes[][32]);
|
virtual void handleClipboardData(const char* data, int len);
|
||||||
virtual void supportsLocalCursor();
|
virtual void supportsLocalCursor();
|
||||||
virtual void supportsFence();
|
virtual void supportsFence();
|
||||||
virtual void supportsContinuousUpdates();
|
virtual void supportsContinuousUpdates();
|
||||||
@@ -227,6 +225,19 @@ namespace rfb {
|
|||||||
(AccessPtrEvents | AccessKeyEvents);
|
(AccessPtrEvents | AccessKeyEvents);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// setAccessRights() allows a security package to limit the access rights
|
||||||
|
// of a VNCSConnectioST to the server. These access rights are applied
|
||||||
|
// such that the actual rights granted are the minimum of the server's
|
||||||
|
// default access settings and the connection's access settings.
|
||||||
|
virtual void setAccessRights(AccessRights ar) {
|
||||||
|
accessRights = ar;
|
||||||
|
|
||||||
|
bool write, owner;
|
||||||
|
if (!getPerms(write, owner) || !write)
|
||||||
|
accessRights &= ~WRITER_PERMS;
|
||||||
|
needsPermCheck = false;
|
||||||
|
}
|
||||||
|
|
||||||
// Timer callbacks
|
// Timer callbacks
|
||||||
virtual bool handleTimeout(Timer* t);
|
virtual bool handleTimeout(Timer* t);
|
||||||
|
|
||||||
@@ -234,7 +245,7 @@ namespace rfb {
|
|||||||
|
|
||||||
bool isShiftPressed();
|
bool isShiftPressed();
|
||||||
|
|
||||||
bool getPerms(bool &read, bool &write, bool &owner) const;
|
bool getPerms(bool &write, bool &owner) const;
|
||||||
|
|
||||||
bool checkOwnerConn() const;
|
bool checkOwnerConn() const;
|
||||||
|
|
||||||
@@ -249,8 +260,6 @@ namespace rfb {
|
|||||||
void writeNoDataUpdate();
|
void writeNoDataUpdate();
|
||||||
void writeDataUpdate();
|
void writeDataUpdate();
|
||||||
|
|
||||||
void writeBinaryClipboard();
|
|
||||||
|
|
||||||
void screenLayoutChange(rdr::U16 reason);
|
void screenLayoutChange(rdr::U16 reason);
|
||||||
void setCursor();
|
void setCursor();
|
||||||
void setCursorPos();
|
void setCursorPos();
|
||||||
@@ -273,7 +282,6 @@ namespace rfb {
|
|||||||
Timer congestionTimer;
|
Timer congestionTimer;
|
||||||
Timer losslessTimer;
|
Timer losslessTimer;
|
||||||
Timer kbdLogTimer;
|
Timer kbdLogTimer;
|
||||||
Timer binclipTimer;
|
|
||||||
|
|
||||||
VNCServerST* server;
|
VNCServerST* server;
|
||||||
SimpleUpdateTracker updates;
|
SimpleUpdateTracker updates;
|
||||||
|
|||||||
@@ -52,11 +52,22 @@ namespace rfb {
|
|||||||
// getPixelBuffer() returns a pointer to the PixelBuffer object.
|
// getPixelBuffer() returns a pointer to the PixelBuffer object.
|
||||||
virtual PixelBuffer* getPixelBuffer() const = 0;
|
virtual PixelBuffer* getPixelBuffer() const = 0;
|
||||||
|
|
||||||
|
// requestClipboard() will result in a request to a client to
|
||||||
|
// transfer its clipboard data. A call to
|
||||||
|
// SDesktop::handleClipboardData() will be made once the data is
|
||||||
|
// available.
|
||||||
|
virtual void requestClipboard() = 0;
|
||||||
|
|
||||||
// announceClipboard() informs all clients of changes to the
|
// announceClipboard() informs all clients of changes to the
|
||||||
// clipboard on the server. A client may later request the
|
// clipboard on the server. A client may later request the
|
||||||
// clipboard data via SDesktop::handleClipboardRequest().
|
// clipboard data via SDesktop::handleClipboardRequest().
|
||||||
virtual void announceClipboard(bool available) = 0;
|
virtual void announceClipboard(bool available) = 0;
|
||||||
|
|
||||||
|
// sendClipboardData() transfers the clipboard data to a client
|
||||||
|
// and should be called whenever a client has requested the
|
||||||
|
// clipboard via SDesktop::handleClipboardRequest().
|
||||||
|
virtual void sendClipboardData(const char* data) = 0;
|
||||||
|
|
||||||
// bell() tells the server that it should make all clients make a bell sound.
|
// bell() tells the server that it should make all clients make a bell sound.
|
||||||
virtual void bell() = 0;
|
virtual void bell() = 0;
|
||||||
|
|
||||||
|
|||||||
@@ -131,8 +131,7 @@ 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), trackingFrameStats(0)
|
||||||
clipboardId(0)
|
|
||||||
{
|
{
|
||||||
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);
|
||||||
@@ -519,6 +518,14 @@ void VNCServerST::setScreenLayout(const ScreenSet& layout)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void VNCServerST::requestClipboard()
|
||||||
|
{
|
||||||
|
if (clipboardClient == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
clipboardClient->requestClipboard();
|
||||||
|
}
|
||||||
|
|
||||||
void VNCServerST::announceClipboard(bool available)
|
void VNCServerST::announceClipboard(bool available)
|
||||||
{
|
{
|
||||||
std::list<VNCSConnectionST*>::iterator ci, ci_next;
|
std::list<VNCSConnectionST*>::iterator ci, ci_next;
|
||||||
@@ -534,33 +541,20 @@ void VNCServerST::announceClipboard(bool available)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void VNCServerST::sendBinaryClipboardData(const char* mime, const unsigned char *data,
|
void VNCServerST::sendClipboardData(const char* data)
|
||||||
const unsigned len)
|
|
||||||
{
|
{
|
||||||
std::list<VNCSConnectionST*>::iterator ci, ci_next;
|
std::list<VNCSConnectionST*>::iterator ci, ci_next;
|
||||||
for (ci = clients.begin(); ci != clients.end(); ci = ci_next) {
|
|
||||||
|
if (strchr(data, '\r') != NULL)
|
||||||
|
throw Exception("Invalid carriage return in clipboard data");
|
||||||
|
|
||||||
|
for (ci = clipboardRequestors.begin();
|
||||||
|
ci != clipboardRequestors.end(); ci = ci_next) {
|
||||||
ci_next = ci; ci_next++;
|
ci_next = ci; ci_next++;
|
||||||
(*ci)->sendBinaryClipboardDataOrClose(mime, data, len, clipboardId);
|
(*ci)->sendClipboardDataOrClose(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
clipboardId++;
|
clipboardRequestors.clear();
|
||||||
}
|
|
||||||
|
|
||||||
void VNCServerST::getBinaryClipboardData(const char* mime, const unsigned char **data,
|
|
||||||
unsigned *len)
|
|
||||||
{
|
|
||||||
if (!clipboardClient)
|
|
||||||
return;
|
|
||||||
clipboardClient->getBinaryClipboardData(mime, data, len);
|
|
||||||
}
|
|
||||||
|
|
||||||
void VNCServerST::clearBinaryClipboardData()
|
|
||||||
{
|
|
||||||
std::list<VNCSConnectionST*>::iterator ci, ci_next;
|
|
||||||
for (ci = clients.begin(); ci != clients.end(); ci = ci_next) {
|
|
||||||
ci_next = ci; ci_next++;
|
|
||||||
(*ci)->clearBinaryClipboardData();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void VNCServerST::bell()
|
void VNCServerST::bell()
|
||||||
@@ -808,11 +802,49 @@ static void checkAPIMessages(network::GetAPIMessager *apimessager,
|
|||||||
slog.info("Main thread processing user API request %u/%u", i + 1, num);
|
slog.info("Main thread processing user API request %u/%u", i + 1, num);
|
||||||
|
|
||||||
const network::GetAPIMessager::action_data &act = apimessager->actionQueue[i];
|
const network::GetAPIMessager::action_data &act = apimessager->actionQueue[i];
|
||||||
|
struct kasmpasswd_t *set = NULL;
|
||||||
|
unsigned s;
|
||||||
|
bool found;
|
||||||
|
|
||||||
switch (act.action) {
|
switch (act.action) {
|
||||||
case network::GetAPIMessager::NONE:
|
case network::GetAPIMessager::USER_REMOVE:
|
||||||
slog.info("Empty request (bug!)");
|
set = readkasmpasswd(kasmpasswdpath);
|
||||||
|
found = false;
|
||||||
|
for (s = 0; s < set->num; s++) {
|
||||||
|
if (!strcmp(set->entries[s].user, act.data.user)) {
|
||||||
|
set->entries[s].user[0] = '\0';
|
||||||
|
found = true;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (found) {
|
||||||
|
writekasmpasswd(kasmpasswdpath, set);
|
||||||
|
slog.info("User %s removed", act.data.user);
|
||||||
|
} else {
|
||||||
|
slog.error("Tried to remove nonexistent user %s", act.data.user);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case network::GetAPIMessager::USER_GIVE_CONTROL:
|
||||||
|
set = readkasmpasswd(kasmpasswdpath);
|
||||||
|
found = false;
|
||||||
|
for (s = 0; s < set->num; s++) {
|
||||||
|
if (!strcmp(set->entries[s].user, act.data.user)) {
|
||||||
|
set->entries[s].write = 1;
|
||||||
|
found = true;
|
||||||
|
} else {
|
||||||
|
set->entries[s].write = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (found) {
|
||||||
|
writekasmpasswd(kasmpasswdpath, set);
|
||||||
|
slog.info("User %s given control", act.data.user);
|
||||||
|
} else {
|
||||||
|
slog.error("Tried to give control to nonexistent user %s", act.data.user);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case network::GetAPIMessager::WANT_FRAME_STATS_SERVERONLY:
|
case network::GetAPIMessager::WANT_FRAME_STATS_SERVERONLY:
|
||||||
trackingFrameStats = act.action;
|
trackingFrameStats = act.action;
|
||||||
break;
|
break;
|
||||||
@@ -827,6 +859,11 @@ static void checkAPIMessages(network::GetAPIMessager *apimessager,
|
|||||||
memcpy(trackingClient, act.data.password, 128);
|
memcpy(trackingClient, act.data.password, 128);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (set) {
|
||||||
|
free(set->entries);
|
||||||
|
free(set);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
apimessager->actionQueue.clear();
|
apimessager->actionQueue.clear();
|
||||||
@@ -1161,6 +1198,13 @@ bool VNCServerST::getComparerState()
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void VNCServerST::handleClipboardRequest(VNCSConnectionST* client)
|
||||||
|
{
|
||||||
|
clipboardRequestors.push_back(client);
|
||||||
|
if (clipboardRequestors.size() == 1)
|
||||||
|
desktop->handleClipboardRequest();
|
||||||
|
}
|
||||||
|
|
||||||
void VNCServerST::handleClipboardAnnounce(VNCSConnectionST* client,
|
void VNCServerST::handleClipboardAnnounce(VNCSConnectionST* client,
|
||||||
bool available)
|
bool available)
|
||||||
{
|
{
|
||||||
@@ -1174,10 +1218,11 @@ void VNCServerST::handleClipboardAnnounce(VNCSConnectionST* client,
|
|||||||
desktop->handleClipboardAnnounce(available);
|
desktop->handleClipboardAnnounce(available);
|
||||||
}
|
}
|
||||||
|
|
||||||
void VNCServerST::handleClipboardAnnounceBinary(VNCSConnectionST* client,
|
void VNCServerST::handleClipboardData(VNCSConnectionST* client,
|
||||||
const unsigned num,
|
const char* data, int len)
|
||||||
const char mimes[][32])
|
|
||||||
{
|
{
|
||||||
clipboardClient = client;
|
if (client != clipboardClient)
|
||||||
desktop->handleClipboardAnnounceBinary(num, mimes);
|
return;
|
||||||
|
desktop->handleClipboardData(data, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -96,12 +96,9 @@ namespace rfb {
|
|||||||
virtual void setPixelBuffer(PixelBuffer* pb);
|
virtual void setPixelBuffer(PixelBuffer* pb);
|
||||||
virtual void setScreenLayout(const ScreenSet& layout);
|
virtual void setScreenLayout(const ScreenSet& layout);
|
||||||
virtual PixelBuffer* getPixelBuffer() const { if (DLPRegion.enabled && blackedpb) return blackedpb; else return pb; }
|
virtual PixelBuffer* getPixelBuffer() const { if (DLPRegion.enabled && blackedpb) return blackedpb; else return pb; }
|
||||||
|
virtual void requestClipboard();
|
||||||
virtual void announceClipboard(bool available);
|
virtual void announceClipboard(bool available);
|
||||||
virtual void clearBinaryClipboardData();
|
virtual void sendClipboardData(const char* data);
|
||||||
virtual void sendBinaryClipboardData(const char* mime, const unsigned char *data,
|
|
||||||
const unsigned len);
|
|
||||||
virtual void getBinaryClipboardData(const char *mime, const unsigned char **ptr,
|
|
||||||
unsigned *len);
|
|
||||||
virtual void add_changed(const Region ®ion);
|
virtual void add_changed(const Region ®ion);
|
||||||
virtual void add_copied(const Region &dest, const Point &delta);
|
virtual void add_copied(const Region &dest, const Point &delta);
|
||||||
virtual void setCursor(int width, int height, const Point& hotspot,
|
virtual void setCursor(int width, int height, const Point& hotspot,
|
||||||
@@ -194,9 +191,9 @@ namespace rfb {
|
|||||||
|
|
||||||
void setAPIMessager(network::GetAPIMessager *msgr) { apimessager = msgr; }
|
void setAPIMessager(network::GetAPIMessager *msgr) { apimessager = msgr; }
|
||||||
|
|
||||||
|
void handleClipboardRequest(VNCSConnectionST* client);
|
||||||
void handleClipboardAnnounce(VNCSConnectionST* client, bool available);
|
void handleClipboardAnnounce(VNCSConnectionST* client, bool available);
|
||||||
void handleClipboardAnnounceBinary(VNCSConnectionST* client, const unsigned num,
|
void handleClipboardData(VNCSConnectionST* client, const char* data, int len);
|
||||||
const char mimes[][32]);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
@@ -281,8 +278,6 @@ namespace rfb {
|
|||||||
} DLPRegion;
|
} DLPRegion;
|
||||||
|
|
||||||
void translateDLPRegion(rdr::U16 &x1, rdr::U16 &y1, rdr::U16 &x2, rdr::U16 &y2) const;
|
void translateDLPRegion(rdr::U16 &x1, rdr::U16 &y1, rdr::U16 &x2, rdr::U16 &y2) const;
|
||||||
|
|
||||||
rdr::U32 clipboardId;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -31,7 +31,6 @@ namespace rfb {
|
|||||||
// kasm
|
// kasm
|
||||||
const int msgTypeStats = 178;
|
const int msgTypeStats = 178;
|
||||||
const int msgTypeRequestFrameStats = 179;
|
const int msgTypeRequestFrameStats = 179;
|
||||||
const int msgTypeBinaryClipboard = 180;
|
|
||||||
|
|
||||||
const int msgTypeServerFence = 248;
|
const int msgTypeServerFence = 248;
|
||||||
|
|
||||||
@@ -50,7 +49,6 @@ namespace rfb {
|
|||||||
// kasm
|
// kasm
|
||||||
const int msgTypeRequestStats = 178;
|
const int msgTypeRequestStats = 178;
|
||||||
const int msgTypeFrameStats = 179;
|
const int msgTypeFrameStats = 179;
|
||||||
//const int msgTypeBinaryClipboard = 180;
|
|
||||||
|
|
||||||
const int msgTypeClientFence = 248;
|
const int msgTypeClientFence = 248;
|
||||||
|
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ void SSE2_halve(const uint8_t *oldpx,
|
|||||||
|
|
||||||
uint8_t * const dst = newpx + newstride * (y / 2) * 4;
|
uint8_t * const dst = newpx + newstride * (y / 2) * 4;
|
||||||
|
|
||||||
for (x = 0; x < srcw - 3; x += 4) {
|
for (x = 0; x < srcw; x += 4) {
|
||||||
__m128i lo, hi, a, b, c, d;
|
__m128i lo, hi, a, b, c, d;
|
||||||
lo = _mm_loadu_si128((__m128i *) &row0[x * 4]);
|
lo = _mm_loadu_si128((__m128i *) &row0[x * 4]);
|
||||||
hi = _mm_loadu_si128((__m128i *) &row1[x * 4]);
|
hi = _mm_loadu_si128((__m128i *) &row1[x * 4]);
|
||||||
@@ -141,7 +141,7 @@ void SSE2_scale(const uint8_t *oldpx,
|
|||||||
const __m128i vertmul = _mm_set1_epi16(top);
|
const __m128i vertmul = _mm_set1_epi16(top);
|
||||||
const __m128i vertmul2 = _mm_set1_epi16(bot);
|
const __m128i vertmul2 = _mm_set1_epi16(bot);
|
||||||
|
|
||||||
for (x = 0; x < tgtw - 1; x += 2) {
|
for (x = 0; x < tgtw; x += 2) {
|
||||||
const float nx[2] = {
|
const float nx[2] = {
|
||||||
x * invdiff,
|
x * invdiff,
|
||||||
(x + 1) * invdiff,
|
(x + 1) * invdiff,
|
||||||
|
|||||||
2
debian/Makefile.to_fakebuild_tar_package
vendored
2
debian/Makefile.to_fakebuild_tar_package
vendored
@@ -16,14 +16,12 @@ install: unpack_tarball
|
|||||||
cp $(SRC_BIN)/vncserver $(DESTDIR)/usr/bin/kasmvncserver
|
cp $(SRC_BIN)/vncserver $(DESTDIR)/usr/bin/kasmvncserver
|
||||||
cp $(SRC_BIN)/vncconfig $(DESTDIR)/usr/bin/kasmvncconfig
|
cp $(SRC_BIN)/vncconfig $(DESTDIR)/usr/bin/kasmvncconfig
|
||||||
cp $(SRC_BIN)/kasmvncpasswd $(DESTDIR)/usr/bin/
|
cp $(SRC_BIN)/kasmvncpasswd $(DESTDIR)/usr/bin/
|
||||||
cp $(SRC_BIN)/kasmxproxy $(DESTDIR)/usr/bin/
|
|
||||||
cp -r $(SRC)/share/doc/kasmvnc*/* $(DESTDIR)/usr/share/doc/kasmvncserver/
|
cp -r $(SRC)/share/doc/kasmvnc*/* $(DESTDIR)/usr/share/doc/kasmvncserver/
|
||||||
rsync -r --exclude '.git*' --exclude po2js --exclude xgettext-html \
|
rsync -r --exclude '.git*' --exclude po2js --exclude xgettext-html \
|
||||||
--exclude www/utils/ --exclude .eslintrc \
|
--exclude www/utils/ --exclude .eslintrc \
|
||||||
$(SRC)/share/kasmvnc $(DESTDIR)/usr/share
|
$(SRC)/share/kasmvnc $(DESTDIR)/usr/share
|
||||||
cp $(SRC)/man/man1/Xvnc.1 $(DESTDIR)/usr/share/man/man1/Xkasmvnc.1
|
cp $(SRC)/man/man1/Xvnc.1 $(DESTDIR)/usr/share/man/man1/Xkasmvnc.1
|
||||||
cp $(SRC)/share/man/man1/vncserver.1 $(DST_MAN)/kasmvncserver.1
|
cp $(SRC)/share/man/man1/vncserver.1 $(DST_MAN)/kasmvncserver.1
|
||||||
cp $(SRC)/share/man/man1/kasmxproxy.1 $(DST_MAN)/kasmxproxy.1
|
|
||||||
cp $(SRC)/share/man/man1/vncpasswd.1 $(DST_MAN)/kasmvncpasswd.1
|
cp $(SRC)/share/man/man1/vncpasswd.1 $(DST_MAN)/kasmvncpasswd.1
|
||||||
cp $(SRC)/share/man/man1/vncconfig.1 $(DST_MAN)/kasmvncconfig.1
|
cp $(SRC)/share/man/man1/vncconfig.1 $(DST_MAN)/kasmvncconfig.1
|
||||||
|
|
||||||
|
|||||||
6
debian/changelog
vendored
6
debian/changelog
vendored
@@ -1,9 +1,3 @@
|
|||||||
kasmvnc (0.9.3~beta-1) unstable; urgency=medium
|
|
||||||
|
|
||||||
* New upstream release.
|
|
||||||
|
|
||||||
-- Kasm Technologies LLC <info@kasmweb.com> Tue, 22 Mar 2022 09:15:38 +0000
|
|
||||||
|
|
||||||
kasmvnc (0.9.1~beta-1) unstable; urgency=medium
|
kasmvnc (0.9.1~beta-1) unstable; urgency=medium
|
||||||
|
|
||||||
* Initial release of the Debian package.
|
* Initial release of the Debian package.
|
||||||
|
|||||||
4
debian/control
vendored
4
debian/control
vendored
@@ -3,14 +3,14 @@ Section: x11
|
|||||||
Priority: optional
|
Priority: optional
|
||||||
Maintainer: Kasm Technologies LLC <info@kasmweb.com>
|
Maintainer: Kasm Technologies LLC <info@kasmweb.com>
|
||||||
Build-Depends: debhelper (>= 11), rsync, libjpeg-dev, libjpeg-dev, libpng-dev,
|
Build-Depends: debhelper (>= 11), rsync, libjpeg-dev, libjpeg-dev, libpng-dev,
|
||||||
libtiff-dev, libgif-dev, libavcodec-dev, libssl-dev, libgl1, libxfont2, libsm6, libxext-dev, libxrandr-dev, libxtst-dev, libxcursor-dev, libunwind8
|
libtiff-dev, libgif-dev, libavcodec-dev, libssl-dev, libgl1, libxfont2, libsm6
|
||||||
Standards-Version: 4.1.3
|
Standards-Version: 4.1.3
|
||||||
Homepage: https://github.com/kasmtech/KasmVNC
|
Homepage: https://github.com/kasmtech/KasmVNC
|
||||||
#Vcs-Browser: https://salsa.debian.org/debian/kasmvnc
|
#Vcs-Browser: https://salsa.debian.org/debian/kasmvnc
|
||||||
#Vcs-Git: https://salsa.debian.org/debian/kasmvnc.git
|
#Vcs-Git: https://salsa.debian.org/debian/kasmvnc.git
|
||||||
|
|
||||||
Package: kasmvncserver
|
Package: kasmvncserver
|
||||||
Architecture: amd64 arm64
|
Architecture: amd64
|
||||||
Depends: ${shlibs:Depends}, ${misc:Depends}, ${perl:Depends}, ssl-cert, xauth,
|
Depends: ${shlibs:Depends}, ${misc:Depends}, ${perl:Depends}, ssl-cert, xauth,
|
||||||
x11-xkb-utils, xkb-data, procps
|
x11-xkb-utils, xkb-data, procps
|
||||||
Provides: vnc-server
|
Provides: vnc-server
|
||||||
|
|||||||
2
debian/postinst
vendored
2
debian/postinst
vendored
@@ -21,7 +21,7 @@ case "$1" in
|
|||||||
configure)
|
configure)
|
||||||
bindir=/usr/bin
|
bindir=/usr/bin
|
||||||
mandir=/usr/share/man
|
mandir=/usr/share/man
|
||||||
commands="kasmvncserver kasmvncpasswd kasmvncconfig Xkasmvnc kasmxproxy"
|
commands="kasmvncserver kasmvncpasswd kasmvncconfig Xkasmvnc"
|
||||||
|
|
||||||
for kasm_command in $commands; do
|
for kasm_command in $commands; do
|
||||||
generic_command=`echo "$kasm_command" | sed -e 's/kasm//'`;
|
generic_command=`echo "$kasm_command" | sed -e 's/kasm//'`;
|
||||||
|
|||||||
2
debian/prerm
vendored
2
debian/prerm
vendored
@@ -21,7 +21,7 @@ case "$1" in
|
|||||||
remove)
|
remove)
|
||||||
bindir=/usr/bin
|
bindir=/usr/bin
|
||||||
mandir=/usr/share/man
|
mandir=/usr/share/man
|
||||||
commands="kasmvncserver kasmvncpasswd kasmvncconfig Xkasmvnc kasmxproxy"
|
commands="kasmvncserver kasmvncpasswd kasmvncconfig Xkasmvnc"
|
||||||
|
|
||||||
for kasm_command in $commands; do
|
for kasm_command in $commands; do
|
||||||
generic_command=`echo "$kasm_command" | sed -e 's/kasm//'`;
|
generic_command=`echo "$kasm_command" | sed -e 's/kasm//'`;
|
||||||
|
|||||||
4491
doc/rfbproto.rst
4491
doc/rfbproto.rst
File diff suppressed because it is too large
Load Diff
2
kasmweb
2
kasmweb
Submodule kasmweb updated: 7e5a302a7a...d1e4bda4b3
@@ -1,108 +0,0 @@
|
|||||||
Name: kasmvncserver
|
|
||||||
Version: 0.9.3~beta
|
|
||||||
Release: leap15
|
|
||||||
Summary: VNC server accessible from a web browser
|
|
||||||
|
|
||||||
License: GPLv2+
|
|
||||||
URL: https://github.com/kasmtech/KasmVNC
|
|
||||||
|
|
||||||
BuildRequires: rsync
|
|
||||||
Requires: xauth, libxkbcommon-x11-0, xkeyboard-config, x11-tools, openssl, perl, libpixman-1-0, libnettle6, libjpeg8, libgomp1, libgnutls30, libXfont2-2, libXdmcp6, libglvnd, xkbcomp
|
|
||||||
Conflicts: tigervnc, tigervnc-x11vnc
|
|
||||||
|
|
||||||
%description
|
|
||||||
VNC stands for Virtual Network Computing. It is, in essence, a remote
|
|
||||||
display system which allows you to view a computing `desktop' environment
|
|
||||||
not only on the machine where it is running, but from anywhere on the
|
|
||||||
Internet and from a wide variety of machine architectures.
|
|
||||||
|
|
||||||
KasmVNC has different goals than TigerVNC:
|
|
||||||
|
|
||||||
Web-based - KasmVNC is designed to provide a web accessible remote desktop.
|
|
||||||
It comes with a web server and web-socket server built in. There is no need to
|
|
||||||
install other components. Simply run and navigate to your desktop's URL on the
|
|
||||||
port you specify. While you can still tun on the legacy VNC port, it is
|
|
||||||
disabled by default.
|
|
||||||
|
|
||||||
Security - KasmVNC defaults to HTTPS and allows for HTTP Basic Auth. VNC
|
|
||||||
Password authentication is limited by specification to 8 characters and is not
|
|
||||||
sufficient for use on an internet accessible remote desktop. Our goal is to
|
|
||||||
create a by default secure, web based experience.
|
|
||||||
|
|
||||||
Simplicity - KasmVNC aims at being simple to deploy and configure.
|
|
||||||
|
|
||||||
%prep
|
|
||||||
|
|
||||||
%install
|
|
||||||
rm -rf $RPM_BUILD_ROOT
|
|
||||||
|
|
||||||
TARGET_OS=$KASMVNC_BUILD_OS
|
|
||||||
TARGET_OS_CODENAME=$KASMVNC_BUILD_OS_CODENAME
|
|
||||||
TARBALL=$RPM_SOURCE_DIR/kasmvnc.${TARGET_OS}_${TARGET_OS_CODENAME}.tar.gz
|
|
||||||
TAR_DATA=$(mktemp -d)
|
|
||||||
tar -xzf "$TARBALL" -C "$TAR_DATA"
|
|
||||||
|
|
||||||
SRC=$TAR_DATA/usr/local
|
|
||||||
SRC_BIN=$SRC/bin
|
|
||||||
DESTDIR=$RPM_BUILD_ROOT
|
|
||||||
DST_MAN=$DESTDIR/usr/share/man/man1
|
|
||||||
|
|
||||||
mkdir -p $DESTDIR/usr/bin $DESTDIR/usr/share/man/man1 \
|
|
||||||
$DESTDIR/usr/share/doc/kasmvncserver
|
|
||||||
cp $SRC_BIN/Xvnc $DESTDIR/usr/bin;
|
|
||||||
cp $SRC_BIN/vncserver $DESTDIR/usr/bin;
|
|
||||||
cp $SRC_BIN/vncconfig $DESTDIR/usr/bin;
|
|
||||||
cp $SRC_BIN/kasmvncpasswd $DESTDIR/usr/bin;
|
|
||||||
cp $SRC_BIN/kasmxproxy $DESTDIR/usr/bin;
|
|
||||||
cd $DESTDIR/usr/bin && ln -s kasmvncpasswd vncpasswd;
|
|
||||||
cp -r $SRC/share/doc/kasmvnc*/* $DESTDIR/usr/share/doc/kasmvncserver/
|
|
||||||
rsync -r --exclude '.git*' --exclude po2js --exclude xgettext-html \
|
|
||||||
--exclude www/utils/ --exclude .eslintrc \
|
|
||||||
$SRC/share/kasmvnc $DESTDIR/usr/share
|
|
||||||
cp $SRC/man/man1/Xvnc.1 $DESTDIR/usr/share/man/man1/;
|
|
||||||
cp $SRC/share/man/man1/vncserver.1 $DST_MAN;
|
|
||||||
cp $SRC/share/man/man1/vncconfig.1 $DST_MAN;
|
|
||||||
cp $SRC/share/man/man1/vncpasswd.1 $DST_MAN;
|
|
||||||
cp $SRC/share/man/man1/kasmxproxy.1 $DST_MAN;
|
|
||||||
cd $DST_MAN && ln -s vncpasswd.1 kasmvncpasswd.1;
|
|
||||||
|
|
||||||
|
|
||||||
%files
|
|
||||||
/usr/bin/*
|
|
||||||
/usr/share/man/man1/*
|
|
||||||
/usr/share/kasmvnc/www
|
|
||||||
|
|
||||||
%license /usr/share/doc/kasmvncserver/LICENSE.TXT
|
|
||||||
%doc /usr/share/doc/kasmvncserver/README.md
|
|
||||||
|
|
||||||
%changelog
|
|
||||||
* Tue Mar 22 2022 KasmTech <info@kasmweb.com> - 0.9.3~beta-1
|
|
||||||
* Fri Feb 12 2021 KasmTech <info@kasmweb.com> - 0.9.1~beta-1
|
|
||||||
- Initial release of the rpm package.
|
|
||||||
|
|
||||||
%post
|
|
||||||
kasmvnc_group="kasmvnc-cert"
|
|
||||||
|
|
||||||
create_kasmvnc_group() {
|
|
||||||
if ! getent group "$kasmvnc_group" >/dev/null; then
|
|
||||||
groupadd --system "$kasmvnc_group"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
make_self_signed_certificate() {
|
|
||||||
local cert_file=/etc/pki/tls/private/kasmvnc.pem
|
|
||||||
[ -f "$cert_file" ] && return 0
|
|
||||||
|
|
||||||
openssl req -x509 -nodes -days 3650 -newkey rsa:2048 \
|
|
||||||
-keyout "$cert_file" \
|
|
||||||
-out "$cert_file" -subj \
|
|
||||||
"/C=US/ST=VA/L=None/O=None/OU=DoFu/CN=kasm/emailAddress=none@none.none"
|
|
||||||
chgrp "$kasmvnc_group" "$cert_file"
|
|
||||||
chmod 640 "$cert_file"
|
|
||||||
}
|
|
||||||
|
|
||||||
create_kasmvnc_group
|
|
||||||
make_self_signed_certificate
|
|
||||||
|
|
||||||
%postun
|
|
||||||
rm -f /etc/pki/tls/private/kasmvnc.pem
|
|
||||||
@@ -1,108 +0,0 @@
|
|||||||
Name: kasmvncserver
|
|
||||||
Version: 0.9.3~beta
|
|
||||||
Release: 1%{?dist}
|
|
||||||
Summary: VNC server accessible from a web browser
|
|
||||||
|
|
||||||
License: GPLv2+
|
|
||||||
URL: https://github.com/kasmtech/KasmVNC
|
|
||||||
|
|
||||||
BuildRequires: rsync
|
|
||||||
Requires: xorg-x11-xauth, xorg-x11-xkb-utils, xkeyboard-config, xorg-x11-server-utils, openssl, perl
|
|
||||||
Conflicts: tigervnc-server, tigervnc-server-minimal
|
|
||||||
|
|
||||||
%description
|
|
||||||
VNC stands for Virtual Network Computing. It is, in essence, a remote
|
|
||||||
display system which allows you to view a computing `desktop' environment
|
|
||||||
not only on the machine where it is running, but from anywhere on the
|
|
||||||
Internet and from a wide variety of machine architectures.
|
|
||||||
|
|
||||||
KasmVNC has different goals than TigerVNC:
|
|
||||||
|
|
||||||
Web-based - KasmVNC is designed to provide a web accessible remote desktop.
|
|
||||||
It comes with a web server and web-socket server built in. There is no need to
|
|
||||||
install other components. Simply run and navigate to your desktop's URL on the
|
|
||||||
port you specify. While you can still tun on the legacy VNC port, it is
|
|
||||||
disabled by default.
|
|
||||||
|
|
||||||
Security - KasmVNC defaults to HTTPS and allows for HTTP Basic Auth. VNC
|
|
||||||
Password authentication is limited by specification to 8 characters and is not
|
|
||||||
sufficient for use on an internet accessible remote desktop. Our goal is to
|
|
||||||
create a by default secure, web based experience.
|
|
||||||
|
|
||||||
Simplicity - KasmVNC aims at being simple to deploy and configure.
|
|
||||||
|
|
||||||
%prep
|
|
||||||
|
|
||||||
%install
|
|
||||||
rm -rf $RPM_BUILD_ROOT
|
|
||||||
|
|
||||||
TARGET_OS=$KASMVNC_BUILD_OS
|
|
||||||
TARGET_OS_CODENAME=$KASMVNC_BUILD_OS_CODENAME
|
|
||||||
TARBALL=$RPM_SOURCE_DIR/kasmvnc.${TARGET_OS}_${TARGET_OS_CODENAME}.tar.gz
|
|
||||||
TAR_DATA=$(mktemp -d)
|
|
||||||
tar -xzf "$TARBALL" -C "$TAR_DATA"
|
|
||||||
|
|
||||||
SRC=$TAR_DATA/usr/local
|
|
||||||
SRC_BIN=$SRC/bin
|
|
||||||
DESTDIR=$RPM_BUILD_ROOT
|
|
||||||
DST_MAN=$DESTDIR/usr/share/man/man1
|
|
||||||
|
|
||||||
mkdir -p $DESTDIR/usr/bin $DESTDIR/usr/share/man/man1 \
|
|
||||||
$DESTDIR/usr/share/doc/kasmvncserver
|
|
||||||
cp $SRC_BIN/Xvnc $DESTDIR/usr/bin;
|
|
||||||
cp $SRC_BIN/vncserver $DESTDIR/usr/bin;
|
|
||||||
cp $SRC_BIN/vncconfig $DESTDIR/usr/bin;
|
|
||||||
cp $SRC_BIN/kasmvncpasswd $DESTDIR/usr/bin;
|
|
||||||
cp $SRC_BIN/kasmxproxy $DESTDIR/usr/bin;
|
|
||||||
cd $DESTDIR/usr/bin && ln -s kasmvncpasswd vncpasswd;
|
|
||||||
cp -r $SRC/share/doc/kasmvnc*/* $DESTDIR/usr/share/doc/kasmvncserver/
|
|
||||||
rsync -r --exclude '.git*' --exclude po2js --exclude xgettext-html \
|
|
||||||
--exclude www/utils/ --exclude .eslintrc \
|
|
||||||
$SRC/share/kasmvnc $DESTDIR/usr/share
|
|
||||||
cp $SRC/man/man1/Xvnc.1 $DESTDIR/usr/share/man/man1/;
|
|
||||||
cp $SRC/share/man/man1/vncserver.1 $DST_MAN;
|
|
||||||
cp $SRC/share/man/man1/vncconfig.1 $DST_MAN;
|
|
||||||
cp $SRC/share/man/man1/vncpasswd.1 $DST_MAN;
|
|
||||||
cp $SRC/share/man/man1/kasmxproxy.1 $DST_MAN;
|
|
||||||
cd $DST_MAN && ln -s vncpasswd.1 kasmvncpasswd.1;
|
|
||||||
|
|
||||||
|
|
||||||
%files
|
|
||||||
/usr/bin/*
|
|
||||||
/usr/share/man/man1/*
|
|
||||||
/usr/share/kasmvnc/www
|
|
||||||
|
|
||||||
%license /usr/share/doc/kasmvncserver/LICENSE.TXT
|
|
||||||
%doc /usr/share/doc/kasmvncserver/README.md
|
|
||||||
|
|
||||||
%changelog
|
|
||||||
* Tue Mar 22 2022 KasmTech <info@kasmweb.com> - 0.9.3~beta-1
|
|
||||||
* Fri Feb 12 2021 KasmTech <info@kasmweb.com> - 0.9.1~beta-1
|
|
||||||
- Initial release of the rpm package.
|
|
||||||
|
|
||||||
%post
|
|
||||||
kasmvnc_group="kasmvnc-cert"
|
|
||||||
|
|
||||||
create_kasmvnc_group() {
|
|
||||||
if ! getent group "$kasmvnc_group" >/dev/null; then
|
|
||||||
groupadd --system "$kasmvnc_group"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
make_self_signed_certificate() {
|
|
||||||
local cert_file=/etc/pki/tls/private/kasmvnc.pem
|
|
||||||
[ -f "$cert_file" ] && return 0
|
|
||||||
|
|
||||||
openssl req -x509 -nodes -days 3650 -newkey rsa:2048 \
|
|
||||||
-keyout "$cert_file" \
|
|
||||||
-out "$cert_file" -subj \
|
|
||||||
"/C=US/ST=VA/L=None/O=None/OU=DoFu/CN=kasm/emailAddress=none@none.none"
|
|
||||||
chgrp "$kasmvnc_group" "$cert_file"
|
|
||||||
chmod 640 "$cert_file"
|
|
||||||
}
|
|
||||||
|
|
||||||
create_kasmvnc_group
|
|
||||||
make_self_signed_certificate
|
|
||||||
|
|
||||||
%postun
|
|
||||||
rm -f /etc/pki/tls/private/kasmvnc.pem
|
|
||||||
@@ -45,7 +45,6 @@ mkdir -p $OUTDIR/man/man1
|
|||||||
|
|
||||||
make DESTDIR=$TMPDIR/inst install
|
make DESTDIR=$TMPDIR/inst install
|
||||||
if [ $SERVER = 1 ]; then
|
if [ $SERVER = 1 ]; then
|
||||||
install -m 755 ./unix/kasmxproxy/kasmxproxy $OUTDIR/bin/
|
|
||||||
install -m 755 ./xorg.build/bin/Xvnc $OUTDIR/bin/
|
install -m 755 ./xorg.build/bin/Xvnc $OUTDIR/bin/
|
||||||
install -m 644 ./xorg.build/man/man1/Xvnc.1 $OUTDIR/man/man1/Xvnc.1
|
install -m 644 ./xorg.build/man/man1/Xvnc.1 $OUTDIR/man/man1/Xvnc.1
|
||||||
install -m 644 ./xorg.build/man/man1/Xserver.1 $OUTDIR/man/man1/Xserver.1
|
install -m 644 ./xorg.build/man/man1/Xserver.1 $OUTDIR/man/man1/Xserver.1
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ add_subdirectory(common)
|
|||||||
add_subdirectory(vncconfig)
|
add_subdirectory(vncconfig)
|
||||||
add_subdirectory(vncpasswd)
|
add_subdirectory(vncpasswd)
|
||||||
add_subdirectory(kasmvncpasswd)
|
add_subdirectory(kasmvncpasswd)
|
||||||
add_subdirectory(kasmxproxy)
|
|
||||||
|
|
||||||
install(PROGRAMS vncserver DESTINATION ${BIN_DIR})
|
install(PROGRAMS vncserver DESTINATION ${BIN_DIR})
|
||||||
install(FILES vncserver.man DESTINATION ${MAN_DIR}/man1 RENAME vncserver.1)
|
install(FILES vncserver.man DESTINATION ${MAN_DIR}/man1 RENAME vncserver.1)
|
||||||
|
|||||||
@@ -1,39 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
URL=https://to-be-filled.com/path
|
|
||||||
|
|
||||||
die() {
|
|
||||||
echo "$@"
|
|
||||||
exit
|
|
||||||
}
|
|
||||||
|
|
||||||
[ "$#" -ne 1 ] && die "Usage: $0 logfile"
|
|
||||||
|
|
||||||
grep -q Backtrace: $1 || die "No crash in log file"
|
|
||||||
|
|
||||||
CURL=`which curl`
|
|
||||||
WGET=`which wget`
|
|
||||||
|
|
||||||
[ -n "$CURL" -o -n "$WGET" ] || die "Curl or wget required"
|
|
||||||
|
|
||||||
BIN=`grep vnc $1 | tail -n1 | cut -d: -f2 | cut -d\( -f1`
|
|
||||||
[ -f $BIN ] || die "Can't locate binary"
|
|
||||||
|
|
||||||
#
|
|
||||||
# prep done, filter the log file
|
|
||||||
#
|
|
||||||
|
|
||||||
TMP=`mktemp`
|
|
||||||
|
|
||||||
LANG=C date >> $TMP
|
|
||||||
md5sum $BIN >> $TMP
|
|
||||||
$BIN -version 2>&1 | grep built >> $TMP
|
|
||||||
grep -A200 Backtrace: $1 >> $TMP
|
|
||||||
|
|
||||||
if [ -n "$CURL" ]; then
|
|
||||||
echo curl --data-binary @"$TMP" "$URL"
|
|
||||||
else
|
|
||||||
echo wget --post-file "$TMP" "$URL"
|
|
||||||
fi
|
|
||||||
|
|
||||||
rm $TMP
|
|
||||||
@@ -60,8 +60,6 @@ struct kasmpasswd_t *readkasmpasswd(const char path[]) {
|
|||||||
strcpy(set->entries[cur].user, buf);
|
strcpy(set->entries[cur].user, buf);
|
||||||
strcpy(set->entries[cur].password, pw);
|
strcpy(set->entries[cur].password, pw);
|
||||||
|
|
||||||
if (strchr(perms, 'r'))
|
|
||||||
set->entries[cur].read = 1;
|
|
||||||
if (strchr(perms, 'w'))
|
if (strchr(perms, 'w'))
|
||||||
set->entries[cur].write = 1;
|
set->entries[cur].write = 1;
|
||||||
if (strchr(perms, 'o'))
|
if (strchr(perms, 'o'))
|
||||||
@@ -92,17 +90,22 @@ void writekasmpasswd(const char path[], const struct kasmpasswd_t *set) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const char * const perms[] = {
|
||||||
|
"",
|
||||||
|
"w",
|
||||||
|
"o",
|
||||||
|
"ow"
|
||||||
|
};
|
||||||
|
|
||||||
unsigned i;
|
unsigned i;
|
||||||
for (i = 0; i < set->num; i++) {
|
for (i = 0; i < set->num; i++) {
|
||||||
if (!set->entries[i].user[0])
|
if (!set->entries[i].user[0])
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
fprintf(f, "%s:%s:%s%s%s\n",
|
fprintf(f, "%s:%s:%s\n",
|
||||||
set->entries[i].user,
|
set->entries[i].user,
|
||||||
set->entries[i].password,
|
set->entries[i].password,
|
||||||
set->entries[i].read ? "r" : "",
|
perms[set->entries[i].owner * 2 + set->entries[i].write]);
|
||||||
set->entries[i].write ? "w" : "",
|
|
||||||
set->entries[i].owner ? "o" : "");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fsync(fileno(f));
|
fsync(fileno(f));
|
||||||
|
|||||||
@@ -8,14 +8,10 @@ extern "C" {
|
|||||||
struct kasmpasswd_entry_t {
|
struct kasmpasswd_entry_t {
|
||||||
char user[32];
|
char user[32];
|
||||||
char password[128];
|
char password[128];
|
||||||
unsigned char read : 1;
|
|
||||||
unsigned char write : 1;
|
unsigned char write : 1;
|
||||||
unsigned char owner : 1;
|
unsigned char owner : 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define USERNAME_LEN sizeof(((struct kasmpasswd_entry_t *)0)->user)
|
|
||||||
#define PASSWORD_LEN sizeof(((struct kasmpasswd_entry_t *)0)->password)
|
|
||||||
|
|
||||||
struct kasmpasswd_t {
|
struct kasmpasswd_t {
|
||||||
struct kasmpasswd_entry_t *entries;
|
struct kasmpasswd_entry_t *entries;
|
||||||
unsigned num;
|
unsigned num;
|
||||||
|
|||||||
@@ -34,7 +34,6 @@
|
|||||||
static void usage(const char *prog)
|
static void usage(const char *prog)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Usage: %s -u username [-wnod] [file]\n"
|
fprintf(stderr, "Usage: %s -u username [-wnod] [file]\n"
|
||||||
"-r Read permission\n"
|
|
||||||
"-w Write permission\n"
|
"-w Write permission\n"
|
||||||
"-o Owner\n"
|
"-o Owner\n"
|
||||||
"-n Don't change password, change permissions only\n"
|
"-n Don't change password, change permissions only\n"
|
||||||
@@ -119,10 +118,10 @@ int main(int argc, char** argv)
|
|||||||
{
|
{
|
||||||
const char *fname = NULL;
|
const char *fname = NULL;
|
||||||
const char *user = NULL;
|
const char *user = NULL;
|
||||||
const char args[] = "u:rwnod";
|
const char args[] = "u:wnod";
|
||||||
int opt;
|
int opt;
|
||||||
|
|
||||||
unsigned char nopass = 0, reader = 0, writer = 0, owner = 0, deleting = 0;
|
unsigned char nopass = 0, writer = 0, owner = 0, deleting = 0;
|
||||||
|
|
||||||
while ((opt = getopt(argc, argv, args)) != -1) {
|
while ((opt = getopt(argc, argv, args)) != -1) {
|
||||||
switch (opt) {
|
switch (opt) {
|
||||||
@@ -136,9 +135,6 @@ int main(int argc, char** argv)
|
|||||||
case 'n':
|
case 'n':
|
||||||
nopass = 1;
|
nopass = 1;
|
||||||
break;
|
break;
|
||||||
case 'r':
|
|
||||||
reader = 1;
|
|
||||||
break;
|
|
||||||
case 'w':
|
case 'w':
|
||||||
writer = 1;
|
writer = 1;
|
||||||
break;
|
break;
|
||||||
@@ -154,7 +150,7 @@ int main(int argc, char** argv)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (deleting && (nopass || reader || writer || owner))
|
if (deleting && (nopass || writer || owner))
|
||||||
usage(argv[0]);
|
usage(argv[0]);
|
||||||
|
|
||||||
if (!user)
|
if (!user)
|
||||||
@@ -179,7 +175,6 @@ int main(int argc, char** argv)
|
|||||||
if (nopass) {
|
if (nopass) {
|
||||||
for (i = 0; i < set->num; i++) {
|
for (i = 0; i < set->num; i++) {
|
||||||
if (!strcmp(set->entries[i].user, user)) {
|
if (!strcmp(set->entries[i].user, user)) {
|
||||||
set->entries[i].read = reader;
|
|
||||||
set->entries[i].write = writer;
|
set->entries[i].write = writer;
|
||||||
set->entries[i].owner = owner;
|
set->entries[i].owner = owner;
|
||||||
|
|
||||||
@@ -216,7 +211,6 @@ int main(int argc, char** argv)
|
|||||||
|
|
||||||
strcpy(set->entries[i].user, user);
|
strcpy(set->entries[i].user, user);
|
||||||
strcpy(set->entries[i].password, encrypted);
|
strcpy(set->entries[i].password, encrypted);
|
||||||
set->entries[i].read = reader;
|
|
||||||
set->entries[i].write = writer;
|
set->entries[i].write = writer;
|
||||||
set->entries[i].owner = owner;
|
set->entries[i].owner = owner;
|
||||||
|
|
||||||
|
|||||||
1
unix/kasmxproxy/.gitignore
vendored
1
unix/kasmxproxy/.gitignore
vendored
@@ -1 +0,0 @@
|
|||||||
kasmxproxy
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
include_directories(${X11_INCLUDE_DIR})
|
|
||||||
|
|
||||||
add_executable(kasmxproxy
|
|
||||||
xxhash.c
|
|
||||||
kasmxproxy.c)
|
|
||||||
|
|
||||||
target_link_libraries(kasmxproxy ${X11_LIBRARIES} ${X11_XTest_LIB} ${X11_Xrandr_LIB}
|
|
||||||
${X11_Xcursor_LIB} ${X11_Xfixes_LIB})
|
|
||||||
|
|
||||||
install(TARGETS kasmxproxy DESTINATION ${BIN_DIR})
|
|
||||||
install(FILES kasmxproxy.man DESTINATION ${MAN_DIR}/man1 RENAME kasmxproxy.1)
|
|
||||||
@@ -1,530 +0,0 @@
|
|||||||
/* Copyright (C) 2021 Kasm. All Rights Reserved.
|
|
||||||
*
|
|
||||||
* This is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This software is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this software; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
|
||||||
* USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <getopt.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <sys/ipc.h>
|
|
||||||
#include <sys/shm.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <X11/Xatom.h>
|
|
||||||
#include <X11/Xlib.h>
|
|
||||||
#include <X11/Xutil.h>
|
|
||||||
#include <X11/Xcursor/Xcursor.h>
|
|
||||||
#include <X11/extensions/Xfixes.h>
|
|
||||||
#include <X11/extensions/Xrandr.h>
|
|
||||||
#include <X11/extensions/XShm.h>
|
|
||||||
#include <X11/extensions/XTest.h>
|
|
||||||
|
|
||||||
#include "xxhash.h"
|
|
||||||
|
|
||||||
#define min(a, b) ((a) < (b) ? (a) : (b))
|
|
||||||
|
|
||||||
static void help(const char name[]) {
|
|
||||||
printf("Usage: %s [opts]\n\n"
|
|
||||||
"-a --app-display disp App display, default :0\n"
|
|
||||||
"-v --vnc-display disp VNC display, default :1\n"
|
|
||||||
"\n"
|
|
||||||
"-f --fps fps FPS, default 30\n"
|
|
||||||
"-r --resize Enable resize, default disabled.\n"
|
|
||||||
" Do not enable this if there's a physical screen\n"
|
|
||||||
" connected to the app display.\n",
|
|
||||||
name);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
#define CUT_MAX (16 * 1024)
|
|
||||||
static uint8_t cutbuf[CUT_MAX];
|
|
||||||
|
|
||||||
static void supplyselection(Display *disp, const XEvent * const ev, const Atom xa_targets) {
|
|
||||||
XSelectionEvent sev;
|
|
||||||
|
|
||||||
sev.type = SelectionNotify;
|
|
||||||
sev.display = disp;
|
|
||||||
sev.requestor = ev->xselectionrequest.requestor;
|
|
||||||
sev.selection = ev->xselectionrequest.selection;
|
|
||||||
sev.target = ev->xselectionrequest.target;
|
|
||||||
sev.time = ev->xselectionrequest.time;
|
|
||||||
/*printf("someone wants our clipboard, sel %lu, tgt %lu, prop %lu\n",
|
|
||||||
sev.selection, sev.target,
|
|
||||||
ev.xselectionrequest.property);*/
|
|
||||||
|
|
||||||
if (ev->xselectionrequest.property == None)
|
|
||||||
sev.property = sev.target;
|
|
||||||
else
|
|
||||||
sev.property = ev->xselectionrequest.property;
|
|
||||||
|
|
||||||
const uint32_t len = strlen((char *) cutbuf);
|
|
||||||
|
|
||||||
if (xa_targets != None &&
|
|
||||||
sev.target == xa_targets) {
|
|
||||||
// Which formats can we do
|
|
||||||
Atom tgt[2] = {
|
|
||||||
xa_targets,
|
|
||||||
XA_STRING
|
|
||||||
};
|
|
||||||
|
|
||||||
XChangeProperty(disp, sev.requestor,
|
|
||||||
ev->xselectionrequest.property,
|
|
||||||
XA_ATOM, 32,
|
|
||||||
PropModeReplace,
|
|
||||||
(unsigned char *) tgt,
|
|
||||||
2);
|
|
||||||
//puts("sent targets");
|
|
||||||
} else {
|
|
||||||
// Data
|
|
||||||
XChangeProperty(disp, sev.requestor,
|
|
||||||
ev->xselectionrequest.property,
|
|
||||||
sev.target, 8,
|
|
||||||
PropModeReplace,
|
|
||||||
cutbuf, len);
|
|
||||||
//printf("sent data, of len %u\n", len);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Send the notify event
|
|
||||||
XSendEvent(disp, sev.requestor, False, 0,
|
|
||||||
(XEvent *) &sev);
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
|
||||||
|
|
||||||
const char *appstr = ":0";
|
|
||||||
const char *vncstr = ":1";
|
|
||||||
uint8_t resize = 0;
|
|
||||||
uint8_t fps = 30;
|
|
||||||
|
|
||||||
const struct option longargs[] = {
|
|
||||||
{"app-display", 1, NULL, 'a'},
|
|
||||||
{"vnc-display", 1, NULL, 'v'},
|
|
||||||
{"resize", 0, NULL, 'r'},
|
|
||||||
{"fps", 1, NULL, 'f'},
|
|
||||||
|
|
||||||
{NULL, 0, NULL, 0},
|
|
||||||
};
|
|
||||||
|
|
||||||
while (1) {
|
|
||||||
int c = getopt_long(argc, argv, "a:v:rf:", longargs, NULL);
|
|
||||||
if (c == -1)
|
|
||||||
break;
|
|
||||||
switch (c) {
|
|
||||||
case 'a':
|
|
||||||
appstr = strdup(optarg);
|
|
||||||
break;
|
|
||||||
case 'v':
|
|
||||||
vncstr = strdup(optarg);
|
|
||||||
break;
|
|
||||||
case 'r':
|
|
||||||
resize = 1;
|
|
||||||
break;
|
|
||||||
case 'f':
|
|
||||||
fps = atoi(optarg);
|
|
||||||
if (fps < 1 || fps > 120) {
|
|
||||||
printf("Invalid fps\n");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
help(argv[0]);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Display *appdisp = XOpenDisplay(appstr);
|
|
||||||
if (!appdisp) {
|
|
||||||
printf("Cannot open display %s\n", appstr);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
if (!XShmQueryExtension(appdisp)) {
|
|
||||||
printf("Display %s lacks SHM extension\n", appstr);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
Display *vncdisp = XOpenDisplay(vncstr);
|
|
||||||
if (!vncdisp) {
|
|
||||||
printf("Cannot open display %s\n", vncstr);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
if (!XShmQueryExtension(vncdisp)) {
|
|
||||||
printf("Display %s lacks SHM extension\n", vncstr);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
const int appscreen = DefaultScreen(appdisp);
|
|
||||||
const int vncscreen = DefaultScreen(vncdisp);
|
|
||||||
Visual *appvis = DefaultVisual(appdisp, appscreen);
|
|
||||||
//Visual *vncvis = DefaultVisual(vncdisp, vncscreen);
|
|
||||||
const int appdepth = DefaultDepth(appdisp, appscreen);
|
|
||||||
const int vncdepth = DefaultDepth(vncdisp, vncscreen);
|
|
||||||
if (appdepth != vncdepth) {
|
|
||||||
printf("Depths don't match, app %u vnc %u\n", appdepth, vncdepth);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
Window approot = DefaultRootWindow(appdisp);
|
|
||||||
Window vncroot = DefaultRootWindow(vncdisp);
|
|
||||||
XWindowAttributes appattr, vncattr;
|
|
||||||
|
|
||||||
XGCValues gcval;
|
|
||||||
gcval.plane_mask = AllPlanes;
|
|
||||||
gcval.function = GXcopy;
|
|
||||||
GC gc = XCreateGC(vncdisp, vncroot, GCFunction | GCPlaneMask, &gcval);
|
|
||||||
|
|
||||||
XImage *img = NULL;
|
|
||||||
XShmSegmentInfo shminfo;
|
|
||||||
unsigned imgw = 0, imgh = 0;
|
|
||||||
|
|
||||||
if (XGrabPointer(vncdisp, vncroot, False,
|
|
||||||
ButtonPressMask | ButtonReleaseMask | PointerMotionMask,
|
|
||||||
GrabModeAsync, GrabModeAsync, None, None,
|
|
||||||
CurrentTime) != Success)
|
|
||||||
return 1;
|
|
||||||
if (XGrabKeyboard(vncdisp, vncroot, False, GrabModeAsync, GrabModeAsync,
|
|
||||||
CurrentTime) != Success)
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
int xfixesbase, xfixeserrbase;
|
|
||||||
XFixesQueryExtension(appdisp, &xfixesbase, &xfixeserrbase);
|
|
||||||
XFixesSelectSelectionInput(appdisp, approot, XA_PRIMARY,
|
|
||||||
XFixesSetSelectionOwnerNotifyMask);
|
|
||||||
|
|
||||||
int xfixesbasevnc, xfixeserrbasevnc;
|
|
||||||
XFixesQueryExtension(vncdisp, &xfixesbasevnc, &xfixeserrbasevnc);
|
|
||||||
XFixesSelectSelectionInput(vncdisp, vncroot, XA_PRIMARY,
|
|
||||||
XFixesSetSelectionOwnerNotifyMask);
|
|
||||||
|
|
||||||
Atom xa_targets_vnc = XInternAtom(vncdisp, "TARGETS", False);
|
|
||||||
Atom xa_targets_app = XInternAtom(appdisp, "TARGETS", False);
|
|
||||||
Window selwin = XCreateSimpleWindow(appdisp, approot, 3, 2, 1, 1, 0, 0, 0);
|
|
||||||
Window vncselwin = XCreateSimpleWindow(vncdisp, vncroot, 3, 2, 1, 1, 0, 0, 0);
|
|
||||||
|
|
||||||
XFixesCursorImage *cursor = NULL;
|
|
||||||
uint64_t cursorhash = 0;
|
|
||||||
Cursor xcursor = None;
|
|
||||||
|
|
||||||
const unsigned sleeptime = 1000 * 1000 / fps;
|
|
||||||
|
|
||||||
while (1) {
|
|
||||||
if (!XGetWindowAttributes(appdisp, approot, &appattr))
|
|
||||||
break;
|
|
||||||
if (!XGetWindowAttributes(vncdisp, vncroot, &vncattr))
|
|
||||||
break;
|
|
||||||
if (resize && (appattr.width != vncattr.width ||
|
|
||||||
appattr.height != vncattr.height)) {
|
|
||||||
// resize app display to VNC display size
|
|
||||||
XRRScreenConfiguration *config = XRRGetScreenInfo(appdisp, approot);
|
|
||||||
|
|
||||||
int nsizes, i, match = -1;
|
|
||||||
XRRScreenSize *sizes = XRRConfigSizes(config, &nsizes);
|
|
||||||
//printf("%u sizes\n", nsizes);
|
|
||||||
for (i = 0; i < nsizes; i++) {
|
|
||||||
if (sizes[i].width == vncattr.width &&
|
|
||||||
sizes[i].height == vncattr.height) {
|
|
||||||
//printf("match %u\n", i);
|
|
||||||
match = i;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (match >= 0) {
|
|
||||||
XRRSetScreenConfig(appdisp, config, approot, match,
|
|
||||||
RR_Rotate_0, CurrentTime);
|
|
||||||
} else {
|
|
||||||
/*XRRSetScreenSize(appdisp, approot,
|
|
||||||
vncattr.width, vncattr.height,
|
|
||||||
sizes[0].mwidth, sizes[0].mheight);*/
|
|
||||||
XRRScreenResources *res = XRRGetScreenResources(appdisp, approot);
|
|
||||||
//printf("%u outputs, %u crtcs\n", res->noutput, res->ncrtc);
|
|
||||||
// Nvidia crap uses a *different* list for 1.0 and 1.2!
|
|
||||||
unsigned oldmode = 0xffff;
|
|
||||||
//printf("1.2 modes %u\n", res->nmode);
|
|
||||||
for (i = 0; i < res->nmode; i++) {
|
|
||||||
if (res->modes[i].width == vncattr.width &&
|
|
||||||
res->modes[i].height == vncattr.height) {
|
|
||||||
oldmode = i;
|
|
||||||
//printf("old mode %u matched\n", i);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned tgt = 0;
|
|
||||||
if (res->noutput > 1) {
|
|
||||||
for (i = 0; i < res->noutput; i++) {
|
|
||||||
XRROutputInfo *info = XRRGetOutputInfo(appdisp, res, res->outputs[i]);
|
|
||||||
if (info->connection == RR_Connected)
|
|
||||||
tgt = i;
|
|
||||||
//printf("%u %s %u\n", i, info->name, info->connection);
|
|
||||||
XRRFreeOutputInfo(info);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (oldmode < 0xffff) {
|
|
||||||
Status s;
|
|
||||||
// nvidia needs this weird dance
|
|
||||||
s = XRRSetCrtcConfig(appdisp, res, res->crtcs[tgt],
|
|
||||||
CurrentTime,
|
|
||||||
0, 0,
|
|
||||||
None, RR_Rotate_0,
|
|
||||||
NULL, 0);
|
|
||||||
//printf("disable %u\n", s);
|
|
||||||
XRRSetScreenSize(appdisp, approot,
|
|
||||||
vncattr.width, vncattr.height,
|
|
||||||
sizes[0].mwidth, sizes[0].mheight);
|
|
||||||
s = XRRSetCrtcConfig(appdisp, res, res->crtcs[tgt],
|
|
||||||
CurrentTime,
|
|
||||||
0, 0,
|
|
||||||
res->modes[oldmode].id, RR_Rotate_0,
|
|
||||||
&res->outputs[tgt], 1);
|
|
||||||
//printf("set %u\n", s);
|
|
||||||
} else {
|
|
||||||
char name[32];
|
|
||||||
sprintf(name, "%ux%u_60", vncattr.width, vncattr.height);
|
|
||||||
printf("Creating new Mode %s\n", name);
|
|
||||||
XRRModeInfo *mode = XRRAllocModeInfo(name, strlen(name));
|
|
||||||
|
|
||||||
mode->width = vncattr.width;
|
|
||||||
mode->height = vncattr.height;
|
|
||||||
|
|
||||||
RRMode rmode = XRRCreateMode(appdisp, approot, mode);
|
|
||||||
XRRAddOutputMode(appdisp,
|
|
||||||
res->outputs[tgt],
|
|
||||||
rmode);
|
|
||||||
XRRFreeModeInfo(mode);
|
|
||||||
}
|
|
||||||
|
|
||||||
XRRFreeScreenResources(res);
|
|
||||||
}
|
|
||||||
|
|
||||||
XRRFreeScreenConfigInfo(config);
|
|
||||||
}
|
|
||||||
|
|
||||||
const unsigned w = min(appattr.width, vncattr.width);
|
|
||||||
const unsigned h = min(appattr.height, vncattr.height);
|
|
||||||
|
|
||||||
if (w != imgw || h != imgh) {
|
|
||||||
if (img) {
|
|
||||||
XShmDetach(appdisp, &shminfo);
|
|
||||||
XDestroyImage(img);
|
|
||||||
shmdt(shminfo.shmaddr);
|
|
||||||
shmctl(shminfo.shmid, IPC_RMID, NULL);
|
|
||||||
}
|
|
||||||
img = XShmCreateImage(appdisp, appvis, appdepth, ZPixmap,
|
|
||||||
NULL, &shminfo, w, h);
|
|
||||||
if (!img)
|
|
||||||
break;
|
|
||||||
|
|
||||||
shminfo.shmid = shmget(IPC_PRIVATE,
|
|
||||||
img->bytes_per_line * img->height,
|
|
||||||
IPC_CREAT | 0666);
|
|
||||||
if (shminfo.shmid == -1)
|
|
||||||
break;
|
|
||||||
shminfo.shmaddr = img->data = shmat(shminfo.shmid, 0, 0);
|
|
||||||
shminfo.readOnly = False;
|
|
||||||
if (!XShmAttach(appdisp, &shminfo))
|
|
||||||
break;
|
|
||||||
|
|
||||||
imgw = w;
|
|
||||||
imgh = h;
|
|
||||||
}
|
|
||||||
|
|
||||||
XShmGetImage(appdisp, approot, img, 0, 0, 0xffffffff);
|
|
||||||
XPutImage(vncdisp, vncroot, gc, img, 0, 0, 0, 0, w, h);
|
|
||||||
|
|
||||||
// Handle events
|
|
||||||
while (XPending(vncdisp)) {
|
|
||||||
XEvent ev;
|
|
||||||
XNextEvent(vncdisp, &ev);
|
|
||||||
|
|
||||||
if (ev.type == xfixesbasevnc + XFixesSelectionNotify) {
|
|
||||||
XFixesSelectionNotifyEvent *xfe =
|
|
||||||
(XFixesSelectionNotifyEvent *) &ev;
|
|
||||||
// printf("vnc disp did a copy, owner %lu, root %lu\n",
|
|
||||||
// xfe->owner, vncroot);
|
|
||||||
if (xfe->owner == None || xfe->owner == vncroot)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
XConvertSelection(vncdisp, XA_PRIMARY, XA_STRING, XA_STRING,
|
|
||||||
vncselwin, CurrentTime);
|
|
||||||
} else switch (ev.type) {
|
|
||||||
case KeyPress:
|
|
||||||
case KeyRelease:
|
|
||||||
XTestFakeKeyEvent(appdisp, ev.xkey.keycode,
|
|
||||||
ev.type == KeyPress,
|
|
||||||
CurrentTime);
|
|
||||||
break;
|
|
||||||
case ButtonPress:
|
|
||||||
case ButtonRelease:
|
|
||||||
XTestFakeButtonEvent(appdisp, ev.xbutton.button,
|
|
||||||
ev.type == ButtonPress,
|
|
||||||
CurrentTime);
|
|
||||||
break;
|
|
||||||
case MotionNotify:
|
|
||||||
XTestFakeMotionEvent(appdisp, appscreen,
|
|
||||||
ev.xmotion.x,
|
|
||||||
ev.xmotion.y,
|
|
||||||
CurrentTime);
|
|
||||||
break;
|
|
||||||
case SelectionRequest:
|
|
||||||
supplyselection(vncdisp, &ev, xa_targets_vnc);
|
|
||||||
break;
|
|
||||||
case SelectionNotify:
|
|
||||||
{
|
|
||||||
Atom realtype;
|
|
||||||
int fmt;
|
|
||||||
unsigned long nitems, bytes_rem;
|
|
||||||
unsigned char *data;
|
|
||||||
if (XGetWindowProperty(vncdisp, vncselwin,
|
|
||||||
XA_STRING,
|
|
||||||
0, CUT_MAX / 4,
|
|
||||||
False, AnyPropertyType,
|
|
||||||
&realtype, &fmt,
|
|
||||||
&nitems, &bytes_rem,
|
|
||||||
&data) == Success) {
|
|
||||||
|
|
||||||
if (bytes_rem) {
|
|
||||||
printf("Clipboard too large, ignoring\n");
|
|
||||||
} else {
|
|
||||||
const uint32_t len = nitems * (fmt / 8);
|
|
||||||
//printf("realtype %lu, fmt %u, nitems %lu\n",
|
|
||||||
// realtype, fmt, nitems);
|
|
||||||
memcpy(cutbuf, data, len);
|
|
||||||
if (len < CUT_MAX)
|
|
||||||
cutbuf[len] = 0;
|
|
||||||
else
|
|
||||||
cutbuf[CUT_MAX - 1] = 0;
|
|
||||||
|
|
||||||
// Send it to the app screen
|
|
||||||
XSetSelectionOwner(appdisp, XA_PRIMARY,
|
|
||||||
approot,
|
|
||||||
CurrentTime);
|
|
||||||
}
|
|
||||||
|
|
||||||
XFree(data);
|
|
||||||
} else {
|
|
||||||
printf("Failed to fetch vnc clipboard\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case SelectionClear:
|
|
||||||
cutbuf[0] = '\0';
|
|
||||||
XSetSelectionOwner(appdisp, XA_PRIMARY, None,
|
|
||||||
CurrentTime);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
printf("Unexpected event type %u\n", ev.type);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// App-side events
|
|
||||||
while (XPending(appdisp)) {
|
|
||||||
XEvent ev;
|
|
||||||
XNextEvent(appdisp, &ev);
|
|
||||||
|
|
||||||
if (ev.type == xfixesbase + XFixesSelectionNotify) {
|
|
||||||
XFixesSelectionNotifyEvent *xfe =
|
|
||||||
(XFixesSelectionNotifyEvent *) &ev;
|
|
||||||
//printf("app disp did a copy, owner %lu\n", xfe->owner);
|
|
||||||
if (xfe->owner == None || xfe->owner == approot)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
XConvertSelection(appdisp, XA_PRIMARY, XA_STRING, XA_STRING,
|
|
||||||
selwin, CurrentTime);
|
|
||||||
} else switch (ev.type) {
|
|
||||||
case SelectionNotify:
|
|
||||||
{
|
|
||||||
Atom realtype;
|
|
||||||
int fmt;
|
|
||||||
unsigned long nitems, bytes_rem;
|
|
||||||
unsigned char *data;
|
|
||||||
if (XGetWindowProperty(appdisp, selwin,
|
|
||||||
XA_STRING,
|
|
||||||
0, CUT_MAX / 4,
|
|
||||||
False, AnyPropertyType,
|
|
||||||
&realtype, &fmt,
|
|
||||||
&nitems, &bytes_rem,
|
|
||||||
&data) == Success) {
|
|
||||||
|
|
||||||
if (bytes_rem) {
|
|
||||||
printf("Clipboard too large, ignoring\n");
|
|
||||||
} else {
|
|
||||||
const uint32_t len = nitems * (fmt / 8);
|
|
||||||
//printf("realtype %lu, fmt %u, nitems %lu\n",
|
|
||||||
// realtype, fmt, nitems);
|
|
||||||
memcpy(cutbuf, data, len);
|
|
||||||
if (len < CUT_MAX)
|
|
||||||
cutbuf[len] = 0;
|
|
||||||
else
|
|
||||||
cutbuf[CUT_MAX - 1] = 0;
|
|
||||||
|
|
||||||
// Send it to the VNC screen
|
|
||||||
XSetSelectionOwner(vncdisp, XA_PRIMARY,
|
|
||||||
vncroot,
|
|
||||||
CurrentTime);
|
|
||||||
}
|
|
||||||
|
|
||||||
XFree(data);
|
|
||||||
} else {
|
|
||||||
printf("Failed to fetch app clipboard\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case SelectionRequest:
|
|
||||||
supplyselection(appdisp, &ev, xa_targets_app);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
printf("Unexpected app event type %u\n", ev.type);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Cursors
|
|
||||||
cursor = XFixesGetCursorImage(appdisp);
|
|
||||||
uint64_t newhash = XXH64(cursor->pixels,
|
|
||||||
cursor->width * cursor->height * sizeof(unsigned long),
|
|
||||||
0);
|
|
||||||
if (cursorhash != newhash) {
|
|
||||||
if (cursorhash)
|
|
||||||
XFreeCursor(vncdisp, xcursor);
|
|
||||||
|
|
||||||
XcursorImage *converted = XcursorImageCreate(cursor->width, cursor->height);
|
|
||||||
|
|
||||||
converted->xhot = cursor->xhot;
|
|
||||||
converted->yhot = cursor->yhot;
|
|
||||||
unsigned i;
|
|
||||||
for (i = 0; i < cursor->width * cursor->height; i++) {
|
|
||||||
converted->pixels[i] = cursor->pixels[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
xcursor = XcursorImageLoadCursor(vncdisp, converted);
|
|
||||||
XDefineCursor(vncdisp, vncroot, xcursor);
|
|
||||||
|
|
||||||
XcursorImageDestroy(converted);
|
|
||||||
|
|
||||||
cursorhash = newhash;
|
|
||||||
}
|
|
||||||
|
|
||||||
usleep(sleeptime);
|
|
||||||
}
|
|
||||||
|
|
||||||
XCloseDisplay(appdisp);
|
|
||||||
XCloseDisplay(vncdisp);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
@@ -1,46 +0,0 @@
|
|||||||
.TH kasmxproxy 1 "" "KasmVNC" "Virtual Network Computing"
|
|
||||||
.SH NAME
|
|
||||||
kasmxproxy \- proxy an existing X11 display to a KasmVNC display
|
|
||||||
.SH SYNOPSIS
|
|
||||||
.B kasmxproxy
|
|
||||||
.RB [ \-a|\-\-app\-display
|
|
||||||
.IR source\-display ]
|
|
||||||
.RB [ \-v|\-\-vnc\-display
|
|
||||||
.IR destination\-display ]
|
|
||||||
.RB [ \-f|\-\-fps
|
|
||||||
.IR FPS ]
|
|
||||||
.RB [ \-r|\-\-resize ]
|
|
||||||
.br
|
|
||||||
|
|
||||||
.SH DESCRIPTION
|
|
||||||
.B kasmxproxy
|
|
||||||
is used to proxy an x display, usually attached to a physical GPU, to KasmVNC display. This is usually used in the context of providing GPU acceleration to a KasmVNC session.
|
|
||||||
|
|
||||||
.SH OPTIONS
|
|
||||||
.TP
|
|
||||||
.B \-a, \-\-app\-display \fIsource-display\fP
|
|
||||||
Existing X display to proxy.
|
|
||||||
Defaults to :0.
|
|
||||||
|
|
||||||
.TP
|
|
||||||
.B \-v, \-\-vnc\-display \fIdestination-display\fP
|
|
||||||
X display, where source display will be available on.
|
|
||||||
Defaults to :1.
|
|
||||||
|
|
||||||
.TP
|
|
||||||
.B \-f, \-\-fps \fIframes-per-second\fP
|
|
||||||
X display, where the source display will be available on.
|
|
||||||
Defaults to 30 frames per second.
|
|
||||||
|
|
||||||
.TP
|
|
||||||
.B \-r|\-\-resize
|
|
||||||
Enable resizing. WARNING: DO NOT ENABLE IF PHYSICAL DISPLAY IS ATTACHED.
|
|
||||||
Disabled by default.
|
|
||||||
|
|
||||||
.SH EXAMPLES
|
|
||||||
.TP
|
|
||||||
.BI "kasmxproxy -a :1 -v :10 -r"
|
|
||||||
.B Proxy display :1 to display :10, with resizing on.
|
|
||||||
|
|
||||||
.SH AUTHOR
|
|
||||||
Kasm Technologies http://kasmweb.com
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
../../common/rfb/xxhash.c
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
../../common/rfb/xxhash.h
|
|
||||||
@@ -39,7 +39,6 @@
|
|||||||
#include "xkbsrv.h"
|
#include "xkbsrv.h"
|
||||||
#include "xkbstr.h"
|
#include "xkbstr.h"
|
||||||
#include "xserver-properties.h"
|
#include "xserver-properties.h"
|
||||||
#include "stdbool.h"
|
|
||||||
extern _X_EXPORT DevPrivateKey CoreDevicePrivateKey;
|
extern _X_EXPORT DevPrivateKey CoreDevicePrivateKey;
|
||||||
#include <X11/keysym.h>
|
#include <X11/keysym.h>
|
||||||
#include <X11/Xlib.h>
|
#include <X11/Xlib.h>
|
||||||
@@ -67,8 +66,6 @@ static const unsigned short *codeMap;
|
|||||||
static unsigned int codeMapLen;
|
static unsigned int codeMapLen;
|
||||||
|
|
||||||
static KeySym pressedKeys[256];
|
static KeySym pressedKeys[256];
|
||||||
static unsigned int needFree[256];
|
|
||||||
static bool freeKeys;
|
|
||||||
|
|
||||||
static int vncPointerProc(DeviceIntPtr pDevice, int onoff);
|
static int vncPointerProc(DeviceIntPtr pDevice, int onoff);
|
||||||
static void vncKeyboardBell(int percent, DeviceIntPtr device,
|
static void vncKeyboardBell(int percent, DeviceIntPtr device,
|
||||||
@@ -94,7 +91,7 @@ static void vncKeysymKeyboardEvent(KeySym keysym, int down);
|
|||||||
* Instead we call it from XserverDesktop at an appropriate
|
* Instead we call it from XserverDesktop at an appropriate
|
||||||
* time.
|
* time.
|
||||||
*/
|
*/
|
||||||
void vncInitInputDevice(bool freeKeyMappings)
|
void vncInitInputDevice(void)
|
||||||
{
|
{
|
||||||
int i, ret;
|
int i, ret;
|
||||||
|
|
||||||
@@ -113,8 +110,6 @@ void vncInitInputDevice(bool freeKeyMappings)
|
|||||||
codeMap = code_map_qnum_to_xorgkbd;
|
codeMap = code_map_qnum_to_xorgkbd;
|
||||||
codeMapLen = code_map_qnum_to_xorgkbd_len;
|
codeMapLen = code_map_qnum_to_xorgkbd_len;
|
||||||
#endif
|
#endif
|
||||||
freeKeys = freeKeyMappings;
|
|
||||||
memset(needFree, 0, sizeof(needFree));
|
|
||||||
|
|
||||||
for (i = 0;i < 256;i++)
|
for (i = 0;i < 256;i++)
|
||||||
pressedKeys[i] = NoSymbol;
|
pressedKeys[i] = NoSymbol;
|
||||||
@@ -239,48 +234,6 @@ void vncPointerMove(int x, int y)
|
|||||||
cursorPosY = y;
|
cursorPosY = y;
|
||||||
}
|
}
|
||||||
|
|
||||||
void vncPointerMoveRelative(int x, int y, int absx, int absy)
|
|
||||||
{
|
|
||||||
int valuators[2];
|
|
||||||
#if XORG < 111
|
|
||||||
int n;
|
|
||||||
#endif
|
|
||||||
#if XORG >= 110
|
|
||||||
ValuatorMask mask;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// if (cursorPosX == absx && cursorPosY == absy)
|
|
||||||
// return;
|
|
||||||
|
|
||||||
valuators[0] = x;
|
|
||||||
valuators[1] = y;
|
|
||||||
#if XORG < 110
|
|
||||||
n = GetPointerEvents(eventq, vncPointerDev, MotionNotify, 0,
|
|
||||||
POINTER_RELATIVE, 0, 2, valuators);
|
|
||||||
enqueueEvents(vncPointerDev, n);
|
|
||||||
#elif XORG < 111
|
|
||||||
valuator_mask_set_range(&mask, 0, 2, valuators);
|
|
||||||
n = GetPointerEvents(eventq, vncPointerDev, MotionNotify, 0,
|
|
||||||
POINTER_RELATIVE, &mask);
|
|
||||||
enqueueEvents(vncPointerDev, n);
|
|
||||||
#else
|
|
||||||
valuator_mask_set_range(&mask, 0, 2, valuators);
|
|
||||||
QueuePointerEvents(vncPointerDev, MotionNotify, 0,
|
|
||||||
POINTER_RELATIVE, &mask);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
cursorPosX = absx;
|
|
||||||
cursorPosY = absy;
|
|
||||||
}
|
|
||||||
|
|
||||||
void vncScroll(int x, int y) {
|
|
||||||
ValuatorMask mask;
|
|
||||||
valuator_mask_zero(&mask);
|
|
||||||
valuator_mask_set(&mask, 2, x);
|
|
||||||
valuator_mask_set(&mask, 3, y);
|
|
||||||
QueuePointerEvents(vncPointerDev, MotionNotify, 0, POINTER_RELATIVE, &mask);
|
|
||||||
}
|
|
||||||
|
|
||||||
void vncGetPointerPos(int *x, int *y)
|
void vncGetPointerPos(int *x, int *y)
|
||||||
{
|
{
|
||||||
if (vncPointerDev != NULL) {
|
if (vncPointerDev != NULL) {
|
||||||
@@ -308,7 +261,7 @@ static int vncPointerProc(DeviceIntPtr pDevice, int onoff)
|
|||||||
* is not a bug.
|
* is not a bug.
|
||||||
*/
|
*/
|
||||||
Atom btn_labels[BUTTONS];
|
Atom btn_labels[BUTTONS];
|
||||||
Atom axes_labels[4];
|
Atom axes_labels[2];
|
||||||
|
|
||||||
switch (onoff) {
|
switch (onoff) {
|
||||||
case DEVICE_INIT:
|
case DEVICE_INIT:
|
||||||
@@ -325,29 +278,11 @@ static int vncPointerProc(DeviceIntPtr pDevice, int onoff)
|
|||||||
|
|
||||||
axes_labels[0] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_X);
|
axes_labels[0] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_X);
|
||||||
axes_labels[1] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_Y);
|
axes_labels[1] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_Y);
|
||||||
axes_labels[2] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_HSCROLL);
|
|
||||||
axes_labels[3] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_VSCROLL);
|
|
||||||
|
|
||||||
|
|
||||||
InitPointerDeviceStruct(pDev, map, BUTTONS, btn_labels,
|
InitPointerDeviceStruct(pDev, map, BUTTONS, btn_labels,
|
||||||
(PtrCtrlProcPtr)NoopDDA,
|
(PtrCtrlProcPtr)NoopDDA,
|
||||||
GetMotionHistorySize(),
|
GetMotionHistorySize(),
|
||||||
4, axes_labels);
|
2, axes_labels);
|
||||||
|
|
||||||
InitValuatorAxisStruct(pDevice, 2, axes_labels[2], NO_AXIS_LIMITS, NO_AXIS_LIMITS, 0, 0, 0, Relative);
|
|
||||||
InitValuatorAxisStruct(pDevice, 3, axes_labels[3], NO_AXIS_LIMITS, NO_AXIS_LIMITS, 0, 0, 0, Relative);
|
|
||||||
|
|
||||||
char* envScrollFactorH = getenv("SCROLL_FACTOR_H");
|
|
||||||
char* envScrollFactorV = getenv("SCROLL_FACTOR_V");
|
|
||||||
|
|
||||||
float scrollFactorH = envScrollFactorH ? atof(envScrollFactorH) : 50.0;
|
|
||||||
float scrollFactorV = envScrollFactorV ? atof(envScrollFactorV) : 50.0;
|
|
||||||
|
|
||||||
LOG_INFO("Mouse horizonatl scroll factor: %f", scrollFactorH);
|
|
||||||
LOG_INFO("Mouse vertical scroll factor: %f", scrollFactorV);
|
|
||||||
|
|
||||||
SetScrollValuator(pDevice, 2, SCROLL_TYPE_HORIZONTAL, scrollFactorH, SCROLL_FLAG_NONE);
|
|
||||||
SetScrollValuator(pDevice, 3, SCROLL_TYPE_VERTICAL, scrollFactorV, SCROLL_FLAG_PREFERRED);
|
|
||||||
break;
|
break;
|
||||||
case DEVICE_ON:
|
case DEVICE_ON:
|
||||||
pDev->on = TRUE;
|
pDev->on = TRUE;
|
||||||
@@ -539,7 +474,6 @@ static void vncKeysymKeyboardEvent(KeySym keysym, int down)
|
|||||||
pressedKeys[i] = NoSymbol;
|
pressedKeys[i] = NoSymbol;
|
||||||
pressKey(vncKeyboardDev, i, FALSE, "keycode");
|
pressKey(vncKeyboardDev, i, FALSE, "keycode");
|
||||||
mieqProcessInputEvents();
|
mieqProcessInputEvents();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -584,7 +518,7 @@ static void vncKeysymKeyboardEvent(KeySym keysym, int down)
|
|||||||
|
|
||||||
/* No matches. Will have to add a new entry... */
|
/* No matches. Will have to add a new entry... */
|
||||||
if (keycode == 0) {
|
if (keycode == 0) {
|
||||||
keycode = vncAddKeysym(keysym, state, needFree, freeKeys);
|
keycode = vncAddKeysym(keysym, state);
|
||||||
if (keycode == 0) {
|
if (keycode == 0) {
|
||||||
LOG_ERROR("Failure adding new keysym 0x%x", keysym);
|
LOG_ERROR("Failure adding new keysym 0x%x", keysym);
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -25,20 +25,16 @@
|
|||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <X11/X.h>
|
#include <X11/X.h>
|
||||||
#include "stdbool.h"
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void vncInitInputDevice(bool freeKeyMappings);
|
void vncInitInputDevice(void);
|
||||||
|
|
||||||
void vncPointerButtonAction(int buttonMask, const unsigned char skipclick,
|
void vncPointerButtonAction(int buttonMask, const unsigned char skipclick,
|
||||||
const unsigned char skiprelease);
|
const unsigned char skiprelease);
|
||||||
void vncPointerMove(int x, int y);
|
void vncPointerMove(int x, int y);
|
||||||
void vncPointerMoveRelative(int x, int y, int absx, int absy);
|
|
||||||
|
|
||||||
void vncScroll(int x, int y);
|
|
||||||
void vncGetPointerPos(int *x, int *y);
|
void vncGetPointerPos(int *x, int *y);
|
||||||
|
|
||||||
void vncKeyboardEvent(KeySym keysym, unsigned xtcode, int down);
|
void vncKeyboardEvent(KeySym keysym, unsigned xtcode, int down);
|
||||||
@@ -60,8 +56,7 @@ KeyCode vncKeysymToKeycode(KeySym keysym, unsigned state, unsigned *new_state);
|
|||||||
|
|
||||||
int vncIsAffectedByNumLock(KeyCode keycode);
|
int vncIsAffectedByNumLock(KeyCode keycode);
|
||||||
|
|
||||||
KeyCode vncAddKeysym(KeySym keysym, unsigned state, unsigned int *needfree, bool freeKeys);
|
KeyCode vncAddKeysym(KeySym keysym, unsigned state);
|
||||||
void vncRemoveKeycode(unsigned keycode);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,19 +25,16 @@
|
|||||||
#include "xorg-version.h"
|
#include "xorg-version.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <limits.h>
|
|
||||||
|
|
||||||
#include <X11/keysym.h>
|
#include <X11/keysym.h>
|
||||||
#include <X11/Xlib.h>
|
#include <X11/Xlib.h>
|
||||||
#include <X11/Xutil.h>
|
#include <X11/Xutil.h>
|
||||||
|
|
||||||
#include "RFBGlue.h"
|
|
||||||
#include "xkbsrv.h"
|
#include "xkbsrv.h"
|
||||||
#include "xkbstr.h"
|
#include "xkbstr.h"
|
||||||
#include "eventstr.h"
|
#include "eventstr.h"
|
||||||
#include "scrnintstr.h"
|
#include "scrnintstr.h"
|
||||||
#include "mi.h"
|
#include "mi.h"
|
||||||
#include "stdbool.h"
|
|
||||||
|
|
||||||
#include "Input.h"
|
#include "Input.h"
|
||||||
|
|
||||||
@@ -53,15 +50,7 @@
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define LOG_NAME "Input"
|
|
||||||
|
|
||||||
#define LOG_ERROR(...) vncLogError(LOG_NAME, __VA_ARGS__)
|
|
||||||
#define LOG_STATUS(...) vncLogStatus(LOG_NAME, __VA_ARGS__)
|
|
||||||
#define LOG_INFO(...) vncLogInfo(LOG_NAME, __VA_ARGS__)
|
|
||||||
#define LOG_DEBUG(...) vncLogDebug(LOG_NAME, __VA_ARGS__)
|
|
||||||
|
|
||||||
extern DeviceIntPtr vncKeyboardDev;
|
extern DeviceIntPtr vncKeyboardDev;
|
||||||
static unsigned int MAX_MAPPINGS = UINT_MAX - 1;
|
|
||||||
|
|
||||||
static void vncXkbProcessDeviceEvent(int screenNum,
|
static void vncXkbProcessDeviceEvent(int screenNum,
|
||||||
InternalEvent *event,
|
InternalEvent *event,
|
||||||
@@ -547,15 +536,11 @@ int vncIsAffectedByNumLock(KeyCode keycode)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
KeyCode vncAddKeysym(KeySym keysym, unsigned state, unsigned int *needFree, bool freeKeys)
|
KeyCode vncAddKeysym(KeySym keysym, unsigned state)
|
||||||
{
|
{
|
||||||
DeviceIntPtr master;
|
DeviceIntPtr master;
|
||||||
XkbDescPtr xkb;
|
XkbDescPtr xkb;
|
||||||
unsigned int key = 0;
|
unsigned int key;
|
||||||
unsigned int i;
|
|
||||||
unsigned int newest_k = 0;
|
|
||||||
unsigned int oldest_k = 0;
|
|
||||||
unsigned int freeCnt = 0;
|
|
||||||
|
|
||||||
XkbEventCauseRec cause;
|
XkbEventCauseRec cause;
|
||||||
XkbChangesRec changes;
|
XkbChangesRec changes;
|
||||||
@@ -566,45 +551,14 @@ KeyCode vncAddKeysym(KeySym keysym, unsigned state, unsigned int *needFree, bool
|
|||||||
|
|
||||||
master = GetMaster(vncKeyboardDev, KEYBOARD_OR_FLOAT);
|
master = GetMaster(vncKeyboardDev, KEYBOARD_OR_FLOAT);
|
||||||
xkb = master->key->xkbInfo->desc;
|
xkb = master->key->xkbInfo->desc;
|
||||||
|
for (key = xkb->max_key_code; key >= xkb->min_key_code; key--) {
|
||||||
//find the first free key to map
|
if (XkbKeyNumGroups(xkb, key) == 0)
|
||||||
for (i = xkb->max_key_code; i >= xkb->min_key_code; i--) {
|
break;
|
||||||
if (XkbKeyNumGroups(xkb, i) == 0 && *(needFree + i) != UINT_MAX) {
|
|
||||||
if (++freeCnt == 1)
|
|
||||||
key = i;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (key < xkb->min_key_code)
|
if (key < xkb->min_key_code)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
//find the oldest and newest keys that have been remapped
|
|
||||||
for (i = 1;i < 256;i++) {
|
|
||||||
//protect from uint rollover
|
|
||||||
if (*(needFree + i) == MAX_MAPPINGS)
|
|
||||||
*(needFree + i) = 1;
|
|
||||||
if (*(needFree + i) > *(needFree + newest_k) && *(needFree + i) != UINT_MAX)
|
|
||||||
newest_k = i;
|
|
||||||
if (*(needFree + i) < *(needFree + oldest_k) && *(needFree +i) > 0)
|
|
||||||
oldest_k = i;
|
|
||||||
//mark as free to use
|
|
||||||
if (*(needFree + i) == UINT_MAX)
|
|
||||||
*(needFree + i) = 0;
|
|
||||||
}
|
|
||||||
*(needFree + key) = ++(*(needFree + newest_k));
|
|
||||||
|
|
||||||
//if running low on free keys, free the oldest key that was used
|
|
||||||
if (freeCnt < 3 && *(needFree + oldest_k) > 0 && freeKeys) {
|
|
||||||
vncRemoveKeycode(oldest_k);
|
|
||||||
LOG_DEBUG("Removed mapping for keycode %d", oldest_k);
|
|
||||||
//mark as free to use after one more cycle
|
|
||||||
*(needFree + oldest_k) = UINT_MAX;
|
|
||||||
} else if (freeCnt < 3 && freeKeys) {
|
|
||||||
//this should only happen if the system had fewer than 3 free keys to begin with
|
|
||||||
LOG_INFO("The system has fewer than 3 unmapped keys with no available keys to free.");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
memset(&changes, 0, sizeof(changes));
|
memset(&changes, 0, sizeof(changes));
|
||||||
memset(&cause, 0, sizeof(cause));
|
memset(&cause, 0, sizeof(cause));
|
||||||
|
|
||||||
@@ -658,40 +612,6 @@ KeyCode vncAddKeysym(KeySym keysym, unsigned state, unsigned int *needFree, bool
|
|||||||
return key;
|
return key;
|
||||||
}
|
}
|
||||||
|
|
||||||
void vncRemoveKeycode(unsigned keycode)
|
|
||||||
{
|
|
||||||
DeviceIntPtr master;
|
|
||||||
XkbDescPtr xkb;
|
|
||||||
|
|
||||||
XkbEventCauseRec cause;
|
|
||||||
XkbChangesRec changes;
|
|
||||||
|
|
||||||
master = GetMaster(vncKeyboardDev, KEYBOARD_OR_FLOAT);
|
|
||||||
xkb = master->key->xkbInfo->desc;
|
|
||||||
|
|
||||||
memset(&changes, 0, sizeof(changes));
|
|
||||||
memset(&cause, 0, sizeof(cause));
|
|
||||||
|
|
||||||
XkbSetCauseUnknown(&cause);
|
|
||||||
|
|
||||||
KeySym ks = NoSymbol;
|
|
||||||
|
|
||||||
KeySymsRec keysyms;
|
|
||||||
keysyms.minKeyCode = keycode;
|
|
||||||
keysyms.maxKeyCode = keycode;
|
|
||||||
keysyms.mapWidth = 1;
|
|
||||||
keysyms.map = &ks;
|
|
||||||
|
|
||||||
unsigned check = 0;
|
|
||||||
XkbUpdateKeyTypesFromCore(master, &keysyms, keycode, 1, &changes);
|
|
||||||
XkbUpdateActions(master, keycode, 1, &changes, &check, &cause);
|
|
||||||
|
|
||||||
if (check)
|
|
||||||
XkbCheckSecondaryEffects(master->key->xkbInfo, 1, &changes, &cause);
|
|
||||||
|
|
||||||
XkbSendNotification(master, &changes, &cause);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void vncXkbProcessDeviceEvent(int screenNum,
|
static void vncXkbProcessDeviceEvent(int screenNum,
|
||||||
InternalEvent *event,
|
InternalEvent *event,
|
||||||
DeviceIntPtr dev)
|
DeviceIntPtr dev)
|
||||||
|
|||||||
@@ -41,7 +41,6 @@ nodist_EXTRA_Xvnc_SOURCES = dummy.cxx
|
|||||||
|
|
||||||
Xvnc_CPPFLAGS = $(XVNC_CPPFLAGS) -DKASMVNC -DNO_MODULE_EXTS \
|
Xvnc_CPPFLAGS = $(XVNC_CPPFLAGS) -DKASMVNC -DNO_MODULE_EXTS \
|
||||||
-UHAVE_CONFIG_H \
|
-UHAVE_CONFIG_H \
|
||||||
-DXVNCEXTRAVERSION="\".$(KASMVNC_COMMIT_ID)\"" \
|
|
||||||
-DXFree86Server -DVENDOR_RELEASE="$(VENDOR_RELEASE)" \
|
-DXFree86Server -DVENDOR_RELEASE="$(VENDOR_RELEASE)" \
|
||||||
-DVENDOR_STRING="\"$(VENDOR_STRING)\"" -I$(KASMVNC_SRCDIR)/common -I$(KASMVNC_SRCDIR)/unix/common \
|
-DVENDOR_STRING="\"$(VENDOR_STRING)\"" -I$(KASMVNC_SRCDIR)/common -I$(KASMVNC_SRCDIR)/unix/common \
|
||||||
-I$(top_srcdir)/include ${XSERVERLIBS_CFLAGS} -I$(includedir)
|
-I$(top_srcdir)/include ${XSERVERLIBS_CFLAGS} -I$(includedir)
|
||||||
|
|||||||
@@ -60,10 +60,6 @@ BoolParameter rawKeyboard("RawKeyboard",
|
|||||||
"Send keyboard events straight through and "
|
"Send keyboard events straight through and "
|
||||||
"avoid mapping them to the current keyboard "
|
"avoid mapping them to the current keyboard "
|
||||||
"layout", false);
|
"layout", false);
|
||||||
BoolParameter freeKeyMappings("FreeKeyMappings",
|
|
||||||
"Automatically free added keyboard mappings "
|
|
||||||
"when there are not enough unused keys to "
|
|
||||||
"map symbols to.", false);
|
|
||||||
IntParameter queryConnectTimeout("QueryConnectTimeout",
|
IntParameter queryConnectTimeout("QueryConnectTimeout",
|
||||||
"Number of seconds to show the "
|
"Number of seconds to show the "
|
||||||
"Accept Connection dialog before "
|
"Accept Connection dialog before "
|
||||||
@@ -180,6 +176,15 @@ XserverDesktop::queryConnection(network::Socket* sock,
|
|||||||
return rfb::VNCServerST::PENDING;
|
return rfb::VNCServerST::PENDING;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void XserverDesktop::requestClipboard()
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
server->requestClipboard();
|
||||||
|
} catch (rdr::Exception& e) {
|
||||||
|
vlog.error("XserverDesktop::requestClipboard: %s",e.str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void XserverDesktop::announceClipboard(bool available)
|
void XserverDesktop::announceClipboard(bool available)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
@@ -189,34 +194,12 @@ void XserverDesktop::announceClipboard(bool available)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void XserverDesktop::clearBinaryClipboardData()
|
void XserverDesktop::sendClipboardData(const char* data)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
server->clearBinaryClipboardData();
|
server->sendClipboardData(data);
|
||||||
} catch (rdr::Exception& e) {
|
} catch (rdr::Exception& e) {
|
||||||
vlog.error("XserverDesktop::clearBinaryClipboardData: %s",e.str());
|
vlog.error("XserverDesktop::sendClipboardData: %s",e.str());
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void XserverDesktop::sendBinaryClipboardData(const char* mime,
|
|
||||||
const unsigned char *data,
|
|
||||||
const unsigned len)
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
server->sendBinaryClipboardData(mime, data, len);
|
|
||||||
} catch (rdr::Exception& e) {
|
|
||||||
vlog.error("XserverDesktop::sendBinaryClipboardData: %s",e.str());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void XserverDesktop::getBinaryClipboardData(const char* mime,
|
|
||||||
const unsigned char **data,
|
|
||||||
unsigned *len)
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
server->getBinaryClipboardData(mime, data, len);
|
|
||||||
} catch (rdr::Exception& e) {
|
|
||||||
vlog.error("XserverDesktop::getBinaryClipboardData: %s",e.str());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -374,7 +357,7 @@ void XserverDesktop::blockHandler(int* timeout)
|
|||||||
// so we abuse the fact that this routine will be called first thing
|
// so we abuse the fact that this routine will be called first thing
|
||||||
// once the dix is done initialising.
|
// once the dix is done initialising.
|
||||||
// [1] Technically Xvnc has InitInput(), but libvnc.so has nothing.
|
// [1] Technically Xvnc has InitInput(), but libvnc.so has nothing.
|
||||||
vncInitInputDevice(freeKeyMappings);
|
vncInitInputDevice();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
std::list<Socket*> sockets;
|
std::list<Socket*> sockets;
|
||||||
@@ -461,21 +444,13 @@ void XserverDesktop::approveConnection(uint32_t opaqueId, bool accept,
|
|||||||
//
|
//
|
||||||
// SDesktop callbacks
|
// SDesktop callbacks
|
||||||
|
|
||||||
void XserverDesktop::pointerEvent(const Point& pos, const Point& abspos, int buttonMask,
|
|
||||||
const bool skipClick, const bool skipRelease, int scrollX, int scrollY)
|
void XserverDesktop::pointerEvent(const Point& pos, int buttonMask,
|
||||||
|
const bool skipClick, const bool skipRelease)
|
||||||
{
|
{
|
||||||
if (scrollX == 0 && scrollY == 0) {
|
vncPointerMove(pos.x + vncGetScreenX(screenIndex),
|
||||||
if (pos.equals(abspos)) {
|
pos.y + vncGetScreenY(screenIndex));
|
||||||
vncPointerMove(pos.x + vncGetScreenX(screenIndex), pos.y + vncGetScreenY(screenIndex));
|
|
||||||
} else {
|
|
||||||
vncPointerMoveRelative(pos.x, pos.y,
|
|
||||||
abspos.x + vncGetScreenX(screenIndex),
|
|
||||||
abspos.y + vncGetScreenY(screenIndex));
|
|
||||||
}
|
|
||||||
vncPointerButtonAction(buttonMask, skipClick, skipRelease);
|
vncPointerButtonAction(buttonMask, skipClick, skipRelease);
|
||||||
} else {
|
|
||||||
vncScroll(scrollX, scrollY);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int XserverDesktop::setScreenLayout(int fb_width, int fb_height,
|
unsigned int XserverDesktop::setScreenLayout(int fb_width, int fb_height,
|
||||||
@@ -494,14 +469,19 @@ unsigned int XserverDesktop::setScreenLayout(int fb_width, int fb_height,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void XserverDesktop::handleClipboardRequest()
|
||||||
|
{
|
||||||
|
vncHandleClipboardRequest();
|
||||||
|
}
|
||||||
|
|
||||||
void XserverDesktop::handleClipboardAnnounce(bool available)
|
void XserverDesktop::handleClipboardAnnounce(bool available)
|
||||||
{
|
{
|
||||||
vncHandleClipboardAnnounce(available);
|
vncHandleClipboardAnnounce(available);
|
||||||
}
|
}
|
||||||
|
|
||||||
void XserverDesktop::handleClipboardAnnounceBinary(const unsigned num, const char mimes[][32])
|
void XserverDesktop::handleClipboardData(const char* data_, int len)
|
||||||
{
|
{
|
||||||
vncHandleClipboardAnnounceBinary(num, mimes);
|
vncHandleClipboardData(data_, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
void XserverDesktop::grabRegion(const rfb::Region& region)
|
void XserverDesktop::grabRegion(const rfb::Region& region)
|
||||||
|
|||||||
@@ -62,11 +62,7 @@ public:
|
|||||||
void refreshScreenLayout();
|
void refreshScreenLayout();
|
||||||
void requestClipboard();
|
void requestClipboard();
|
||||||
void announceClipboard(bool available);
|
void announceClipboard(bool available);
|
||||||
void clearBinaryClipboardData();
|
void sendClipboardData(const char* data);
|
||||||
void sendBinaryClipboardData(const char* mime, const unsigned char *data,
|
|
||||||
const unsigned len);
|
|
||||||
void getBinaryClipboardData(const char *mime, const unsigned char **ptr,
|
|
||||||
unsigned *len);
|
|
||||||
void bell();
|
void bell();
|
||||||
void setLEDState(unsigned int state);
|
void setLEDState(unsigned int state);
|
||||||
void setDesktopName(const char* name);
|
void setDesktopName(const char* name);
|
||||||
@@ -93,13 +89,14 @@ public:
|
|||||||
const char* rejectMsg=0);
|
const char* rejectMsg=0);
|
||||||
|
|
||||||
// rfb::SDesktop callbacks
|
// rfb::SDesktop callbacks
|
||||||
virtual void pointerEvent(const rfb::Point& pos, const rfb::Point& abspos, int buttonMask,
|
virtual void pointerEvent(const rfb::Point& pos, int buttonMask,
|
||||||
const bool skipClick, const bool skipRelease, int scrollX = 0, int scrollY = 0);
|
const bool skipClick, const bool skipRelease);
|
||||||
virtual void keyEvent(rdr::U32 keysym, rdr::U32 keycode, bool down);
|
virtual void keyEvent(rdr::U32 keysym, rdr::U32 keycode, bool down);
|
||||||
virtual unsigned int setScreenLayout(int fb_width, int fb_height,
|
virtual unsigned int setScreenLayout(int fb_width, int fb_height,
|
||||||
const rfb::ScreenSet& layout);
|
const rfb::ScreenSet& layout);
|
||||||
|
virtual void handleClipboardRequest();
|
||||||
virtual void handleClipboardAnnounce(bool available);
|
virtual void handleClipboardAnnounce(bool available);
|
||||||
virtual void handleClipboardAnnounceBinary(const unsigned num, const char mimes[][32]);
|
virtual void handleClipboardData(const char* data, int len);
|
||||||
|
|
||||||
// rfb::PixelBuffer callbacks
|
// rfb::PixelBuffer callbacks
|
||||||
virtual void grabRegion(const rfb::Region& r);
|
virtual void grabRegion(const rfb::Region& r);
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user