diff --git a/.docker/build.sh b/.docker/build.sh old mode 100644 new mode 100755 index 79a95f1..2de139c --- a/.docker/build.sh +++ b/.docker/build.sh @@ -7,4 +7,6 @@ cd ../client npm install && npm run build cd ../ -docker build -f Dockerfile -t neko . \ No newline at end of file +sudo docker build -f Dockerfile -t neko . + +# sudo docker run -p 8080:8080 --shm-size=2gb neko:latest \ No newline at end of file diff --git a/.docker/pulseaudio.pa b/.docker/default.pa similarity index 54% rename from .docker/pulseaudio.pa rename to .docker/default.pa index 62ba416..799bba5 100644 --- a/.docker/pulseaudio.pa +++ b/.docker/default.pa @@ -1,4 +1,7 @@ -unload-module module-suspend-on-idle +#!/usr/bin/pulseaudio -nF # Allow pulse audio to be accessed via TCP (from localhost only), to allow other users to access the virtual devices -load-module module-native-protocol-unix socket=/tmp/pulseaudio.socket auth-anonymous=1 \ No newline at end of file +load-module module-native-protocol-unix socket=/tmp/pulseaudio.socket auth-anonymous=1 + +### Make sure we always have a sink around, even if it is a null sink. +load-module module-always-sink \ No newline at end of file diff --git a/.docker/entrypoint.sh b/.docker/entrypoint.sh old mode 100644 new mode 100755 index fbd9fdc..92d1361 --- a/.docker/entrypoint.sh +++ b/.docker/entrypoint.sh @@ -1,7 +1,6 @@ #!/bin/bash -echo "Starting dbus" -/etc/init.d/dbus start +sudo /etc/init.d/dbus start echo "Starting supervisord" -su -p -l $NEKO_USER -c '/usr/bin/supervisord -c /etc/neko/supervisord.conf' -s /bin/bash \ No newline at end of file +/usr/bin/supervisord -c /etc/neko/supervisord.conf \ No newline at end of file diff --git a/.docker/policies.json b/.docker/policies.json index 5cf126a..f60e52d 100644 --- a/.docker/policies.json +++ b/.docker/policies.json @@ -3,10 +3,40 @@ "DisableAppUpdate": true, "DisableTelemetry": true, "DontCheckDefaultBrowser": true, + "DisableFirefoxAccounts": true, + "DisablePrivateBrowsing": true, + "DisableProfileImport": true, "BlockAboutConfig": true, + "BlockAboutProfiles": true, + "BlockAboutSupport": true, "OverrideFirstRunPage": "", "OfferToSaveLogins": false, "PromptForDownloadLocation":false, + "DisableSetDesktopBackground":false, + "DisableDeveloperTools":false, + "DisableFeedbackCommands":false, + "DisableFirefoxScreenshots":false, + "DisableProfileRefresh":false, + "OfferToSaveLoginsDefault":false, + "PasswordManagerEnabled":false, + "SanitizeOnShutdown": { + "Cache": true, + "Cookies": true, + "Downloads": true, + "FormData": true, + "History": true, + "Sessions": true, + "SiteSettings": true, + "OfflineApps": true + }, + "FirefoxHome": { + "Search": true, + "TopSites": true, + "Highlights": false, + "Pocket": false, + "Snippets": false, + "Locked": false + }, "ExtensionSettings": { "uBlock0@raymondhill.net": { "installation_mode": "force_installed", @@ -20,6 +50,14 @@ "Homepage": { "Additional": [], "StartPage": "none" - } + }, + "Bookmarks": [ + { + "Title": "9 Anime", + "URL": "https://9anime.xyz/", + "Favicon": "https://9anime.xyz/favicon.png", + "Placement": "toolbar" + } + ] } } \ No newline at end of file diff --git a/.docker/supervisord.conf b/.docker/supervisord.conf index 2b38f39..875488a 100644 --- a/.docker/supervisord.conf +++ b/.docker/supervisord.conf @@ -1,18 +1,17 @@ [supervisord] environment=PULSE_SERVER="unix:/tmp/pulseaudio.socket",DISPLAY=":%(ENV_NEKO_DISPLAY)s" nodaemon=true -pidfile=/var/run/supervisord.pid logfile=/dev/null logfile_maxbytes=0 +loglevel=debug [program:xvfb] command=/usr/bin/Xvfb :%(ENV_NEKO_DISPLAY)s -screen 0 %(ENV_NEKO_WIDTH)sx%(ENV_NEKO_HEIGHT)sx24+32 -redirect_stderr=true autorestart=true priority=300 [program:pulseaudio] -command=/usr/bin/pulseaudio --disallow-module-loading -vvvv --disallow-exit --exit-idle-time=-1 --file=/etc/neko/pulseaudio.pa +command=/usr/bin/pulseaudio --disallow-module-loading -vvvv --disallow-exit --exit-idle-time=-1 autorestart=true priority=300 @@ -27,6 +26,6 @@ autorestart=true priority=400 [program:neko] -command=/usr/bin/neko serve -d --static "/var/www" +command=/usr/bin/neko serve --static "/var/www" autorestart=true -priority=500 \ No newline at end of file +priority=800 \ No newline at end of file diff --git a/.docker/supervisord.dev.conf b/.docker/supervisord.dev.conf index 9bf4927..ef0e19d 100644 --- a/.docker/supervisord.dev.conf +++ b/.docker/supervisord.dev.conf @@ -1,7 +1,6 @@ [supervisord] environment=PULSE_SERVER="unix:/tmp/pulseaudio.socket",DISPLAY=":%(ENV_NEKO_DISPLAY)s" nodaemon=true -pidfile=/var/run/supervisord.pid #logfile=/dev/null #logfile_maxbytes=0 loglevel=debug @@ -13,7 +12,7 @@ autorestart=true priority=300 [program:pulseaudio] -command=/usr/bin/pulseaudio --disallow-module-loading -vvvv --disallow-exit --exit-idle-time=-1 --file=/etc/neko/pulseaudio.pa +command=/usr/bin/pulseaudio --disallow-module-loading -vvvv --disallow-exit --exit-idle-time=-1 autorestart=true priority=300 diff --git a/.docker/test.sh b/.docker/test.sh index 41857d6..19ce65f 100755 --- a/.docker/test.sh +++ b/.docker/test.sh @@ -6,8 +6,9 @@ sudo mkdir -p /var/run/dbus /etc/neko sudo /etc/init.d/dbus start sudo cp supervisord.conf /etc/neko/supervisord.conf -sudo cp pulseaudio.pa /etc/neko/pulseaudio.pa sudo cp openbox.xml /etc/neko/openbox.xml + +sudo cp default.pa /etc/pulse/default.pa sudo cp policies.json /usr/lib/firefox-esr/distribution/policies.json if [ ! -f /usr/lib/firefox-esr/distribution/extensions/uBlock0@raymondhill.net.xpi ]; then diff --git a/.github/.gitkeep b/.github/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/.github/logo.png b/.github/logo.png new file mode 100644 index 0000000..46ffaba Binary files /dev/null and b/.github/logo.png differ diff --git a/Dockerfile b/Dockerfile index 007524f..43dcf8f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM buildpack-deps:stretch +FROM debian:stretch-slim ARG USERNAME=neko ARG USER_UID=1000 @@ -7,9 +7,9 @@ ARG USER_GID=$USER_UID # Avoid warnings by switching to noninteractive ENV DEBIAN_FRONTEND=noninteractive -# Install dependencies +# Install dependencies ttf-freefont RUN apt-get update \ - && apt-get -y install curl supervisor openbox dbus-x11 ttf-freefont xvfb pulseaudio consolekit firefox-esr \ + && apt-get -y install curl supervisor openbox dbus-x11 xvfb pulseaudio firefox-esr \ && apt-get -y install gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-pulseaudio libxcb-xkb-dev libxkbcommon-x11-dev \ # # Create a non-root user @@ -19,18 +19,23 @@ RUN apt-get update \ && adduser $USERNAME video \ && adduser $USERNAME pulse \ # + # Add sudo support for the non-root user + && apt-get install -y sudo \ + && echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \ + && chmod 0440 /etc/sudoers.d/$USERNAME \ + # # Install uBlock && mkdir -p /usr/lib/firefox-esr/distribution/extensions \ && curl -o /usr/lib/firefox-esr/distribution/extensions/uBlock0@raymondhill.net.xpi https://addons.mozilla.org/firefox/downloads/latest/ublock-origin/addon-607454-latest.xpi \ # - # Make directories for neko - && mkdir -p /etc/neko /var/www \ - # # Setup Pulse Audio mkdir -p /home/$USERNAME/.config/pulse/ \ && echo "default-server=unix:/tmp/pulseaudio.socket" > /home/$USERNAME/.config/pulse/client.conf \ && chown -R $USERNAME:$USERNAME /home/$USERNAME \ # + # Make directories for neko + && mkdir -p /etc/neko /var/www \ + # # Clean up && apt-get autoremove -y \ && apt-get clean -y \ @@ -38,9 +43,9 @@ RUN apt-get update \ # # Copy configuation files -COPY .docker/pulseaudio.pa /etc/neko/pulseaudio.pa COPY .docker/openbox.xml /etc/neko/openbox.xml COPY .docker/supervisord.conf /etc/neko/supervisord.conf +COPY .docker/default.pa /etc/pulse/default.pa COPY .docker/policies.json /usr/lib/firefox-esr/distribution/policies.json # @@ -48,18 +53,22 @@ COPY .docker/policies.json /usr/lib/firefox-esr/distribution/policies.json COPY client/dist/ /var/www COPY server/bin/neko /usr/bin/neko +USER $USERNAME + # # Neko Env ENV NEKO_USER=$USERNAME ENV NEKO_DISPLAY=0 ENV NEKO_WIDTH=1280 ENV NEKO_HEIGHT=720 -ENV NEKO_URL=https://www.youtube.com/embed/QH2-TGUlwu4 ENV NEKO_PASSWORD=neko -ENV NEKO_BIND=0.0.0.0:80 +ENV NEKO_BIND=0.0.0.0:8080 ENV NEKO_KEY= ENV NEKO_CERT= +# Nayn +ENV NEKO_URL=https://www.youtube.com/embed/QH2-TGUlwu4 + # # Copy entrypoint COPY .docker/entrypoint.sh /entrypoint.sh diff --git a/README.md b/README.md index 9eabea0..bb9bf03 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,7 @@ +
+ +
+ # n.eko This is a proof of concept project I threw together over the last few days, its ugly its not perfect but it looks nice. This uses web rtc to stream a desktop inside of a docker container, I made this because [rabb.it](https://en.wikipedia.org/wiki/Rabb.it) went under and my internet can't handle streaming and discord keeps crashing. I just want to watch anime with my friends ლ(ಠ益ಠლ) so I started digging throughout the net and found a few *kinda* clones, but non of them had the virtual browser, then I found [Turtus](https://github.com/Khauri/Turtus) and I was able to figure out the rest. @@ -7,10 +11,28 @@ This is by no means a fully featured clone of rabbit. It has no concept of other I like cats, I'm a weeb and a nerd, I own the domain [n.eko.moe](https://n.eko.moe/) and I love that logo I came across, had to use it for something /shrug ### I need help setting this up! -Its a docker container, you need to have docker installed and then run - +Its a docker container, you need to have docker installed, you then need to build the image ``` -TODO: +cd .docker && ./build.sh +``` + +Then run the container: +``` +sudo docker run -p 8080:8080 --shm-size=2gb neko:latest +``` + +*Note:* `--shm-size=2gb` is required, firefox-esr tabs will crash (not sure if 2gb is *really* needed) + +### Config +``` +NEKO_USER=$USERNAME // User +NEKO_DISPLAY=0 // Display number +NEKO_WIDTH=1280 // Display width +NEKO_HEIGHT=720 // Display width +NEKO_PASSWORD=neko // Password +NEKO_BIND=0.0.0.0:8080 // Bind +NEKO_KEY= // Key (SSL) +NEKO_CERT= // Cert (SSL) ``` ### Development diff --git a/client/README.md b/client/README.md index e69de29..04b4fc2 100644 --- a/client/README.md +++ b/client/README.md @@ -0,0 +1 @@ +# n.eko Client diff --git a/server/README.md b/server/README.md index e69de29..d314c98 100644 --- a/server/README.md +++ b/server/README.md @@ -0,0 +1 @@ +# n.eko Server diff --git a/server/internal/webrtc/peer.go b/server/internal/webrtc/peer.go index b1172c6..d5e098a 100644 --- a/server/internal/webrtc/peer.go +++ b/server/internal/webrtc/peer.go @@ -152,16 +152,16 @@ func (manager *WebRTCManager) onData(session *session, msg webrtc.DataChannelMes if key, ok := keys.Mouse[int(payload.Key)]; ok { switch int(payload.Key) { case keys.MOUSE_WHEEL_DOWN: - robotgo.Scroll(0, -10) + robotgo.Scroll(0, -1) break case keys.MOUSE_WHEEL_UP: - robotgo.Scroll(0, 10) + robotgo.Scroll(0, 1) break case keys.MOUSE_WHEEL_LEFT: - robotgo.Scroll(-10, 0) + robotgo.Scroll(-1, 0) break case keys.MOUSE_WHEEL_RIGH: - robotgo.Scroll(10, 0) + robotgo.Scroll(1, 0) break default: robotgo.Click(key, false)