Compare commits

...

437 Commits

Author SHA1 Message Date
Dmitry Maksyoma
ba942e102e Easy start script: remove obsolete code 2021-07-21 22:48:36 +12:00
Dmitry Maksyoma
c4cc856e56 Revert "vncserver: add magic text to signify that the file can be replaced"
This reverts commit b8fd6a28a4.
2021-07-21 19:20:38 +12:00
Dmitry Maksyoma
7d842fe3d2 Easy start script: warn xstartup will be overwritten 2021-07-21 19:18:07 +12:00
Dmitry Maksyoma
7c4896ac66 Easy start script: refactor 2021-07-21 19:10:49 +12:00
Dmitry Maksyoma
24336b236a Early start script: add -select-de support 2021-07-21 19:08:20 +12:00
Dmitry Maksyoma
8a11d171d5 Easy start script: fail if unsupported option is given 2021-07-21 19:03:30 +12:00
Dmitry Maksyoma
892c285963 Easy start script: refactor and correct option processing 2021-07-21 18:53:24 +12:00
Dmitry Maksyoma
26cc3845b0 Easy start script: sort DEs presented to user 2021-07-19 00:07:20 +12:00
Dmitry Maksyoma
f046e3340c Easy start script: remember DE choice 2021-07-18 23:30:37 +12:00
Dmitry Maksyoma
bd144b71bf Easy start script: add manual xstartup choice 2021-07-18 23:30:13 +12:00
Dmitry Maksyoma
66d999beaf Refactor easy start script 2021-07-18 23:16:03 +12:00
Dmitry Maksyoma
3584d8c3cb Refactor easy start script 2021-07-18 23:05:11 +12:00
Dmitry Maksyoma
f8bcfcc493 Easy start script: add did_user_forbid_replacing_xstartup() 2021-07-18 23:04:36 +12:00
Dmitry Maksyoma
22654f7ab6 Easy start script: handle incorrect DE number selection 2021-07-18 22:20:20 +12:00
Dmitry Maksyoma
33327c1159 Easy start script: can choose DE and run it via xstartup 2021-07-18 01:04:33 +12:00
Dmitry Maksyoma
aeec23bd68 test-deb: add temporary volume of . 2021-07-18 01:03:56 +12:00
Dmitry Maksyoma
34a389f714 Add temporary DE installations to Buster dockerfile 2021-07-18 01:03:00 +12:00
Dmitry Maksyoma
b8fd6a28a4 vncserver: add magic text to signify that the file can be replaced 2021-07-18 01:02:04 +12:00
Dmitry Maksyoma
240b1342fd Easy start script: DE -> Desktop Environment 2021-07-17 18:28:32 +12:00
Dmitry Maksyoma
640a195e3e Easy start script: choose DE to run spike 2021-07-03 18:13:59 +12:00
mmcclaskey
72affbfcf4 [skip CI] Readme updates 2021-06-25 10:04:26 -04:00
mmcclaskey
b362110b07 [skip CI] update readme 2021-06-25 05:59:14 -04:00
Lauri Kasanen
29e0e2bd2e Fix animated cursor resize crash 2021-06-15 15:40:14 +03:00
Lauri Kasanen
9144045718 Append the microsecond-level connection time to the abstract socket name, making it always unique 2021-05-10 19:16:28 +03:00
Lauri Kasanen
7a695c976e Writer perms were checked in multiple places, consolidate and fix a missing case 2021-05-10 11:02:20 +03:00
matt
aefdb1392f KASM-1511 istouch bugfix 2021-04-26 05:58:04 -04:00
Lauri Kasanen
14e08a2067 Add trailing slash in dir listing 2021-04-22 11:33:05 +03:00
matt
f64bd4f1a4 Correct spelling of License file 2021-04-20 15:41:38 -04:00
Kasm
0b6334369c Merge pull request #36 from kasmtech/upstreamsync_sans_novnc
Upstream Syncs
2021-04-20 14:51:25 -04:00
matt
b8c69a7560 update noVNC submodule commit 2021-04-20 09:46:01 -04:00
matt
e84a37fb3d switched submodule commit id 2021-04-20 08:11:20 -04:00
matt
23935145a8 update submodule branch 2021-04-18 06:55:26 -04:00
matt
7f7b177b1a Update noVNC to latest master 2021-04-18 06:45:32 -04:00
Kasm
adcf902733 Merge pull request #35 from kasmtech/deb-installation-instructions-readme [skip CI]
Deb installation instructions readme
2021-04-13 12:04:28 -04:00
Kasm
ce2f2adc59 [skip CI] Updates to install instructions 2021-04-13 11:33:30 -04:00
matt
80d401af51 [skip CI] updates to docs 2021-04-13 10:23:00 -04:00
Kasm
5c832ed93d [skip CI] updates to readme 2021-04-13 09:07:49 -04:00
Kasm
55f888b923 Update README.md
minor grammar tweaks
2021-04-13 08:59:37 -04:00
Dmitry Maksyoma
bbdf6c4361 Update README.md 2021-04-13 23:04:52 +12:00
Dmitry Maksyoma
90d1702702 Update README.md 2021-04-13 22:57:10 +12:00
Lauri Kasanen
95d34f7e58 Fix some local->remote clipboard merge misses 2021-04-13 13:49:43 +03:00
Dmitry Maksyoma
e7f8caa752 Building: describe how to build and test packages 2021-04-13 22:48:41 +12:00
Dmitry Maksyoma
f532e3244b Add deb/rpm package build instructions 2021-04-13 21:59:51 +12:00
Dmitry Maksyoma
2f47aca1db README: remove obsolete info 2021-04-13 21:46:19 +12:00
Dmitry Maksyoma
15571e4720 README.md formatting 2021-04-13 07:28:33 +12:00
Dmitry Maksyoma
232f20e917 Improve README.md 2021-04-13 07:28:26 +12:00
Dmitry Maksyoma
a9bf5bdcf8 Update README: deb installation only 2021-04-13 07:28:17 +12:00
Lauri Kasanen
a1cf454f06 Sync utf8 clipboard support 2021-04-12 12:38:24 +03:00
matt
04461b9d4c fixes 2021-04-11 21:35:13 +00:00
matt
0d482f9a9b Update noVNC commit 2021-04-01 08:18:59 -04:00
matt
a7773bee6b Updated submodule ref 2021-03-31 15:06:27 -04:00
matt
75cef8b726 [skip CI] build fixes 2021-03-31 07:54:59 -04:00
matt
380bc0e7f8 merged master in 2021-03-31 05:21:35 -04:00
matt
999cfbb806 Added kasm novnc as submod 2021-03-30 15:32:18 -04:00
matt
12a0c0d8af removed novnc 2021-03-30 15:25:35 -04:00
Lauri Kasanen
7bfcb19ee1 Fixups 2021-03-29 13:25:16 +03:00
Quentin Dreyer
df9ca2e0ce chore: sync with W3C documentation
https://www.w3.org/TR/uievents-key/
2021-03-29 12:50:39 +03:00
Pierre Ossman
4fda2526f4 Send combination keysyms for some Japanese keys
Windows doesn't give us stable symbols for a bunch of Japanese IM keys,
instead alternating between two symbols. This state is not synchronised
with the IM running on the remote server so to have stable behaviour we
have to collapse these multiple symbols in to a single keysym.
2021-03-29 12:50:22 +03:00
Pierre Ossman
102257cb32 Fix typo for ZenkakuHankaku key 2021-03-29 12:50:16 +03:00
Pierre Ossman
77509c1e56 Use toggle keysym for Eisu key
This matches how the key behaves on a Linux system.
2021-03-29 12:50:12 +03:00
Pierre Ossman
9e0a5d26af Update keycode mappings to latest version
This update fixes Korean layouts.
2021-03-29 12:48:56 +03:00
Pierre Ossman
c6c2661121 Add workaround for Firefox PNG rounding bug 2021-03-29 12:48:06 +03:00
Pierre Ossman
8b8201fd73 Remove Firefox Alt workaround
The bug got fixed way back in Firefox 63, and it is also misbehaving
with modern Firefox as they no longer consider AltGr an Alt-key.
2021-03-29 12:48:02 +03:00
Pierre Ossman
33a113a475 Handle empty rects in RAW decoder as well
It was overlooked in the previous commit because we couldn't feed
empty data messages through the test framework.
2021-03-29 12:47:49 +03:00
Samuel Mannehed
6d1cebc24a Ignore recording variables in our linter 2021-03-29 12:47:43 +03:00
Pierre Ossman
fcd7836a83 Approximate comparison of JPEG result
The browsers have various rounding errors so we need to compare the
output data only approximately and not exactly.
2021-03-29 12:47:38 +03:00
Pierre Ossman
073737c8ac Handle empty rects from the server
These are very pointless for the server to send, but not a violation of
the protocol so we need to be able to handle them. We've seen this
happen in real world scenarios a few times.
2021-03-29 12:47:30 +03:00
Samuel Mannehed
16c72ba0a7 Fix call to _recvMessage()
Missed to rename this one in commit ea858bfa275d85541ac26d035967959714e8e255
2021-03-29 12:45:49 +03:00
Samuel Mannehed
d3c9ff8b12 Fix names of recording variables
The name of these variables must match how they were set when the
recording was created.

Reverts part of 95632e413d75030c49577c0e5cf1003208a5ba09
2021-03-29 12:45:41 +03:00
Pierre Ossman
4bc4c1d7f6 noVNC 1.2.0 2021-03-29 12:45:36 +03:00
Pierre Ossman
d8ba9a61e2 Update generated JS files for translations 2021-03-29 12:45:31 +03:00
Samuel Mannehed
0e2a25476f Update Swedish translation 2021-03-29 12:45:28 +03:00
Pierre Ossman
b3b4acaaa3 noVNC 1.2.0 beta 2021-03-29 12:45:08 +03:00
Pierre Ossman
201f2517f7 Remove note about clipboard ISO 8859-1 restriction
We now support full Unicode, provided the server also supports the
proper extension.
2021-03-29 12:44:59 +03:00
Pierre Ossman
f51167a2ce Update translation template file 2021-03-29 12:44:54 +03:00
Pierre Ossman
87b3a630cf Remove redundant VERSION file
We want to avoid having this in multiple places.
2021-03-29 12:44:42 +03:00
Pierre Ossman
7412dde8ee Handle quick Cursor detach after mouse up
This timer might fire after the Cursor object has detached from a DOM
element, causing crashes. This will likely not happen in real scenarios,
but the tests are quick enough to trigger this.
2021-03-29 12:44:25 +03:00
Pierre Ossman
3ef6e1333b Remove default Karma options
No need to mention things where we already use the default value.
2021-03-29 12:43:59 +03:00
Samuel Mannehed
b84220f319 Add lint rule for function declaration indentation 2021-03-29 12:41:44 +03:00
Pierre Ossman
42d437ad25 Start fake test clock at real clock time
Some code relies on the clock having a somewhat sane value, so let's not
start at 0.
2021-03-29 12:41:15 +03:00
Pierre Ossman
d5b84d9185 Avoid fractional pixel sizes from Display 2021-03-29 12:41:06 +03:00
Pierre Ossman
6db1c2bf0d Avoid printing the Websock buffer in tests
It takes forever and just messes up the output.
2021-03-29 12:40:09 +03:00
Pierre Ossman
ae1bc396bf Standardise on a single blit function
Keep everything simpler by always blitting in the same pixel format.
It's up to the decoders to convert if they need to.
2021-03-29 12:39:31 +03:00
Pierre Ossman
c7a7ce70be Fix bad BasicCompression check in Tight decoder 2021-03-29 12:37:29 +03:00
Pierre Ossman
55178c76b8 Test correct handling of alpha
The forth byte of a pixel is undefined in most encodings, so make sure
the decoders don't leak that through as an alpha channel.
2021-03-29 12:36:47 +03:00
Pierre Ossman
5752bf8ab7 Add tests for the Tight decoders 2021-03-29 12:36:42 +03:00
Pierre Ossman
6fd1035fb1 Split decoder tests to separate files 2021-03-29 12:36:35 +03:00
Pierre Ossman
212e0f1a10 Move tile handling to Hextile decoder
It is only used there so no need for it to be in the general
Display class.
2021-03-29 12:36:23 +03:00
Samuel Mannehed
69b945fc87 Standardize on camelCase in Display 2021-03-29 12:35:23 +03:00
Samuel Mannehed
b837bd6f59 Add camelCase rule to eslint 2021-03-29 12:34:42 +03:00
Samuel Mannehed
670eefbc97 Standardize on camelCase in Base64 2021-03-29 12:34:31 +03:00
Samuel Mannehed
b2d8db3f7b Standardize on camelCase in Decoders 2021-03-29 12:34:29 +03:00
Samuel Mannehed
a3e2b1e46e Standardize on camelCase in Logging 2021-03-29 12:34:25 +03:00
Samuel Mannehed
472ede66ea Standardize on camelCase in Websock 2021-03-29 12:34:23 +03:00
Samuel Mannehed
da228af778 Standardize on camelCase in tests 2021-03-29 12:34:13 +03:00
Samuel Mannehed
59f5648592 Remove unused properties and variables
The code that used these were removed in the following commits:

* 9ff86fb718477515ede2d6457f06643935d76bcd (RFB._mouse_arr)
* bb6965f2e60c2301dd638383bdc792d1f10af942 (old_requestAnimationFrame)
* 490d471c53b1791398d6c30f0efce54925939f33 (Display._c_forceCanvas)
2021-03-29 12:27:54 +03:00
Samuel Mannehed
19c473f792 Properly limit mouse moves to once every 17 ms
Previous attempt in c958269 had a number of issues, this is a full
rewrite, complete with improved unit tests.

Fixes github issue #1402
2021-03-29 12:26:12 +03:00
Samuel Mannehed
8a8fa1d906 Stop send mouse clicks while dragging in view only 2021-03-29 12:23:20 +03:00
Samuel Mannehed
5a81223d96 Standardize on camelCase for functions in RFB 2021-03-29 12:23:12 +03:00
Samuel Mannehed
eff38d47f9 Standardize on camelCase for variables in RFB 2021-03-29 12:21:50 +03:00
Samuel Mannehed
1de3769fd3 Remove unused mouse_arr variable 2021-03-29 12:16:38 +03:00
Samuel Mannehed
749ddce5b9 Add unit tests for mouse move limit 2021-03-29 12:16:01 +03:00
Samuel Mannehed
d420aa6413 Shorten rows to max 80 chars in mouse.js 2021-03-29 12:15:56 +03:00
Samuel Mannehed
93e42772bc Fix wording in comment 2021-03-29 12:15:49 +03:00
Uwe Klatt
9098478faf Limit mouse move events to one every 17 ms 2021-03-29 12:15:39 +03:00
Samuel Mannehed
4710ec1822 Fix indentation for focus check 2021-03-29 12:15:34 +03:00
Samuel Mannehed
02b9b268ff Don't fade the control bar if it has focus
Fixes github issue #1369
2021-03-29 12:15:29 +03:00
Samuel Mannehed
a015e33111 Hide the clipboard when not connected
Fixes github issue #1367.
2021-03-29 12:15:25 +03:00
Ingo Blechschmidt
950d871b0e Document default setting of focusOnClick 2021-03-29 12:15:19 +03:00
Filip Stedronsky
02e7b006de rfb: VeNCrypt Plain SecurityType support
This allows using TigerVNC server with PAM authentication (e.g. agains
LDAP or other extensible authentication mechanisms)

Tested with TigerVNC server (Xvnc -SecurityTypes Plain -PlainUsers '*')

Should not break anything else, this method is tried last when all
other fail.

Tested in Firefox 74 and Chromium 80
2021-03-29 12:14:55 +03:00
Alex Tanskanen
95af51e28d Fix focus problem after closing the toolbar
Closing the toolbar would make the focus remain on the toolbar and
not in the session. The only way to switch focus was to click in the
session. This commit will automatically switch back focus to the session
after closing the toolbar.
2021-03-29 12:14:49 +03:00
Niko Lehto
64dfb8d1d6 Hide clipboard side bar button when view only mode
The clipboard side bar button serves no purpose if user uses 'View Only'
mode, this commit hides this button in those instances.
2021-03-29 12:14:25 +03:00
Alex Tanskanen
b173c8854a Fix crash with too large clipboard data
If too much text is copied in the session, String.fromCharCode.apply()
would crash in Safari on macOS and Chrome on Linux. This commit fixes
this issue by avoiding apply() altogether. Also added test to cover this
issue.
2021-03-29 12:14:19 +03:00
Pierre Ossman
888f24e7af Style all input types for consistent UI
At least all that the browsers will let us.
2021-03-29 12:14:14 +03:00
Niko Lehto
8be81165bd Add extended clipboard Pseudo-Encoding
Add extended clipboard pseudo-encoding to allow the use of unicode
characters in the clipboard.
2021-03-29 12:13:59 +03:00
Niko Lehto
509b5795a0 Export constants in inflate.js for easier usage 2021-03-29 12:09:49 +03:00
Niko Lehto
581fe511ad Fix bug where inflate would read too much data 2021-03-29 12:09:44 +03:00
Niko Lehto
9ca647667b Split api of inflate
Added ability to read data chunk wise.
2021-03-29 12:09:40 +03:00
Niko Lehto
dbe2930758 Handle errors from zlib/pako 2021-03-29 12:09:36 +03:00
Niko Lehto
b690ae4c2d Move error handling to Inflate class
Every call wants this check so this should be done inside the class.
2021-03-29 12:09:32 +03:00
Niko Lehto
5e4544d5fc Add missing copyright header for Inflator.js 2021-03-29 12:09:27 +03:00
Niko Lehto
0b19961b06 Remove unused inflate argument
The value true was an invalid flush argument so it was in practice
unused.
2021-03-29 12:09:21 +03:00
Niko Lehto
286694869b Add util for unsigned and signed int. conversion
Will be used in later commit in extended clipboard handling.
2021-03-29 12:09:10 +03:00
Niko Lehto
fdeefcfab4 Add deflator helper class for deflating data
Wraps pako's deflate for easier usage.
2021-03-29 12:09:05 +03:00
Niko Lehto
24cf1f0f9a Make clipBoardPasteFrom() test more specific
Don't rely on clientCutText() to test clipboardPasteFrom().
2021-03-29 12:08:58 +03:00
Alvin Townsend
d01f6e6d27 Correcting path to package.json for running at a path other than root. 2021-03-29 12:08:52 +03:00
Samuel Mannehed
c1160d1468 Fix color channels for VMware alpha cursors
The red and blue channels were incorrectly swapped.
2021-03-29 12:08:36 +03:00
Juanjo Diaz
1c38b6f120 Remove generated HTML by Cursor when it detaches 2021-03-29 12:08:01 +03:00
Samuel Mannehed
70dd0058ac Simplify encodeUTF8/decodeUTF8 unittests 2021-03-29 12:07:57 +03:00
Samuel Mannehed
a4c5c38b53 Add unit tests for encodeUTF8 and decodeUTF8 2021-03-29 12:07:52 +03:00
Samuel Mannehed
789308212b Remove unused python scripts 2021-03-29 12:07:48 +03:00
Samuel Mannehed
ce5fe304cb Fix chinese translation for "Disconnect"
Thanks for @wavezhang, @litongjava, and @bhzhu203 for helping out.
2021-03-29 12:07:41 +03:00
Samuel Mannehed
781075c841 Update chinese translation strings
Thanks to @QQ2017 and @wavezhang for helping out with correcting these.
2021-03-29 12:07:36 +03:00
Samuel Mannehed
2f43cead79 Add comment for browser and platform detection 2021-03-29 12:07:32 +03:00
Samuel Mannehed
e7a5aa271e Add short description at the top of browser.js 2021-03-29 12:07:23 +03:00
Samuel Mannehed
ad206180d2 Properly detect scrollbar gutter
As a rule, instead of hard-coding a behavior on specific platforms we
should do dynamic detection.

This commit moves away from always hiding scrollbars on Android and iOS
and instead detects the rendered width of scrollbars in the browser.
2021-03-29 12:07:09 +03:00
Pierre Ossman
89dd199317 Allow cursor to be updated while connecting
We haven't got a server provided cursor at this point, but we might
have done something local, e.g. enabled the dot cursor.
2021-03-29 12:06:42 +03:00
Pierre Ossman
8be70e5ae0 Handle slow loading of images
Internet Explorer seems to flag images as loaded prematurely, which
can result in rendering bugs. We can detect this by looking at the
dimensions though.
2021-03-29 12:06:28 +03:00
Samuel Mannehed
ce94d92e18 Build in the behavior to ignore decodeUTF8 errors
Makes the code clearer and more explicit in intent.
2021-03-29 12:03:54 +03:00
Samuel Mannehed
c3ef9ff557 Peter is no longer part of the noVNC team 2021-03-29 12:02:16 +03:00
Chris \"Koying\" Browet
c0276776e9 Add support for Unix Tight auth 2021-03-29 12:02:05 +03:00
VanyM
10f4aa9e7b Add try catch in every place that uses decodeUTF8 2021-03-29 12:02:00 +03:00
Samuel Mannehed
b2dc76ee18 Add encodeUTF8 function to core/util/strings.js 2021-03-29 12:01:15 +03:00
Pierre Ossman
12cdad066e Make Cursor.detach() safe to call when not attached
Avoids having checks in higher layers.
2021-03-29 12:01:10 +03:00
Samuel Mannehed
a850be4afa Fix chinese translation errors
Thanks to @QQ2017 for providing the translation strings
2021-03-29 12:01:07 +03:00
Samuel Mannehed
354d544843 Simplify logic for status hierarchy
Removes unnecessary variable
2021-03-29 12:01:02 +03:00
Samuel Mannehed
0bf9403a36 Ensure warning status timeouts are honored
When showing a new status popup we want to set a timer for how long to
show it. In cases where we show many statuses in a fast succession we
need to remove any running timeouts when showing a new one.

There are exceptions when new statuses won't be shown, and thats if a
more severe status is already showing, i.e and error or a warning.

Warnings can still have timeouts. There was a bug that occured when we
tried to show a normal status while a warning was showing. The bug
caused the warning status timeout to be removed even if the normal
status was never shown. We should only remove running timeouts if we're
actually going to show a new status.
2021-03-29 12:00:47 +03:00
Pierre Ossman
29db8997ec Don't use arrow functions in legacy loader
The browsers that need the legacy code do not support such fancy
modern things.
2021-03-29 12:00:38 +03:00
Pierre Ossman
46f15667f7 Load support scripts first
E.g. SystemJS requires the Promise polyfill, so make sure all our
support files are loaded first.
2021-03-29 11:59:59 +03:00
Pierre Ossman
edb5fee88b Upgrade to latest babel
There has been a lot of renaming and restructuring in babel, so we need
to modify our code to handle the latest version. We also need to adjust
the way we build our babel worker as babel itself no longer runs in older
browsers such as Internet Explorer.
2021-03-29 11:59:50 +03:00
Pierre Ossman
23871b42d1 Always include Promise polyfill for legacy browsers
It is now used by our general code and not just by the conversion
routines, so we need to make sure it is always included for the
old browsers.
2021-03-29 11:58:26 +03:00
Pierre Ossman
d6d875ef3b Clean up handling of untransformed files
This control flow is difficult enough as it is to follow. Move the
handling of the untransformed files to a separate block to make it
slightly easier to understand.
2021-03-29 11:58:20 +03:00
Pierre Ossman
6c84631bbc Remove redundant "no copy" check
We also check this list as a filter to walkDir(), so no need for the
extra check here.
2021-03-29 11:58:13 +03:00
wavezhang
6bb87ee2b2 Update zh_CN.po
fix spell errors, improve translations
2021-03-29 11:57:31 +03:00
Alex Tanskanen
15c74e7dc9 Fix missing caps lock events on iOS
Caps Lock on iOS only trigged key release or key press events.
When it's clicked it would only send keydown, and next time
it would only send keyup and so on. It should send both a key press
and a key release.

Also added the unit tests for macOS since those were missing.

Co-Authored-By: Alex Tanskanen <aleta@cendio.se>
2021-03-29 11:57:26 +03:00
Samuel Mannehed
f1be4be653 Add README to app/locale warning not to modify 2021-03-29 11:57:09 +03:00
Alex Tanskanen
b5f1a00282 Add "macOS shuffle" to iOS as well
Since iOS functions like macOS with regards to Alt behaving like AltGr,
we need the same workaround on iOS as well.
2021-03-29 11:57:05 +03:00
Pierre Ossman
740a8217ab Handle missing Shift events on Windows
This is a bug in the OS that leaks through to the browsers. We need
to fake a Shift release here to avoid Shift getting stuck in the remote
session.
2021-03-29 11:57:00 +03:00
Pierre Ossman
796de9653f Send NumLock on macOS, even though the key is Clear
There is no obvious choice what works best here, but this is what
TigerVNC has been doing for years without complaints. Let's follow
them until we get reports that this doesn't work well.
2021-03-29 11:56:55 +03:00
Pierre Ossman
6916c83b48 Fix typo for MailSend key 2021-03-29 11:56:49 +03:00
Pierre Ossman
d10d7167f6 Update to latest UI Events key specification 2021-03-29 11:56:45 +03:00
Pierre Ossman
a8dc933701 Fix AltGr for a few more keys in IE and Edge
Some keys apparently send 'Unidentified' rather than an unshifted value.
Make sure those are also handled. Examples are \ and | on a Swedish
keyboard.
2021-03-29 11:56:40 +03:00
Samuel Mannehed
d61bf69c33 Keep the virtual keyboard after using extra keys
If using the extra keys always gives focus to the screen then an
on-screen keyboard would be closed. When using on-screen keyboards we
instead want to give focus to our virtual keyboard input element.
2021-03-29 11:56:34 +03:00
Pierre Ossman
62fca18cb9 Revert iOS keyup workaround
It seems Apple has fixed their buggy keyup events, so remove the
workaround and allow keys to be kept pressed again.

This is a revert of 9e99ce126ca8f6f350fa015c0e58d35103c62f7e.
2021-03-29 11:56:31 +03:00
Pierre Ossman
dc3ddc8efc Handle broken numpad delete key in Chrome 2021-03-29 11:56:24 +03:00
Pierre Ossman
e497b53d09 Explain why Clear maps to KP_Begin 2021-03-29 11:56:11 +03:00
Pierre Ossman
7dc51fa7a5 Try to handle Meta key properly
The standards have unfortunatly caused some confusion between the Windows
key and the original Meta key. Try to handle the common case sanely at least.
2021-03-29 11:56:08 +03:00
Samuel Mannehed
443858cf83 Move focus to the screen when using extra keys
A regression from 2afda54 and friends was that you couldn't use the
extra keys and then directly use the keyboard, you would have to click
in the session first.

This commit restores the correct behavior and also adds a visual queue
to the fact that the screen got the focus by fading the controlbar.
2021-03-29 11:56:01 +03:00
Samuel Mannehed
6b39933658 Add missing scancode for sendTab 2021-03-29 11:55:55 +03:00
Samuel Mannehed
6067290169 Rename document.capturedElem to captureElement
To better fit most naming.
2021-03-29 11:55:52 +03:00
Pierre Ossman
a8699ab8cb Improve Windows key image
The previous one didn't have sharp lines, or follow pixel boundaries
properly.
2021-03-29 11:55:45 +03:00
Samuel Mannehed
996895268e Hide the emulated cursor when target is null
Makes it easier to understand what happens when a real element isn't
passed as a target to updateVisibility(). Also makes the code more
robust to future changes.

Co-authored-by: Alex Tanskanen <aleta@cendio.se>
Co-authored-by: Niko Lehto <nikle@cendio.se>
2021-03-29 11:55:38 +03:00
Samuel Mannehed
fb14c2dec9 Fix disappearing cursor after click
In the cursor emulation when deciding if the cursor should be hidden -
Instead of checking what's under the cursor, we check the element that
has capture.

This introduced another bug in the cursor emulation. The cursor did not
always disappear properly when using our cursor emulation together with
our setCapture polyfill. More specifically, we saw a problem when a
capture ended on an element without cursor emulation.

We solved this by introducing another visibility check on a timer in
the cursor emulation. However this led to yet another problem where
this timer conflicted with the timer in the setCapture polyfill.

We removed the timeout in the setCapture polyfill and created a
variable to make sure that all the events remaining in the queue can be
completed.

Co-authored-by: Alex Tanskanen <aleta@cendio.se>
Co-authored-by: Niko Lehto <nikle@cendio.se>
2021-03-29 11:55:28 +03:00
Samuel Mannehed
83d5e5bffd Check next elem at mouseleave in cursor emulation
It's not obvious that we want to hide the cursor when we get a leave,
it depends on the element that we're leaving to. This makes the code
more robust.

Co-authored-by: Alex Tanskanen <aleta@cendio.se>
Co-authored-by: Niko Lehto <nikle@cendio.se>
2021-03-29 11:55:20 +03:00
Samuel Mannehed
19dfb7901c Rename variables in setCapture proxy
The names of many variables were too similar. To make the code easier
to follow we renamed:

* _captureElem to _capturedElem
* _captureElemChanged() to _capturedElemChanged()
* captureElem to proxyElem
* elem to target

Co-authored-by: Alex Tanskanen <aleta@cendio.se>
Co-authored-by: Niko Lehto <nikle@cendio.se>
2021-03-29 11:55:13 +03:00
Pierre Ossman
6acf3c9e62 Never show drag icon if clipping is disabled
Toggling the enabled state is a remnant from an earlier version
of the code where we could determine if the the session is actually
clipped, and not just that the setting is enabled.

Right now we only change things based on the setting, so let's
completely hide the button when clipping is disabled.
2021-03-29 11:54:51 +03:00
Samuel Mannehed
0dcb896920 Update copyright to 2019 for modified files 2021-03-29 11:54:44 +03:00
Samuel Mannehed
d88aefba4e Code comments for how the receieve queue works 2021-03-29 11:54:33 +03:00
Samuel Mannehed
b0c54f6b24 Clarify why we ENABLE_COPYWITHIN is false 2021-03-29 11:54:26 +03:00
Samuel Mannehed
6342a117ff Clarify comments for broken alt in FF on Windows 2021-03-29 11:54:18 +03:00
Niko Lehto
766fc43855 Add support for VMware cursor encoding
Supports both classic cursor type and alpha cursor type. In classic
mode the server can send 'inverted' pixels for the cursor, our code
does not support this but handles these pixels as opaque black.

Co-authored-by: Samuel Mannehed <samuel@cendio.se>
2021-03-29 11:53:24 +03:00
Niko Lehto
19f0803636 Fix url cursor detection on Edge
_supportCursorURIs was set to true even when Edge didn't support
URIs because the fallback value "default" was used.
2021-03-29 11:51:50 +03:00
Niko Lehto
3c3ac34eb8 Test unicode desktop names 2021-03-29 11:51:18 +03:00
Niko Lehto
8c43287afb Add support for DesktopName extension
This extension allows session name to be changed during runtime.
2021-03-29 11:50:44 +03:00
Pierre Ossman
c16cc6e2b9 Set viewport size for autoscale tests
We were incorrectly relying on the viewport being indirectly set
for us. Make sure we are explicit in what we want for these tests.
2021-03-29 11:49:41 +03:00
Pierre Ossman
c211f31113 Remove pointless Display.clear()
It served no meaningful purpose and it had bugs. So let's remove it
rather than try to fix it.
2021-03-29 11:49:36 +03:00
Pierre Ossman
4cc536636a Remove unused Display.logo attribute 2021-03-29 11:49:21 +03:00
Pierre Ossman
734bdd3746 Deprecate showDotCursor option for RFB constructor
It is not relevant for the connection stage so it should not have
been a constructor argument to begin with. Ship with a warning for
a release before we remove it.
2021-03-29 11:47:35 +03:00
Pierre Ossman
8218a0cb2a Make sure showDotCursor can be modified before connecting
The cursor object is only attached to our canvas whilst connecting,
so we need to make sure we don't try to update anything when were
not connected or we'll get a crash.
2021-03-29 11:46:22 +03:00
Pierre Ossman
2525174260 Regenerate module loader after tool upgrades 2021-03-29 11:46:12 +03:00
Jesper Alf Dam
b0896c8859 When compacting the receive buffer don't copy unused buffer space
When compacting the receive buffer, we should only copy the bytes
between _rQi and _rQlen (the index of the first unread byte, and the
next write position).

Previously, we copied everything for _rQi up untill the end of the
buffer.
2021-03-29 11:45:23 +03:00
Jesper Alf Dam
09de4b8349 Don't compact the receive buffer unless we've actually run out of space
Previously, we would compact the buffer (moving unread data to the
start of the buffer) as follows:

- after processing a message, if there are zero unread bytes, just reset
  the indices for first and last unread byte to zero
- else, if at least 1/8th of the buffer is used, copy remaining data to the beginning of the buffer

The second option is never actually necessary, as before inserting new data
into the array, we already check if there's enough free space, and
compact the buffer first if necessary. So we've been doing a lot of
copies that weren't actually needed. Let's not do that any more.
2021-03-29 11:45:00 +03:00
Jesper Alf Dam
d4747a8c80 Avoid recursion in Alt check on Firefox
The Firefox workaround which checks for missing Alt key events may
synthesise new KeyboardEvents. On these events, checkAlt should not be
recursively triggered. Otherwise, we get "too much recursion" errors
whenever the Alt key is pressed.
2021-03-29 11:44:49 +03:00
Pierre Ossman
5b73c1ca23 Fix trivial lint issues in translation tools
Indentation, missing semicolon, etc.
2021-03-29 11:44:42 +03:00
Pierre Ossman
f21fb95bb9 Remove unused import from module loader 2021-03-29 11:44:23 +03:00
Pierre Ossman
7b02f3d8b8 Avoid deprecated called.once from sinon-chai
It's been removed in newer versions and will break eventually.
2021-03-29 11:44:04 +03:00
Samuel Mannehed
03a333fb18 Add missing parentheses for arrow func arg
Our lint tests expect this when an arrow functino has a body with
curly braces.
2021-03-29 11:43:15 +03:00
Samuel Mannehed
54253efaa0 Add documentation for the option showDotCursor
This is not only a property, it's also a parameter to the constructor.
2021-03-29 11:43:09 +03:00
Samuel Mannehed
8b859f4598 Remove the default value of wsProtocols
Using the 'binary' protocol by default is very non-standard.
2021-03-29 11:42:58 +03:00
Shira Maximov
8c5b5f17eb Add support in websocket sub-protocols 2021-03-29 11:42:28 +03:00
Juanjo Diaz
71fa476514 Add version number to UI 2021-03-29 11:40:55 +03:00
Samuel Mannehed
4fd1f19f3b Update link to websock.js API 2021-03-29 11:40:48 +03:00
Lee Yarwood
257aabecb0 launch.sh: Check for a local websockify directory
Previously launch.sh would check both for the existence of a local
websockify file and /websockify/run file.

This initial check should really be for a local websockify directory
as in packaged environments a file could very well be the actual
executable leading to launch.sh incorrectly attempting to use a local
version of websockify.
2021-03-29 11:40:40 +03:00
Pierre Ossman
74161066af Add support for separate key file in launch script 2021-03-29 11:40:25 +03:00
Samuel Mannehed
e2d86788ba Revert "Fullscreen from iframe (#1236)" (#1247)
This reverts commit 19cdc15aa314760446866a1bcc2db99a80479683.
2021-03-29 11:39:56 +03:00
Pierre Ossman
4c635f65d3 Remove server pixel format warnings
These are harmless and really only for debugging. So remove them
as they tend to trick people in to thinking something is wrong.
We already print the entire server pixel format earlier anyway in
case we need the details.
2021-03-29 11:39:47 +03:00
Ján Jockusch
1d4ada6815 Fullscreen from iframe (#1236)
* First attempt to make the fullscreen button work inside an iframe.

* Cleaner distinction between document element and document.

* Scoping corrections. Auto-detect correct iframe.

* Added comments to the relevant sections.

* IE issue fixed.

* Same source issue solved. fullscreenToggle now checks if it is permitted to inspect other iframes.
2021-03-29 11:39:32 +03:00
Samuel Mannehed
d3ec2aa4d1 noVNC 1.1.0 2021-03-29 11:39:20 +03:00
Samuel Mannehed
10c334303a Update generated JS files for translations 2021-03-29 11:39:13 +03:00
Samuel Mannehed
c4987024ef Update Dutch translations
Co-authored-by: Arend Lapere <arend.lapere@gmail.com>
2021-03-29 11:39:04 +03:00
Samuel Mannehed
04d7bef2ae Update Swedish translations 2021-03-29 11:38:58 +03:00
Samuel Mannehed
12565dc4ac Allow autoscale() with zero height or width
Commit 6e7e6f9 stopped the function from running if width or height was
zero, this commit reverts that change. This commit also makes the
resulting canvas 0x0 if autoscale is called with zero. By adding this
special case we can avoid division by zero in the calculations.
2021-03-29 11:38:52 +03:00
Pierre Ossman
46b7d1db95 Fix up errors and warnings in vnc_playback.html
Remove the styling, as it isn't really needed, and fix some minor
things that the w3c validator complains about.
2021-03-29 11:38:25 +03:00
Samuel Mannehed
0045f07965 Remove invalid HTML attributes from textarea 2021-03-29 11:37:52 +03:00
Samuel Mannehed
d1fdb877ef Fix invalid input type 'input' 2021-03-29 11:37:36 +03:00
Samuel Mannehed
e62e12fbfe Input type image is not allowed to have values 2021-03-29 11:37:18 +03:00
Samuel Mannehed
50183c7caa Add default language 2021-03-29 11:36:20 +03:00
Samuel Mannehed
79ab05192b Add check for bad values for Display.autoscale() 2021-03-29 11:36:08 +03:00
Juanjo Diaz
c6c278f9d5 Replace unnecessary function supportsCursorURIs by a constant variable 2021-03-29 11:35:44 +03:00
Juanjo Diaz
37c17ddbf9 Move support check from display to browser 2021-03-29 11:35:38 +03:00
Dmitriy Shweew
c755008d15 Add Russian translation (#1211)
By Dmitriy Shweew (shweew)
2021-03-29 11:35:31 +03:00
Juanjo Diaz
075eed5cbb Convert DES into a class 2021-03-29 11:35:23 +03:00
Juanjo Diaz
7b7295fd4e Use default argument for base64 2021-03-29 11:35:16 +03:00
Juanjo Diaz
5964156a6f Remove unnecessary context from eventtarget 2021-03-29 11:35:11 +03:00
Juanjo Diaz
1ff792cf4b Remove unnecessary constructor parameter from Cursor 2021-03-29 11:35:06 +03:00
Juanjo Diaz
3043216b63 Remove intermediate variable from mouse 2021-03-29 11:34:56 +03:00
Pierre Ossman
499b251716 Remove error handling in clientCutText()
It is not necessary as Websock.flush() is guaranteed to succeed and
give us some space. It also remove the call to _fail(), which was
invalid at this place as clientCutText() is not a method on RFB.
2021-03-29 11:34:50 +03:00
Pierre Ossman
d20f751441 Throw correct Error object
We've already defined the name Error as a logging function, so we
need to be more explicit when we want to refer to the exception
class.
2021-03-29 11:34:45 +03:00
Pierre Ossman
915901848d Send data one byte at a time in tests
This makes sure we don't have code assuming that everything is
neatly packaged in a single WebSocket message.
2021-03-29 11:34:38 +03:00
Pierre Ossman
ee2423ed2b Clean up RFB._rfb_auth_schema assignment 2021-03-29 11:34:29 +03:00
Pierre Ossman
ce6d66f030 Fix security failure reason handling of slow data
Things would break if the security result and security reason did
not arrive in the same WebSocket message.
2021-03-29 11:34:21 +03:00
Pierre Ossman
41e6fedba6 Fix version handshake to handle slow data 2021-03-29 11:34:08 +03:00
Pierre Ossman
642a67f76f Use arrow function to avoid bind 2021-03-29 11:34:00 +03:00
Pierre Ossman
d7198cbe5d Consume data properly in Hextile decoder
We accidentally removed the code updating the data index in 8a189a6,
resulting in the decoder newer consuming any data. So the data would
be parsed as the next rect, causing weird errors.
2021-03-29 11:33:25 +03:00
lhchavez
25b8e64adb Add support for notifying clients about pointer movements
This change adds support for the VMware Mouse Position
pseudo-encoding[1], which is used to notify VNC clients when X11 clients
call `XWarpPointer()`[2]. This function is called by SDL (and other
similar libraries)  when they detect that the server does not support
native relative motion, like some RFB clients.

With this, RFB clients can choose to adjust the local cursor position
under certain circumstances to match what the server has set. For
instance, if pointer lock has been enabled on the client's machine and
the cursor is not being drawn locally, the local position of the cursor
is irrelevant, so the RFB client can use what the server sends as the
canonical absolute position of the cursor. This ultimately enables the
possibility of games (especially FPS games) to behave how users expect
(if the clients implement the corresponding change).

Part of: #619

1: https://github.com/rfbproto/rfbproto/blob/master/rfbproto.rst#vmware-cursor-position-pseudo-encoding
2: https://tronche.com/gui/x/xlib/input/XWarpPointer.html
3: https://hg.libsdl.org/SDL/file/28e3b60e2131/src/events/SDL_mouse.c#l804
2021-03-29 11:27:54 +03:00
Pierre Ossman
d8caab699d Add missing headers for TCP_CORK
We didn't include the proper headers to get the correct define, so
corking was never enabled.
2021-03-29 11:04:00 +03:00
Pierre Ossman
da83ecf86a Drop other selection on ownership change
Otherwise we might end up owners of something we cannot deliver data on,
which can hang applications.
2021-03-29 11:03:38 +03:00
Pierre Ossman
189f503b98 Fix handling of bad update requests
We computed a safe area if a client gave us a bogus one, but we didn't
actually use it. Fix this properly and make sure we don't pass on bad
coordinates further.
2021-03-29 11:00:41 +03:00
Pierre Ossman
f54dc7829a Update keycode maps to latest version
Mainly fixes for Japanese and Korean keyboard layouts.
2021-03-29 10:57:41 +03:00
Pierre Ossman
fde088ce65 Improved bandwidth monitoring
Now measures over an entire update, which should hopefully give us more
stable values. They are still small values for fast networks though so
increase precision in the values we keep.
2021-03-29 10:52:51 +03:00
Pierre Ossman
a55f142c98 Don't shuffle input buffer unless actually needed 2021-03-29 10:50:16 +03:00
Pierre Ossman
25995e2490 Remove unused bufSize argument from streams 2021-03-29 10:49:25 +03:00
Pierre Ossman
281d65292a Remove special functions from JPEG compressor
We can do what we want with the standard methods.
2021-03-29 10:48:55 +03:00
Pierre Ossman
57a3c3bba8 Simplify stream availability handling
Just have a simply number of bytes argument to avoid a lot of
complexity.
2021-03-29 10:48:26 +03:00
Pierre Ossman
92c7695981 Create common base classes for buffered streams
Most streams are backed by a memory buffer. Create common base classes
for this functionality to avoid code duplication.
2021-03-29 10:11:16 +03:00
Pierre Ossman
7f90205cf2 Add stream avail() methods
Makes it more readable to write code that needs to know how much
data/space is available in a stream.
2021-03-29 10:08:40 +03:00
Pierre Ossman
910fd8fa3e Remove unused stream methods
They were accidentally left unused in fbad8a9 so they haven't been used
in some time.
2021-03-29 10:04:04 +03:00
Pierre Ossman
c97828471c Use proper constants for socket shutdown()
For readability.
2021-03-29 10:03:05 +03:00
Pierre Ossman
c5b7137f2b Flush data on close
There might be some final handshake data that is still stuck in the
buffers, so make a best effort attempt at getting it to the client.
2021-03-29 10:02:31 +03:00
Pierre Ossman
a3c0ce55c9 Support calling methods from timers
We can't safely use the normal timers in base classes as we cannot
guarantee that subclasses will call the base class' handleTimeout()
properly if the subclass overrides it.
2021-03-29 09:58:18 +03:00
Kasm
02721a0270 Merge pull request #34 from kasmtech/bugfix/freezing
Apply patch for 1.20.x
2021-03-28 07:54:47 -04:00
matt
29415a8c7d Apply patch for 1.20.x 2021-03-26 19:53:04 +00:00
Kasm
0638245ff9 Merge pull request #33 from kasmtech/vncserver-remove-basicauth
Vncserver remove basicauth
2021-03-26 13:40:53 -04:00
Dmitry Maksyoma
9b3e1f73f5 Deb/rpm: update barebones images 2021-03-26 01:10:43 +13:00
Dmitry Maksyoma
da4ff4fa70 Merge branch 'master' into vncserver-remove-basicauth 2021-03-25 23:16:22 +13:00
Kasm
1e8451ce21 Merge pull request #32 from kasmtech/squashed_buster_release
CI building and uploading to S3, prepare deb release
2021-03-25 06:13:31 -04:00
Dmitry Maksyoma
4e8750e37a Disable passing of basicauth in vncserver 2021-03-25 23:05:20 +13:00
Dmitry Maksyoma
ca326ee1f1 Revert "Update README: deb installation only"
This reverts commit 213f91c1a7.
2021-03-25 22:27:47 +13:00
Dmitry Maksyoma
40facbcc46 Revert "Improve README.md"
This reverts commit e5cd3d6753.
2021-03-25 22:27:47 +13:00
Dmitry Maksyoma
963ea6b6d3 Revert "README.md formatting"
This reverts commit fc12e38571.
2021-03-25 22:27:47 +13:00
Dmitry Maksyoma
f758fc5021 CI: build all distros and upload to S3 2021-03-25 22:27:27 +13:00
Lauri Kasanen
1632f4888d Enable basicauth by default, remove the option to supply it on the command line 2021-03-25 11:25:30 +02:00
matt
93d3bf052d Removed old line 2021-03-22 11:36:33 +00:00
matt
7b3f6876b4 Fixed syntax error 2021-03-22 11:23:49 +00:00
matt
46e03289be Manually merged region changes 2021-03-22 10:36:39 +00:00
Dmitry Maksyoma
56fd118c43 CI: extract after_script 2021-03-18 23:17:52 +13:00
Dmitry Maksyoma
9a9b14daf1 CI: extract before_script 2021-03-18 23:01:28 +13:00
Dmitry Maksyoma
349ed4cb41 CI: remove tarballs from artifacts 2021-03-18 22:42:40 +13:00
Lauri Kasanen
c3e30dcea1 Add support for DLP_Region 2021-03-15 13:48:56 +02:00
Dmitry Maksyoma
fc12e38571 README.md formatting 2021-03-15 22:38:08 +13:00
Dmitry Maksyoma
e5cd3d6753 Improve README.md 2021-03-15 22:37:48 +13:00
Dmitry Maksyoma
7bffbb53da vncserver: remove securitytypes mention from man page
securitytypes is no longer used.
2021-03-15 22:27:19 +13:00
Dmitry Maksyoma
df92791550 Gitlab CI: build all distros if branch has "release" or "testing" in it 2021-03-15 21:59:39 +13:00
Dmitry Maksyoma
25c32c96e5 Deb: fix Ubuntu Focal (vnc_startup.sh XFCE start issue) 2021-03-14 23:38:48 +13:00
Dmitry Maksyoma
213f91c1a7 Update README: deb installation only 2021-03-14 23:25:53 +13:00
Dmitry Maksyoma
ed4c514bcb Deb: test images have lsb-release now
To ensure it's the right image, I double-check with lsb_release.
2021-03-14 23:24:14 +13:00
Dmitry Maksyoma
2005b86a92 Deb: make easy-start script easier to modify 2021-03-14 21:19:08 +13:00
Dmitry Maksyoma
d73ffc8a38 Deb: example script can now -kill, -d (debug), --help 2021-03-14 21:01:04 +13:00
Dmitry Maksyoma
a73b890c92 Code formatting 2021-03-13 23:51:33 +13:00
Dmitry Maksyoma
8c2e8c9acb Deb: add example script to easily run kasmvncserver 2021-03-13 21:54:06 +13:00
Dmitry Maksyoma
b48fa8a262 vncpasswd man: update the top level description 2021-03-13 21:51:54 +13:00
Dmitry Maksyoma
6f803f744d vncpasswd man: update to be current regarding password length 2021-03-13 21:48:59 +13:00
Dmitry Maksyoma
79682d3dee vncpasswd man: add overview 2021-03-13 20:17:23 +13:00
Dmitry Maksyoma
2b8374f544 Update vncpasswd manual page 2021-03-13 20:07:06 +13:00
Lauri Kasanen
fed991d697 Return 401 unauth for non-owner trying /api/ 2021-03-04 13:59:29 +02:00
Lauri Kasanen
1269fddadf Add a more specific error for a nonexistent screenshot 2021-03-04 13:43:05 +02:00
Dmitry Maksyoma
56ed2855bd Testing: keep foo-owner as -o and -w
Changing permissions to just -w removed -o.
2021-03-04 23:22:28 +13:00
Lauri Kasanen
688e749fda Tentative build fix for newer gccs 2021-03-03 15:33:58 +02:00
Lauri Kasanen
980eedd33b Add HTTP GET APIs for creating, removing users and giving control 2021-03-03 14:55:14 +02:00
Dmitry Maksyoma
43658a27f7 Deb: provide an easy way to start KasmVNC with default options
...via kasmvncserver-start.
2021-03-03 23:27:02 +13:00
Dmitry Maksyoma
e61885a448 Deb: remove obsolete code 2021-03-03 23:09:52 +13:00
Dmitry Maksyoma
8eb7e06d6c Deb: update Debian Buster barebones test to work 2021-03-03 22:47:48 +13:00
Dmitry Maksyoma
62eae815b6 Remove obsolete comment 2021-03-03 22:04:09 +13:00
Lauri Kasanen
3f6524ee30 Add support for owner screenshot HTTP GET API 2021-03-02 15:23:32 +02:00
Kasm
784a9c611d Merge pull request #26 from kasmtech/multiuser_and_new_ui
Packaging changes, multiuser passwd, clipboard (UI) changes
2021-03-01 10:46:20 -05:00
Dmitry Maksyoma
05ea1b99ee Merge branch 'KASM-1298_manually_merge_offline_changes' into multiuser_and_new_ui 2021-02-28 22:55:47 +13:00
Dmitry Maksyoma
101695970b Reapply "Use crypt_r in threaded code" 2021-02-28 22:53:06 +13:00
Dmitry Maksyoma
6d0a020f4f Move build-and-test-* to builder/ 2021-02-28 21:28:14 +13:00
Dmitry Maksyoma
5e5467a3b0 Add build-and-test-deb and -rpm
It builds tarball, deb/rpm pckage, and runs the test image. It doesn't
detect source changes, so it'll always build tarball and the package.
2021-02-28 21:24:59 +13:00
Dmitry Maksyoma
9fb709087d Add verbose logging via KASMVNC_VERBOSE_LOGGING env var
Running "KASMVNC_VERBOSE_LOGGING=1 builder/test-deb debian buster" will
turn on verbose logging of kasmvncserver.
2021-02-28 21:21:49 +13:00
Dmitry Maksyoma
e0c056f36b Add rw, ro and owner users on container startup 2021-02-28 21:03:02 +13:00
Dmitry Maksyoma
7a1c1edeb4 Deb/rpm: change test user password to "foobar"
kasmvncpasswd validates password, so "bar" would be too short.
2021-02-28 20:48:17 +13:00
Dmitry Maksyoma
489c68f7cc Merge branch 'users' into packages_and_multiuser_passwd 2021-02-28 19:50:27 +13:00
Dmitry Maksyoma
01d448f018 Deb: run test image, instead of just printing command 2021-02-28 19:46:18 +13:00
Kasm
f981b1e88a Update ui.js 2021-02-26 10:10:00 -05:00
Kasm
e79b454fb5 Merge pull request #22 from kasmtech/create_fedora_package
Create fedora package
2021-02-25 07:27:24 -05:00
Lauri Kasanen
59fe8ad9db kasmvncpasswd: Nicer behavior when piping a password, add example in help 2021-02-25 13:15:02 +02:00
Dmitry Maksyoma
78768d52ff VNC Docker startup: commented out verbose logging for ease of use 2021-02-25 23:14:50 +13:00
Dmitry Maksyoma
e9626fdacf VNC Docker startup: use new kasmvncpasswd with multiple users support 2021-02-25 23:13:32 +13:00
Dmitry Maksyoma
9084409a20 Merge branch 'users' into packages_and_multiuser_passwd 2021-02-25 22:10:40 +13:00
Dmitry Maksyoma
a5e3a47f48 Merge branch 'master' into create_fedora_package 2021-02-25 22:00:38 +13:00
Dmitry Maksyoma
fbfdf21612 Deb: Debian Bullseye XFCE works now 2021-02-25 21:58:10 +13:00
Dmitry Maksyoma
d7916b081b Deb: Kali XFCE works now 2021-02-25 21:33:38 +13:00
Dmitry Maksyoma
fbe05cee86 Fix random 401 Forbidden on Ubuntu 20 and other newer releases 2021-02-25 21:23:21 +13:00
Dmitry Maksyoma
120dcbeaba Deb: fix code formatting 2021-02-25 21:22:56 +13:00
Lauri Kasanen
6052f28537 Use crypt_r in threaded code 2021-02-24 14:46:48 +02:00
Dmitry Maksyoma
b3ec357e99 Rpm: extract rpm-related install to the spec 2021-02-24 22:53:43 +13:00
Dmitry Maksyoma
a865b6e6eb Deb/Rpm: all file copying to packages is done in debian/ atm 2021-02-24 21:20:33 +13:00
Dmitry Maksyoma
9301fe9d33 Deb/Rpm: add package description 2021-02-24 21:19:49 +13:00
Dmitry Maksyoma
7f9a50562d Deb: fix build dependencies install 2021-02-24 21:16:53 +13:00
Dmitry Maksyoma
ece969fd05 Rpm: group kasmvnc -> kasmvnc-cert
I feel it'd be confusing to use kasmvnc group to provide access to the
TSL certificate. Groups like that control whether you can run software,
e.g. "docker" group. Using "-cert" clearly shows it's just for
certificate access. Not unlide ssl-cert group in Debian.
2021-02-22 22:28:30 +13:00
Dmitry Maksyoma
969c64ced3 Packages: Ubuntu 20 and Fedora 33 barebones tests 2021-02-22 21:25:02 +13:00
Dmitry Maksyoma
f6e2675c02 Rpm: initial Fedora support 2021-02-22 21:24:16 +13:00
Dmitry Maksyoma
0d62f6b7aa Rpm: don't use update-alternatives
Even if I set rpm as conflicting with TigerVNC, update-alternatives
breaks in post-install. That is because files like /usr/bin/vncserver
are left from TigerVNC, when post-install runs.

So, I chose to use /usr/bin/vncserver without update-alternatives.
2021-02-22 21:21:21 +13:00
Dmitry Maksyoma
9e7d57cc3c tarball: include Xvnc.1 man page 2021-02-19 22:58:38 +13:00
Dmitry Maksyoma
24ea2d6c45 Deb: switch Buster barebones to use no WM 2021-02-18 22:32:09 +13:00
Dmitry Maksyoma
6575bbe1b3 Rpm: run xterm w/o WM in CentOS 7 barebones test 2021-02-18 22:00:34 +13:00
Kasm
c401a21c7c Merge pull request #20 from kasmtech/create_ubuntu20_package
Debian, Ubuntu, Kali, CentOS support
2021-02-17 08:25:01 -05:00
Dmitry Maksyoma
5159cb9ae1 build-tarball: only rebuild www if it was changed 2021-02-16 22:21:48 +13:00
Dmitry Maksyoma
7bcf8ebf1f Update GitLab pipeline to use new build/ structure 2021-02-14 19:20:13 +13:00
Dmitry Maksyoma
c151f479f4 Merge branch 'master' into create_ubuntu20_package 2021-02-14 18:59:53 +13:00
Dmitry Maksyoma
4f561568a3 Rpm: make rpmlint happier 2021-02-12 23:07:53 +13:00
Dmitry Maksyoma
0aeffaf2ef Rpm: run rpmlint after building rpm 2021-02-12 23:07:03 +13:00
Dmitry Maksyoma
0d0f8afceb Update FSF address in licences to please rpmlint 2021-02-12 23:06:40 +13:00
Dmitry Maksyoma
e9e7ecd74d Rpm: create certificate on postinst, remove on postrm 2021-02-12 18:11:27 +13:00
Dmitry Maksyoma
b97633ca10 Rpm: automate rpm building with build-rpm 2021-02-11 21:50:14 +13:00
Dmitry Maksyoma
d658f2b8a3 Deb: trim cruft from Makefile 2021-02-11 20:46:05 +13:00
Dmitry Maksyoma
69efc52614 Rpm: add test-rpm-barebones with Openbox
Twm wasn't available.
2021-02-11 20:45:01 +13:00
Dmitry Maksyoma
49996f91e6 Rpm: trim cruft in spec file 2021-02-11 20:44:08 +13:00
Dmitry Maksyoma
a8507afb21 Rpm: add runtime dependencies 2021-02-11 20:43:21 +13:00
matt
c81df7f198 KASM-1298 manually merged in offline changes 2021-02-07 11:12:18 +00:00
Dmitry Maksyoma
90101a7e91 Rpm: CentOS dfart. Rpm building isn't automated yet. 2021-02-05 23:49:47 +13:00
Dmitry Maksyoma
a6512a7801 Docker copy will ignore builder/build, where debs are 2021-02-05 23:40:44 +13:00
Kasm
57f4e0a856 Merge pull request #18 from kasmtech/gitlab-pipeline-produce-deb
Gitlab pipeline produce deb
2021-02-03 12:51:27 -05:00
Dmitry Maksyoma
b98a9eb5fa Pkg build: patch with quilt if it's present 2021-01-29 22:52:10 +13:00
Dmitry Maksyoma
b224addece Deb: add first quilt patch 2021-01-29 22:12:43 +13:00
Dmitry Maksyoma
9fbda8e518 Deb: add Bullseye support 2021-01-29 21:29:04 +13:00
Dmitry Maksyoma
2e98b08cec Deb: add Kali kali-rolling support 2021-01-28 23:46:21 +13:00
Dmitry Maksyoma
9eb9664bcf Pkg test: refactor for readability 2021-01-28 23:44:25 +13:00
Dmitry Maksyoma
ead31ae2e7 Pkg test: use dpkg to find libnss_wrapper.so 2021-01-28 23:35:57 +13:00
Dmitry Maksyoma
6d6ebffeae Package building: compile with debug symbols for deb purposes 2021-01-28 22:45:36 +13:00
Dmitry Maksyoma
070458d302 Deb: release numbers (18.04) -> codenames (bionic) 2021-01-28 22:10:46 +13:00
Dmitry Maksyoma
e5b8d4df11 Deb: add barebones testing image for Debian 10 2021-01-26 21:45:33 +13:00
Dmitry Maksyoma
7a6067e081 Deb: add Xorg-related dependencies 2021-01-26 21:44:56 +13:00
Dmitry Maksyoma
acd9f18f64 Deb: remove python dependency
Programs in www/utils are no longer included, and nothing else uses it.
2021-01-22 22:10:02 +13:00
Dmitry Maksyoma
c5061e67b4 Deb: Debian 10 support 2021-01-22 21:54:22 +13:00
Dmitry Maksyoma
b6f16eabb7 Deb: woraroudn dbgsym package that's created now 2021-01-22 21:53:52 +13:00
Dmitry Maksyoma
0851741360 Deb: Debian 10 building requires package libsm6 2021-01-22 21:52:05 +13:00
Dmitry Maksyoma
3c3eed0e46 Deb: exclude www/utils, instead of individual files 2021-01-21 23:35:56 +13:00
Dmitry Maksyoma
f7e6d8d039 Deb: build-deb doesn't fail if Lintian complains
For now, disable Lintian warnings. In the future, a flag may be used to
determine this behaviour.
2021-01-21 22:09:43 +13:00
Dmitry Maksyoma
39e5cbc182 Fix build-tarball: use dir shared between GitLab runner and Docker 2021-01-21 22:09:32 +13:00
Dmitry Maksyoma
e456357c68 Deb: empty postrm -> postrm.ex 2021-01-21 00:24:59 +13:00
Dmitry Maksyoma
85f2ed4f71 Gitignore deb building tmp files 2021-01-21 00:20:02 +13:00
Dmitry Maksyoma
2b9a4d0d8b Deb: remove /etc/kasmvnc and cert generation as we use snakeoil now 2021-01-21 00:14:30 +13:00
Dmitry Maksyoma
a479b2fcd4 Use snakeoil certificate if available 2021-01-20 23:56:50 +13:00
Dmitry Maksyoma
c32137fa17 Merge branch 'master' into create_ubuntu20_package 2021-01-20 23:39:29 +13:00
Lauri Kasanen
0d47d4890a Enable TLS 1.1 and 1.2 2021-01-20 22:49:32 +13:00
Dmitry Maksyoma
a6d37c2a31 Deb: update test-deb to use debs in <os>_<os_ver> dirs 2021-01-19 23:23:33 +13:00
Dmitry Maksyoma
fbeed1da72 Deb: put debs under <os>_<os_ver> directories 2021-01-19 23:02:49 +13:00
Dmitry Maksyoma
35cf095a31 Deb: create Ubuntu 20.04 tarball and deb 2021-01-19 22:44:32 +13:00
Kasm
dd3364822d Update build-tarball 2021-01-18 13:46:24 -06:00
Kasm
c1691b6895 Update .gitlab-ci.yml 2021-01-18 13:30:05 -06:00
Kasm
ec5a73c8ec Update .gitlab-ci.yml 2021-01-18 13:26:37 -06:00
Kasm
7e5c8c9ad3 Update .gitlab-ci.yml 2021-01-18 13:17:10 -06:00
Kasm
48bc79162a Added gitlab pipeline 2021-01-18 13:12:23 -06:00
Kasm
41d518eda4 Merge pull request #16 from kasmtech/create_ubuntu_packages
Create Ubuntu 18.04 package
2021-01-18 13:02:38 -06:00
matt
2813e7fe09 Fixes to webcode for Kasm CDI 2021-01-18 18:58:31 +00:00
Lauri Kasanen
a4e70ff56b Remove less-than-256-colors indexed limit for small rects 2021-01-15 13:08:20 +02:00
Lauri Kasanen
83c83f43ef Add a parameter for separate SSL key 2021-01-15 13:07:53 +02:00
Dmitry Maksyoma
a4369e8897 Deb: apt -> apt-get, cause apt doesn't have a stable interface 2021-01-15 22:49:28 +13:00
Dmitry Maksyoma
5ffe76f08d Deb: don't install libjpeg-dev on deb test image
Dependencies should be pulled by the package.
2021-01-15 22:48:32 +13:00
Dmitry Maksyoma
1486f3f4c2 Deb: use /etc/kasmvnc/server.pem cert in builder/test-deb 2021-01-14 23:15:17 +13:00
Dmitry Maksyoma
b8c380d17f Deb: move self-signed cert to /etc/kasmvnc 2021-01-14 22:13:46 +13:00
Dmitry Maksyoma
fc91e4d622 Don't use "sodu docker", just "docker" 2021-01-14 21:25:41 +13:00
Dmitry Maksyoma
2a64e062c4 Gitignore builder/www, builder/build 2021-01-14 19:07:04 +13:00
Dmitry Maksyoma
955183dcf0 Use/build ./builder/www when building tarball 2021-01-14 19:04:43 +13:00
Dmitry Maksyoma
d98157f3fc Merge remote-tracking branch 'origin/webpack2' into create_ubuntu_packages 2021-01-12 23:26:59 +13:00
Dmitry Maksyoma
945f9a07a3 Deb: exclude .eslintrc 2021-01-12 22:22:21 +13:00
matt
4394ab6edd Merge branch 'webpack2' of https://github.com/kasmtech/KasmVNC into webpack2 2021-01-10 19:05:17 +00:00
matt
76f8d905f0 added dockerfile build process for www 2021-01-10 19:03:13 +00:00
matt
de4ddcb154 Fix auth error and build permissions 2021-01-10 16:24:09 +00:00
arsenmanukyan94
b9cdecc34c update gitignore 2021-01-09 13:38:10 +00:00
matt
d71734a206 initial commit of webpack 2021-01-08 12:48:07 +00:00
Dmitry Maksyoma
2b801e3397 Deb: remove obsolete code 2021-01-08 00:42:37 +13:00
Dmitry Maksyoma
543796d6a4 Deb: automated build chain draft ready 2021-01-07 23:28:58 +13:00
Dmitry Maksyoma
4558750348 Deb: remove a TODO comment 2021-01-07 23:27:39 +13:00
Dmitry Maksyoma
be854aef68 Add www dir detection to vnc_startup.sh 2021-01-07 23:10:04 +13:00
Dmitry Maksyoma
59382451dc Deb: build-deb now builds a .deb for Ubuntu 18
It builds the builder image first, then proceeeds to building .deb
inside it, and the result is put into the parent (../) directory.
2021-01-07 21:57:53 +13:00
Dmitry Maksyoma
702f817845 Deb: add build-tarball and build-deb commands WIP 2021-01-07 00:36:52 +13:00
Dmitry Maksyoma
5154f86b60 Deb: add lots of libraries as build dependencies
This way, no need to copy that over multiple dockerfiles, and is a best
practice.
2021-01-07 00:32:30 +13:00
Dmitry Maksyoma
d82d67762e Merge branch 'feature/12_ubuntu_20' into create_ubuntu_packages 2021-01-05 23:36:21 +13:00
Dmitry Maksyoma
f1b3e0f6de Deb: remove redundant code 2021-01-03 23:35:23 +13:00
Dmitry Maksyoma
c6d3c5271c Deb: exclude Node scripts from the package 2021-01-03 23:29:04 +13:00
Dmitry Maksyoma
eaa5c24439 Generate self-signed cert in /etc/ssl/private/kasmvnc.pem
I piggyback on ssl-cert package that's got ssl-cert group and the
directory /etc/ssl/private, the group can read files from (but not list
files there). Thus, by adding a user to ssl-cert group, they can read
both ssl-cert certificates and the KasmVNC certificate.o

Note: currently, KasmVNC only supports one file that must contain both
private and public keys. For this reason, I didn't use the snakeoil
certificate from ssl-cert, as it's split into two files.
2021-01-03 23:12:21 +13:00
Dmitry Maksyoma
a7e7deaf99 Deb: add as vncserver, etc alternative 2020-12-31 01:09:51 +13:00
Dmitry Maksyoma
f8c3d981bf Deb: update dependencies, add Provides: vnc-server 2020-12-31 01:09:11 +13:00
Dmitry Maksyoma
a1089dd356 Deb: XkasmVnc -> Xkasmvnc 2020-12-31 01:08:31 +13:00
Dmitry Maksyoma
1f266ad206 Add dependencies on python and xorg to .deb 2020-12-29 23:28:03 +13:00
Dmitry Maksyoma
54f163a44c Exclude .git* files from .deb 2020-12-29 23:27:32 +13:00
Dmitry Maksyoma
251b8a6388 -beta -> ~beta for .deb 2020-12-29 22:01:27 +13:00
Dmitry Maksyoma
fccd9d29cd Update debian/copyright to include libwebp license 2020-12-29 21:52:49 +13:00
Dmitry Maksyoma
bab0412bc5 Add man pages and improve file locations in .deb 2020-12-29 21:32:31 +13:00
Dmitry Maksyoma
0b4804a3a9 Properly name binaries in .deb 2020-12-29 21:12:58 +13:00
Dmitry Maksyoma
f1291cb520 Draft .deb build system ready 2020-12-29 20:47:16 +13:00
Dmitry Maksyoma
dabf7d4d5e Clean up Makefile I use to fake-build source 2020-12-27 00:10:30 +13:00
Dmitry Maksyoma
86c6ae566c Debian package spike. Using ../release as bin/ source. 2020-12-26 00:33:19 +13:00
matt
55f9755dbd Added build docker images for debian and others 2020-12-24 19:54:58 +00:00
Lauri Kasanen
481b063eb7 Fix missing init for DLP timestamps 2020-12-03 12:29:38 +02:00
Kasm
ef23f13045 Update README.md
missing step in instructions
2020-11-04 15:25:23 -05:00
matt
28d19cd556 Disable VNC password, fix bug when running inside Kasm VDI 2020-10-29 19:24:59 +00:00
Lauri Kasanen
531705c05c Remove set-desktop-size perms from read-only clients 2020-10-14 15:50:28 +03:00
Lauri Kasanen
1f69d1584a Prevent read-only clients from changing kasm settings 2020-10-14 15:44:48 +03:00
Lauri Kasanen
a27744bca6 Enable TLS 1.1 and 1.2 2020-10-14 14:39:33 +03:00
Lauri Kasanen
36deba3a75 Correct non-basicauth and command-line user:pass being read-only 2020-10-14 14:27:08 +03:00
Lauri Kasanen
0c83a86bc8 Dynamically apply permissions 2020-10-13 13:38:18 +03:00
Lauri Kasanen
263d05a296 Apply read-only perms upon connecting 2020-10-12 15:11:49 +03:00
Lauri Kasanen
9a5afc5a62 Handle the new, multi-user kasmpasswd format auth 2020-10-12 14:58:11 +03:00
Lauri Kasanen
30b9a82c08 kasmvncpasswd: Add delete support 2020-10-12 13:34:18 +03:00
Kasm
e23bd08167 Delete index.html 2020-10-12 06:29:06 -04:00
matt
8fc49afcae Add sym link for index.html 2020-10-12 10:21:29 +00:00
mmcclaskey
730fdcb15c Merge pull request #10 from kasmtech/docker
Docker
2020-10-11 13:46:09 -04:00
mmcclaskey
9f8fa7bf8b Update README.md 2020-10-11 13:44:40 -04:00
mmcclaskey
7bc0b29413 Update README.md 2020-10-11 13:41:11 -04:00
mmcclaskey
2afe7b5fa5 Create README.md 2020-10-11 13:33:35 -04:00
mmcclaskey
097fe0815c Added Containerized example Doom 2020-10-11 17:22:42 +00:00
Kasm
9c50cae9fd Update README.md
updated install instructions
2020-10-11 08:16:40 -04:00
Lauri Kasanen
896950ea13 kasmvncpasswd: Add support for multiple users 2020-10-09 15:36:03 +03:00
400 changed files with 7410 additions and 92145 deletions

View File

@@ -0,0 +1,20 @@
#!/usr/bin/ruby
package_name = ARGV.first
DEB_PACKAGE_REGEX = %r!(?<os>[^/]+)/kasmvncserver_.+?_(?<arch>.+?).(?<format>deb)!
RPM_PACKAGE_REGEX = %r!(?<os>[^/]+)/kasmvncserver-.+?\.(?<arch>[^.]+).(?<format>rpm)!
if matches = package_name.match(DEB_PACKAGE_REGEX)
else matches = package_name.match(RPM_PACKAGE_REGEX)
end
os = matches["os"]
arch = matches["arch"]
package_format = matches["format"]
puts <<-EXPORT
export PACKAGE_OS=#{os}
export OS_ARCH=#{arch}
export PACKAGE_FORMAT=#{package_format}
EXPORT

25
.ci/next_release_version Executable file
View File

@@ -0,0 +1,25 @@
#!/bin/bash
set -e
version_from_tags() {
git tag | sort -r | head -1 | sed -e 's/^v//' -e 's/\-.\+//' | awk -F. -v OFS=. 'NF==1{print ++$NF}; NF>1{if(length($NF+1)>length($NF))$(NF-1)++; $NF=sprintf("%0*d", length($NF), ($NF+1)%(10^length($NF))); print}'
}
branch_name="$1"
if [ -z "$branch_name" ]; then
echo >&2 "Usage: `basename $0` <branch_name>"
exit 1
fi
if echo "$branch_name" | grep -Pq '^release/([\d.]+)$'; then
RELEASE_BRANCH=1
fi
if [ -n "$RELEASE_BRANCH" ]; then
RELEASE_VERSION=$(echo "$branch_name" | sed 's!release/!!');
else
RELEASE_VERSION="$(version_from_tags)"
fi
echo "$RELEASE_VERSION"

40
.ci/upload.sh Normal file
View File

@@ -0,0 +1,40 @@
#!/bin/bash
function prepare_upload_filename() {
local package="$1";
.ci/detect_os_arch_package_format "$package" > /tmp/os_arch_package_format;
source /tmp/os_arch_package_format;
detect_release_branch
if [ -n "$RELEASE_BRANCH" ]; then
export upload_filename="kasmvncserver_${PACKAGE_OS}_${RELEASE_VERSION}_${OS_ARCH}.${PACKAGE_FORMAT}";
else
export SANITIZED_BRANCH="$(echo $CI_COMMIT_REF_NAME | sed 's/\//_/g')";
export upload_filename="kasmvncserver_${PACKAGE_OS}_${RELEASE_VERSION}_${SANITIZED_BRANCH}_${CI_COMMIT_SHA:0:6}_${OS_ARCH}.${PACKAGE_FORMAT}";
fi
};
function upload_to_s3() {
local package="$1";
local upload_filename="$2";
# Transfer to S3
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
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() {
export DEBIAN_FRONTEND=noninteractive;
apt-get update;
apt-get install -y ruby2.7 git;
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;
};
detect_release_branch() {
if echo $CI_COMMIT_REF_NAME | grep -Pq '^release/([\d.]+)$'; then
export RELEASE_BRANCH=1;
fi
}

1
.dockerignore Normal file
View File

@@ -0,0 +1 @@
builder/build

10
.gitignore vendored
View File

@@ -11,3 +11,13 @@ CMakeCache.txt
Makefile
Makefile.in
config.h
builder/build/
builder/www/
# Deb building artefacts
debian/.debhelper/
debian/files
debian/kasmvncserver.substvars
debian/kasmvncserver/
.pc

111
.gitlab-ci.yml Normal file
View File

@@ -0,0 +1,111 @@
image: docker
services:
- docker:dind
variables:
GITLAB_SHARED_DIND_DIR: /builds/$CI_PROJECT_PATH/shared
GIT_SUBMODULE_STRATEGY: normal
GIT_FETCH_EXTRA_FLAGS: --tags
stages:
- build
- upload
.prepare_build: &prepare_build
- ls -l
- pwd
- apk add bash
- mkdir -p "$GITLAB_SHARED_DIND_DIR" && chmod 777 "$GITLAB_SHARED_DIND_DIR"
.prepare_artfacts: &prepare_artfacts
- mkdir output
- cp -r builder/build/* output/
- rm output/*.tar.gz
build_ubuntu_bionic:
stage: build
before_script:
- *prepare_build
after_script:
- *prepare_artfacts
script:
- bash builder/build-package ubuntu bionic
artifacts:
paths:
- output/
build_ubuntu_focal:
stage: build
before_script:
- *prepare_build
after_script:
- *prepare_artfacts
script:
- bash builder/build-package ubuntu focal;
artifacts:
paths:
- output/
build_debian_buster:
stage: build
before_script:
- *prepare_build
after_script:
- *prepare_artfacts
script:
- bash builder/build-package debian buster;
artifacts:
paths:
- output/
build_debian_bullseye:
stage: build
before_script:
- *prepare_build
after_script:
- *prepare_artfacts
script:
- bash builder/build-package debian bullseye;
artifacts:
paths:
- output/
build_kali_rolling:
stage: build
before_script:
- *prepare_build
after_script:
- *prepare_artfacts
script:
- bash builder/build-package kali kali-rolling;
artifacts:
paths:
- output/
build_centos7:
stage: build
before_script:
- *prepare_build
after_script:
- *prepare_artfacts
script:
- bash builder/build-package centos core
artifacts:
paths:
- output/
upload:
stage: upload
image: ubuntu:focal
before_script:
- . .ci/upload.sh
script:
- export S3_BUILD_DIRECTORY="kasmvnc/${CI_COMMIT_SHA}"
- prepare_to_run_scripts_and_s3_uploads
- export RELEASE_VERSION=$(.ci/next_release_version "$CI_COMMIT_REF_NAME")
- for package in `find output/ -type f -name 'kasmvncserver_*.deb' -or -name '*.rpm'`; do
prepare_upload_filename "$package";
echo;
echo "File to upload $upload_filename";
upload_to_s3 "$package" "$upload_filename";
done

4
.gitmodules vendored Normal file
View File

@@ -0,0 +1,4 @@
[submodule "kasmweb"]
path = kasmweb
url = https://github.com/kasmtech/noVNC.git
branch = master

108
ACKNOWLEDGEMENTS.md Normal file
View File

@@ -0,0 +1,108 @@
### License & Legal
Incomplete and generally out of date copyright list::
Copyright (C) 2020 Kasm Technologies LLC
Copyright (C) 1999 AT&T Laboratories Cambridge
Copyright (C) 2002-2005 RealVNC Ltd.
Copyright (C) 2000-2006 TightVNC Group
Copyright (C) 2005-2006 Martin Koegler
Copyright (C) 2005-2006 Sun Microsystems, Inc.
Copyright (C) 2006 OCCAM Financial Technology
Copyright (C) 2000-2008 Constantin Kaplinsky
Copyright (C) 2004-2017 Peter Astrand for Cendio AB
Copyright (C) 2010 Antoine Martin
Copyright (C) 2010 m-privacy GmbH
Copyright (C) 2009-2011 D. R. Commander
Copyright (C) 2009-2011 Pierre Ossman for Cendio AB
Copyright (C) 2004, 2009-2011 Red Hat, Inc.
Copyright (C) 2009-2018 TigerVNC Team
All Rights Reserved.
This software is distributed under the GNU General Public Licence as published
by the Free Software Foundation. See the file LICENSE.TXT for the conditions
under which this software is made available. KasmVNC also contains code from
other sources. See the Acknowledgements section below, and the individual
source files, for details of the conditions under which they are made
available.
### Acknowledgements
This distribution contains zlib compression software. This is:
Copyright (C) 1995-2002 Jean-loup Gailly and Mark Adler
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
Jean-loup Gailly Mark Adler
jloup@gzip.org madler@alumni.caltech.edu
The data format used by the zlib library is described by RFCs (Request for
Comments) 1950 to 1952 in the files ftp://ds.internic.net/rfc/rfc1950.txt
(zlib format), rfc1951.txt (deflate format) and rfc1952.txt (gzip format).
This distribution contains public domain DES software by Richard Outerbridge.
This is:
Copyright (c) 1988,1989,1990,1991,1992 by Richard Outerbridge.
(GEnie : OUTER; CIS : [71755,204]) Graven Imagery, 1992.
This distribution contains software from the X Window System. This is:
Copyright 1987, 1988, 1998 The Open Group
Permission to use, copy, modify, distribute, and sell this software and its
documentation for any purpose is hereby granted without fee, provided that
the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting
documentation.
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
OPEN GROUP 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.
Except as contained in this notice, the name of The Open Group shall not be
used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from The Open Group.
Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts.
All Rights Reserved
Permission to use, copy, modify, and distribute this software and its
documentation for any purpose and without fee is hereby granted,
provided that the above copyright notice appear in all copies and that
both that copyright notice and this permission notice appear in
supporting documentation, and that the name of Digital not be
used in advertising or publicity pertaining to distribution of the
software without specific, written prior permission.
DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
SOFTWARE.

View File

@@ -1,340 +0,0 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Library General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
Appendix: How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) 19yy <name of author>
This program 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 program 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 program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
USA.
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) 19yy name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Library General
Public License instead of this License.

193
README.md
View File

@@ -1,11 +1,11 @@
# KasmVNC - Linux Web Remote Desktop
[![Kasm Technologies](https://kasm-static-content.s3.amazonaws.com/368_kasm_logo_.jpg "Kasm Logo")](https://kasmweb.com)
[Kasm Technologies LLC](https://www.kasmweb.com) developed Kasm Server, a Containerized Desktop Infrastructure (CDI) solution. Kasm started with TigerVNC and eventually forked it to create KasmVNC. KasmVNC is used within the overal Kasm CDI infrastructure, however, you can use KasmVNC for individual servers. KasmVNC has different goals than TigerVNC:
<a href="https://kasmweb.com"><img src="https://kasm-static-content.s3.amazonaws.com/logo_kasm.png" width="300"><a/>
[Kasm Technologies](https://www.kasmweb.com) developed Kasm Workspaces, the Containerized Streaming Platform. Kasm has open-sourced the Workspace docker images, which include containerized [full desktops and apps](https://github.com/kasmtech/workspaces-images) and [base images](https://github.com/kasmtech/workspaces-core-images) intended for developers to create custimized streaming containers. These containers can be used standalone or within the [Kasm Workspaces Platform](https://www.kasmweb.com) which provides a full Enterprise feature set. KasmVNC is used as the streaming tech for our container images, however, you can use KasmVNC for individual servers. While the term VNC is in the name, KasmVNC is not intended to remain compliant with the RFB spec and has different goals than other VNC projects:
- Web-based - KasmVNC is designed to provide a web accessible remote desktop. It comes with a web server and websocket 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 suffecient for use on an internet accessible remote desktop. Our goal is to create a by default secure, web based experience.
- Security - The RFB specification (VNC) limits the password field to 8 characters, so while the client may take a longer password, only the first 8 characters are sent. KasmVNC defaults to HTTPS with HTTP Basic Auth and disables the legacy VNC authentication method which is not sufficiently secure for internet accessible systems.
- Simplicity - KasmVNC aims at being simple to deploy and configure.
# New Features!
@@ -13,59 +13,73 @@
- Webp image compression for better bandwidth usage
- Automatic mixing of webp and jpeg based on CPU availability on server
- Multi-threaded image encoding for smoother frame rate for servers with more cores
- Full screen video detection, goes into configurable video mode for better full screen videoo playback performance.
- Dynamic jpeg/webp image coompression quality settings based on screen change rates
- Seemless clipboard support
- [Full screen video detection](https://github.com/kasmtech/KasmVNC/wiki/Video-Rendering-Options#video-mode), goes into configurable video mode for better full screen videoo playback performance.
- [Dynamic jpeg/webp image coompression](https://github.com/kasmtech/KasmVNC/wiki/Video-Rendering-Options#dynamic-image-quality) quality settings based on screen change rates
- Seemless clipboard support (on Chromium based browsers)
- Allow client to set/change most configuration settings
- Data Loss Prevention features
- [Data Loss Prevention features](https://github.com/kasmtech/KasmVNC/wiki/Data-Loss-Prevention)
- Key stroke logging
- Clipboard logging
- Max clipboard transfer size up and down
- Min time between clipboard operations required
- Keyboard input rate limit
- Screen region selection
- Deb packages for Debian, Ubuntu, and Kali Linux included in release.
- RPM packages for CentOS, Fedora. RPM packages are currently not updatable and not released, though you can build and install them. See build documentation.
- Web [API](https://github.com/kasmtech/KasmVNC/wiki/API) added for remotely controlling and getting information from KasmVNC
- Multi-User with ability to pass control to other users.
- Web UI uses a webpack for faster load times.
- Network and CPU bottleneck statistics
Future Goals:
- Support uploads and downloads
- Pre-build Packages for all major Linux distributions
- CI pipelines to create releases
### Installation
We are currently developing releasable packages for major operating sytems. The install script available with releases will install dependencies, compile webp, and pull down and install the pre-compiled KasmVNC tarball. Currently, only Ubuntu 18.04 LTS is pre-compiled.
This installer assumes you already have a desktop environment installed, but have never configured a VNC server. Use the install script found in this project under builder/install/install.sh, currently Ubuntu 18.04LTS is the only operating system with pre-compiled binaries.
#### Debian-based
```sh
# install dependencies
sudo apt-get -y install libjpeg-dev
wget -qO- https://github.com/kasmtech/KasmVNC/releases/download/v0.9.1-beta/kasmvncserver_0.9.1~beta-1_amd64.deb
# install KasmVNC
wget https://github.com/kasmtech/KasmVNC/releases/download/v0.9.1-beta/KasmVNC_0.9.1-beta_Ubuntu_18.04.tar.gz | sudo tar xz --strip 1 -C /
sudo dpkg -i kasmvncserver_0.9.1~beta-1_amd64.deb
sudo apt-get -f install
# Generate an SSL Cert and change owner
sudo openssl req -x509 -nodes -days 3650 -newkey rsa:2048 -keyout /usr/local/share/kasmvnc/certs/self.pem -out /usr/local/share/kasmvnc/certs/self.pem -subj "/C=US/ST=VA/L=None/O=None/OU=DoFu/CN=kasm/emailAddress=none@none.none"
sudo chown $USER /usr/local/share/kasmvnc/certs/self.pem
# We provide an example script to run KasmVNC at #
# /usr/share/doc/kasmvncserver/examples/kasmvncserver-easy-start. It runs a VNC
# server on display :10 and on interface 0.0.0.0. If you're happy with those
# defaults you can just use it as is:
sudo ln -s /usr/share/doc/kasmvncserver/examples/kasmvncserver-easy-start /usr/bin/
# start kasmvnc and set password for remote access
vncserver :1 -interface 0.0.0.0
# stop kasmvnc to make config changes
vncserver -kill :1
# Add your user to the ssl-cert group
sudo addgroup $USER ssl-cert
# You will need to re-connect in order to pick up the group change
# modify vncstartup to launch your environment of choice, in this example LXDE
# Create ~/.vnc directory and corresponding files.
kasmvncserver-easy-start -d && kasmvncserver-easy-start -kill
# Modify vncstartup to launch your environment of choice, in this example LXDE
# This may be optional depending on your system configuration
echo '/usr/bin/lxsession -s LXDE &' >> ~/.vnc/xstartup
# The KasmVNC username is automatically set to your system username, you can mofify it if you wish
vi ~/.vnc/config
# Start KasmVNC with debug logging:
kasmvncserver-easy-start -d
# launch KasmVNC
vncserver $DISPLAY -depth 24 -geometry 1280x1050 -websocketPort 8443 -cert /usr/local/share/kasmvnc/certs/self.pem -sslOnly -FrameRate=24 -interface 0.0.0.0
# Tail the logs
tail -f ~/.vnc/`hostname`:10.log
```
Now navigate to your system at https://[ip-address]:8443/vnc.html
Now navigate to your system at https://[ip-address]:8443/
The options for vncserver in the example above:
To stop a running KasmVNC:
```sh
kasmvncserver-easy-start -kill
```
The options for vncserver:
| Argument | Description |
| -------- | ----------- |
@@ -77,119 +91,16 @@ The options for vncserver in the example above:
| interface | Which interface to bind the web server to. |
### Development
Would you like to contribute to KasmVNC? Please reachout to us at info@kasmweb.com
Would you like to contribute to KasmVNC? Please reachout to us at info@kasmweb.com. We have investigated or are working on the following, if you have experience in these fields and would like to help please let us know.
We need help, especially in packaging KasmVNC for various operating systems. We would love to have standard debian or RMP packages and host our own repo, however, that all requires a lot of experience, proper testing, and pipeline development for automated builds.
Real-time H264 encoding using NVIDIA and Intel encoding technology.
We also need help with Windows, which is not currently supported. While KasmVNC can technically be built for Windows 10, it is unusably slow, due to all the changes that occured in Windows since the original Windows support was added in the chain of VNC forked projects.
Windows version of KasmVNC. We have been able to get it to compile for Windows and increased the performance, but still not releasable. Experienced Windows developers with a background in cross compiling would help.
ARM version of KasmVNC, we have had requests for this and at one point we did have an ARM build of KasmVNC but it takes dev cycles to mainain and bring it back to life.
### Compiling From Source
See the builder/README.md. We containerize our build systems to ensure highly repeatable builds.
See the [builder/README.md](https://github.com/kasmtech/KasmVNC/blob/master/builder/README.md). We containerize our build systems to ensure highly repeatable builds.
License & Legal
----
Incomplete and generally out of date copyright list::
Copyright (C) 2020 Kasm Technologies LLC
Copyright (C) 1999 AT&T Laboratories Cambridge
Copyright (C) 2002-2005 RealVNC Ltd.
Copyright (C) 2000-2006 TightVNC Group
Copyright (C) 2005-2006 Martin Koegler
Copyright (C) 2005-2006 Sun Microsystems, Inc.
Copyright (C) 2006 OCCAM Financial Technology
Copyright (C) 2000-2008 Constantin Kaplinsky
Copyright (C) 2004-2017 Peter Astrand for Cendio AB
Copyright (C) 2010 Antoine Martin
Copyright (C) 2010 m-privacy GmbH
Copyright (C) 2009-2011 D. R. Commander
Copyright (C) 2009-2011 Pierre Ossman for Cendio AB
Copyright (C) 2004, 2009-2011 Red Hat, Inc.
Copyright (C) 2009-2018 TigerVNC Team
All Rights Reserved.
This software is distributed under the GNU General Public Licence as published
by the Free Software Foundation. See the file LICENCE.TXT for the conditions
under which this software is made available. KasmVNC also contains code from
other sources. See the Acknowledgements section below, and the individual
source files, for details of the conditions under which they are made
available.
### Acknoledgements
This distribution contains zlib compression software. This is:
Copyright (C) 1995-2002 Jean-loup Gailly and Mark Adler
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
Jean-loup Gailly Mark Adler
jloup@gzip.org madler@alumni.caltech.edu
The data format used by the zlib library is described by RFCs (Request for
Comments) 1950 to 1952 in the files ftp://ds.internic.net/rfc/rfc1950.txt
(zlib format), rfc1951.txt (deflate format) and rfc1952.txt (gzip format).
This distribution contains public domain DES software by Richard Outerbridge.
This is:
Copyright (c) 1988,1989,1990,1991,1992 by Richard Outerbridge.
(GEnie : OUTER; CIS : [71755,204]) Graven Imagery, 1992.
This distribution contains software from the X Window System. This is:
Copyright 1987, 1988, 1998 The Open Group
Permission to use, copy, modify, distribute, and sell this software and its
documentation for any purpose is hereby granted without fee, provided that
the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting
documentation.
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
OPEN GROUP 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.
Except as contained in this notice, the name of The Open Group shall not be
used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from The Open Group.
Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts.
All Rights Reserved
Permission to use, copy, modify, and distribute this software and its
documentation for any purpose and without fee is hereby granted,
provided that the above copyright notice appear in all copies and that
both that copyright notice and this permission notice appear in
supporting documentation, and that the name of Digital not be
used in advertising or publicity pertaining to distribution of the
software without specific, written prior permission.
DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
SOFTWARE.
### License and Acknowledgements
See the [LICENSE.TXT](https://github.com/kasmtech/KasmVNC/blob/master/LICENSE.TXT) and [ACKNOWLEDGEMENTS.MD](https://github.com/kasmtech/KasmVNC/blob/master/LICENSE.TXT)

View File

@@ -1,30 +0,0 @@
image: ubuntu:xenial
pipelines:
default:
- step:
name: Build and Package
services:
- docker
script:
- export BASE_DIR="$(readlink -f .)"
- export RELEASE_VERSION=1.9
- export BUILD_FILE="kasmvnc_${RELEASE_VERSION}.${BITBUCKET_COMMIT}.tar.gz"
- export S3_BUILD_DIRECTORY="kasmvnc/${BITBUCKET_COMMIT}"
- export SANITIZED_BRANCH="$(echo $BITBUCKET_BRANCH | sed 's/\//_/g')"
- apt-get update
- apt-get install -y git python3 python3-pip python3-boto3 curl
- echo $SANITIZED_BRANCH
- docker build -t kasmvncbuilder:latest -f builder/dockerfile.build .
- docker run -v $BITBUCKET_CLONE_DIR:/build kasmvncbuilder:latest
- ls -la $BITBUCKET_CLONE_DIR
- ls -la $BITBUCKET_CLONE_DIR/kasmvnc-Linux-x86_64-*.tar.gz
- git clone https://bitbucket.org/awslabs/amazon-s3-bitbucket-pipelines-python.git
- python3 amazon-s3-bitbucket-pipelines-python/s3_upload.py "${S3_BUCKET}" $BITBUCKET_CLONE_DIR/kasmvnc-Linux-x86_64-*.tar.gz "${S3_BUILD_DIRECTORY}/${BUILD_FILE}"
- export S3_URL="https://${S3_BUCKET}.s3.amazonaws.com/${S3_BUILD_DIRECTORY}/${BUILD_FILE}"
- export BUILD_STATUS="{\"key\":\"doc\", \"state\":\"SUCCESSFUL\", \"name\":\"${BUILD_FILE}\", \"url\":\"${S3_URL}\"}"
- echo ${BITBUCKET_REPO_OWNER}
- echo ${BITBUCKET_REPO_SLUG}
- echo ${BITBUCKET_COMMIT}
- echo ${BB_AUTH_STRING}
- echo ${BUILD_STATUS}
- curl -H "Content-Type:application/json" -X POST --user "${BB_AUTH_STRING}" -d "${BUILD_STATUS}" "https://api.bitbucket.org/2.0/repositories/${BITBUCKET_REPO_OWNER}/${BITBUCKET_REPO_SLUG}/commit/${BITBUCKET_COMMIT}/statuses/build"

View File

@@ -1,22 +1,72 @@
REQIUREMENTS
## REQIUREMENTS
Docker CE
# build the docker image
cd /src_code_root
sudo docker build -t kasmvncbuilder:18.04 -f builder/dockerfile.build .
# Build a deb/rpm package
```
# builder/build-package <os> <os_codename>
# os_codename is what "lsb_release -c" outputs, e.g. buster, focal.
# Packages will be placed under builder/build/
# run the builder
sudo docker run -v /tmp:/build --rm kasmvncbuilder:18.04
builder/build-package ubuntu bionic
builder/build-package ubuntu focal
builder/build-package debian buster
builder/build-package debian bullseye
builder/build-package kali kali-rolling
builder/build-package centos core # CentOS 7
builder/build-package fedora thirtythree
```
# tar will be on /tmp of host
cp /tmp/kasmvnc*.tar.gz builder/
# Build and test a package
```
builder/build-and-test-deb ubuntu focal
builder/build-and-test-rpm centos core
```
# build test desktop container with new binary installed
cd builder
sudo docker build -t kasmvnctester:18.04 -f dockerfile.test .
# run an instance of the new destkop
sudo docker run -d -p 80:6901 -p 5901:5901 -e VNCOPTIONS="-detectScrolling -PreferBandwidth -DynamicQualityMin=0" kasmvnctester:latest
Open browser and point to https://localhost:443/ or https://\<ip-address\>:443/
open browser and point to http://IPAddress/vnc_lite.html
default password is "vncpassword" or use a VNC client
3 default users are created:
* 'foo' with default password 'foobar'. It can use mouse and keyboard.
* 'foo-ro' with default password 'foobar'. It can only view.
* 'foo-owner' with default password 'foobar'. It can manage other users.
# Test a package
If you want to test deb/rpm package you've already built, please use this:
```
builder/test-deb ubuntu focal
```
It will install the package inside a new container and run KasmVNC.
Open browser and point to https://localhost:443/ or https://\<ip-address\>:443/
# Package development
## deb/rpm package building and testing
First, a tarball is built, and then its files are copied to deb/rpm package as
it is being built.
Package testing stage installs the deb/rpm package in a fresh docker container
and runs KasmVNC.
```
builder/build-tarball debian buster
builder/build-deb debian buster
builder/test-deb debian buster
```
Use `build-and-test-deb` to perform the whole dev lifecycle, but to iterate
quickly, you'll need to skip building the tarball (which takes a long time), and
just build your deb/rpm with `build-deb` and test with `test-deb`.
`build-rpm` and `test-rpm` are also available.
## Ensuring packages have all dependencies they need.
If you're working on a deb/rpm package, testing that it has all the necessary
dependencies is done via testing in a barebones environment (read: no XFCE). In
this way we can be sure that runtime dependencies aren't met accidentally by
packages installed with XFCE.
```
builder/test-deb-barebones ubuntu focal
```

16
builder/build-and-test-deb Executable file
View File

@@ -0,0 +1,16 @@
#!/bin/bash
set -e
os="$1"
codename="$2"
if [[ -z "$os" ]] || [[ -z "$codename" ]]; then
echo "Usage: $0 <os> <codename>" >&2
exit 1
fi
cd "$(dirname "$0")"
./build-tarball "$os" "$codename" && ./build-deb "$os" "$codename" && \
./test-deb "$os" "$codename"

16
builder/build-and-test-rpm Executable file
View File

@@ -0,0 +1,16 @@
#!/bin/bash
set -e
os="$1"
codename="$2"
if [[ -z "$os" ]] || [[ -z "$codename" ]]; then
echo "Usage: $0 <os> <codename>" >&2
exit 1
fi
cd "$(dirname "$0")"
./build-tarball "$os" "$codename" && ./build-rpm "$os" "$codename" && \
./test-rpm "$os" "$codename"

16
builder/build-deb Executable file
View File

@@ -0,0 +1,16 @@
#!/bin/bash
set -e
cd "$(dirname "$0")/.."
. builder/os_ver_cli.sh
docker build -t debbuilder_${os}:${os_codename} -f \
builder/dockerfile.${os}_${os_codename}.deb.build .
deb_output_dir=$(cd .. && echo $PWD)
L_UID=$(id -u) #Ubuntu already has UID env var, but this should work on all Linix systems
L_GID=$(id -g)
docker run --rm -v "$deb_output_dir":/src --user $L_UID:$L_GID \
debbuilder_${os}:${os_codename} /bin/bash -c \
'/src/*/builder/build-deb-inside-docker'

14
builder/build-deb-inside-docker Executable file
View File

@@ -0,0 +1,14 @@
#!/bin/bash
set -e
cd "$(dirname "$0")/.."
os=$(lsb_release -is | tr '[:upper:]' '[:lower:]')
os_codename=$(lsb_release -cs)
os_dir="builder/build/${os_codename}"
dpkg-buildpackage -us -uc -b
mkdir -p "$os_dir"
cp ../*.deb "$os_dir"
lintian ../*.deb || true

19
builder/build-package Executable file
View File

@@ -0,0 +1,19 @@
#!/bin/bash
set -e
os="$1"
codename="$2"
detect_package_format() {
package_format=rpm
if ls builder/dockerfile*"$os"* | grep -q .deb.build; then
package_format=deb
fi
}
cd "$(dirname "$0")/.."
detect_package_format
builder/build-tarball "$os" "$codename"
builder/build-${package_format} "$os" "$codename"

16
builder/build-rpm Executable file
View File

@@ -0,0 +1,16 @@
#!/bin/bash
set -e
cd "$(dirname "$0")/.."
. builder/os_ver_cli.sh
docker build -t kasmvnc_rpmbuilder_${os}:${os_codename} -f \
builder/dockerfile.${os}_${os_codename}.rpm.build .
source_dir=$(echo $PWD)
L_UID=$(id -u) #Ubuntu already has UID env var, but this should work on all Linix systems
L_GID=$(id -g)
docker run --rm -v "$source_dir":/src --user $L_UID:$L_GID \
kasmvnc_rpmbuilder_${os}:${os_codename} /bin/bash -c \
'/src/builder/build-rpm-inside-docker'

30
builder/build-rpm-inside-docker Executable file
View File

@@ -0,0 +1,30 @@
#!/bin/bash
set -e
prepare_build_env() {
rpmdev-setuptree
copy_spec_and_tar_with_binaries
}
copy_spec_and_tar_with_binaries() {
cp /src/centos/kasmvncserver.spec ~/rpmbuild/SPECS/
cp /src/builder/build/kasmvnc.${os}_${os_codename}.tar.gz \
~/rpmbuild/SOURCES/
}
copy_rpm_to_build_dir() {
cd /src/builder && \
mkdir -p "$os_dir" && cp ~/rpmbuild/RPMS/*/*.rpm ${os_dir}
}
cd "$(dirname "$0")/.."
os=$(lsb_release -is | tr '[:upper:]' '[:lower:]')
os_codename=$(lsb_release -cs | tr '[:upper:]' '[:lower:]')
os_dir="build/${os}_${os_codename}"
prepare_build_env
rpmbuild -ba ~/rpmbuild/SPECS/kasmvncserver.spec
copy_rpm_to_build_dir
rpmlint "$os_dir"/*.rpm || true

31
builder/build-tarball Executable file
View File

@@ -0,0 +1,31 @@
#!/bin/bash
set -e
build_www_dir() {
local webpacked_www=$PWD/builder/www
local src_www=kasmweb
if [ "$src_www" -nt "$webpacked_www" ]; then
docker build -t kasmweb/www -f builder/dockerfile.www.build .
docker run --rm -v $PWD/builder/www:/build kasmweb/www:latest
fi
}
shared_with_docker_dir=${GITLAB_SHARED_DIND_DIR:-/tmp}
cd "$(dirname "$0")/.."
. builder/os_ver_cli.sh
build_www_dir
docker build -t kasmvncbuilder:$os_codename \
-f builder/dockerfile.${os}_${os_codename}.build .
mkdir -p builder/build
docker run -v $shared_with_docker_dir:/build --rm kasmvncbuilder:$os_codename
L_GID=$(id -g)
L_UID=$(id -u)
tarball_name="kasmvnc.${os}_${os_codename}.tar.gz"
chown $L_UID:$L_GID $shared_with_docker_dir/$tarball_name
mv $shared_with_docker_dir/$tarball_name $PWD/builder/build/

View File

@@ -1,5 +1,12 @@
#!/bin/sh -e
detect_quilt() {
if which quilt 1>/dev/null; then
QUILT_PRESENT=1
export QUILT_PATCHES=debian/patches
fi
}
# For build-dep to work, the apt sources need to have the source server
#sudo apt-get build-dep xorg-server
@@ -7,7 +14,10 @@
# Ubuntu applies a million patches, but here we use upstream to simplify matters
cd /tmp
wget https://www.x.org/archive/individual/xserver/xorg-server-1.19.6.tar.bz2
# default to the version of x in Ubuntu 18.04, otherwise caller will need to specify
XORG_VER=${XORG_VER:-"1.19.6"}
XORG_PATCH=$(echo "$XORG_VER" | grep -Po '^\d.\d+' | sed 's#\.##')
wget https://www.x.org/archive/individual/xserver/xorg-server-${XORG_VER}.tar.bz2
#git clone https://kasmweb@bitbucket.org/kasmtech/kasmvnc.git
#cd kasmvnc
@@ -20,13 +30,17 @@ sed -i -e '/find_package(FLTK/s@^@#@' \
-e '/add_subdirectory(tests/s@^@#@' \
CMakeLists.txt
cmake .
cmake -D CMAKE_BUILD_TYPE=RelWithDebInfo .
make -j5
tar -C unix/xserver -xvf /tmp/xorg-server-1.19.6.tar.bz2 --strip-components=1
tar -C unix/xserver -xvf /tmp/xorg-server-${XORG_VER}.tar.bz2 --strip-components=1
cd unix/xserver
patch -Np1 -i ../xserver119.patch
patch -Np1 -i ../xserver${XORG_PATCH}.patch
if [[ $XORG_VER =~ ^1\.20\..*$ ]]; then
patch -Np1 -i ../xserver120.7.patch
fi
autoreconf -i
# Configuring Xorg is long and has many distro-specific paths.
# The distro paths start after prefix and end with the font path,
@@ -53,15 +67,20 @@ ln -s /src/unix/xserver/hw/vnc/Xvnc Xvnc
cd ..
mkdir -p man/man1
touch man/man1/Xserver.1
touch man/man1/Xvnc.1
cp /src/unix/xserver/hw/vnc/Xvnc.man man/man1/Xvnc.1
mkdir lib
cd lib
ln -s /usr/lib/x86_64-linux-gnu/dri dri
if [ -d /usr/lib/x86_64-linux-gnu/dri ]; then
ln -s /usr/lib/x86_64-linux-gnu/dri dri
else
ln -s /usr/lib64/dri dri
fi
cd /src
sed $'s#pushd $TMPDIR/inst#CWD=$(pwd)\\\ncd $TMPDIR/inst#' release/maketarball > release/maketarball2
sed $'s#popd#cd $CWD#' release/maketarball2 > release/maketarball3
mv release/maketarball3 release/maketarball
detect_quilt
if [ -n "$QUILT_PRESENT" ]; then
quilt push -a
fi
make servertarball
cp kasmvnc*.tar.gz /build/
cp kasmvnc*.tar.gz /build/kasmvnc.${KASMVNC_BUILD_OS}_${KASMVNC_BUILD_OS_CODENAME}.tar.gz

18
builder/build_www.sh Executable file
View File

@@ -0,0 +1,18 @@
#!/bin/bash
# clear previous build
rm -rf /build/*
# build webpack
npm run build
# remove node stuff from directory
rm -rf node_modules/
# copy all to build dir
cp -R ./* /build/
# remove unneccesary files
cd /build
rm *.md
rm AUTHORS
rm vnc.html
rm vnc_lite.html

View File

@@ -0,0 +1,18 @@
FROM centos:centos7
RUN yum install -y xterm
RUN yum install -y vim less
RUN yum install -y redhat-lsb-core
ARG KASMVNC_PACKAGE_DIR
COPY $KASMVNC_PACKAGE_DIR/*.rpm /tmp
RUN yum 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 "

View File

@@ -0,0 +1,29 @@
FROM centos:centos7
ENV KASMVNC_BUILD_OS centos
ENV KASMVNC_BUILD_OS_CODENAME core
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 libjpeg-dev libpng-dev libtiff-dev libgif-dev libavcodec-dev openssl-devel
RUN yum install -y make
RUN yum group install -y "Development Tools"
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 \
xorg-x11-xtrans-devel xorg-x11-xkb-utils-devel
RUN yum install -y mesa-dri-drivers
# Additions for webp
RUN cd /tmp && wget https://storage.googleapis.com/downloads.webmproject.org/releases/webp/libwebp-1.0.2.tar.gz
RUN cd /tmp && tar -xzvf /tmp/libwebp-*
RUN cd /tmp/libwebp-1.0.2 && \
./configure --enable-static --disable-shared && \
make && make install
RUN useradd -m docker && echo "docker:docker" | chpasswd
COPY . /src
RUN chown -R docker:docker /src
USER docker
ENTRYPOINT ["/src/builder/build.sh"]

View File

@@ -0,0 +1,12 @@
FROM centos:centos7
RUN yum install -y rpm* gpg* rng-tools rpmlint
RUN yum install -y tree vim less
RUN yum install -y redhat-lsb-core
COPY centos/*.spec /tmp
RUN yum-builddep -y /tmp/*.spec
RUN useradd -m docker && echo "docker:docker" | chpasswd
USER docker

View File

@@ -0,0 +1,61 @@
FROM centos:centos7
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=centos \
KASMVNC_BUILD_OS_CODENAME=core
EXPOSE $VNC_PORT
WORKDIR $HOME
### REQUIRED STUFF ###
RUN yum install -y openssl xterm gettext wget
RUN yum install -y centos-release-scl-rh && yum install -y nss_wrapper
RUN yum install -y xorg-x11-server xorg-x11-xauth xorg-x11-xkb-utils \
xkeyboard-config xorg-x11-server-utils
RUN yum install -y epel-release && yum groupinstall xfce -y
RUN yum erase -y pm-utils xscreensaver*
RUN yum install -y redhat-lsb-core
RUN yum install -y vim less
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/*.rpm /tmp
RUN yum localinstall -y /tmp/*.rpm
### END CUSTOM STUFF ###
RUN chown -R 1000:0 $HOME
USER 1000:kasmvnc-cert
WORKDIR $HOME
RUN mkdir ~/.vnc && echo '/usr/bin/xfce4-session &' >> ~/.vnc/xstartup && \
chmod +x ~/.vnc/xstartup
ENTRYPOINT [ "/dockerstartup/vnc_startup.sh" ]

View File

@@ -0,0 +1,31 @@
FROM debian:bullseye-slim
ENV KASMVNC_BUILD_OS debian
ENV KASMVNC_BUILD_OS_CODENAME bullseye
ENV XORG_VER 1.20.10
ENV DEBIAN_FRONTEND noninteractive
RUN grep '^deb' /etc/apt/sources.list | sed 's#^deb#deb-src#' >> /etc/apt/sources.list
RUN apt-get update && \
apt-get -y install sudo
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 install cmake git libjpeg-dev libgnutls28-dev vim wget tightvncserver
RUN apt-get update && apt-get -y install libjpeg-dev libpng-dev libtiff-dev libgif-dev libavcodec-dev libssl-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 -xzvf /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 . /src
RUN chown -R docker:docker /src
USER docker
ENTRYPOINT ["/src/builder/build.sh"]

View File

@@ -0,0 +1,12 @@
FROM debian:bullseye
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
USER 1000

View File

@@ -0,0 +1,54 @@
FROM debian:bullseye-slim
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=debian \
KASMVNC_BUILD_OS_CODENAME=buster
EXPOSE $VNC_PORT
WORKDIR $HOME
### REQUIRED STUFF ###
RUN apt-get update && apt-get install -y supervisor xfce4 xfce4-terminal dbus-x11 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 dpkg -i /tmp/*.deb; apt-get -yf install
### END CUSTOM STUFF ###
RUN chown -R 1000:0 $HOME
USER 1000:ssl-cert
WORKDIR $HOME
ENTRYPOINT [ "/dockerstartup/vnc_startup.sh" ]

View File

@@ -0,0 +1,19 @@
FROM debian:buster-slim
ARG KASMVNC_PACKAGE_DIR
COPY $KASMVNC_PACKAGE_DIR/kasmvncserver_*.deb /tmp
RUN apt-get update && dpkg -i /tmp/*.deb; apt-get -yf install
RUN apt-get update && apt-get -y install xterm
COPY startup/deb/kasmvncserver-easy-start /usr/local/bin
RUN useradd -m foo
USER foo:ssl-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 $HOME/.kasmpasswd && \
kasmvncserver-easy-start && tail -f $HOME/.vnc/*.log"

View File

@@ -0,0 +1,31 @@
FROM debian:buster
ENV KASMVNC_BUILD_OS debian
ENV KASMVNC_BUILD_OS_CODENAME buster
ENV XORG_VER 1.20.10
ENV DEBIAN_FRONTEND noninteractive
RUN grep '^deb' /etc/apt/sources.list | sed 's#^deb#deb-src#' >> /etc/apt/sources.list
RUN apt-get update && \
apt-get -y install sudo
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 install cmake git libjpeg-dev libgnutls28-dev vim wget tightvncserver
RUN apt-get update && apt-get -y install libjpeg-dev libpng-dev libtiff-dev libgif-dev libavcodec-dev libssl-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 -xzvf /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 . /src
RUN chown -R docker:docker /src
USER docker
ENTRYPOINT ["/src/builder/build.sh"]

View File

@@ -0,0 +1,12 @@
FROM debian:buster
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
USER 1000

View File

@@ -0,0 +1,62 @@
FROM debian:buster-slim
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=debian \
KASMVNC_BUILD_OS_CODENAME=buster
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 apt-get update && apt-get install -y task-cinnamon-desktop
RUN apt-get update && apt-get install -y task-gnome-desktop
RUN mkdir -p /usr/share/man/man1
RUN apt-get update && apt-get install -y apt-utils openjdk-11-jre
RUN apt-get update && apt-get install -y task-lxde-desktop
RUN apt-get update && apt-get install -y task-mate-desktop
RUN apt-get update && apt-get install -y task-kde-desktop
RUN echo 'source $STARTUPDIR/generate_container_user' >> $HOME/.bashrc
RUN mkdir -p $STARTUPDIR
COPY startup/ $STARTUPDIR
### START CUSTOM STUFF ####
ARG KASMVNC_PACKAGE_DIR
COPY $KASMVNC_PACKAGE_DIR/kasmvncserver_*.deb /tmp
RUN dpkg -i /tmp/*.deb; apt-get -yf install
### END CUSTOM STUFF ###
RUN chown -R 1000:0 $HOME
USER 1000:ssl-cert
WORKDIR $HOME
ENTRYPOINT [ "/dockerstartup/vnc_startup.sh" ]

View File

@@ -0,0 +1,18 @@
FROM fedora:33
RUN dnf install -y xterm
RUN dnf install -y vim less
RUN yum install -y redhat-lsb-core
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 "

View File

@@ -0,0 +1,38 @@
FROM fedora:33
ENV KASMVNC_BUILD_OS fedora
ENV KASMVNC_BUILD_OS_CODENAME thirtythree
ENV XORG_VER 1.20.10
# RUN dnf install -y build-dep xorg-server libxfont-dev sudo
RUN dnf install -y gcc cmake git gnutls-devel vim wget
#tightvncserver
RUN dnf install -y libjpeg-turbo-devel libpng-devel libtiff-devel giflib-devel openssl-devel
#libavcodec-dev
RUN dnf -y install https://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm
RUN dnf -y install https://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-$(rpm -E %fedora).noarch.rpm
RUN dnf -y install ffmpeg-devel
RUN dnf install -y make
RUN dnf group install -y "Development Tools"
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 \
xorg-x11-xtrans-devel xorg-x11-xkb-utils-devel
RUN dnf install -y mesa-dri-drivers
RUN dnf install -y bzip2 redhat-lsb-core
# Additions for webp
RUN cd /tmp && wget https://storage.googleapis.com/downloads.webmproject.org/releases/webp/libwebp-1.0.2.tar.gz
RUN cd /tmp && tar -xzvf /tmp/libwebp-*
RUN cd /tmp/libwebp-1.0.2 && \
./configure --enable-static --disable-shared && \
make && make install
RUN useradd -m docker && echo "docker:docker" | chpasswd
COPY . /src
RUN chown -R docker:docker /src
USER docker
ENTRYPOINT ["/src/builder/build.sh"]

View File

@@ -0,0 +1,13 @@
FROM fedora:33
RUN dnf install -y fedora-packager fedora-review
RUN dnf install -y tree vim less
RUN dnf install -y redhat-lsb-core
RUN dnf install -y dnf-plugins-core
COPY centos/*.spec /tmp
RUN dnf builddep -y /tmp/*.spec
RUN useradd -m docker && echo "docker:docker" | chpasswd
USER docker

View File

@@ -0,0 +1,64 @@
FROM fedora:33
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=fedora \
KASMVNC_BUILD_OS_CODENAME=thirtythree
EXPOSE $VNC_PORT
WORKDIR $HOME
### REQUIRED STUFF ###
RUN dnf install -y openssl xterm gettext wget
RUN dnf install -y nss_wrapper
RUN dnf install -y xorg-x11-xauth xorg-x11-xkb-utils \
xkeyboard-config xorg-x11-server-utils
# xorg-x11-server-Xorg
# RUN dnf install -y @xfce-desktop-environment
RUN dnf group install -y lxde-desktop
RUN dnf erase -y pm-utils xscreensaver*
RUN dnf install -y redhat-lsb-core
RUN dnf install -y vim less
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/*.rpm /tmp
# RUN dnf remove -y tigervnc-server-minimal
RUN dnf localinstall -y --allowerasing /tmp/*.rpm
### END CUSTOM STUFF ###
RUN chown -R 1000:0 $HOME
USER 1000:kasmvnc-cert
WORKDIR $HOME
RUN mkdir ~/.vnc && echo '/usr/bin/lxsession -s LXDE &' >> ~/.vnc/xstartup && \
chmod +x ~/.vnc/xstartup
ENTRYPOINT [ "/dockerstartup/vnc_startup.sh" ]

View File

@@ -0,0 +1,31 @@
FROM kalilinux/kali-rolling:latest
ENV KASMVNC_BUILD_OS kali
ENV KASMVNC_BUILD_OS_CODENAME kali-rolling
ENV XORG_VER 1.20.10
ENV DEBIAN_FRONTEND noninteractive
RUN grep '^deb' /etc/apt/sources.list | sed 's#^deb#deb-src#' >> /etc/apt/sources.list
RUN apt-get update && \
apt-get -y install sudo
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 install cmake git libjpeg-dev libgnutls28-dev vim wget tightvncserver
RUN apt-get update && apt-get -y install libjpeg-dev libpng-dev libtiff-dev libgif-dev libavcodec-dev libssl-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 -xzvf /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 . /src
RUN chown -R docker:docker /src
USER docker
ENTRYPOINT ["/src/builder/build.sh"]

View File

@@ -0,0 +1,12 @@
FROM kalilinux/kali-rolling:latest
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
USER 1000

View File

@@ -0,0 +1,54 @@
FROM kalilinux/kali-rolling:latest
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_VER=18.04
EXPOSE $VNC_PORT
WORKDIR $HOME
### REQUIRED STUFF ###
RUN apt-get update && apt-get install -y supervisor xfce4 xfce4-terminal dbus-x11 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 dpkg -i /tmp/*.deb; apt-get -yf install
### END CUSTOM STUFF ###
RUN chown -R 1000:0 $HOME
USER 1000:ssl-cert
WORKDIR $HOME
ENTRYPOINT [ "/dockerstartup/vnc_startup.sh" ]

View File

@@ -1,12 +0,0 @@
FROM kasmweb/desktop-deluxe:develop
ENV VNCOPTIONS "-PreferBandwidth -DynamicQualityMin=3 -DynamicQualityMax=7 -detectScrolling"
USER root
COPY kasmvnc-Linux-x86_64-*.tar.gz /tmp/
RUN tar -xzvf /tmp/kasmvnc-Linux-x86_64-*.tar.gz --strip 1 -C /
USER 1000
CMD ["--tail-log"]

View File

@@ -1,5 +1,9 @@
FROM ubuntu:18.04
ENV KASMVNC_BUILD_OS ubuntu
ENV KASMVNC_BUILD_OS_CODENAME bionic
ENV XORG_VER 1.20.10
RUN sed -i 's$# deb-src$deb-src$' /etc/apt/sources.list
RUN apt-get update && \

View File

@@ -0,0 +1,10 @@
FROM ubuntu:bionic
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
USER 1000

View File

@@ -0,0 +1,54 @@
FROM ubuntu:bionic
ENV DISPLAY=:1 \
VNC_PORT=8443 \
VNC_RESOLUTION=1280x720 \
MAX_FRAME_RATE=24 \
VNCOPTIONS="-PreferBandwidth -DynamicQualityMin=4 -DynamicQualityMax=7" \
HOME=/home/user \
TERM=xterm \
STARTUPDIR=/dockerstartup \
INST_SCRIPTS=/dockerstartup/install \
KASM_RX_HOME=/dockerstartup/kasmrx \
DEBIAN_FRONTEND=noninteractive \
VNC_COL_DEPTH=24 \
VNC_RESOLUTION=1280x1024 \
VNC_PW=vncpassword \
VNC_USER=user \
VNC_VIEW_ONLY_PW=vncviewonlypassword \
LD_LIBRARY_PATH=/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 dpkg -i /tmp/*.deb; apt-get -yf install
### END CUSTOM STUFF ###
RUN chown -R 1000:0 $HOME
USER 1000:ssl-cert
WORKDIR $HOME
ENTRYPOINT [ "/dockerstartup/vnc_startup.sh" ]

View File

@@ -0,0 +1,51 @@
FROM ubuntu:18.04
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 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" ]

View File

@@ -0,0 +1,15 @@
FROM ubuntu:focal
ARG KASMVNC_PACKAGE_DIR
COPY $KASMVNC_PACKAGE_DIR/kasmvncserver_*.deb /tmp
RUN apt-get update && dpkg -i /tmp/*.deb; apt-get -yf install
RUN apt-get update && apt-get -y install xterm lsb-release
RUN useradd -m foo && addgroup foo ssl-cert
USER foo
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/ssl/certs/ssl-cert-snakeoil.pem -key /etc/ssl/private/ssl-cert-snakeoil.key -sslOnly -FrameRate=24 -interface 0.0.0.0 -httpd /usr/share/kasmvnc/www && tail -f $HOME/.vnc/*.log "

View File

@@ -0,0 +1,31 @@
FROM ubuntu:focal
ENV KASMVNC_BUILD_OS ubuntu
ENV KASMVNC_BUILD_OS_CODENAME focal
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 libjpeg-dev libpng-dev libtiff-dev libgif-dev libavcodec-dev libssl-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 -xzvf /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 . /src
RUN chown -R docker:docker /src
USER docker
ENTRYPOINT ["/src/builder/build.sh"]

View File

@@ -0,0 +1,12 @@
FROM ubuntu:focal
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
USER 1000

View File

@@ -0,0 +1,57 @@
FROM ubuntu:focal
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 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" ]

View File

@@ -0,0 +1,51 @@
FROM ubuntu:focal
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=focal
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" ]

View File

@@ -0,0 +1,10 @@
FROM node:12-buster
COPY kasmweb/ /src/www/
COPY builder/build_www.sh /src/
WORKDIR /src/www
RUN npm install
ENTRYPOINT [ "/src/build_www.sh" ]

8
builder/os_ver_cli.sh Normal file
View File

@@ -0,0 +1,8 @@
default_os=ubuntu
default_os_codename=bionic
os=${1:-$default_os}
os_codename=${2:-$default_os_codename}
os_image="$os:$os_codename"
echo "Building for $os_image"

View File

@@ -0,0 +1,209 @@
#!/bin/bash
set -e
display=:10
interface=0.0.0.0
cert_group=ssl-cert
xstartup_script=~/.vnc/xstartup
de_was_selected_file="$HOME/.vnc/.kasmvncserver-easy-start-de-was-selected"
action=start
manual_xstartup_choice="Manually edit xstartup"
declare -A all_desktop_environments=(
[Cinnamon]=cinnamon-session
[Mate]="XDG_CURRENT_DESKTOP=MATE dbus-launch --exit-with-session mate-session"
[LXDE]=lxsession [Lxqt]=startlxqt
[KDE]=startkde
[Gnome]="XDG_CURRENT_DESKTOP=GNOME dbus-launch --exit-with-session /usr/bin/gnome-session"
[XFCE]=xfce4-session)
readarray -t sorted_desktop_environments < <(for de in "${!all_desktop_environments[@]}"; do echo "$de"; done | sort)
all_desktop_environments[$manual_xstartup_choice]=""
sorted_desktop_environments+=("$manual_xstartup_choice")
detected_desktop_environments=()
declare -A numbered_desktop_environments
debug() {
if [ -z "$debug" ]; then return; fi
echo "$@"
}
print_detected_desktop_environments() {
declare -i i=1
echo "Please choose Desktop Environment to run:"
for detected_de in "${detected_desktop_environments[@]}"; do
echo "[$i] $detected_de"
numbered_desktop_environments[$i]=$detected_de
i+=1
done
}
detect_desktop_environments() {
for de_name in "${sorted_desktop_environments[@]}"; do
if [[ "$de_name" = "$manual_xstartup_choice" ]]; then
detected_desktop_environments+=("$de_name")
continue;
fi
local executable=${all_desktop_environments[$de_name]}
executable=($executable)
executable=${executable[-1]}
if detect_desktop_environment "$de_name" "$executable"; then
detected_desktop_environments+=("$de_name")
fi
done
}
ask_user_to_choose_de() {
while : ; do
print_detected_desktop_environments
read -r de_number_to_run
de_name_from_number "$de_number_to_run"
if [[ -n "$de_name" ]]; then
break;
fi
echo "Incorrect number: $de_number_to_run"
echo
done
}
remember_de_choice() {
touch "$de_was_selected_file"
}
de_was_selected_on_previous_run() {
[[ -f "$de_was_selected_file" ]]
}
detect_desktop_environment() {
local de_name="$1"
local executable="$2"
if command -v "$executable" &>/dev/null; then
return 0
fi
return 1
}
did_user_forbid_replacing_xstartup() {
grep -q -v KasmVNC-safe-to-replace-this-file "$xstartup_script"
}
de_cmd_from_name() {
de_cmd=${all_desktop_environments[$de_name]}
}
de_name_from_number() {
local de_number_to_run="$1"
de_name=${numbered_desktop_environments[$de_number_to_run]}
}
warn_xstartup_will_be_overwriten() {
echo -n "WARNING: $xstartup_script will be overwritten y/N?"
read -r do_overwrite_xstartup
if [[ "$do_overwrite_xstartup" = "y" || "$do_overwrite_xstartup" = "Y" ]]; then
return 0
fi
return 1
}
setup_de_to_run_via_xstartup() {
warn_xstartup_will_be_overwriten
generate_xstartup "$de_name"
}
generate_xstartup() {
local de_name="$1"
de_cmd_from_name
cat <<-SCRIPT > "$xstartup_script"
#!/bin/sh
exec $de_cmd
SCRIPT
chmod +x "$xstartup_script"
}
enable_debug() {
debug=1
log_option="-log *:stderr:100"
}
kill_vnc_server() {
vncserver -kill $display
}
process_cli_options() {
for option in "$@"; do
case "$option" in
--help)
show_help
exit
;;
-d)
enable_debug
;;
-kill)
kill_vnc_server
exit
;;
-select-de)
action=select-de-and-start
;;
*)
echo >&2 "Unsupported argument: $option"
exit 1
esac
done
}
user_asked_to_select_de() {
[[ "$action" = "select-de-and-start" ]]
}
show_help() {
cat >&2 <<-USAGE
Usage: `basename $0` [options]
-d Debug output
-kill Kill vncserver
-select-de Select desktop environent to run
--help show this help
USAGE
}
process_cli_options "$@"
if groups | grep -qvw ssl-cert; then
cat <<-EOF
Can't access TLS certificate.
Please add your user to $cert_group via 'addgroup <user> ssl-cert'
EOF
exit 1
fi
if user_asked_to_select_de || ! de_was_selected_on_previous_run; then
detect_desktop_environments
ask_user_to_choose_de
debug "You selected $de_name desktop environment"
if [[ "$de_name" != "$manual_xstartup_choice" ]]; then
setup_de_to_run_via_xstartup
fi
remember_de_choice
fi
vncserver $display -interface $interface
vncserver -kill $display
vncserver $display -depth 24 -geometry 1280x1050 -websocketPort 8443 \
-cert /etc/ssl/certs/ssl-cert-snakeoil.pem \
-key /etc/ssl/private/ssl-cert-snakeoil.key -sslOnly -FrameRate=24 \
-interface $interface -httpd /usr/share/kasmvnc/www $log_option

View File

@@ -0,0 +1,46 @@
detect_libnss_wrapper() {
if $(which dpkg &>/dev/null); then
libnss_wrapper_file=$(dpkg -S libnss_wrapper.so | awk -F' ' '{ print $2 }')
return
fi
if [ -r /usr/lib/libnss_wrapper.so ]; then
libnss_wrapper_file=/usr/lib/libnss_wrapper.so
elif [ -r /usr/lib64/libnss_wrapper.so ]; then
libnss_wrapper_file=/usr/lib64/libnss_wrapper.so
else
echo "no libnss_wrapper.so installed!"
exit 1
fi
}
# Set current user in nss_wrapper
USER_ID=$(id -u)
GROUP_ID=$(id -g)
echo "USER_ID: $USER_ID, GROUP_ID: $GROUP_ID"
# Attempt to set the username to the kasm username
USERNAME=${VNC_USER:-default}
# Make the username posix compliant
USERNAME=$(echo "$USERNAME" | sed -r 's#[^a-zA-Z0-9\._\-]#_#g')
if ! echo "$USERNAME" | grep -qP "^[a-zA-Z0-9_\.][a-zA-Z0-9_\-\.]*"; then
USERNAME="default"
fi
export PS1="$USERNAME:\w\$ "
if [ x"$USER_ID" != x"0" ]; then
NSS_WRAPPER_PASSWD=/tmp/passwd
NSS_WRAPPER_GROUP=/etc/group
cat /etc/passwd > $NSS_WRAPPER_PASSWD
echo "${USERNAME}:x:${USER_ID}:${GROUP_ID}:Default Application User:${HOME}:/bin/bash" >> $NSS_WRAPPER_PASSWD
export NSS_WRAPPER_PASSWD
export NSS_WRAPPER_GROUP
detect_libnss_wrapper
echo "nss_wrapper location: $libnss_wrapper_file"
export LD_PRELOAD="$libnss_wrapper_file"
fi

114
builder/startup/vnc_startup.sh Executable file
View File

@@ -0,0 +1,114 @@
#!/bin/bash
### every exit != 0 fails the script
set -e
# should also source $STARTUPDIR/generate_container_user
source $HOME/.bashrc
## correct forwarding of shutdown signal
cleanup () {
kill -s SIGTERM $!
exit 0
}
trap cleanup SIGINT SIGTERM
detect_www_dir() {
local package_www_dir="/usr/share/kasmvnc/www"
if [[ -d "$package_www_dir" ]]; then
package_www_dir_option="-httpd $package_www_dir"
fi
}
detect_cert_location() {
local tarball_cert="$HOME/.vnc/self.pem"
local deb_cert="/etc/ssl/certs/ssl-cert-snakeoil.pem"
local deb_key="/etc/ssl/private/ssl-cert-snakeoil.key"
local rpm_cert="/etc/pki/tls/private/kasmvnc.pem"
if [[ -f "$deb_cert" ]]; then
cert_option="-cert $deb_cert -key $deb_key"
elif [[ -f "$rpm_cert" ]]; then
cert_option="-cert $rpm_cert"
else
cert_option="-cert $tarball_cert"
fi
}
add_vnc_user() {
local username="$1"
local password="$2"
local permission_option="$3"
echo "Adding user $username"
echo -e "$password\n$password" | kasmvncpasswd $permission_option \
-u "$username" $HOME/.kasmpasswd
}
## resolve_vnc_connection
VNC_IP=$(hostname -i)
# first entry is control, second is view (if only one is valid for both)
mkdir -p "$HOME/.vnc"
PASSWD_PATH="$HOME/.vnc/passwd"
add_vnc_user "$VNC_USER" "$VNC_PW" "-w"
add_vnc_user "$VNC_USER-ro" "$VNC_PW"
add_vnc_user "$VNC_USER-owner" "$VNC_PW" "-o"
add_vnc_user "$VNC_USER-to-delete" "$VNC_PW"
kasmvncpasswd -n -u "$VNC_USER-owner" -w -o $HOME/.kasmpasswd
kasmvncpasswd -d -u "$VNC_USER-to-delete" $HOME/.kasmpasswd
chmod 0600 $HOME/.kasmpasswd
openssl req -x509 -nodes -days 3650 -newkey rsa:2048 -keyout $HOME/.vnc/self.pem -out $HOME/.vnc/self.pem -subj "/C=US/ST=VA/L=None/O=None/OU=DoFu/CN=kasm/emailAddress=none@none.none"
exec /bin/bash
vncserver :1 -interface 0.0.0.0
vncserver -kill :1
if [[ -f $PASSWD_PATH ]]; then
rm -f $PASSWD_PATH
fi
#echo "$VNC_PW" | vncpasswd -f > $PASSWD_PATH
#echo "$VNC_VIEW_ONLY_PW" | vncpasswd -f >> $PASSWD_PATH
#chmod 600 $PASSWD_PATH
unset VNC_VIEW_ONLY_PW
unset VNC_PW
if [[ $DEBUG == true ]]; then
echo -e "\n------------------ start VNC server ------------------------"
echo "remove old vnc locks to be a reattachable container"
fi
vncserver -kill $DISPLAY &> $HOME/.vnc/vnc_startup.log \
|| rm -rfv /tmp/.X*-lock /tmp/.X11-unix &> $HOME/.vnc/vnc_startup.log \
|| echo "no locks present"
detect_www_dir
detect_cert_location
[ -n "$KASMVNC_VERBOSE_LOGGING" ] && verbose_logging_option="-log *:stderr:100"
echo -e "start vncserver with param: VNC_COL_DEPTH=$VNC_COL_DEPTH, VNC_RESOLUTION=$VNC_RESOLUTION\n..."
vncserver $DISPLAY -depth $VNC_COL_DEPTH -geometry $VNC_RESOLUTION -FrameRate=$MAX_FRAME_RATE -websocketPort $VNC_PORT $cert_option -sslOnly -interface 0.0.0.0 $VNCOPTIONS $package_www_dir_option $verbose_logging_option #&> $STARTUPDIR/no_vnc_startup.log
PID_SUN=$!
echo -e "start window manager\n..."
$STARTUPDIR/window_manager_startup.sh #&> $STARTUPDIR/window_manager_startup.log
## log connect options
echo -e "\n\n------------------ VNC environment started ------------------"
echo -e "\nVNCSERVER started on DISPLAY= $DISPLAY \n\t=> connect via VNC viewer with $VNC_IP:$VNC_PORT"
echo -e "\nnoVNC HTML client started:\n\t=> connect via http://$VNC_IP:$NO_VNC_PORT/?password=...\n"
echo "WEB PID: $PID_SUB"
# tail vncserver logs
tail -f $HOME/.vnc/*$DISPLAY.log &
eval "$@"
wait $PID_SUB
echo "Exiting Kasm container"

View File

@@ -0,0 +1,15 @@
#!/usr/bin/env bash
set -e
echo -e "\n------------------ Xfce4 window manager startup------------------"
### disable screen saver and power management
xset -dpms &
xset s noblank &
xset s off &
if [ "$SINGLE_APPLICATION" -eq "1" ]; then
echo "Configured of Single Application Mode"
sed -i "s/O|SHMC/|/g" $HOME/.config/xfce4/xfconf/xfce-perchannel-xml/xfwm4.xml
#xfwm4 --daemon
fi

14
builder/test-deb Executable file
View File

@@ -0,0 +1,14 @@
#!/bin/bash
set -e
cd "$(dirname "$0")"
. ./os_ver_cli.sh
docker build --build-arg KASMVNC_PACKAGE_DIR="build/${os_codename}" \
-t kasmvnctester_${os}:$os_codename \
-f dockerfile.${os}_${os_codename}.deb.test .
docker run -it -v $(realpath ${PWD}/..):/src -p 8443:8443 --rm \
-e KASMVNC_VERBOSE_LOGGING=$KASMVNC_VERBOSE_LOGGING \
-e "VNC_USER=foo" -e "VNC_PW=foobar" \
kasmvnctester_${os}:$os_codename

14
builder/test-deb-barebones Executable file
View File

@@ -0,0 +1,14 @@
#!/bin/bash
set -e
cd "$(dirname "$0")"
os="${1:-debian}"
os_codename="${2:-buster}"
docker build --build-arg KASMVNC_PACKAGE_DIR="build/${os_codename}" \
-t kasmvnctester_barebones_${os}:$os_codename \
-f dockerfile.${os}_${os_codename}.barebones.deb.test .
echo
docker run -it -p 443:8443 --rm -e "VNC_USER=foo" -e "VNC_PW=foobar" \
kasmvnctester_barebones_${os}:$os_codename

17
builder/test-rpm Executable file
View File

@@ -0,0 +1,17 @@
#!/bin/bash
set -e
cd "$(dirname "$0")"
. ./os_ver_cli.sh
echo kasmvnctester_${os}:$os_codename
docker build --build-arg \
KASMVNC_PACKAGE_DIR="build/${os}_${os_codename}" \
-t kasmvnctester_${os}:$os_codename \
-f dockerfile.${os}_${os_codename}.rpm.test .
docker run -it -p 443:8443 --rm \
-e KASMVNC_VERBOSE_LOGGING=$KASMVNC_VERBOSE_LOGGING \
-e "VNC_USER=foo" -e "VNC_PW=foobar" \
kasmvnctester_${os}:$os_codename

13
builder/test-rpm-barebones Executable file
View File

@@ -0,0 +1,13 @@
#!/bin/bash
set -e
cd "$(dirname "$0")"
os="${1:-centos}"
os_codename="${2:-core}"
docker build --build-arg KASMVNC_PACKAGE_DIR="build/${os}_${os_codename}" \
-t kasmvnctester_barebones_${os}:$os_codename \
-f dockerfile.${os}_${os_codename}.barebones.rpm.test .
docker run -it -p 443:8443 --rm -e "VNC_USER=foo" -e "VNC_PW=foobar" \
kasmvnctester_barebones_${os}:$os_codename

104
centos/kasmvncserver.spec Normal file
View File

@@ -0,0 +1,104 @@
Name: kasmvncserver
Version: 0.9.1~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=$(lsb_release -is | tr '[:upper:]' '[:lower:]')
TARGET_OS_CODENAME=$(lsb_release -cs | tr '[:upper:]' '[:lower:]')
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;
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;
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
* 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

View File

@@ -76,5 +76,5 @@ endif() #UNIX
# Common
#
install(FILES ${CMAKE_SOURCE_DIR}/LICENCE.TXT DESTINATION ${DOC_DIR})
install(FILES ${CMAKE_SOURCE_DIR}/LICENSE.TXT DESTINATION ${DOC_DIR})
install(FILES ${CMAKE_SOURCE_DIR}/README.md DESTINATION ${DOC_DIR})

View File

@@ -1,10 +1,12 @@
include_directories(${CMAKE_SOURCE_DIR}/common)
include_directories(${CMAKE_SOURCE_DIR}/common ${CMAKE_SOURCE_DIR}/unix/kasmvncpasswd)
set(NETWORK_SOURCES
GetAPIMessager.cxx
Socket.cxx
TcpSocket.cxx
websocket.c
websockify.c)
websockify.c
${CMAKE_SOURCE_DIR}/unix/kasmvncpasswd/kasmpasswd.c)
if(NOT WIN32)
set(NETWORK_SOURCES ${NETWORK_SOURCES} UnixSocket.cxx)

75
common/network/GetAPI.h Normal file
View File

@@ -0,0 +1,75 @@
/* 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_H__
#define __NETWORK_GET_API_H__
#include <kasmpasswd.h>
#include <pthread.h>
#include <rfb/PixelBuffer.h>
#include <rfb/PixelFormat.h>
#include <stdint.h>
#include <vector>
namespace network {
class GetAPIMessager {
public:
GetAPIMessager(const char *passwdfile_);
// from main thread
void mainUpdateScreen(rfb::PixelBuffer *pb);
// from network threads
uint8_t *netGetScreenshot(uint16_t w, uint16_t h,
const uint8_t q, const bool dedup,
uint32_t &len, uint8_t *staging);
uint8_t netAddUser(const char name[], const char pw[], const bool write);
uint8_t netRemoveUser(const char name[]);
uint8_t netGiveControlTo(const char name[]);
enum USER_ACTION {
//USER_ADD, - handled locally for interactivity
USER_REMOVE,
USER_GIVE_CONTROL,
};
struct action_data {
enum USER_ACTION action;
kasmpasswd_entry_t data;
};
pthread_mutex_t userMutex;
std::vector<action_data> actionQueue;
private:
const char *passwdfile;
pthread_mutex_t screenMutex;
rfb::ManagedPixelBuffer screenPb;
uint16_t screenW, screenH;
uint64_t screenHash;
std::vector<uint8_t> cachedJpeg;
uint16_t cachedW, cachedH;
uint8_t cachedQ;
};
}
#endif // __NETWORK_GET_API_H__

View File

@@ -0,0 +1,288 @@
/* 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.
*/
#define __STDC_FORMAT_MACROS
#include <inttypes.h>
#include <network/GetAPI.h>
#include <rfb/ConnParams.h>
#include <rfb/LogWriter.h>
#include <rfb/JpegCompressor.h>
#include <rfb/xxhash.h>
#include <stdio.h>
#include <stdlib.h>
using namespace network;
using namespace rfb;
static LogWriter vlog("GetAPIMessager");
PixelBuffer *progressiveBilinearScale(const PixelBuffer *pb,
const uint16_t tgtw, const uint16_t tgth,
const float tgtdiff);
struct TightJPEGConfiguration {
int quality;
int subsampling;
};
static const struct TightJPEGConfiguration conf[10] = {
{ 15, subsample4X }, // 0
{ 29, subsample4X }, // 1
{ 41, subsample4X }, // 2
{ 42, subsample2X }, // 3
{ 62, subsample2X }, // 4
{ 77, subsample2X }, // 5
{ 79, subsampleNone }, // 6
{ 86, subsampleNone }, // 7
{ 92, subsampleNone }, // 8
{ 100, subsampleNone } // 9
};
GetAPIMessager::GetAPIMessager(const char *passwdfile_): passwdfile(passwdfile_),
screenW(0), screenH(0), screenHash(0),
cachedW(0), cachedH(0), cachedQ(0) {
pthread_mutex_init(&screenMutex, NULL);
pthread_mutex_init(&userMutex, NULL);
}
// from main thread
void GetAPIMessager::mainUpdateScreen(rfb::PixelBuffer *pb) {
if (pthread_mutex_trylock(&screenMutex))
return;
int stride;
const rdr::U8 * const buf = pb->getBuffer(pb->getRect(), &stride);
if (pb->width() != screenW || pb->height() != screenH) {
screenHash = 0;
screenW = pb->width();
screenH = pb->height();
screenPb.setPF(pb->getPF());
screenPb.setSize(screenW, screenH);
cachedW = cachedH = cachedQ = 0;
cachedJpeg.clear();
}
const uint64_t newHash = XXH64(buf, pb->area() * 4, 0);
if (newHash != screenHash) {
cachedW = cachedH = cachedQ = 0;
cachedJpeg.clear();
screenHash = newHash;
rdr::U8 *rw = screenPb.getBufferRW(screenPb.getRect(), &stride);
memcpy(rw, buf, screenW * screenH * 4);
screenPb.commitBufferRW(screenPb.getRect());
}
pthread_mutex_unlock(&screenMutex);
}
// from network threads
uint8_t *GetAPIMessager::netGetScreenshot(uint16_t w, uint16_t h,
const uint8_t q, const bool dedup,
uint32_t &len, uint8_t *staging) {
uint8_t *ret = NULL;
len = 0;
if (w > screenW)
w = screenW;
if (h > screenH)
h = screenH;
if (!screenW || !screenH)
vlog.error("Screenshot requested but no screenshot exists (screen hasn't been viewed)");
if (!w || !h || q > 9 || !staging)
return NULL;
if (pthread_mutex_lock(&screenMutex))
return NULL;
if (w == cachedW && h == cachedH && q == cachedQ) {
if (dedup) {
// Return the hash of the unchanged image
sprintf((char *) staging, "%" PRIx64, screenHash);
ret = staging;
len = 16;
} else {
// Return the cached image
len = cachedJpeg.size();
ret = staging;
memcpy(ret, &cachedJpeg[0], len);
vlog.info("Returning cached screenshot");
}
} else {
// Encode the new JPEG, cache it
JpegCompressor jc;
int quality, subsampling;
quality = conf[q].quality;
subsampling = conf[q].subsampling;
jc.clear();
int stride;
if (w != screenW || h != screenH) {
float xdiff = w / (float) screenW;
float ydiff = h / (float) screenH;
const float diff = xdiff < ydiff ? xdiff : ydiff;
const uint16_t neww = screenW * diff;
const uint16_t newh = screenH * diff;
const PixelBuffer *scaled = progressiveBilinearScale(&screenPb, neww, newh, diff);
const rdr::U8 * const buf = scaled->getBuffer(scaled->getRect(), &stride);
jc.compress(buf, stride, scaled->getRect(),
scaled->getPF(), quality, subsampling);
cachedJpeg.resize(jc.length());
memcpy(&cachedJpeg[0], jc.data(), jc.length());
delete scaled;
vlog.info("Returning scaled screenshot");
} else {
const rdr::U8 * const buf = screenPb.getBuffer(screenPb.getRect(), &stride);
jc.compress(buf, stride, screenPb.getRect(),
screenPb.getPF(), quality, subsampling);
cachedJpeg.resize(jc.length());
memcpy(&cachedJpeg[0], jc.data(), jc.length());
vlog.info("Returning normal screenshot");
}
cachedQ = q;
cachedW = w;
cachedH = h;
len = cachedJpeg.size();
ret = staging;
memcpy(ret, &cachedJpeg[0], len);
}
pthread_mutex_unlock(&screenMutex);
return ret;
}
#define USERNAME_LEN sizeof(((struct kasmpasswd_entry_t *)0)->user)
#define PASSWORD_LEN sizeof(((struct kasmpasswd_entry_t *)0)->password)
uint8_t GetAPIMessager::netAddUser(const char name[], const char pw[], const bool write) {
if (strlen(name) >= USERNAME_LEN) {
vlog.error("Username too long");
return 0;
}
if (strlen(pw) >= PASSWORD_LEN) {
vlog.error("Password too long");
return 0;
}
if (!passwdfile)
return 0;
action_data act;
memcpy(act.data.user, name, USERNAME_LEN);
act.data.user[USERNAME_LEN - 1] = '\0';
memcpy(act.data.password, pw, PASSWORD_LEN);
act.data.password[PASSWORD_LEN - 1] = '\0';
act.data.owner = 0;
act.data.write = write;
if (pthread_mutex_lock(&userMutex))
return 0;
// This needs to be handled locally for proper interactivity
// (consider adding users when nobody is connected).
// The mutex and atomic rename keep things in sync.
struct kasmpasswd_t *set = readkasmpasswd(passwdfile);
unsigned s;
for (s = 0; s < set->num; s++) {
if (!strcmp(set->entries[s].user, act.data.user)) {
vlog.error("Can't create user %s, already exists", act.data.user);
goto out;
}
}
s = set->num++;
set->entries = (struct kasmpasswd_entry_t *) realloc(set->entries,
set->num * sizeof(struct kasmpasswd_entry_t));
set->entries[s] = act.data;
writekasmpasswd(passwdfile, set);
vlog.info("User %s created", act.data.user);
out:
pthread_mutex_unlock(&userMutex);
return 1;
}
uint8_t GetAPIMessager::netRemoveUser(const char name[]) {
if (strlen(name) >= USERNAME_LEN) {
vlog.error("Username too long");
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))
return 0;
actionQueue.push_back(act);
pthread_mutex_unlock(&userMutex);
return 1;
}
uint8_t GetAPIMessager::netGiveControlTo(const char name[]) {
if (strlen(name) >= USERNAME_LEN) {
vlog.error("Username too long");
return 0;
}
action_data act;
act.action = USER_GIVE_CONTROL;
memcpy(act.data.user, name, USERNAME_LEN);
act.data.user[USERNAME_LEN - 1] = '\0';
if (pthread_mutex_lock(&userMutex))
return 0;
actionQueue.push_back(act);
pthread_mutex_unlock(&userMutex);
return 1;
}

View File

@@ -25,6 +25,9 @@
#include <winsock2.h>
#include <ws2tcpip.h>
#define errorNumber WSAGetLastError()
#define SHUT_RD SD_RECEIVE
#define SHUT_WR SD_SEND
#define SHUT_RDWR SD_BOTH
#else
#define errorNumber errno
#define closesocket close
@@ -94,7 +97,7 @@ Socket::~Socket()
void Socket::shutdown()
{
isShutdown_ = true;
::shutdown(getFd(), 2);
::shutdown(getFd(), SHUT_RDWR);
}
bool Socket::isShutdown() const
@@ -149,7 +152,7 @@ void SocketListener::shutdown()
closesocket(fd);
fd = -1;
#else
::shutdown(fd, 2);
::shutdown(fd, SHUT_RDWR);
#endif
}

View File

@@ -74,6 +74,8 @@ namespace network {
virtual ~ConnectionFilter() {}
};
class GetAPIMessager;
class SocketListener {
public:
SocketListener(int fd);
@@ -93,6 +95,8 @@ namespace network {
void setFilter(ConnectionFilter* f) {filter = f;}
int getFd() {return fd;}
virtual GetAPIMessager *getMessager() { return NULL; }
protected:
SocketListener();

View File

@@ -1,15 +1,15 @@
/* Copyright (C) 2002-2005 RealVNC Ltd. 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,
@@ -38,9 +38,11 @@
#include <sys/un.h>
#include <stdlib.h>
#include <unistd.h>
#include <pthread.h>
#include <wordexp.h>
#include "websocket.h"
#include <network/GetAPI.h>
#include <network/TcpSocket.h>
#include <rfb/LogWriter.h>
#include <rfb/Configuration.h>
@@ -123,11 +125,20 @@ WebSocket::WebSocket(int sock) : Socket(sock)
}
char* WebSocket::getPeerAddress() {
return rfb::strDup("websocket");
struct sockaddr_un addr;
socklen_t len = sizeof(struct sockaddr_un);
if (getpeername(getFd(), (struct sockaddr *) &addr, &len) != 0) {
vlog.error("unable to get peer name for socket");
return rfb::strDup("websocket");
}
return rfb::strDup(addr.sun_path + 1);
}
char* WebSocket::getPeerEndpoint() {
return rfb::strDup("websocket");
char buf[1024];
sprintf(buf, "%s::websocket", getPeerAddress());
return rfb::strDup(buf);
}
// -=- TcpSocket
@@ -421,10 +432,37 @@ int TcpListener::getMyPort() {
extern settings_t settings;
static uint8_t *screenshotCb(void *messager, uint16_t w, uint16_t h, const uint8_t q,
const uint8_t dedup,
uint32_t *len, uint8_t *staging)
{
GetAPIMessager *msgr = (GetAPIMessager *) messager;
return msgr->netGetScreenshot(w, h, q, dedup, *len, staging);
}
static uint8_t adduserCb(void *messager, const char name[], const char pw[],
const uint8_t write)
{
GetAPIMessager *msgr = (GetAPIMessager *) messager;
return msgr->netAddUser(name, pw, write);
}
static uint8_t removeCb(void *messager, const char name[])
{
GetAPIMessager *msgr = (GetAPIMessager *) messager;
return msgr->netRemoveUser(name);
}
static uint8_t givecontrolCb(void *messager, const char name[])
{
GetAPIMessager *msgr = (GetAPIMessager *) messager;
return msgr->netGiveControlTo(name);
}
WebsocketListener::WebsocketListener(const struct sockaddr *listenaddr,
socklen_t listenaddrlen,
bool sslonly, const char *cert,
const char *basicauth,
bool sslonly, const char *cert, const char *certkey,
bool disablebasicauth,
const char *httpdir)
{
int one = 1;
@@ -494,9 +532,9 @@ WebsocketListener::WebsocketListener(const struct sockaddr *listenaddr,
settings.passwdfile = strdup(wexp.we_wordv[0]);
wordfree(&wexp);
settings.basicauth = basicauth;
settings.disablebasicauth = disablebasicauth;
settings.cert = cert;
settings.key = "";
settings.key = certkey;
settings.ssl_only = sslonly;
settings.verbose = vlog.getLevel() >= vlog.LEVEL_DEBUG;
settings.httpdir = NULL;
@@ -505,6 +543,12 @@ WebsocketListener::WebsocketListener(const struct sockaddr *listenaddr,
settings.listen_sock = sock;
settings.messager = messager = new GetAPIMessager(settings.passwdfile);
settings.screenshotCb = screenshotCb;
settings.adduserCb = adduserCb;
settings.removeCb = removeCb;
settings.givecontrolCb = givecontrolCb;
pthread_t tid;
pthread_create(&tid, NULL, start_server, NULL);
}
@@ -673,8 +717,8 @@ void network::createTcpListeners(std::list<SocketListener*> *listeners,
void network::createWebsocketListeners(std::list<SocketListener*> *listeners,
const struct addrinfo *ai,
bool sslonly, const char *cert,
const char *basicauth,
bool sslonly, const char *cert, const char *certkey,
bool disablebasicauth,
const char *httpdir)
{
const struct addrinfo *current;
@@ -701,7 +745,7 @@ void network::createWebsocketListeners(std::list<SocketListener*> *listeners,
try {
new_listeners.push_back(new WebsocketListener(current->ai_addr,
current->ai_addrlen,
sslonly, cert, basicauth,
sslonly, cert, certkey, disablebasicauth,
httpdir));
} catch (SocketException& e) {
// Ignore this if it is due to lack of address family support on
@@ -729,7 +773,8 @@ void network::createWebsocketListeners(std::list<SocketListener*> *listeners,
const char *addr,
bool sslonly,
const char *cert,
const char *basicauth,
const char *certkey,
bool disablebasicauth,
const char *httpdir)
{
if (addr && !strcmp(addr, "local")) {
@@ -757,7 +802,7 @@ void network::createWebsocketListeners(std::list<SocketListener*> *listeners,
ai[1].ai_addrlen = sizeof(sa[1].u.sin6);
ai[1].ai_next = NULL;
createWebsocketListeners(listeners, ai, sslonly, cert, basicauth, httpdir);
createWebsocketListeners(listeners, ai, sslonly, cert, certkey, disablebasicauth, httpdir);
} else {
struct addrinfo *ai, hints;
char service[16];
@@ -780,7 +825,7 @@ void network::createWebsocketListeners(std::list<SocketListener*> *listeners,
gai_strerror(result));
try {
createWebsocketListeners(listeners, ai, sslonly, cert, basicauth, httpdir);
createWebsocketListeners(listeners, ai, sslonly, cert, certkey, disablebasicauth, httpdir);
} catch(...) {
freeaddrinfo(ai);
throw;

View File

@@ -90,7 +90,8 @@ namespace network {
class WebsocketListener : public SocketListener {
public:
WebsocketListener(const struct sockaddr *listenaddr, socklen_t listenaddrlen,
bool sslonly, const char *cert, const char *basicauth,
bool sslonly, const char *cert, const char *certkey,
bool disablebasicauth,
const char *httpdir);
virtual int getMyPort();
@@ -99,8 +100,12 @@ namespace network {
int internalSocket;
virtual GetAPIMessager *getMessager() { return messager; }
protected:
virtual Socket* createSocket(int fd);
private:
GetAPIMessager *messager;
};
void createLocalTcpListeners(std::list<SocketListener*> *listeners,
@@ -110,7 +115,8 @@ namespace network {
const char *addr,
bool sslonly,
const char *cert,
const char *basicauth,
const char *certkey,
bool disablebasicauth,
const char *httpdir);
void createTcpListeners(std::list<SocketListener*> *listeners,
const char *addr,
@@ -121,7 +127,8 @@ namespace network {
const struct addrinfo *ai,
bool sslonly,
const char *cert,
const char *basicauth,
const char *certkey,
bool disablebasicauth,
const char *httpdir);
typedef struct vnc_sockaddr {

View File

@@ -9,8 +9,10 @@
*/
#define _GNU_SOURCE
#include <ctype.h>
#include <pthread.h>
#include <unistd.h>
#include <crypt.h>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
@@ -29,6 +31,7 @@
#include <openssl/md5.h> /* md5 hash */
#include <openssl/sha.h> /* sha1 hash */
#include "websocket.h"
#include "kasmpasswd.h"
/*
* Global state
@@ -58,29 +61,78 @@ void fatal(char *msg)
exit(1);
}
/* resolve host with also IP address parsing */
int resolve_host(struct in_addr *sin_addr, const char *hostname)
{
if (!inet_aton(hostname, sin_addr)) {
struct addrinfo *ai, *cur;
struct addrinfo hints;
memset(&hints, 0, sizeof(hints));
hints.ai_family = AF_INET;
if (getaddrinfo(hostname, NULL, &hints, &ai))
return -1;
for (cur = ai; cur; cur = cur->ai_next) {
if (cur->ai_family == AF_INET) {
*sin_addr = ((struct sockaddr_in *)cur->ai_addr)->sin_addr;
freeaddrinfo(ai);
return 0;
}
}
freeaddrinfo(ai);
return -1;
}
return 0;
}
/* resolve host with also IP address parsing */
int resolve_host(struct in_addr *sin_addr, const char *hostname)
{
if (!inet_aton(hostname, sin_addr)) {
struct addrinfo *ai, *cur;
struct addrinfo hints;
memset(&hints, 0, sizeof(hints));
hints.ai_family = AF_INET;
if (getaddrinfo(hostname, NULL, &hints, &ai))
return -1;
for (cur = ai; cur; cur = cur->ai_next) {
if (cur->ai_family == AF_INET) {
*sin_addr = ((struct sockaddr_in *)cur->ai_addr)->sin_addr;
freeaddrinfo(ai);
return 0;
}
}
freeaddrinfo(ai);
return -1;
}
return 0;
}
static const char *parse_get(const char * const in, const char * const opt, unsigned *len) {
const char *start = in;
const char *end = strchrnul(start, '&');
const unsigned optlen = strlen(opt);
*len = 0;
while (1) {
if (!strncmp(start, opt, optlen)) {
const char *arg = strchr(start, '=');
if (!arg)
return "";
arg++;
*len = end - arg;
return arg;
}
if (!*end)
break;
end++;
start = end;
end = strchrnul(start, '&');
}
return "";
}
static void percent_decode(const char *src, char *dst) {
while (1) {
if (!*src)
break;
if (*src != '%') {
*dst++ = *src++;
} else {
src++;
if (!src[0] || !src[1])
break;
char hex[3];
hex[0] = src[0];
hex[1] = src[1];
hex[2] = '\0';
src += 2;
*dst++ = strtol(hex, NULL, 16);
}
}
*dst = '\0';
}
/*
* SSL Wrapper Code
@@ -106,7 +158,7 @@ ssize_t ws_send(ws_ctx_t *ctx, const void *buf, size_t len) {
ws_ctx_t *alloc_ws_ctx() {
ws_ctx_t *ctx;
if (! (ctx = malloc(sizeof(ws_ctx_t))) )
if (! (ctx = calloc(sizeof(ws_ctx_t), 1)) )
{ fatal("malloc()"); }
if (! (ctx->cin_buf = malloc(BUFSIZE)) )
@@ -160,12 +212,14 @@ ws_ctx_t *ws_socket_ssl(ws_ctx_t *ctx, int socket, char * certfile, char * keyfi
}
ctx->ssl_ctx = SSL_CTX_new(TLSv1_server_method());
ctx->ssl_ctx = SSL_CTX_new(SSLv23_server_method());
if (ctx->ssl_ctx == NULL) {
ERR_print_errors_fp(stderr);
fatal("Failed to configure SSL context");
}
SSL_CTX_set_options(ctx->ssl_ctx, SSL_OP_NO_SSLv2 | SSL_OP_NO_SSLv3);
if (SSL_CTX_use_PrivateKey_file(ctx->ssl_ctx, use_keyfile,
SSL_FILETYPE_PEM) <= 0) {
sprintf(msg, "Unable to load private key file %s\n", use_keyfile);
@@ -305,7 +359,7 @@ int decode_hixie(char *src, size_t srclength,
*left = srclength;
if (srclength == 2 &&
(src[0] == '\xff') &&
(src[0] == '\xff') &&
(src[1] == '\x00')) {
// client sent orderly close frame
*opcode = 0x8; // Close frame
@@ -323,7 +377,7 @@ int decode_hixie(char *src, size_t srclength,
return len;
}
retlen += len;
start = end + 2; // Skip '\xff' end and '\x00' start
start = end + 2; // Skip '\xff' end and '\x00' start
framecount++;
} while (end < (src+srclength-1));
if (framecount > 1) {
@@ -396,7 +450,7 @@ int decode_hybi(unsigned char *src, size_t srclength,
int i = 0, len, framecount = 0;
size_t remaining = 0;
unsigned int target_offset = 0, hdr_length = 0, payload_length = 0;
*left = srclength;
frame = src;
@@ -496,7 +550,7 @@ int decode_hybi(unsigned char *src, size_t srclength,
snprintf(cntstr, 3, "%d", framecount);
traffic(cntstr);
}
*left = remaining;
return target_offset;
}
@@ -540,7 +594,7 @@ int parse_handshake(ws_ctx_t *ws_ctx, char *handshake) {
end = strstr(start, "\r\n");
strncpy(headers->origin, start, end-start);
headers->origin[end-start] = '\0';
start = strstr(handshake, "\r\nSec-WebSocket-Version: ");
if (start) {
// HyBi/RFC 6455
@@ -557,14 +611,14 @@ int parse_handshake(ws_ctx_t *ws_ctx, char *handshake) {
end = strstr(start, "\r\n");
strncpy(headers->key1, start, end-start);
headers->key1[end-start] = '\0';
start = strstr(handshake, "\r\nConnection: ");
if (!start) { return 0; }
start += 14;
end = strstr(start, "\r\n");
strncpy(headers->connection, start, end-start);
headers->connection[end-start] = '\0';
start = strstr(handshake, "\r\nSec-WebSocket-Protocol: ");
if (!start) { return 0; }
start += 26;
@@ -589,7 +643,7 @@ int parse_handshake(ws_ctx_t *ws_ctx, char *handshake) {
end = strstr(start, "\r\n");
strncpy(headers->key1, start, end-start);
headers->key1[end-start] = '\0';
start = strstr(handshake, "\r\nSec-WebSocket-Key2: ");
if (!start) { return 0; }
start += 22;
@@ -725,7 +779,13 @@ static void dirlisting(ws_ctx_t *ws_ctx, const char fullpath[], const char path[
if (!strcmp(names[i]->d_name, ".") || !strcmp(names[i]->d_name, ".."))
continue;
sprintf(buf, "<li><a href=\"%s\">%s</a></li>", names[i]->d_name, names[i]->d_name);
if (names[i]->d_type == DT_DIR)
sprintf(buf, "<li><a href=\"%s/\">%s/</a></li>", names[i]->d_name,
names[i]->d_name);
else
sprintf(buf, "<li><a href=\"%s\">%s</a></li>", names[i]->d_name,
names[i]->d_name);
ws_send(ws_ctx, buf, strlen(buf));
}
@@ -810,6 +870,226 @@ nope:
ws_send(ws_ctx, buf, strlen(buf));
}
static uint8_t ownerapi(ws_ctx_t *ws_ctx, const char *in) {
char buf[4096], path[4096], args[4096] = "";
uint8_t ret = 0; // 0 = continue checking
if (strncmp(in, "GET ", 4)) {
wserr("non-GET request, rejecting\n");
return 0;
}
in += 4;
const char *end = strchr(in, ' ');
unsigned len = end - in;
if (len < 1 || len > 1024 || strstr(in, "../")) {
wserr("Request too long (%u) or attempted dir traversal attack, rejecting\n", len);
return 0;
}
end = memchr(in, '?', len);
if (end) {
len = end - in;
end++;
const char *argend = strchr(end, ' ');
strncpy(args, end, argend - end);
args[argend - end] = '\0';
}
memcpy(path, in, len);
path[len] = '\0';
if (strstr(args, "password=")) {
wserr("Requested owner api '%s' with args (skipped, includes password)\n", path);
} else {
wserr("Requested owner api '%s' with args '%s'\n", path, args);
}
#define entry(x) if (!strcmp(path, x))
const char *param;
entry("/api/get_screenshot") {
uint8_t q = 7, dedup = 0;
uint16_t w = 4096, h = 4096;
param = parse_get(args, "width", &len);
if (len && isdigit(param[0]))
w = atoi(param);
param = parse_get(args, "height", &len);
if (len && isdigit(param[0]))
h = atoi(param);
param = parse_get(args, "quality", &len);
if (len && isdigit(param[0]))
q = atoi(param);
param = parse_get(args, "deduplicate", &len);
if (len && isalpha(param[0])) {
if (!strncmp(param, "true", len))
dedup = 1;
}
uint8_t *staging = malloc(1024 * 1024 * 8);
settings.screenshotCb(settings.messager, w, h, q, dedup, &len, staging);
if (len == 16) {
sprintf(buf, "HTTP/1.1 200 OK\r\n"
"Server: KasmVNC/4.0\r\n"
"Connection: close\r\n"
"Content-type: text/plain\r\n"
"Content-length: %u\r\n"
"\r\n", len);
ws_send(ws_ctx, buf, strlen(buf));
ws_send(ws_ctx, staging, len);
wserr("Screenshot hadn't changed and dedup was requested, sent hash\n");
ret = 1;
} else if (len) {
sprintf(buf, "HTTP/1.1 200 OK\r\n"
"Server: KasmVNC/4.0\r\n"
"Connection: close\r\n"
"Content-type: image/jpeg\r\n"
"Content-length: %u\r\n"
"\r\n", len);
ws_send(ws_ctx, buf, strlen(buf));
ws_send(ws_ctx, staging, len);
wserr("Sent screenshot %u bytes\n", len);
ret = 1;
}
free(staging);
if (!len) {
wserr("Invalid params to screenshot\n");
goto nope;
}
} else entry("/api/create_user") {
char decname[1024] = "", decpw[1024] = "";
uint8_t write = 0;
param = parse_get(args, "name", &len);
if (len) {
memcpy(buf, param, len);
buf[len] = '\0';
percent_decode(buf, decname);
}
param = parse_get(args, "password", &len);
if (len) {
memcpy(buf, param, len);
buf[len] = '\0';
percent_decode(buf, decpw);
struct crypt_data cdata;
cdata.initialized = 0;
const char *encrypted = crypt_r(decpw, "$5$kasm$", &cdata);
strcpy(decpw, encrypted);
}
param = parse_get(args, "write", &len);
if (len && isalpha(param[0])) {
if (!strncmp(param, "true", len))
write = 1;
}
if (!decname[0] || !decpw[0])
goto nope;
if (!settings.adduserCb(settings.messager, decname, decpw, write)) {
wserr("Invalid params to create_user\n");
goto nope;
}
sprintf(buf, "HTTP/1.1 200 OK\r\n"
"Server: KasmVNC/4.0\r\n"
"Connection: close\r\n"
"Content-type: text/plain\r\n"
"Content-length: 6\r\n"
"\r\n"
"200 OK");
ws_send(ws_ctx, buf, strlen(buf));
ret = 1;
} else entry("/api/remove_user") {
char decname[1024] = "";
param = parse_get(args, "name", &len);
if (len) {
memcpy(buf, param, len);
buf[len] = '\0';
percent_decode(buf, decname);
}
if (!decname[0])
goto nope;
if (!settings.removeCb(settings.messager, decname)) {
wserr("Invalid params to remove_user\n");
goto nope;
}
sprintf(buf, "HTTP/1.1 200 OK\r\n"
"Server: KasmVNC/4.0\r\n"
"Connection: close\r\n"
"Content-type: text/plain\r\n"
"Content-length: 6\r\n"
"\r\n"
"200 OK");
ws_send(ws_ctx, buf, strlen(buf));
wserr("Passed remove_user request to main thread\n");
ret = 1;
} else entry("/api/give_control") {
char decname[1024] = "";
param = parse_get(args, "name", &len);
if (len) {
memcpy(buf, param, len);
buf[len] = '\0';
percent_decode(buf, decname);
}
if (!decname[0])
goto nope;
if (!settings.givecontrolCb(settings.messager, decname)) {
wserr("Invalid params to give_control\n");
goto nope;
}
sprintf(buf, "HTTP/1.1 200 OK\r\n"
"Server: KasmVNC/4.0\r\n"
"Connection: close\r\n"
"Content-type: text/plain\r\n"
"Content-length: 6\r\n"
"\r\n"
"200 OK");
ws_send(ws_ctx, buf, strlen(buf));
wserr("Passed give_control request to main thread\n");
ret = 1;
}
#undef entry
return ret;
nope:
sprintf(buf, "HTTP/1.1 400 Bad Request\r\n"
"Server: KasmVNC/4.0\r\n"
"Connection: close\r\n"
"Content-type: text/plain\r\n"
"\r\n"
"400 Bad Request");
ws_send(ws_ctx, buf, strlen(buf));
return 1;
}
ws_ctx_t *do_handshake(int sock) {
char handshake[4096], response[4096], sha1[29], trailer[17];
char *scheme, *pre;
@@ -878,8 +1158,8 @@ ws_ctx_t *do_handshake(int sock) {
usleep(10);
}
const char *colon;
if ((colon = strchr(settings.basicauth, ':'))) {
unsigned char owner = 0;
if (!settings.disablebasicauth) {
const char *hdr = strstr(handshake, "Authorization: Basic ");
if (!hdr) {
handler_emsg("BasicAuth required, but client didn't send any. 401 Unauth\n");
@@ -904,40 +1184,56 @@ ws_ctx_t *do_handshake(int sock) {
tmp[len] = '\0';
len = ws_b64_pton(tmp, response, 256);
char authbuf[4096];
strncpy(authbuf, settings.basicauth, 4096);
authbuf[4095] = '\0';
char authbuf[4096] = "";
// Do we need to read it from the file?
char *resppw = strchr(response, ':');
if (resppw && *resppw)
resppw++;
if (!colon[1] && settings.passwdfile) {
if (resppw && *resppw) {
if (settings.passwdfile) {
if (resppw && *resppw && resppw - response < 32) {
char pwbuf[4096];
FILE *f = fopen(settings.passwdfile, "r");
if (f) {
handler_emsg("BasicAuth reading password from %s\n", settings.passwdfile);
const unsigned len = fread(pwbuf, 1, 4096, f);
fclose(f);
pwbuf[4095] = '\0';
if (len < 4096)
pwbuf[len] = '\0';
snprintf(authbuf, 4096, "%s%s", settings.basicauth, pwbuf);
authbuf[4095] = '\0';
const char *encrypted = crypt(resppw, "$5$kasm$");
*resppw = '\0';
snprintf(pwbuf, 4096, "%s%s", response, encrypted);
pwbuf[4095] = '\0';
strcpy(response, pwbuf);
} else {
fprintf(stderr, " websocket %d: Error: BasicAuth configured to read password from file %s, but the file doesn't exist\n",
struct kasmpasswd_t *set = readkasmpasswd(settings.passwdfile);
if (!set->num) {
fprintf(stderr, " websocket %d: Error: BasicAuth configured to read password from file %s, but the file doesn't exist or has no valid users\n",
wsthread_handler_id,
settings.passwdfile);
} else {
unsigned i;
char inuser[32];
unsigned char found = 0;
memcpy(inuser, response, resppw - response - 1);
inuser[resppw - response - 1] = '\0';
for (i = 0; i < set->num; i++) {
if (!strcmp(set->entries[i].user, inuser)) {
found = 1;
strcpy(ws_ctx->user, inuser);
snprintf(authbuf, 4096, "%s:%s", set->entries[i].user,
set->entries[i].password);
authbuf[4095] = '\0';
if (set->entries[i].owner)
owner = 1;
break;
}
}
if (!found)
handler_emsg("BasicAuth user %s not found\n", inuser);
}
free(set->entries);
free(set);
struct crypt_data cdata;
cdata.initialized = 0;
const char *encrypted = crypt_r(resppw, "$5$kasm$", &cdata);
*resppw = '\0';
snprintf(pwbuf, 4096, "%s%s", response, encrypted);
pwbuf[4095] = '\0';
strcpy(response, pwbuf);
} else {
// Client tried an empty password, just fail them
response[0] = '\0';
@@ -959,9 +1255,28 @@ ws_ctx_t *do_handshake(int sock) {
if (!parse_handshake(ws_ctx, handshake)) {
handler_emsg("Invalid WS request, maybe a HTTP one\n");
if (strstr(handshake, "/api/")) {
handler_emsg("HTTP request under /api/\n");
if (owner) {
if (ownerapi(ws_ctx, handshake))
goto done;
} else {
sprintf(response, "HTTP/1.1 401 Unauthorized\r\n"
"Server: KasmVNC/4.0\r\n"
"Connection: close\r\n"
"Content-type: text/plain\r\n"
"\r\n"
"401 Unauthorized");
ws_send(ws_ctx, response, strlen(response));
goto done;
}
}
if (settings.httpdir && settings.httpdir[0])
servefile(ws_ctx, handshake);
done:
free_ws_ctx(ws_ctx);
return NULL;
}
@@ -995,7 +1310,7 @@ ws_ctx_t *do_handshake(int sock) {
snprintf(response, sizeof(response), SERVER_HANDSHAKE_HIXIE, pre, headers->origin,
pre, scheme, headers->host, headers->path, pre, "base64", trailer);
}
//handler_msg("response: %s\n", response);
ws_send(ws_ctx, response, strlen(response));
@@ -1012,7 +1327,6 @@ void *subthread(void *ptr) {
const int csock = pass->csock;
wsthread_handler_id = pass->id;
free((void *) pass);
ws_ctx_t *ws_ctx;
@@ -1022,11 +1336,14 @@ void *subthread(void *ptr) {
goto out; // Child process exits
}
memcpy(ws_ctx->ip, pass->ip, sizeof(pass->ip));
proxy_handler(ws_ctx);
if (pipe_error) {
handler_emsg("Closing due to SIGPIPE\n");
}
out:
free((void *) pass);
if (ws_ctx) {
ws_socket_free(ws_ctx);
@@ -1062,12 +1379,13 @@ void *start_server(void *unused) {
error("ERROR on accept");
continue;
}
struct wspass_t *pass = calloc(1, sizeof(struct wspass_t));
inet_ntop(cli_addr.sin_family, &cli_addr.sin_addr, pass->ip, sizeof(pass->ip));
fprintf(stderr, " websocket %d: got client connection from %s\n",
settings.handler_id,
inet_ntoa(cli_addr.sin_addr));
pass->ip);
pthread_t tid;
struct wspass_t *pass = calloc(1, sizeof(struct wspass_t));
pass->id = settings.handler_id;
pass->csock = csock;
pthread_create(&tid, NULL, subthread, pass);

View File

@@ -1,4 +1,5 @@
#include <openssl/ssl.h>
#include <stdint.h>
#define BUFSIZE 65536
#define DBUFSIZE (BUFSIZE * 3) / 4 - 20
@@ -53,11 +54,15 @@ typedef struct {
char *cout_buf;
char *tin_buf;
char *tout_buf;
char user[32];
char ip[64];
} ws_ctx_t;
struct wspass_t {
int csock;
unsigned id;
char ip[64];
};
typedef struct {
@@ -66,10 +71,19 @@ typedef struct {
unsigned int handler_id;
const char *cert;
const char *key;
const char *basicauth;
uint8_t disablebasicauth;
const char *passwdfile;
int ssl_only;
const char *httpdir;
void *messager;
uint8_t *(*screenshotCb)(void *messager, uint16_t w, uint16_t h, const uint8_t q,
const uint8_t dedup,
uint32_t *len, uint8_t *staging);
uint8_t (*adduserCb)(void *messager, const char name[], const char pw[],
const uint8_t write);
uint8_t (*removeCb)(void *messager, const char name[]);
uint8_t (*givecontrolCb)(void *messager, const char name[]);
} settings_t;
#ifdef __cplusplus

View File

@@ -20,6 +20,7 @@
#include <fcntl.h>
#include <unistd.h>
#include <sys/stat.h>
#include <sys/time.h>
#include "websocket.h"
/*
@@ -227,7 +228,17 @@ void proxy_handler(ws_ctx_t *ws_ctx) {
strcpy(addr.sun_path, ".KasmVNCSock");
addr.sun_path[0] = '\0';
struct timeval tv;
gettimeofday(&tv, NULL);
struct sockaddr_un myaddr;
myaddr.sun_family = AF_UNIX;
sprintf(myaddr.sun_path, ".%s@%s_%lu.%lu", ws_ctx->user, ws_ctx->ip,
tv.tv_sec, tv.tv_usec);
myaddr.sun_path[0] = '\0';
int tsock = socket(AF_UNIX, SOCK_STREAM, 0);
bind(tsock, (struct sockaddr *) &myaddr, sizeof(struct sockaddr_un));
handler_msg("connecting to VNC target\n");

View File

@@ -0,0 +1,69 @@
/* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved.
* Copyright 2020 Pierre Ossman for Cendio AB
*
* 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 <rdr/BufferedInStream.h>
#include <rdr/Exception.h>
using namespace rdr;
static const size_t DEFAULT_BUF_SIZE = 8192;
BufferedInStream::BufferedInStream()
: bufSize(DEFAULT_BUF_SIZE), offset(0)
{
ptr = end = start = new U8[bufSize];
}
BufferedInStream::~BufferedInStream()
{
delete [] start;
}
size_t BufferedInStream::pos()
{
return offset + ptr - start;
}
bool BufferedInStream::overrun(size_t needed, bool wait)
{
if (needed > bufSize)
throw Exception("BufferedInStream overrun: "
"requested size of %lu bytes exceeds maximum of %lu bytes",
(long unsigned)needed, (long unsigned)bufSize);
// Do we need to shuffle things around?
if ((bufSize - (ptr - start)) < needed) {
memmove(start, ptr, end - ptr);
offset += ptr - start;
end -= ptr - start;
ptr = start;
}
while (avail() < needed) {
if (!fillBuffer(start + bufSize - end, wait))
return false;
}
return true;
}

View File

@@ -0,0 +1,54 @@
/* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved.
* Copyright 2020 Pierre Ossman for Cendio AB
*
* 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.
*/
//
// Base class for input streams with a buffer
//
#ifndef __RDR_BUFFEREDINSTREAM_H__
#define __RDR_BUFFEREDINSTREAM_H__
#include <rdr/InStream.h>
namespace rdr {
class BufferedInStream : public InStream {
public:
virtual ~BufferedInStream();
virtual size_t pos();
private:
virtual bool fillBuffer(size_t maxSize, bool wait) = 0;
virtual bool overrun(size_t needed, bool wait);
private:
size_t bufSize;
size_t offset;
U8* start;
protected:
BufferedInStream();
};
} // end of namespace rdr
#endif

View File

@@ -0,0 +1,108 @@
/* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved.
* Copyright 2011-2020 Pierre Ossman for Cendio AB
* Copyright 2017 Peter Astrand <astrand@cendio.se> for Cendio AB
*
* 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 <rdr/BufferedOutStream.h>
#include <rdr/Exception.h>
using namespace rdr;
static const size_t DEFAULT_BUF_SIZE = 16384;
BufferedOutStream::BufferedOutStream()
: bufSize(DEFAULT_BUF_SIZE), offset(0)
{
ptr = start = sentUpTo = new U8[bufSize];
end = start + bufSize;
}
BufferedOutStream::~BufferedOutStream()
{
// FIXME: Complain about non-flushed buffer?
delete [] start;
}
size_t BufferedOutStream::length()
{
return offset + ptr - sentUpTo;
}
size_t BufferedOutStream::bufferUsage()
{
return ptr - sentUpTo;
}
void BufferedOutStream::flush()
{
while (sentUpTo < ptr) {
size_t len;
len = bufferUsage();
if (!flushBuffer(false))
break;
offset += len - bufferUsage();
}
// Managed to flush everything?
if (sentUpTo == ptr)
ptr = sentUpTo = start;
}
void BufferedOutStream::overrun(size_t needed)
{
if (needed > bufSize)
throw Exception("BufferedOutStream overrun: "
"requested size of %lu bytes exceeds maximum of %lu bytes",
(long unsigned)needed, (long unsigned)bufSize);
// First try to get rid of the data we have
flush();
// Still not enough space?
while (needed > avail()) {
// Can we shuffle things around?
// (don't do this if it gains us less than 25%)
if (((size_t)(sentUpTo - start) > bufSize / 4) &&
(needed < bufSize - (ptr - sentUpTo))) {
memmove(start, sentUpTo, ptr - sentUpTo);
ptr = start + (ptr - sentUpTo);
sentUpTo = start;
} else {
size_t len;
len = bufferUsage();
// Have to get rid of more data, so allow the flush to wait...
flushBuffer(true);
offset += len - bufferUsage();
// Managed to flush everything?
if (sentUpTo == ptr)
ptr = sentUpTo = start;
}
}
}

View File

@@ -0,0 +1,65 @@
/* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved.
* Copyright 2011-2020 Pierre Ossman for Cendio AB
*
* 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.
*/
//
// Base class for output streams with a buffer
//
#ifndef __RDR_BUFFEREDOUTSTREAM_H__
#define __RDR_BUFFEREDOUTSTREAM_H__
#include <rdr/OutStream.h>
namespace rdr {
class BufferedOutStream : public OutStream {
public:
virtual ~BufferedOutStream();
virtual size_t length();
virtual void flush();
size_t bufferUsage();
private:
// flushBuffer() requests that the stream be flushed. Returns true if it is
// able to progress the output (which might still not mean any bytes
// actually moved) and can be called again. If wait is true then it will
// block until all data has been written.
virtual bool flushBuffer(bool wait) = 0;
virtual void overrun(size_t needed);
private:
size_t bufSize;
size_t offset;
U8* start;
protected:
U8* sentUpTo;
protected:
BufferedOutStream();
};
}
#endif

View File

@@ -1,6 +1,8 @@
include_directories(${CMAKE_SOURCE_DIR}/common ${ZLIB_INCLUDE_DIRS})
add_library(rdr STATIC
BufferedInStream.cxx
BufferedOutStream.cxx
Exception.cxx
FdInStream.cxx
FdOutStream.cxx

View File

@@ -36,13 +36,6 @@
#include <unistd.h>
#endif
#ifndef vncmin
#define vncmin(a,b) (((a) < (b)) ? (a) : (b))
#endif
#ifndef vncmax
#define vncmax(a,b) (((a) > (b)) ? (a) : (b))
#endif
/* Old systems have select() in sys/time.h */
#ifdef HAVE_SYS_SELECT_H
#include <sys/select.h>
@@ -53,31 +46,22 @@
using namespace rdr;
enum { DEFAULT_BUF_SIZE = 8192,
MIN_BULK_SIZE = 1024 };
enum { DEFAULT_BUF_SIZE = 8192 };
FdInStream::FdInStream(int fd_, int timeoutms_, size_t bufSize_,
FdInStream::FdInStream(int fd_, int timeoutms_,
bool closeWhenDone_)
: fd(fd_), closeWhenDone(closeWhenDone_),
timeoutms(timeoutms_), blockCallback(0),
timing(false), timeWaitedIn100us(5), timedKbits(0),
bufSize(bufSize_ ? bufSize_ : DEFAULT_BUF_SIZE), offset(0)
timeoutms(timeoutms_), blockCallback(0)
{
ptr = end = start = new U8[bufSize];
}
FdInStream::FdInStream(int fd_, FdInStreamBlockCallback* blockCallback_,
size_t bufSize_)
: fd(fd_), timeoutms(0), blockCallback(blockCallback_),
timing(false), timeWaitedIn100us(5), timedKbits(0),
bufSize(bufSize_ ? bufSize_ : DEFAULT_BUF_SIZE), offset(0)
FdInStream::FdInStream(int fd_, FdInStreamBlockCallback* blockCallback_)
: fd(fd_), timeoutms(0), blockCallback(blockCallback_)
{
ptr = end = start = new U8[bufSize];
}
FdInStream::~FdInStream()
{
delete [] start;
if (closeWhenDone) close(fd);
}
@@ -92,72 +76,15 @@ void FdInStream::setBlockCallback(FdInStreamBlockCallback* blockCallback_)
timeoutms = 0;
}
size_t FdInStream::pos()
bool FdInStream::fillBuffer(size_t maxSize, bool wait)
{
return offset + ptr - start;
}
size_t n = readWithTimeoutOrCallback((U8*)end, maxSize, wait);
if (n == 0)
return false;
end += n;
void FdInStream::readBytes(void* data, size_t length)
{
if (length < MIN_BULK_SIZE) {
InStream::readBytes(data, length);
return;
}
U8* dataPtr = (U8*)data;
size_t n = end - ptr;
if (n > length) n = length;
memcpy(dataPtr, ptr, n);
dataPtr += n;
length -= n;
ptr += n;
while (length > 0) {
n = readWithTimeoutOrCallback(dataPtr, length);
dataPtr += n;
length -= n;
offset += n;
}
}
size_t FdInStream::overrun(size_t itemSize, size_t nItems, bool wait)
{
if (itemSize > bufSize)
throw Exception("FdInStream overrun: max itemSize exceeded");
if (end - ptr != 0)
memmove(start, ptr, end - ptr);
offset += ptr - start;
end -= ptr - start;
ptr = start;
size_t bytes_to_read;
while ((size_t)(end - start) < itemSize) {
bytes_to_read = start + bufSize - end;
if (!timing) {
// When not timing, we must be careful not to read too much
// extra data into the buffer. Otherwise, the line speed
// estimation might stay at zero for a long time: All reads
// during timing=1 can be satisfied without calling
// readWithTimeoutOrCallback. However, reading only 1 or 2 bytes
// bytes is ineffecient.
bytes_to_read = vncmin(bytes_to_read, vncmax(itemSize*nItems, 8));
}
size_t n = readWithTimeoutOrCallback((U8*)end, bytes_to_read, wait);
if (n == 0) return 0;
end += n;
}
size_t nAvail;
nAvail = (end - ptr) / itemSize;
if (nAvail < nItems)
return nAvail;
return nItems;
return true;
}
//
@@ -175,10 +102,6 @@ size_t FdInStream::overrun(size_t itemSize, size_t nItems, bool wait)
size_t FdInStream::readWithTimeoutOrCallback(void* buf, size_t len, bool wait)
{
struct timeval before, after;
if (timing)
gettimeofday(&before, 0);
int n;
while (true) {
do {
@@ -215,48 +138,5 @@ size_t FdInStream::readWithTimeoutOrCallback(void* buf, size_t len, bool wait)
if (n < 0) throw SystemException("read",errno);
if (n == 0) throw EndOfStream();
if (timing) {
gettimeofday(&after, 0);
int newTimeWaited = ((after.tv_sec - before.tv_sec) * 10000 +
(after.tv_usec - before.tv_usec) / 100);
int newKbits = n * 8 / 1000;
// limit rate to between 10kbit/s and 40Mbit/s
if (newTimeWaited > newKbits*1000) newTimeWaited = newKbits*1000;
if (newTimeWaited < newKbits/4) newTimeWaited = newKbits/4;
timeWaitedIn100us += newTimeWaited;
timedKbits += newKbits;
}
return n;
}
void FdInStream::startTiming()
{
timing = true;
// Carry over up to 1s worth of previous rate for smoothing.
if (timeWaitedIn100us > 10000) {
timedKbits = timedKbits * 10000 / timeWaitedIn100us;
timeWaitedIn100us = 10000;
}
}
void FdInStream::stopTiming()
{
timing = false;
if (timeWaitedIn100us < timedKbits/2)
timeWaitedIn100us = timedKbits/2; // upper limit 20Mbit/s
}
unsigned int FdInStream::kbitsPerSecond()
{
// The following calculation will overflow 32-bit arithmetic if we have
// received more than about 50Mbytes (400Mbits) since we started timing, so
// it should be OK for a single RFB update.
return timedKbits * 10000 / timeWaitedIn100us;
}

View File

@@ -23,7 +23,7 @@
#ifndef __RDR_FDINSTREAM_H__
#define __RDR_FDINSTREAM_H__
#include <rdr/InStream.h>
#include <rdr/BufferedInStream.h>
namespace rdr {
@@ -33,31 +33,21 @@ namespace rdr {
virtual ~FdInStreamBlockCallback() {}
};
class FdInStream : public InStream {
class FdInStream : public BufferedInStream {
public:
FdInStream(int fd, int timeoutms=-1, size_t bufSize=0,
bool closeWhenDone_=false);
FdInStream(int fd, FdInStreamBlockCallback* blockCallback,
size_t bufSize=0);
FdInStream(int fd, int timeoutms=-1, bool closeWhenDone_=false);
FdInStream(int fd, FdInStreamBlockCallback* blockCallback);
virtual ~FdInStream();
void setTimeout(int timeoutms);
void setBlockCallback(FdInStreamBlockCallback* blockCallback);
int getFd() { return fd; }
size_t pos();
void readBytes(void* data, size_t length);
void startTiming();
void stopTiming();
unsigned int kbitsPerSecond();
unsigned int timeWaited() { return timeWaitedIn100us; }
protected:
size_t overrun(size_t itemSize, size_t nItems, bool wait);
private:
virtual bool fillBuffer(size_t maxSize, bool wait);
size_t readWithTimeoutOrCallback(void* buf, size_t len, bool wait=true);
int fd;
@@ -65,11 +55,6 @@ namespace rdr {
int timeoutms;
FdInStreamBlockCallback* blockCallback;
bool timing;
unsigned int timeWaitedIn100us;
unsigned int timedKbits;
size_t bufSize;
size_t offset;
U8* start;
};

View File

@@ -35,6 +35,8 @@
#include <unistd.h>
#include <sys/time.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#endif
/* Old systems have select() in sys/time.h */
@@ -49,26 +51,19 @@
using namespace rdr;
enum { DEFAULT_BUF_SIZE = 16384 };
FdOutStream::FdOutStream(int fd_, bool blocking_, int timeoutms_, size_t bufSize_)
: fd(fd_), blocking(blocking_), timeoutms(timeoutms_),
bufSize(bufSize_ ? bufSize_ : DEFAULT_BUF_SIZE), offset(0)
FdOutStream::FdOutStream(int fd_, bool blocking_, int timeoutms_)
: fd(fd_), blocking(blocking_), timeoutms(timeoutms_)
{
ptr = start = sentUpTo = new U8[bufSize];
end = start + bufSize;
gettimeofday(&lastWrite, NULL);
}
FdOutStream::~FdOutStream()
{
try {
blocking = true;
flush();
while (sentUpTo != ptr)
flushBuffer(true);
} catch (Exception&) {
}
delete [] start;
}
void FdOutStream::setTimeout(int timeoutms_) {
@@ -79,82 +74,29 @@ void FdOutStream::setBlocking(bool blocking_) {
blocking = blocking_;
}
size_t FdOutStream::length()
{
return offset + ptr - sentUpTo;
}
int FdOutStream::bufferUsage()
{
return ptr - sentUpTo;
}
unsigned FdOutStream::getIdleTime()
{
return rfb::msSince(&lastWrite);
}
void FdOutStream::flush()
bool FdOutStream::flushBuffer(bool wait)
{
while (sentUpTo < ptr) {
size_t n = writeWithTimeout((const void*) sentUpTo,
ptr - sentUpTo,
blocking? timeoutms : 0);
size_t n = writeWithTimeout((const void*) sentUpTo,
ptr - sentUpTo,
(blocking || wait)? timeoutms : 0);
// Timeout?
if (n == 0) {
// If non-blocking then we're done here
if (!blocking)
break;
// Timeout?
if (n == 0) {
// If non-blocking then we're done here
if (!blocking && !wait)
return false;
throw TimedOut();
}
sentUpTo += n;
offset += n;
throw TimedOut();
}
// Managed to flush everything?
if (sentUpTo == ptr)
ptr = sentUpTo = start;
}
sentUpTo += n;
size_t FdOutStream::overrun(size_t itemSize, size_t nItems)
{
if (itemSize > bufSize)
throw Exception("FdOutStream overrun: max itemSize exceeded");
// First try to get rid of the data we have
flush();
// Still not enough space?
if (itemSize > (size_t)(end - ptr)) {
// Can we shuffle things around?
// (don't do this if it gains us less than 25%)
if (((size_t)(sentUpTo - start) > bufSize / 4) &&
(itemSize < bufSize - (ptr - sentUpTo))) {
memmove(start, sentUpTo, ptr - sentUpTo);
ptr = start + (ptr - sentUpTo);
sentUpTo = start;
} else {
// Have to get rid of more data, so turn off non-blocking
// for a bit...
bool realBlocking;
realBlocking = blocking;
blocking = true;
flush();
blocking = realBlocking;
}
}
size_t nAvail;
nAvail = (end - ptr) / itemSize;
if (nAvail < nItems)
return nAvail;
return nItems;
return true;
}
//

View File

@@ -26,38 +26,29 @@
#include <sys/time.h>
#include <rdr/OutStream.h>
#include <rdr/BufferedOutStream.h>
namespace rdr {
class FdOutStream : public OutStream {
class FdOutStream : public BufferedOutStream {
public:
FdOutStream(int fd, bool blocking=true, int timeoutms=-1, size_t bufSize=0);
FdOutStream(int fd, bool blocking=true, int timeoutms=-1);
virtual ~FdOutStream();
void setTimeout(int timeoutms);
void setBlocking(bool blocking);
int getFd() { return fd; }
void flush();
size_t length();
int bufferUsage();
unsigned getIdleTime();
private:
size_t overrun(size_t itemSize, size_t nItems);
virtual bool flushBuffer(bool wait);
size_t writeWithTimeout(const void* data, size_t length, int timeoutms);
int fd;
bool blocking;
int timeoutms;
size_t bufSize;
size_t offset;
U8* start;
U8* sentUpTo;
struct timeval lastWrite;
};

View File

@@ -30,7 +30,6 @@ FileInStream::FileInStream(const char *fileName)
file = fopen(fileName, "rb");
if (!file)
throw SystemException("fopen", errno);
ptr = end = b;
}
FileInStream::~FileInStream(void) {
@@ -40,50 +39,17 @@ FileInStream::~FileInStream(void) {
}
}
void FileInStream::reset(void) {
if (!file)
throw Exception("File is not open");
if (fseek(file, 0, SEEK_SET) != 0)
throw SystemException("fseek", errno);
ptr = end = b;
}
size_t FileInStream::pos()
bool FileInStream::fillBuffer(size_t maxSize, bool wait)
{
if (!file)
throw Exception("File is not open");
return ftell(file) + ptr - b;
}
size_t FileInStream::overrun(size_t itemSize, size_t nItems, bool wait)
{
if (itemSize > sizeof(b))
throw Exception("FileInStream overrun: max itemSize exceeded");
if (end - ptr != 0)
memmove(b, ptr, end - ptr);
end -= ptr - b;
ptr = b;
while ((size_t)(end - b) < itemSize) {
size_t n = fread((U8 *)end, b + sizeof(b) - end, 1, file);
if (n == 0) {
if (ferror(file))
throw SystemException("fread", errno);
if (feof(file))
throw EndOfStream();
return 0;
}
end += b + sizeof(b) - end;
size_t n = fread((U8 *)end, 1, maxSize, file);
if (n == 0) {
if (ferror(file))
throw SystemException("fread", errno);
if (feof(file))
throw EndOfStream();
return false;
}
end += n;
size_t nAvail;
nAvail = (end - ptr) / itemSize;
if (nAvail < nItems)
return nAvail;
return nItems;
return true;
}

View File

@@ -22,26 +22,21 @@
#include <stdio.h>
#include <rdr/InStream.h>
#include <rdr/BufferedInStream.h>
namespace rdr {
class FileInStream : public InStream {
class FileInStream : public BufferedInStream {
public:
FileInStream(const char *fileName);
~FileInStream(void);
void reset(void);
size_t pos();
protected:
size_t overrun(size_t itemSize, size_t nItems, bool wait = true);
private:
virtual bool fillBuffer(size_t maxSize, bool wait);
private:
U8 b[131072];
FILE *file;
};

View File

@@ -24,18 +24,14 @@
using namespace rdr;
const int DEFAULT_BUF_LEN = 16384;
static inline int min(int a, int b) {return a<b ? a : b;}
HexInStream::HexInStream(InStream& is, size_t bufSize_)
: bufSize(bufSize_ ? bufSize_ : DEFAULT_BUF_LEN), offset(0), in_stream(is)
HexInStream::HexInStream(InStream& is)
: in_stream(is)
{
ptr = end = start = new U8[bufSize];
}
HexInStream::~HexInStream() {
delete [] start;
}
@@ -76,44 +72,24 @@ decodeError:
}
size_t HexInStream::pos() {
return offset + ptr - start;
}
bool HexInStream::fillBuffer(size_t maxSize, bool wait) {
if (!in_stream.check(2, wait))
return false;
size_t HexInStream::overrun(size_t itemSize, size_t nItems, bool wait) {
if (itemSize > bufSize)
throw Exception("HexInStream overrun: max itemSize exceeded");
const U8* iptr = in_stream.getptr();
const U8* eptr = in_stream.getend();
size_t length = min((eptr - iptr)/2, maxSize);
if (end - ptr != 0)
memmove(start, ptr, end - ptr);
end -= ptr - start;
offset += ptr - start;
ptr = start;
while ((size_t)(end - ptr) < itemSize) {
size_t n = in_stream.check(2, 1, wait);
if (n == 0) return 0;
const U8* iptr = in_stream.getptr();
const U8* eptr = in_stream.getend();
size_t length = min((eptr - iptr)/2, start + bufSize - end);
U8* optr = (U8*) end;
for (size_t i=0; i<length; i++) {
int v = 0;
readHexAndShift(iptr[i*2], &v);
readHexAndShift(iptr[i*2+1], &v);
optr[i] = v;
}
in_stream.setptr(iptr + length*2);
end += length;
U8* optr = (U8*) end;
for (size_t i=0; i<length; i++) {
int v = 0;
readHexAndShift(iptr[i*2], &v);
readHexAndShift(iptr[i*2+1], &v);
optr[i] = v;
}
size_t nAvail;
nAvail = (end - ptr) / itemSize;
if (nAvail < nItems)
return nAvail;
in_stream.setptr(iptr + length*2);
end += length;
return nItems;
return true;
}

View File

@@ -19,29 +19,23 @@
#ifndef __RDR_HEX_INSTREAM_H__
#define __RDR_HEX_INSTREAM_H__
#include <rdr/InStream.h>
#include <rdr/BufferedInStream.h>
namespace rdr {
class HexInStream : public InStream {
class HexInStream : public BufferedInStream {
public:
HexInStream(InStream& is, size_t bufSize=0);
HexInStream(InStream& is);
virtual ~HexInStream();
size_t pos();
static bool readHexAndShift(char c, int* v);
static bool hexStrToBin(const char* s, char** data, size_t* length);
protected:
size_t overrun(size_t itemSize, size_t nItems, bool wait);
private:
virtual bool fillBuffer(size_t maxSize, bool wait);
private:
size_t bufSize;
U8* start;
size_t offset;
InStream& in_stream;
};

View File

@@ -25,8 +25,8 @@ const int DEFAULT_BUF_LEN = 16384;
static inline size_t min(size_t a, size_t b) {return a<b ? a : b;}
HexOutStream::HexOutStream(OutStream& os, size_t buflen)
: out_stream(os), offset(0), bufSize(buflen ? buflen : DEFAULT_BUF_LEN)
HexOutStream::HexOutStream(OutStream& os)
: out_stream(os), offset(0), bufSize(DEFAULT_BUF_LEN)
{
if (bufSize % 2)
bufSize--;
@@ -95,18 +95,10 @@ HexOutStream::flush() {
out_stream.flush();
}
size_t
HexOutStream::overrun(size_t itemSize, size_t nItems) {
if (itemSize > bufSize)
throw Exception("HexOutStream overrun: max itemSize exceeded");
void HexOutStream::overrun(size_t needed) {
if (needed > bufSize)
throw Exception("HexOutStream overrun: buffer size exceeded");
writeBuffer();
size_t nAvail;
nAvail = (end - ptr) / itemSize;
if (nAvail < nItems)
return nAvail;
return nItems;
}

View File

@@ -26,7 +26,7 @@ namespace rdr {
class HexOutStream : public OutStream {
public:
HexOutStream(OutStream& os, size_t buflen=0);
HexOutStream(OutStream& os);
virtual ~HexOutStream();
void flush();
@@ -37,7 +37,7 @@ namespace rdr {
private:
void writeBuffer();
size_t overrun(size_t itemSize, size_t nItems);
virtual void overrun(size_t needed);
OutStream& out_stream;

View File

@@ -35,28 +35,25 @@ namespace rdr {
virtual ~InStream() {}
// check() ensures there is buffer data for at least one item of size
// itemSize bytes. Returns the number of items in the buffer (up to a
// maximum of nItems). If wait is false, then instead of blocking to wait
// for the bytes, zero is returned if the bytes are not immediately
// available. If itemSize or nItems is zero, check() will return zero.
// avail() returns the number of bytes that are currenctly directly
// available from the stream.
inline size_t check(size_t itemSize, size_t nItems=1, bool wait=true)
inline size_t avail()
{
size_t nAvail;
return end - ptr;
}
if (itemSize == 0 || nItems == 0)
return 0;
// check() ensures there is buffer data for at least needed bytes. Returns
// true once the data is available. If wait is false, then instead of
// blocking to wait for the bytes, false is returned if the bytes are not
// immediately available.
if (itemSize > (size_t)(end - ptr))
return overrun(itemSize, nItems, wait);
inline size_t check(size_t needed, bool wait=true)
{
if (needed > avail())
return overrun(needed, wait);
// itemSize cannot be zero at this point
nAvail = (end - ptr) / itemSize;
if (nAvail < nItems)
return nAvail;
return nItems;
return true;
}
// checkNoWait() tries to make sure that the given number of bytes can
@@ -64,10 +61,7 @@ namespace rdr {
// otherwise. The length must be "small" (less than the buffer size).
// If length is zero, checkNoWait() will return true.
inline bool checkNoWait(size_t length)
{
return length == 0 || check(length, 1, false) > 0;
}
inline bool checkNoWait(size_t length) { return check(length, false); }
// readU/SN() methods read unsigned and signed N-bit integers.
@@ -138,13 +132,12 @@ namespace rdr {
private:
// overrun() is implemented by a derived class to cope with buffer overrun.
// It ensures there are at least itemSize bytes of buffer data. Returns
// the number of items in the buffer (up to a maximum of nItems). itemSize
// is supposed to be "small" (a few bytes). If wait is false, then
// instead of blocking to wait for the bytes, zero is returned if the bytes
// are not immediately available.
// It ensures there are at least needed bytes of buffer data. Returns true
// once the data is available. If wait is false, then instead of blocking
// to wait for the bytes, false is returned if the bytes are not
// immediately available.
virtual size_t overrun(size_t itemSize, size_t nItems, bool wait=true) = 0;
virtual bool overrun(size_t needed, bool wait=true) = 0;
protected:

View File

@@ -53,7 +53,7 @@ namespace rdr {
private:
size_t overrun(size_t itemSize, size_t nItems, bool wait) { throw EndOfStream(); }
bool overrun(size_t needed, bool wait) { throw EndOfStream(); }
const U8* start;
bool deleteWhenDone;
};

View File

@@ -41,12 +41,6 @@ namespace rdr {
delete [] start;
}
void writeBytes(const void* data, size_t length) {
check(length);
memcpy(ptr, data, length);
ptr += length;
}
size_t length() { return ptr - start; }
void clear() { ptr = start; };
void clearAndZero() { memset(start, 0, ptr-start); clear(); }
@@ -58,11 +52,11 @@ namespace rdr {
protected:
// overrun() either doubles the buffer or adds enough space for nItems of
// size itemSize bytes.
// overrun() either doubles the buffer or adds enough space for
// needed bytes.
size_t overrun(size_t itemSize, size_t nItems) {
size_t len = ptr - start + itemSize * nItems;
virtual void overrun(size_t needed) {
size_t len = ptr - start + needed;
if (len < (size_t)(end - start) * 2)
len = (end - start) * 2;
@@ -75,8 +69,6 @@ namespace rdr {
delete [] start;
start = newStart;
end = newStart + len;
return nItems;
}
U8* start;

View File

@@ -40,22 +40,20 @@ namespace rdr {
virtual ~OutStream() {}
// check() ensures there is buffer space for at least one item of size
// itemSize bytes. Returns the number of items which fit (up to a maximum
// of nItems).
// avail() returns the number of bytes that currently be written to the
// stream without any risk of blocking.
inline size_t check(size_t itemSize, size_t nItems=1)
inline size_t avail()
{
size_t nAvail;
return end - ptr;
}
if (itemSize > (size_t)(end - ptr))
return overrun(itemSize, nItems);
// check() ensures there is buffer space for at least needed bytes.
nAvail = (end - ptr) / itemSize;
if (nAvail < nItems)
return nAvail;
return nItems;
inline void check(size_t needed)
{
if (needed > avail())
overrun(needed);
}
// writeU/SN() methods write unsigned and signed N-bit integers.
@@ -83,19 +81,14 @@ namespace rdr {
while (bytes-- > 0) writeU8(0);
}
inline void skip(size_t bytes) {
while (bytes > 0) {
size_t n = check(1, bytes);
ptr += n;
bytes -= n;
}
}
// writeBytes() writes an exact number of bytes.
void writeBytes(const void* data, size_t length) {
while (length > 0) {
size_t n = check(1, length);
check(1);
size_t n = length;
if (length > avail())
n = avail();
memcpy(ptr, data, n);
ptr += n;
data = (U8*)data + n;
@@ -107,7 +100,10 @@ namespace rdr {
void copyBytes(InStream* is, size_t length) {
while (length > 0) {
size_t n = check(1, length);
check(1);
size_t n = length;
if (length > avail())
n = avail();
is->readBytes(ptr, n);
ptr += n;
length -= n;
@@ -143,11 +139,9 @@ namespace rdr {
private:
// overrun() is implemented by a derived class to cope with buffer overrun.
// It ensures there are at least itemSize bytes of buffer space. Returns
// the number of items which fit (up to a maximum of nItems). itemSize is
// supposed to be "small" (a few bytes).
// It ensures there are at least needed bytes of buffer space.
virtual size_t overrun(size_t itemSize, size_t nItems) = 0;
virtual void overrun(size_t needed) = 0;
protected:

View File

@@ -32,15 +32,10 @@
using namespace rdr;
const size_t DEFAULT_BUF_LEN = 256;
unsigned int RandomStream::seed;
RandomStream::RandomStream()
: offset(0)
{
ptr = end = start = new U8[DEFAULT_BUF_LEN];
#ifdef RFB_HAVE_WINCRYPT
provider = 0;
if (!CryptAcquireContext(&provider, 0, 0, PROV_RSA_FULL, 0)) {
@@ -72,8 +67,6 @@ RandomStream::RandomStream()
}
RandomStream::~RandomStream() {
delete [] start;
#ifdef RFB_HAVE_WINCRYPT
if (provider)
CryptReleaseContext(provider, 0);
@@ -83,50 +76,29 @@ RandomStream::~RandomStream() {
#endif
}
size_t RandomStream::pos() {
return offset + ptr - start;
}
size_t RandomStream::overrun(size_t itemSize, size_t nItems, bool wait) {
if (itemSize > DEFAULT_BUF_LEN)
throw Exception("RandomStream overrun: max itemSize exceeded");
if (end - ptr != 0)
memmove(start, ptr, end - ptr);
end -= ptr - start;
offset += ptr - start;
ptr = start;
size_t length = start + DEFAULT_BUF_LEN - end;
bool RandomStream::fillBuffer(size_t maxSize, bool wait) {
#ifdef RFB_HAVE_WINCRYPT
if (provider) {
if (!CryptGenRandom(provider, length, (U8*)end))
if (!CryptGenRandom(provider, maxSize, (U8*)end))
throw rdr::SystemException("unable to CryptGenRandom", GetLastError());
end += length;
end += maxSize;
} else {
#else
#ifndef WIN32
if (fp) {
size_t n = fread((U8*)end, length, 1, fp);
if (n != 1)
size_t n = fread((U8*)end, 1, maxSize, fp);
if (n <= 0)
throw rdr::SystemException("reading /dev/urandom or /dev/random failed",
errno);
end += length;
end += n;
} else {
#else
{
#endif
#endif
for (size_t i=0; i<length; i++)
for (size_t i=0; i<maxSize; i++)
*(U8*)end++ = (int) (256.0*rand()/(RAND_MAX+1.0));
}
size_t nAvail;
nAvail = (end - ptr) / itemSize;
if (nAvail < nItems)
return nAvail;
return nItems;
return true;
}

View File

@@ -20,7 +20,7 @@
#define __RDR_RANDOMSTREAM_H__
#include <stdio.h>
#include <rdr/InStream.h>
#include <rdr/BufferedInStream.h>
#ifdef WIN32
#include <windows.h>
@@ -32,22 +32,17 @@
namespace rdr {
class RandomStream : public InStream {
class RandomStream : public BufferedInStream {
public:
RandomStream();
virtual ~RandomStream();
size_t pos();
protected:
size_t overrun(size_t itemSize, size_t nItems, bool wait);
private:
virtual bool fillBuffer(size_t maxSize, bool wait);
private:
U8* start;
size_t offset;
static unsigned int seed;
#ifdef RFB_HAVE_WINCRYPT
HCRYPTPROV provider;

View File

@@ -30,21 +30,19 @@
#ifdef HAVE_GNUTLS
using namespace rdr;
enum { DEFAULT_BUF_SIZE = 16384 };
ssize_t TLSInStream::pull(gnutls_transport_ptr_t str, void* data, size_t size)
{
TLSInStream* self= (TLSInStream*) str;
InStream *in = self->in;
try {
if (!in->check(1, 1, false)) {
if (!in->check(1, false)) {
gnutls_transport_set_errno(self->session, EAGAIN);
return -1;
}
if ((size_t)(in->getend() - in->getptr()) < size)
size = in->getend() - in->getptr();
if (in->avail() < size)
size = in->avail();
in->readBytes(data, size);
@@ -57,12 +55,10 @@ ssize_t TLSInStream::pull(gnutls_transport_ptr_t str, void* data, size_t size)
}
TLSInStream::TLSInStream(InStream* _in, gnutls_session_t _session)
: session(_session), in(_in), bufSize(DEFAULT_BUF_SIZE), offset(0)
: session(_session), in(_in)
{
gnutls_transport_ptr_t recv, send;
ptr = end = start = new U8[bufSize];
gnutls_transport_set_pull_function(session, pull);
gnutls_transport_get_ptr2(session, &recv, &send);
gnutls_transport_set_ptr2(session, this, send);
@@ -71,40 +67,16 @@ TLSInStream::TLSInStream(InStream* _in, gnutls_session_t _session)
TLSInStream::~TLSInStream()
{
gnutls_transport_set_pull_function(session, NULL);
delete[] start;
}
size_t TLSInStream::pos()
bool TLSInStream::fillBuffer(size_t maxSize, bool wait)
{
return offset + ptr - start;
}
size_t n = readTLS((U8*) end, maxSize, wait);
if (!wait && n == 0)
return false;
end += n;
size_t TLSInStream::overrun(size_t itemSize, size_t nItems, bool wait)
{
if (itemSize > bufSize)
throw Exception("TLSInStream overrun: max itemSize exceeded");
if (end - ptr != 0)
memmove(start, ptr, end - ptr);
offset += ptr - start;
end -= ptr - start;
ptr = start;
while ((size_t)(end - start) < itemSize) {
size_t n = readTLS((U8*) end, start + bufSize - end, wait);
if (!wait && n == 0)
return 0;
end += n;
}
size_t nAvail;
nAvail = (end - ptr) / itemSize;
if (nAvail < nItems)
return nAvail;
return nItems;
return true;
}
size_t TLSInStream::readTLS(U8* buf, size_t len, bool wait)
@@ -112,7 +84,7 @@ size_t TLSInStream::readTLS(U8* buf, size_t len, bool wait)
int n;
if (gnutls_record_check_pending(session) == 0) {
n = in->check(1, 1, wait);
n = in->check(1, wait);
if (n == 0)
return 0;
}

View File

@@ -27,27 +27,22 @@
#ifdef HAVE_GNUTLS
#include <gnutls/gnutls.h>
#include <rdr/InStream.h>
#include <rdr/BufferedInStream.h>
namespace rdr {
class TLSInStream : public InStream {
class TLSInStream : public BufferedInStream {
public:
TLSInStream(InStream* in, gnutls_session_t session);
virtual ~TLSInStream();
size_t pos();
private:
size_t overrun(size_t itemSize, size_t nItems, bool wait);
virtual bool fillBuffer(size_t maxSize, bool wait);
size_t readTLS(U8* buf, size_t len, bool wait);
static ssize_t pull(gnutls_transport_ptr_t str, void* data, size_t size);
gnutls_session_t session;
InStream* in;
size_t bufSize;
size_t offset;
U8* start;
};
};

View File

@@ -93,19 +93,12 @@ void TLSOutStream::flush()
out->flush();
}
size_t TLSOutStream::overrun(size_t itemSize, size_t nItems)
void TLSOutStream::overrun(size_t needed)
{
if (itemSize > bufSize)
throw Exception("TLSOutStream overrun: max itemSize exceeded");
if (needed > bufSize)
throw Exception("TLSOutStream overrun: buffer size exceeded");
flush();
size_t nAvail;
nAvail = (end - ptr) / itemSize;
if (nAvail < nItems)
return nAvail;
return nItems;
}
size_t TLSOutStream::writeTLS(const U8* data, size_t length)

View File

@@ -39,7 +39,7 @@ namespace rdr {
size_t length();
protected:
size_t overrun(size_t itemSize, size_t nItems);
virtual void overrun(size_t needed);
private:
size_t writeTLS(const U8* data, size_t length);

View File

@@ -24,41 +24,30 @@
using namespace rdr;
enum { DEFAULT_BUF_SIZE = 16384 };
ZlibInStream::ZlibInStream(size_t bufSize_)
: underlying(0), bufSize(bufSize_ ? bufSize_ : DEFAULT_BUF_SIZE), offset(0),
zs(NULL), bytesIn(0)
ZlibInStream::ZlibInStream()
: underlying(0), zs(NULL), bytesIn(0)
{
ptr = end = start = new U8[bufSize];
init();
}
ZlibInStream::~ZlibInStream()
{
deinit();
delete [] start;
}
void ZlibInStream::setUnderlying(InStream* is, size_t bytesIn_)
{
underlying = is;
bytesIn = bytesIn_;
ptr = end = start;
}
size_t ZlibInStream::pos()
{
return offset + ptr - start;
skip(avail());
}
void ZlibInStream::flushUnderlying()
{
ptr = end = start;
while (bytesIn > 0) {
decompress(true);
end = start; // throw away any data
if (!check(1))
throw Exception("ZlibInStream: failed to flush remaining stream data");
skip(avail());
}
setUnderlying(NULL, 0);
@@ -96,47 +85,18 @@ void ZlibInStream::deinit()
zs = NULL;
}
size_t ZlibInStream::overrun(size_t itemSize, size_t nItems, bool wait)
{
if (itemSize > bufSize)
throw Exception("ZlibInStream overrun: max itemSize exceeded");
if (end - ptr != 0)
memmove(start, ptr, end - ptr);
offset += ptr - start;
end -= ptr - start;
ptr = start;
while ((size_t)(end - ptr) < itemSize) {
if (!decompress(wait))
return 0;
}
size_t nAvail;
nAvail = (end - ptr) / itemSize;
if (nAvail < nItems)
return nAvail;
return nItems;
}
// decompress() calls the decompressor once. Note that this won't necessarily
// generate any output data - it may just consume some input data. Returns
// false if wait is false and we would block on the underlying stream.
bool ZlibInStream::decompress(bool wait)
bool ZlibInStream::fillBuffer(size_t maxSize, bool wait)
{
if (!underlying)
throw Exception("ZlibInStream overrun: no underlying stream");
zs->next_out = (U8*)end;
zs->avail_out = start + bufSize - end;
zs->avail_out = maxSize;
size_t n = underlying->check(1, 1, wait);
size_t n = underlying->check(1, wait);
if (n == 0) return false;
zs->next_in = (U8*)underlying->getptr();
zs->avail_in = underlying->getend() - underlying->getptr();
zs->avail_in = underlying->avail();
if (zs->avail_in > bytesIn)
zs->avail_in = bytesIn;

Some files were not shown because too many files have changed in this diff Show More