Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 56297a8

Browse files
Add MacOS support
This is based on macVNC as the VNC server (no root required!) and TigerVNC as the VNC client/viewer.
1 parent d44dac5 commit 56297a8

File tree

6 files changed

+125
-16
lines changed

6 files changed

+125
-16
lines changed

‎.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ dist/
9898
# external resources
9999
vnc-software/tigervnc-linux-x86_64
100100
vnc-software/uvnc-windows
101+
vnc-software/macVNC.app/
102+
vnc-software/tigervnc-macos-x86_64/
101103

102104
# trashcan
103105
trash/

‎build_release_macos.sh

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
#!/bin/sh
2+
3+
echo "0) make sure all changes are committed"
4+
diff=$(git diff | wc -l)
5+
if [ $diff -gt 0 ]; then
6+
echo "You have diff"
7+
#exit 1
8+
fi
9+
10+
echo "1) make sure devtools are set to false in src/main.js"
11+
if grep "devTools: true" src/main.js; then
12+
echo "devTools: true found in src/main.js"
13+
exit 2
14+
fi
15+
16+
echo "2) make sure you've incremented the version number in package.json AND package-lock.json"
17+
read yes
18+
19+
echo "3) Cleaning up old build..."
20+
rm -rf .webpack
21+
rm -rf dist
22+
rm -rf out
23+
# Don't include Windows and Linux binaries on MacOS
24+
rm -rf vnc-software/uvnc-windows
25+
rm -rf vnc-software/tigervnc-linux-x86_64
26+
if [ ! -d "vnc-software/tigervnc-macos-x86_64" ]; then
27+
echo "vnc-software/tigervnc-macos-x86_64 not found, running vnc-software/download_generic.sh"
28+
./vnc-software/download_generic.sh "tigervnc-latest-stable.dmg" "tigervnc-macos-x86_64" "https://altushost-swe.dl.sourceforge.net/project/tigervnc/stable/1.13.1/TigerVNC-1.13.1.dmg" "d823197320e6903458f9039cb9d4dbf5d739ef7f9c18ccabfb68bc3fffe57b9d" "tigervnc.conf" "tigervnc-macos-x86_64/Contents/MacOS/plain.bin"
29+
downloadresult=$?
30+
if [ $downloadresult -ne 0 ]; then
31+
echo "Download of VNC client returned error: $downloadresult"
32+
exit 1
33+
fi
34+
fi
35+
36+
if [ ! -d "macVNC.app" ]; then
37+
echo "macVNC.app not found, downloading it from https://github.com/LibVNC/macVNC and building it..."
38+
brew install libvncserver cmake
39+
brewresult=$?
40+
if [ $? -ne 0 ]; then
41+
echo "brew install libvncserver cmake failed with error: $brewresult"
42+
echo "Make sure you have homebrew installed, see brew.sh"
43+
exit 3
44+
fi
45+
cd vnc-software/
46+
rm -rf build_macVNC
47+
mkdir build_macVNC/
48+
cd build_macVNC/
49+
curl -L "https://github.com/LibVNC/macVNC/archive/59c58931ed5853f344a500b1674405e85d1e70ea.zip" > macVNC.zip
50+
unzip macVNC.zip
51+
cd macVNC-*
52+
mkdir build
53+
cd build
54+
cmake ..
55+
cmake --build .
56+
if [ ! -d "macVNC.app" ]; then
57+
echo "ERROR: building macVNC did not result in macVNC.app - something went wrong..."
58+
exit 4
59+
fi
60+
mv macVNC.app ../../..
61+
cd ../../..
62+
rm -rf build_macVNC
63+
cd ..
64+
fi
65+
66+
67+
# If you run it in dev mode first with:
68+
# npm run start
69+
# Then the app tries to connect to localhost:3000 instead of packaging the actual files when building with:
70+
#./node_modules/.bin/electron-builder
71+
72+
# Therefore, first make sure the correct files are packaged with electron-forge:
73+
echo "4) Packaging with: electron-forge package -p macos -a x64"
74+
./node_modules/.bin/electron-forge package -p darwin
75+
76+
# NOTE: Don't use prepackage because the electron-builder will not add the tigervnc/ folder:
77+
#./node_modules/.bin/electron-builder --prepackaged out/peerviewer-linux-x64/ -l appimage
78+
echo "5) Building release binaries with: electron-builder --linux appimage deb snap rpm tar.gz"
79+
export DEBUG=electron-builder
80+
./node_modules/.bin/electron-builder --macos dmg
81+

‎package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "PeerViewer",
33
"productName": "PeerViewer",
4-
"version": "1.4.0",
4+
"version": "1.5.0",
55
"description": "Peer-to-peer open source remote desktop and support solution, completely free for unlimited personal and commercial use.",
66
"homepage": "https://peerviewer.github.io/",
77
"main": ".webpack/main",

‎src/main.js

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,8 @@ function findResourceFile(filename) {
128128

129129
ipcMain.on('run-server', (event) => {
130130
// Make sure this OS is supported
131-
if (process.platform !== 'linux' && process.platform !== 'win32') {
132-
let error = 'Unsupported platform ' + process.platform + '. Only linux and win32 are supported, darwin (MacOS) not yet. Please reach out!';
131+
if (process.platform !== 'linux' && process.platform !== 'win32'&&process.platform!='darwin') {
132+
let error = 'Unsupported platform ' + process.platform + '. Only Linux, Windows and MacOS are supported, yours not yet. Please reach out!';
133133
console.log(error);
134134
event.reply(error);
135135
return -1;
@@ -153,6 +153,8 @@ ipcMain.on('run-server', (event) => {
153153
serverChild = runProcess(foundBinary, ['SecurityTypes=VncAuth','localhost=1','interface=127.0.0.1','rfbport=55900','PasswordFile='+dirname+nodePath.sep+'plain.bin']);
154154
} else if (process.platform === 'win32') {
155155
serverChild = findAndRunProcess('uvnc-windows\\x64\\winvnc.exe'); // uses the config file next to the binary
156+
} else if (process.platform === 'darwin') {
157+
serverChild = findAndRunProcess('macVNC.app/Contents/MacOS/macVNC', ['-rfbport','55900','-passwd','nopassword']);
156158
}
157159
if (!serverChild) {
158160
event.reply('run-server-log', "ERROR: Listening for connections using VNC server failed.");
@@ -165,8 +167,8 @@ ipcMain.on('run-server', (event) => {
165167

166168
ipcMain.on('run-client', (event, data) => {
167169
// Make sure this OS is supported
168-
if (process.platform !== 'linux' && process.platform !== 'win32') {
169-
let error = 'Unsupported platform ' + process.platform + '. Only linux and win32 are supported, darwin (MacOS) not yet. Please reach out!';
170+
if (process.platform !== 'linux' && process.platform !== 'win32'&&process.platform!='darwin') {
171+
let error = 'Unsupported platform ' + process.platform + '. Only Linux, Windows and MacOS are supported, yours not yet. Please reach out!';
170172
console.log(error);
171173
event.reply(error);
172174
return -1;
@@ -182,12 +184,23 @@ ipcMain.on('run-client', (event, data) => {
182184
event.reply('run-client-log', "Network layer initialized.");
183185

184186
event.reply('run-client-log', "Establishing outgoing connection...");
185-
if (process.platform === 'linux') {
187+
if (process.platform === 'linux'||process.platform==='darwin') {
186188
let binaryName = 'tigervnc-linux-x86_64/usr/bin/vncviewer';
187-
let foundBinary = findResourceFile(binaryName);
188-
if (!foundBinary) {
189-
console.log("Binary " + binaryName + " not found.");
190-
return -2;
189+
let foundBinary = '';
190+
if (process.platform === 'linux') {
191+
let binaryName = 'tigervnc-linux-x86_64/usr/bin/vncviewer';
192+
foundBinary = findResourceFile(binaryName);
193+
if (!foundBinary) {
194+
console.log("Binary " + binaryName + " not found.");
195+
return -2;
196+
}
197+
} else if (process.platform === 'darwin') {
198+
let binaryName = 'tigervnc-macos-x86_64/Contents/MacOS/TigerVNC\ Viewer';
199+
foundBinary = findResourceFile(binaryName);
200+
if (!foundBinary) {
201+
console.log("Binary " + binaryName + " not found.");
202+
return -2;
203+
}
191204
}
192205
// PasswordFile of TigerVNC viewer cannot be passed on commandline, so use the file next to the binary.
193206
let dirname = nodePath.dirname(foundBinary);

‎vnc-software/download_generic.sh

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
#!/bin/sh -x
2-
# This script needs: readlink, dirname, curl, sha256sum, unzip, tar
2+
# This script needs: readlink, dirname, curl, shasum, unzip, tar
3+
# On windows: unzip
4+
# On linux: tar
5+
# On macos: hdiutil
36

47
outfile="1ドル"
58
outdir="2ドル"
@@ -19,15 +22,15 @@ mydir=$(dirname "$mydir")
1922
cd "$mydir"
2023

2124

22-
curl "$downloadlink" > "$outfile"
25+
curl -L "$downloadlink" > "$outfile"
2326
result=$?
2427

2528
if [ $result -eq 0 ]; then
2629
echo "Download successful, checking checksum and extracting..."
2730
# make sure outdir is gone so it will be replaced entierly
2831
rm -rf "$outdir"
2932

30-
echo "$shasum $outfile" | sha256sum -c -
33+
echo "$shasum $outfile" | shasum -a 256 -c -
3134
sharesult=$?
3235
if [ "$sharesult" -eq 0 ]; then
3336
if echo "$outfile" | grep "\.zip"; then
@@ -37,6 +40,12 @@ if [ $result -eq 0 ]; then
3740
echo "ERROR: unzip failed!"
3841
exit 3
3942
fi
43+
elif echo "$outfile" | grep "\.dmg"; then
44+
echo "Extracting .dmg file"
45+
mountpoint=/Volumes/tigervnc-for-peerviewer-build
46+
hdiutil attach -mountpoint "$mountpoint" "$outfile"
47+
cp -R "$mountpoint"/TigerVNC*.app tigervnc-macos-x86_64/
48+
hdiutil detach "$mountpoint"
4049
else # assume it's a tar
4150
if tar xf "$outfile"; then
4251
mv tigervnc-1.13.1.x86_64 tigervnc-linux-x86_64
@@ -48,7 +57,11 @@ if [ $result -eq 0 ]; then
4857
fi
4958
configfiledstdir=$(dirname "$configfiledst")
5059
if [ -f "$configfilesrc" -a -d "$configfiledstdir" ]; then
51-
cat "$configfilesrc" | sed -e 's/\r*$/\r/' > "$configfiledst"
60+
# the windows build requires removing \r so the line endings are only \n
61+
#cat "$configfilesrc" | sed -e 's/\r*$/\r/' > "$configfiledst"
62+
#cat "$configfilesrc" | tr -d '\r' > "$configfiledst"
63+
# Disabled the \r removal because the password file happens to contain a \r
64+
cp "$configfilesrc" "$configfiledst"
5265
else
5366
echo "ERROR: could not write config file because $configfilesrc is not a file or $configfiledstdir is not a directory!"
5467
exit 5

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /