Giter Site home page Giter Site logo

seriousm4x / upsnap Goto Github PK

View Code? Open in Web Editor NEW
2.0K 9.0 74.0 26.47 MB

A simple wake on lan web app written with SvelteKit, Go and PocketBase.

License: MIT License

HTML 0.28% JavaScript 0.91% Svelte 29.89% Go 25.03% TypeScript 43.57% Shell 0.04% Dockerfile 0.27% CSS 0.02%
wakeonlan golang pocketbase sveltekit wol

upsnap's Introduction

UpSnap

A simple wake on lan web app written with SvelteKit, Go and PocketBase.

โœจ Features

  • ๐Ÿš€ One-Click Device Wake-Up Dashboard
  • โฐ Timed Events via Cron for Automation
  • ๐Ÿ”Œ Ping Any Port You Choose
  • ๐Ÿ” Discover Devices with Network Scanning (nmap required)
  • ๐Ÿ‘ค Secured User Management
  • ๐ŸŒ i18n support for these languages
  • ๐ŸŽจ 29 Themes
  • ๐Ÿณ Docker images for amd64, arm64, arm/v7, arm/v6
  • ๐Ÿ  Self-Hostable

๐Ÿ“ธ Screenshots

Dark Light

๐Ÿง Install from the AUR

yay -Sy upsnap-bin

๐Ÿš€ Run the binary

Just download the latest binary from the release page and run it.

Root:

sudo ./upsnap serve --http=0.0.0.0:8090

Non-root:

sudo setcap cap_net_raw=+ep ./upsnap # only once after downloading
./upsnap serve --http=0.0.0.0:8090

For more options check ./upsnap --help or visit PocketBase documentation.

If you want to use network discovery, make sure to have nmap installed and run UpSnap as root/admin.

๐Ÿณ Run in docker

You can use the docker-compose example. See the comments in the file for customization.

Non-root docker user:

Create the mount point first:

mkdir data

Then add user: 1000:1000 to the docker-compose file (or whatever your $UID:$GID is).

Change port

If you want to change the port from 8090 to something else, change the following (5000 in this case):

entrypoint: /bin/sh -c "./upsnap serve --http 0.0.0.0:5000"
healthcheck:
  test: curl -fs "http://localhost:5000/api/health" || exit 1

Install additional packages for shutdown cmd

entrypoint: /bin/sh -c "apk update && apk add --no-cache <YOUR_PACKAGE> && rm -rf /var/cache/apk/* && ./upsnap serve --http 0.0.0.0:8090"

You can search for your needed package here.

Reverse Proxy

Caddy example

upsnap.example.com {
    reverse_proxy localhost:8090
}

๐Ÿ”’ User permissions

UpSnap offers unique access for each user, per device. While admins have all permissions, they can assign specific rights to users such as displaying/hiding a device, accessing device editing, deleting and powering devices on/off. See the last screenshot in the ๐Ÿ“ธ Screenshots section.

๐ŸŒ Exposing to the open web

Although UpSnap has user authorisation, it is not recommended to expose it to the open web and make it accessible by everyone!

Reason: The shutdown device command is basically a command piped to #sh (root if you run docker). If anyone gains unauthorized access and can abuse this api route in any way, the attacker has access to a (root) shell on your local network.

Recommended: If you need access from outside your network, please use a vpn. Wireguard or OpenVPN is your way to go.

๐ŸŒ Help translating

UpSnap is available in the following languages so far:

  • ๐Ÿ‡บ๐Ÿ‡ธ English (en-US)
  • ๐Ÿ‡ฉ๐Ÿ‡ช German (de-DE)
  • ๐Ÿ‡ฎ๐Ÿ‡น Italian (it-IT)
  • ๐Ÿ‡ช๐Ÿ‡ธ Spanish (es-ES)
  • ๐Ÿ‡ซ๐Ÿ‡ท French (fr-FR)
  • ๐Ÿ‡ต๐Ÿ‡น Portuguese (pt-PT)
  • ๐Ÿ‡จ๐Ÿ‡ณ Chinese (zh-CN)
  • ๐Ÿ‡น๐Ÿ‡ผ Chinese (Taiwan) (zh-TW)

If you want to contribute and help translating, check the wiki: How to add languages

๐Ÿ”ง Help developing

Fork this branch and clone it.

  1. Start backend
cd backend
go mod tidy
go run main.go serve
  1. Start frontend
cd frontend
pnpm i
pnpm run dev

Open up http://localhost:5173/, create an admin user and add some devices.

๐ŸŒŸ Star History

Star History Chart

upsnap's People

Contributors

aviscido avatar denymz avatar dependabot[bot] avatar dimitridr avatar gaby avatar github-actions[bot] avatar jarrettgilliam avatar madtiago avatar raulmora22 avatar seriousm4x avatar tstivers avatar twtom041 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

upsnap's Issues

Will not work on portainer/docker

Im trying to install this on portainer as a stack, since thats the only way im able to change the composer but once it starts its just a blank page, could you provide more doccumentation on this

django.db.utils.ProgrammingError: (1146, "Table 'upsnap.wol_websocket' doesn't exist")

What happened

From #11, I'm trying to run v1.4.1 on aarch64 but it says

upsnap_django | django.db.utils.ProgrammingError: (1146, "Table 'upsnap.wol_websocket' doesn't exist")

Reproduce

Straightforward

Check MySQL (mariadb) DB

Changed mysql to mariadb because no mysql image for arm64.
And I confirmed there does not exist the table 'upsnap.wol_websocket'.

root@1d4c0b7296b2:/# mysql -u upsnap -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or g.
Your MariaDB connection id is 8
Server version: 10.4.8-MariaDB-1:10.4.8+maria~bionic mariadb.org binary distribution

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or 'h' for help. Type ' to clear the current input statement.

MariaDB [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| upsnap |
+--------------------+
2 rows in set (0.002 sec)

MariaDB [(none)]> use upsnap;
Database changed
MariaDB [upsnap]> show tables;
Empty set (0.001 sec)

feat: change the title of the webpage

I use Upsnap across multiple locations, so it would help if the page title could be modified using an environment variable, helps in quick identification.

Thanks for this awesome project btw!!

Traefik configuration for UpSnap

This isn't much of an issue, but just a small note on how to configure UpSnap to be used behind Traefik.
Since network_mode: host needs be used for scanning the local network, I needed to make a dynamic config file:

http:
  routers:
    lan:
      rule: "Host(`upsnap.example.com`)"
      entryPoints:
        - websecure
      service: lan
      tls:
        certResolver: myresolver
    lan-backend:
      rule: "Host(`upsnap.example.com`) && PathPrefix(`/wol`)"
      entryPoints:
        - websecure
      service: lan-backend
      middlewares:
        - sslheader@file
      tls:
        certResolver: myresolver
  middlewares:
    sslheader:
      headers:
        customRequestHeaders:
          X-Forwarded-Proto: https
  services:
    lan:
      loadBalancer:
        servers:
          - url: "http://1.2.3.4:8000"
    lan-backend:
      loadBalancer:
        servers:
          - url: "http://1.2.3.4:8001"

If you don't care about the scanning feature, you can also use labels to configure your container:

version: '3.5'

services:
  upsnap:
    image: seriousm4x/upsnap:latest
    container_name: upsnap
    restart: unless-stopped
    environment:
      - FRONTEND_PORT=8000
      - BACKEND_PORT=8001
      - BACKEND_IS_PROXIED=true # set this to true, if you use a reverse proxy
      - DB_TYPE=sqlite
      - REDIS_HOST=upsnap-redis
      - REDIS_PORT=6379
      #- PING_INTERVAL=5 # optional (default: 5 seconds)
      #- DJANGO_SUPERUSER_USER=admin # optional (default: backend login disabled)
      #- DJANGO_SUPERUSER_PASSWORD=admin # optional (default: backend login disabled)
      #- DJANGO_SECRET_KEY=secret # optional (default: randomly generated)
      #- DJANGO_DEBUG=True # optional (default: False)
      #- DJANGO_LANGUAGE_CODE=de # optional (default: en)
      #- DJANGO_TIME_ZONE=Europe/Berlin # optional (default: UTC)
    depends_on:
      redis:
        condition: service_healthy
    volumes:
      - ./db/:/app/backend/db/
    networks:
      - web
      - default
    labels:
      traefik.enable: 'true'
      traefik.docker.network: web
      # Frontend
      traefik.http.routers.upsnap.rule: Host(`upsnap.example.com`)
      traefik.http.routers.upsnap.tls.certresolver: myresolver
      traefik.http.routers.upsnap.entrypoints: websecure
      traefik.http.services.upsnap.loadbalancer.server.port: 8000
      # Backend
      traefik.http.routers.upsnap-backend.rule: Host(`upsnap.example.com`) && Path(`/wol`)
      traefik.http.routers.upsnap-backend.tls.certresolver: myresolver
      traefik.http.routers.upsnap-backend.entrypoints: websecure
      traefik.http.routers.upsnap-backend.middlewares: sslheader
      traefik.http.middlewares.sslheader.headers.customresponseheaders.X-Forwarded-Proto: https
      traefik.http.services.upsnap-backend.loadbalancer.server.port: 8001
      
  redis:
    image: redis:alpine
    container_name: upsnap-redis
    restart: unless-stopped
    command: redis-server --loglevel warning
    healthcheck:
      test: redis-cli ping
      interval: 10s
    networks:
      - default

networks:
  default:
    name: upsnap-net
  web:
    external: true

I am not sure if the docker compose file will work, but the dynamic config works just fine! I have seen that using traefik, you could somehow configure containers with network_mode: host using extra_hosts (you can lookup this discussion), but I didn't succeed in doing it.

Nevertheless, the config above works for me and maybe it will help someone debug their problems in the future if trying it on their own. I spent like 1-2 hours to figure out that the missing piece was the missing sslheader middleware.

After editing the properties of any device, the dialog box doesn't fade away, nor does it notify that changes have been saved

If you bring up the device properties of any device, make changes to it (ports/commands) and click on save changes, there's no notification to tell if the changes have been synced nor does the box fade away automatically.

Either would be fine, but better would be that between 'Delete' and 'Save Changes', gets displayed something 'Changes Saved'/'Changes Synced', so that you don't have to bring up the properties tab again and again.

Thanks for the efforts !

Same goes for when adding a device manually, we need some kind of visual prompt.

Server Error (500) on Docker install

I have just tried this and the Postgres database has the below error

2021-10-01 12:51:13.657 UTC [539] ERROR: relation "wol_websocket" does not exist at character 62,
2021-10-01 12:51:13.657 UTC [539] STATEMENT: SELECT "wol_websocket"."id", "wol_websocket"."visitors" FROM "wol_websocket" ORDER BY "wol_websocket"."id" ASC LIMIT 1,
2021-10-01 12:51:12.655 UTC [538] STATEMENT: SELECT "wol_websocket"."id", "wol_websocket"."visitors" FROM "wol_websocket" ORDER BY "wol_websocket"."id" ASC LIMIT 1,
2021-10-01 12:51:12.655 UTC [538] ERROR: relation "wol_websocket" does not exist at character 62

The django container is erroring with the below:

[2021-10-01 13:52:36,727: ERROR/ForkPoolWorker-2] Task wol.tasks.scheduled_wakes[939342b1-1eb9-4f19-9cdb-9a0efe01fff2] raised unexpected: ProgrammingError('relation "wol_websocket" does not exist\nLINE 1: ..._websocket"."id", "wol_websocket"."visitors" FROM "wol_webso...\n ^\n'),
Traceback (most recent call last):,
return self.cursor.execute(sql, params),
File "/usr/local/lib/python3.9/site-packages/django/db/backends/utils.py", line 84, in _execute,
psycopg2.errors.UndefinedTable: relation "wol_websocket" does not exist,
LINE 1: ..._websocket"."id", "wol_websocket"."visitors" FROM "wol_webso...,
,
^,
The above exception was the direct cause of the following exception:,
File "/usr/local/lib/python3.9/site-packages/celery/app/trace.py", line 450, in trace_task,
R = retval = fun(*args, **kwargs),
File "/usr/local/lib/python3.9/site-packages/celery/app/trace.py", line 731, in protected_call,
return self.run(*args, **kwargs),
File "/app/wol/tasks.py", line 74, in scheduled_wakes,
if Websocket.objects.first().visitors == 0:,
File "/usr/local/lib/python3.9/site-packages/django/db/models/manager.py", line 85, in manager_method,
return getattr(self.get_queryset(), name)(*args, **kwargs),
File "/usr/local/lib/python3.9/site-packages/django/db/models/query.py", line 674, in first,
for obj in (self if self.ordered else self.order_by('pk'))[:1]:,
self._fetch_all(),
File "/usr/local/lib/python3.9/site-packages/django/db/models/query.py", line 280, in iter,
File "/usr/local/lib/python3.9/site-packages/django/db/models/query.py", line 1324, in _fetch_all,
File "/usr/local/lib/python3.9/site-packages/django/db/models/query.py", line 51, in iter,
self._result_cache = list(self._iterable_class(self)),
results = compiler.execute_sql(chunked_fetch=self.chunked_fetch, chunk_size=self.chunk_size),
cursor.execute(sql, params),
File "/usr/local/lib/python3.9/site-packages/django/db/models/sql/compiler.py", line 1175, in execute_sql,
File "/usr/local/lib/python3.9/site-packages/django/db/backends/utils.py", line 66, in execute,
return self._execute_with_wrappers(sql, params, many=False, executor=self._execute),
File "/usr/local/lib/python3.9/site-packages/django/db/backends/utils.py", line 75, in _execute_with_wrappers,
return executor(sql, params, many, context),
File "/usr/local/lib/python3.9/site-packages/django/db/utils.py", line 90, in exit,
raise dj_exc_value.with_traceback(traceback) from exc_value,
django.db.utils.ProgrammingError: relation "wol_websocket" does not exist

Unable to add devices

I'm having an issue after updating to the latest upsnap where all 3 of the computers I had added are missing. I've tried restoring from json backedup file, deleted the docker containers and creating from new and still can't add.

version: "3"
services:
app:
container_name: upsnap_app
image: seriousm4x/upsnap:latest
network_mode: host
restart: unless-stopped
environment:
- FRONTEND_PORT=8100
- BACKEND_PORT=8001
- DB_TYPE=sqlite # required
- REDIS_HOST=127.0.0.1 # required (make sure to use the same ip as below)
- REDIS_PORT=6379 # required (make sure to use the same port as below)
#- PING_INTERVAL=5 # optional (default: 5 seconds)
#- DJANGO_SUPERUSER_USER=admin # optional (default: backend login disabled)
#- DJANGO_SUPERUSER_PASSWORD=admin # optional (default: backend login disabled)
#- DJANGO_SECRET_KEY=secret # optional (default: randomly generated)
#- DJANGO_DEBUG=True # optional (default: False)
#- DJANGO_LANGUAGE_CODE=de # optional (default: en)
#- DJANGO_TIME_ZONE=Europe/Berlin # optional (default: UTC)
depends_on:
redis:
condition: service_healthy
redis:
container_name: upsnap_redis
image: redis:alpine
ports:
- "6379:6379"
restart: unless-stopped
healthcheck:
test: redis-cli ping
interval: 10s

WOL does not work

I am currently using v1. I have a testing instance running on v2 (latest) which is working perfectly well. However, after importing hosts data to a v3 instance, WOL is not working anymore.

I have double checked that "netmork_mode: host" is active and that the entries for MAC and IP address are correct.

login for edit settings

very nice app!
it would be great if only logged in user (admin) could edit settings.
so normal user are only able to wake up there computers - nothing else - without login.
Just one admin/login for adding computer and settings.

Discovery in subnet without zero at the end

I am currently trying to set up upsnap at work and having trouble to enable network discovery. We only have a fraction of an IP range, lets say 10.0.0.128/26. If I try to enter it in upsnap it says Please match the requested format. Does it expect a zero at the end? I tried also 10.0.0.0/24 and even then I don't get any output, but even if it would output something, I do not want to get results from other departments. nmap -sn 10.0.0.128/26 gives me the desired range, while nmap -sn 10.0.0.0/24 also works, but I also get devices that I do not care about.

[BUG] Container shown as unhealthy because of change of suggested ports

Describe the bug
The docker container' health status is shown as unhealthy. Besides that, the app works like intended. I think I have to change something about the ports in the docker compose file shown below, but I don't know what exactly I have to change.

To Reproduce
Had to change the suggested port to 7777 in the docker compose file because of another container. But if I do this, the container is shown as unhealthy

Expected behavior
shown as healthy or running

Logs

Executing busybox-1.35.0-r29.trigger
OK: 133 MiB in 90 packages
[INFO] 2023/02/17 21:52:33 pb.go:157: Ping interval set to @every 10s
2023/02/17 21:52:33 Server started at http://0.0.0.0:7777
 โžœ REST API: http://0.0.0.0:7777/api/
 โžœ Admin UI: http://0.0.0.0:7777/_/
fetch https://dl-cdn.alpinelinux.org/alpine/v3.17/main/x86_64/APKINDEX.tar.gz
fetch https://dl-cdn.alpinelinux.org/alpine/v3.17/community/x86_64/APKINDEX.tar.gz
ERROR: https://dl-cdn.alpinelinux.org/alpine/v3.17/main: temporary error (try again later)
WARNING: Ignoring https://dl-cdn.alpinelinux.org/alpine/v3.17/main: No such file or directory
ERROR: https://dl-cdn.alpinelinux.org/alpine/v3.17/community: temporary error (try again later)
WARNING: Ignoring https://dl-cdn.alpinelinux.org/alpine/v3.17/community: No such file or directory
2 errors; 90 distinct packages available
fetch https://dl-cdn.alpinelinux.org/alpine/v3.17/main/x86_64/APKINDEX.tar.gz
fetch https://dl-cdn.alpinelinux.org/alpine/v3.17/community/x86_64/APKINDEX.tar.gz
v3.17.2-49-g4a4be7caf34 [https://dl-cdn.alpinelinux.org/alpine/v3.17/main]
v3.17.2-51-g81bfab2b2a3 [https://dl-cdn.alpinelinux.org/alpine/v3.17/community]
OK: 17814 distinct packages available
fetch https://dl-cdn.alpinelinux.org/alpine/v3.17/main/x86_64/APKINDEX.tar.gz
fetch https://dl-cdn.alpinelinux.org/alpine/v3.17/community/x86_64/APKINDEX.tar.gz
OK: 133 MiB in 90 packages
[INFO] 2023/02/18 00:26:10 pb.go:157: Ping interval set to @every 10s
2023/02/18 00:26:10 Server started at http://0.0.0.0:7777
 โžœ REST API: http://0.0.0.0:7777/api/
 โžœ Admin UI: http://0.0.0.0:7777/_/
[INFO] 2023/02/18 10:51:49 wake.go:12: wake triggered for Mainframe
[INFO] 2023/02/18 17:35:43 wake.go:12: wake triggered for Mainframe
[INFO] 2023/02/19 10:08:08 wake.go:12: wake triggered for Mainframe
[ERROR] 2023/02/19 10:10:10 handlers.go:27: Mainframe%!(EXTRA string=not online after 2 min)
[INFO] 2023/02/19 10:10:45 wake.go:12: wake triggered for Mainframe
[INFO] 2023/02/19 19:54:38 wake.go:12: wake triggered for Mainframe
[INFO] 2023/02/20 19:22:51 wake.go:12: wake triggered for Mainframe
[INFO] 2023/02/21 15:38:44 wake.go:12: wake triggered for Mainframe
[ERROR] 2023/02/21 15:40:45 handlers.go:27: Mainframe%!(EXTRA string=not online after 2 min)

Screenshots
image

Host OS (and version)
Fedora release 37
Docker version 23.0.0, build e92dd87
Asus X555LB 1.0

Host Architecture
amd64

Docker-compose.yml

version: "3"
services:
  upsnap:
    container_name: upsnap
    image: ghcr.io/seriousm4x/upsnap:3
    network_mode: host
    restart: unless-stopped
    volumes:
      - /volume1/docker/upsnap/data:/app/pb_data
    ports:
    	 - 7777:7777
    environment:
      - TZ=Europe/Berlin 
      - UPSNAP_INTERVAL=@every 10s
      - UPSNAP_SCAN_RANGE 	192.168.0.0/24
      - UPSNAP_WEBSITE_TITLE 	Waky waky
    entrypoint: /bin/sh -c apk update && apk add --no-cache ipmitool && rm -rf /var/cache/apk/* && ./upsnap serve --http 0.0.0.0:7777

Scheduled wake seems to be using UTC

I enabled a scheduled wake but it doesn't wol the computer at the time and seems UpSnap uses UTC.

In my understanding, setting DJANGO_TIME_ZONE="MYZONE" was the solution but not...?
Actually, in the container, date returns for example Wed Apr 20 03:45:15 UTC 2022, and crontab depends on this time?

I'm using the docker version of UpSnap.

Docker upsnap_app always restart

coming from version 1.4

backuped the config an want to go to version 2.x

docker system prune -a
changed the the docker-compose.yml to latest

``
version: "3"
services:
app:
container_name: upsnap_app
image: seriousm4x/upsnap:latest
network_mode: host
restart: unless-stopped
environment:
- FRONTEND_PORT=8000
- BACKEND_PORT=8001
- DB_TYPE=sqlite # required
- REDIS_HOST=127.0.0.1 # required (make sure to use the same ip as below)
- REDIS_PORT=6379 # required (make sure to use the same port as below)
#- PING_INTERVAL=5 # optional (default: 5 seconds)
#- DJANGO_SUPERUSER_USER=admin # optional (default: backend login disabled)
#- DJANGO_SUPERUSER_PASSWORD=admin # optional (default: backend login disabled)
#- DJANGO_SECRET_KEY=secret # optional (default: randomly generated)
#- DJANGO_DEBUG=True # optional (default: False)
#- DJANGO_LANGUAGE_CODE=de # optional (default: en)
#- DJANGO_TIME_ZONE=Europe/Berlin # optional (default: UTC)
depends_on:
redis:
condition: service_healthy
redis:
container_name: upsnap_redis
image: redis:alpine
ports:
- "6379:6379"
restart: unless-stopped
healthcheck:
test: redis-cli ping
interval: 10s

but the gui didt start:
https://pastebin.com/BtJZGq5m

Power button triggers a loop. DOES succesfully wake on lan, but UpSnap doesn't find out, so it keeps pinging endlessly.

Describe the bug
Clicking power button in the frontend app causes a loop to occur. My target (Windows 11) PC wakes up, but it seems my UpSnap instance can't see that information. On the terminal where I am serving the it, the ping comes out as:

ping.go:23: listen ip4:icmp : socket : operation not permitted

this repeats until:

handlers.go:27: JT Home%!(EXTRA string=not online after 2 min)

Host OS (and version)
Ubuntu 22.04

(targetting a Win11 for WoL)

[REQUEST] Edit upsnap port number on docker-compose

Hi there, I cannot set the port number for a docker container based on the new version of upsnap.

I'm deploying a container based on the ghcr image, but port 8090 is already in use on my host. Since host network mode is needed for network discovery, I wanted to edit the port upsnap is using directly in the docker-compose file. So I tried setting FRONTEND_PORT and BACKEND_PORT env variables (as were used in the previous version of upsnap), or simply the PORT env variable, but upsnap was still listening at port 8090 at startup.

Is there a way to edit the upsnap port for the docker-compose file? Thanks!

Install docker in Unraid

Hello, I'm trying to install this in unraid but so far i can't seem to get it working.

This is my current config based on a automatic template created by Unraid and it looks like im missing something for the redis.
What do i need to add to the template to get it working?
Pass a env so that i can point the redis ip:port to the redis container i have already installed?

image

Log


14 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities

> [email protected] build
> rollup -c


> [email protected] start
> sirv public --no-clear --host


  Your application is ready~! ๐Ÿš€

  - Local:      http://0.0.0.0:8080
  - Network:    http://172.17.0.4:8080

 LOGS 

[2023-02-03 20:38:15,997: ERROR/MainProcess] consumer: Cannot connect to redis://127.0.0.1:6379//: Error 111 connecting to 127.0.0.1:6379. Connection refused..
Trying again in 6.00 seconds... (3/100)

[2023-02-03 20:38:22,003: ERROR/MainProcess] consumer: Cannot connect to redis://127.0.0.1:6379//: Error 111 connecting to 127.0.0.1:6379. Connection refused..
Trying again in 8.00 seconds... (4/100)

[2023-02-03 20:38:30,011: ERROR/MainProcess] consumer: Cannot connect to redis://127.0.0.1:6379//: Error 111 connecting to 127.0.0.1:6379. Connection refused..
Trying again in 10.00 seconds... (5/100)

If i try to open the web ui i get a white page but it's showing the correct logo in the browser tab
image

[REQUEST] ipmicfg support

The problem you currently have with this project
It'd be neat if I could issue custom ipmicfg commands via this project.

Describe the solution you'd like
ipmicfg -u user -p pass chassis power on for example

Spawn nmap with -Pn

Some services don't respond to simple pings. At least adding an option to enable -Pn to scan the active ports would be nice

Scheduling WakeUp

Is it possible to set wake up schedule for multiple days - say every Sunday at 06:30 Hrs for rsync backup target.

channels_redis causes event loop error

upsnap_app       | [2022-12-15 20:48:57,934: ERROR/ForkPoolWorker-32] Task exception was never retrieved
upsnap_app       | future: <Task finished name='Task-9' coro=<Connection.disconnect() done, defined at /opt/venv/lib/python3.9/site-packages/redis/asyncio/connection.py:828> exception=RuntimeError('Event loop is closed')>
upsnap_app       | Traceback (most recent call last):
upsnap_app       |   File "/opt/venv/lib/python3.9/site-packages/redis/asyncio/connection.py", line 837, in disconnect
upsnap_app       |     self._writer.close()  # type: ignore[union-attr]
upsnap_app       |   File "/usr/lib/python3.9/asyncio/streams.py", line 353, in close
upsnap_app       |     return self._transport.close()
upsnap_app       |   File "/usr/lib/python3.9/asyncio/selector_events.py", line 700, in close
upsnap_app       |     self._loop.call_soon(self._call_connection_lost, None)
upsnap_app       |   File "/usr/lib/python3.9/asyncio/base_events.py", line 746, in call_soon
upsnap_app       |     self._check_closed()
upsnap_app       |   File "/usr/lib/python3.9/asyncio/base_events.py", line 510, in _check_closed
upsnap_app       |     raise RuntimeError('Event loop is closed')
upsnap_app       | RuntimeError: Event loop is closed

Upstream issue: django/channels_redis#332

[BUG] Version 3.0.3 not working

Describe the bug
The script not working at all and log an error (see logs section)

To Reproduce
Steps to reproduce the behavior:

  1. wget https://github.com/seriousm4x/UpSnap/releases/download/3.0.3/UpSnap_3.0.3_linux_amd64.zip
  2. unzip UpSnap_3.0.3_linux_amd64.zip
  3. run the command: ./upsnap serve --http=0.0.0.0:8080
  4. See error

Expected behavior
The script working and the server running

Logs

./upsnap: line 3: syntax error: unexpected "("

Screenshots
image

Host OS (and version)
Proxmox Container with Alpine 3.15.6

Host Architecture
arm64

VM Proxmox

Hi,

Thank you for this amazing app! In first.

I use Proxmox, that work for Proxmox but not for the VM.

Is it possible to add a founction to control the WOL on a VM?

Thank you for reading me.

[Feature Request] Edit existing devices

Hi @seriousm4x, thank you for making such a fantastic and useful project and for contributing it to the community!

One feature which might be nice to add is a GUI option to edit existing devices. For example, several devices on my network get added with the name "Unknown." It would be nice to have an option to edit the various fields (Name in this case, but also IP and MAC address) after the fact.

Thanks again!

[BUG] Unable to login or create users with existing database

Describe the bug
System auto-updated to the latest release. When opening the application website, I am presented with the new login screen. I followed the documentation to visit the Pocketbase interface to create an account.

However there is no option presented to create an account.

Resizer_16780417510921

If I start a clean instance to setup from scratch and visit the Pocketbase interface it does provide the option to create an account.

Resizer_16780460968221

To Reproduce
Steps to reproduce the behavior:

  1. Upgrade an existing UpSnap instance to latest version
  2. Click on manage users on login prompt
  3. Pocketbase interface does not offer an option for account creation and does not accept any entry

Expected behavior
UpSnap upgrades an existing instance and allows creation of user account in the Pocketbase interface.

Logs
There is nothing of note in the logs
Screenshot_20230305_195636

Host OS (and version)
File: /etc/os-release
1 โ”‚ PRETTY_NAME="Debian GNU/Linux 11 (bullseye)"
2 โ”‚ NAME="Debian GNU/Linux"
3 โ”‚ VERSION_ID="11"
4 โ”‚ VERSION="11 (bullseye)"
5 โ”‚ VERSION_CODENAME=bullseye
6 โ”‚ ID=debian
7 โ”‚ HOME_URL="https://www.debian.org/"
8 โ”‚ SUPPORT_URL="https://www.debian.org/support"
9 โ”‚ BUG_REPORT_URL="https://bugs.debian.org/"

Host Architecture
arm64

Brower (if relevant)
n/a

Additional context
n/a

Security Login

Hi, thank you for this great project. I installed it on my Synology and it works great in my local network.

Maybe my way of thinking is wrong, but how can i securely use UpSnap over the internet? I can open the ports and use it from outside, should be no problem. But without login and password, anybody could start my computers, right ? Just a simple port scan and the person could log into UpSnap and modify my systems, correct?

What is you way of solving that kind of problem?

Thank you

Node Sass does not yet support your current environment: Linux Unsupported architecture (arm64) with Node.js 12.x

What happened

Hello. I'm trying to use UpSnap on aarch64 but as titled, it says

 [!] (plugin svelte) Error: Cannot find any of modules: sass,node-sass

Error: Node Sass does not yet support your current environment: Linux Unsupported architecture (arm64) with Node.js 12.x

Reproduce

  1. Install build-essential in the container to avoid the error below but it's not the main topic.

    npm ERR! gyp verb node dev dir /root/.cache/node-gyp/12.22.5
    npm ERR! gyp ERR! build error
    npm ERR! gyp ERR! stack Error: not found: make
    npm ERR! gyp ERR! stack at getNotFoundError (/app/frontend/node_modules/which/which.js:10:17)
    npm ERR! gyp ERR! stack at /app/frontend/node_modules/which/which.js:57:18

  2. After 1., the error appears.

    app_1 | src/main.js โ†’ public/build/bundle.js...
    app_1 | [!] (plugin svelte) Error: Cannot find any of modules: sass,node-sass
    app_1 |
    app_1 | Error: Node Sass does not yet support your current environment: Linux Unsupported architecture (arm64) with Node.js 12.x
    app_1 | For more information on which environments are supported please see:
    app_1 | https://github.com/sass/node-sass/releases/tag/v7.0.1
    app_1 | src/App.svelte
    app_1 | Error: Cannot find any of modules: sass,node-sass
    app_1 |
    app_1 | Error: Node Sass does not yet support your current environment: Linux Unsupported architecture (arm64) with Node.js 12.x
    app_1 | For more information on which environments are supported please see:
    app_1 | https://github.com/sass/node-sass/releases/tag/v7.0.1
    app_1 | at importAny (/app/frontend/node_modules/svelte-preprocess/dist/modules/utils.js:31:15)
    app_1 |
    app_1 | npm ERR! code 1
    app_1 | npm ERR! path /app/frontend
    app_1 | npm ERR! command failed
    app_1 | npm ERR! command sh -c rollup -c
    app_1 |
    app_1 | npm ERR! A complete log of this run can be found in:
    app_1 | npm ERR! /root/.npm/_logs/2022-03-26T11_36_58_737Z-debug.log

I checked that the command npm run build outputs this error.
so, is arm64 really supported?

UpSnap does not work with docker-compose

Hi, I tried using the following docker-compose file, but I can't access the website on 192.168.2.33:8090. it seems that the container is not listening on 0.0.0.0:8090.

version: "3"
services:
  upsnap:
    container_name: upsnap
    image: ghcr.io/seriousm4x/upsnap:3
    restart: unless-stopped
    volumes:
      - /docker_data/upsnap/data:/app/pb_data
    healthcheck:
      test: wget --no-verbose --tries=1 --spider http://localhost:8090/api/health || exit 1
      interval: 1m
      timeout: 10s
      retries: 3
    environment:
      - TZ=Europe/Amsterdam # Set container timezone for cron schedules
      - UPSNAP_INTERVAL=@every 30s # Sets the interval in which the devices are pinged
      - UPSNAP_SCAN_RANGE=192.168.2.0/24 # Scan range is used for device discovery on local network
    network_mode: host

sudo netstat -tunlp | grep 8090 gave the following result

tcp6 0 0 :::8090 :::* LISTEN 937145/./upsnap

I also tried using Nginx Reverse Proxy as maybe that would work, but it did not.
image

Could you please help me out?

API available?

Hi there,

Thanks for your contributions with UpSnap. I'm looking to use UpSnap to wake one of my PC as part of a home automation routine. Is there an endpoint that I can call (instead of using the UI) to have UpSnap send a WOL packet to a PC?

Thanks!

Linux Shutdown Cron Job fails with error 127

When setting a cron job using the sshpass command method to shutdown a Linux machine the job fails with error 127. As per below screenshot of the logs.

Screenshot_20230201_002639

command syntax used: sshpass -p ssh -o "StrictHostKeyChecking=no" @192.168.1.17 "sudo poweroff"

Googling the error suggests that Error 127 is command not found.

I checked the syntax of the command I was using by running on the docker host that runs UpSnap. This worked successfully.

To try and diagnose the cause I used docker exec to go into the container and manually run the command. When running the command within the UpSnap container it throws a command not found error.

sshpass exists in the container but it looks like the
ssh program, the other app used in the command is not included. Obviously this might be incorrect diagnosis as I am unfamiliar with the inner workings.

WebUI Not Loading, Connection Refused in Logs

Hey guys. A bit of a Docker noob, but struggling to get this operational on my network. I have deployed this within Portainer, and Upsnap doesn't seem to want to run properly. I keep getting a "connection refused" error in the logs. The only thing I've done is define the environment variables so that I am running on a different port, as port 8000 was taken by Portainer itself. Any ideas? Here's a screenshot of the logs: https://i.imgur.com/9rWGJQR.jpeg

Edit: here is what the WebUI looks like: https://i.imgur.com/akMpb7X.jpeg

[REQUEST] Link to devices

Hi. Its possible to add a link to the devices?
For example i want to start a NAS. After its green, i want to go to NAS' Webgui, directly from UpSnap

WebSocket connection error when using lighttpd

I'm using Lighttpd and faced a WebSocket problem.

What happened

When I map name to UpSnap (e.g. upsnap.lan to localhost:7000 (frontend)) by using lighttpd, WebScoket instantiation failed at store.js:6.

const socket = new WebSocket(`ws://${location.hostname}:${BACKEND_PORT}/wol/`);

Because the WebSocket connection to host:port/wol/ (i.e. upsnap.lan:7001/wol/) is not possible due to the Lighttpd config to map name to UpSnap like below.

# This is for upsnap.lan access
$HTTP["host"] == "upsnap.lan" {
  proxy.balance = "hash"
  proxy.server  = ( "" => (
                            ( "host" => "127.0.0.1",
                              "port" => 7000 )
                          ) )
}

# This is for websocket connection
# https://redmine.lighttpd.net/projects/lighttpd/wiki/Docs_ModProxy#Example-websocket-proxy-to-noVNC-since-1446
$HTTP["url"] =~ "/wol" {
  proxy.server = ( "" => ( ( "host" => "127.0.0.1", "port" => "7001" ) ) )
  proxy.header = ( "upgrade" => "enable" )
}

So under this config, websocket access to upsnap.lan:7001/wol/ is not possible because the first config (# This is for upsnap.lan access) prevents WebSocket connection to upsnap.lan:7001/wol/. Connection to upsnap.lan/wol/ is OK actually.

Current solution

I change the connection part as listed below but it is not good....

let socket = new WebSocket(`ws://${location.hostname}:${BACKEND_PORT}/wol/`);
if (socket.readyState!=1){
    socket = new WebSocket(`ws://${location.hostname}/wol/`);
}

What I want to ask

  1. How do you avoid this problem in your environment? (Do Apache or nginx don't have this problem...?)
  2. My understanding (# This is for upsnap.lan access prevents WebSocket connection) fundamentally wrong? There exists a better way to enable name mapping and WebSocket proxy for Lighttpd?

fix vm.overcommit_memory = 1 in docker logs

/etc/sysctl.conf is read only. not sure how to fix it

wol_redis       | 2021-09-19T08:15:22.772432606Z 1:M 19 Sep 2021 08:15:22.772 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.

upSnap on Docker for Win10?

Does this work on docker for windows? The container looks like its running (default options) but is unreachable from the host machine or local LAN.

Seemingly High Ram usage

I just deployed UpSnap stock (sqlite) docker image and I like it. When I looked at the ram usage, The upsnap_app is using 561MB of used memory and 101MB of cache. This is with just one device added to it. I find it hard to believe that a simple web interface and a scheduler need that much ram. The Reddis instance is only taking about 12MB (Usage + cache).

I'm not saying the code is bad. I'm saying that probably the internal DJANGO service needs to be tweaked for more realistic RAM usage.

Can UpSnap be used using portainer on RPi 4?

Hi seriousm4x,

You made a great tool, really enjoy using it for the last couple of days and wanted to install it on a Raspberry Pi 4 using Portainer.
So this is not an issue so much, more a question of the usability of this docker container using Portainer.
When I create this in Portainer using the docker-compose-sqlite.yml as a template, when I navigate to the IP-address of the RPi using the port 8000, I get the message "Not Found. The requested resource was not found on this server.".

Config is like this, there is also a Redist container on the same RPi configured with port 6379 (host) to 6379 (container).
image

Would you be able to shed any light how to make this great image working using Portainer?
Thanks for the time investment creating and publishing this great tool.

[REQUEST] Add Authentication

The problem you currently have with this project
I'd like to expose UpSnap to the World Wide Web so i can issue WOL packets from anywhere, but i'd want authentication before i do that...

Describe the solution you'd like
Implement some form of authentication for viewing the dashboard and issuing commands

Shutdown commands

Great project, congratulations.

Would it be possible to enable other shell commands via the shutdown section?. As mentioned here https://www.reddit.com/r/selfhosted/comments/pz3u9u/comment/ijqaeb1/?utm_source=share&utm_medium=web2x&context=3, I managed to get sshpass working, but this requires username and password in plain text and I haven't found a way to get UpSnap to read a password from a file.

All I really want to do is send a curl request from this command section, like 'curl -k http://192.168.1.9/sleep', to interact with SleepOnLan https://github.com/SR-G/sleep-on-lan

Is this currently possible from the shutdown section, or could this be enabled in a future version?

After clicking on the power toggle, the button goes into an infinite loop

After you click on the power toggle button, it becomes unclickable and goes into an infinite loop until the device can/cannot be pinged (wake-up or shutdown respectively). Becomes hard to reissue a wake-up command unless the page is refreshed.

The button should not change into a loop, instead the button should change according to the next sent ping (the ping that happens regularly every 5 seconds).

Docker container fails to start

Getting below error with the latest Docker image

django.db.utils.OperationalError: SCRAM authentication requires libpq version 10 or above

tried changing postgresql authentication to md5 does not seem to work. Also tried to use posgresql 14 but doesnt work.

doesnt work for me

Thanks for this project.

Unfortunately, it does not work for me. Neither in Proxmox LXC nor in VM mode.
If i try etherwake or wakeonlan command line tool, its works in both

i use default docker-compose.yml

version: "3"
services:
  upsnap_django:
    container_name: upsnap_django
    image: seriousm4x/upsnap:latest
    network_mode: host
    restart: unless-stopped
    environment:
      - DJANGO_SUPERUSER_USER=admin
      - DJANGO_SUPERUSER_PASSWORD=admin
      - DJANGO_SECRET_KEY=secret
      - DJANGO_DEBUG=False
      - DJANGO_LANGUAGE_CODE=de
      - DJANGO_TIME_ZONE=Europe/Berlin
      - DJANGO_PORT=80
      - REDIS_HOST=127.0.0.1
      - REDIS_PORT=6379
      - DB_TYPE=sqlite
      - PING_INTERVAL=5
      - ENABLE_NOTIFICATIONS=True
    depends_on:
      - upsnap_redis
  upsnap_redis:
    container_name: upsnap_redis
    image: redis:alpine
    ports:
      - "6379:6379"
    restart: unless-stopped
    healthcheck:
      test: redis-cli ping
      interval: 10s
`

Backup looks like this:

`{
    "30:9C:23:DB:90:D2": {
        "name": "PC-MAIN",
        "ip": "172.30.60.101",
        "netmask": "255.255.255.0"
    },
    "00:08:9b:db:09:ce": {
        "name": "NAS4",
        "ip": "172.30.70.4",
        "netmask": "255.255.255.0"
    },
    "00:11:32:5d:00:ca": {
        "name": "NAS1",
        "ip": "172.30.70.1",
        "netmask": "255.255.255.0"
    },
    "5c:f4:ab:5e:90:3f": {
        "name": "NAS2",
        "ip": "172.30.70.2",
        "netmask": "255.255.255.0"
    },
    "00:08:9b:c0:4c:e5": {
        "name": "QNAP-NAS (Backup)",
        "ip": "172.30.70.101",
        "netmask": "255.255.255.0"
    }
}```

//Edit//
Code formating here in preview looks okay :(

[BUG] Network Scan produces authorization error

Describe the bug
Scanning for network devices produced an authorization error.

To Reproduce
Steps to reproduce the behavior:

  1. Run the docker as root or user 0
  2. Create an initial Admin user
  3. Go to the login page
  4. Toggle the "Admin" option
  5. Login as an Admin user
  6. Click "Settings" in the header
  7. Enter a valid CIDR (192.168.1.0/24) in the Network Scan section
  8. Click "Scan"
  9. See error "Failed: The request requires valid admin authorization token to be set."

Expected behavior
I would expect it would change to "waiting..." while it scans in the background using nmap.

Logs
N/A

Screenshots
image

Host OS (and version)
Debian 4.19.208-1

Host Architecture
Docker on amd64

Brower (if relevant)
Firefox 110.0.1

Additional context
Upon looking at the code for the project, I believe this error is generated because PB does not believe this user is an Admin but this is an error because it is the only user on the system and it is listed under "Admins".

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.