Coder Social home page Coder Social logo

gotify / server Goto Github PK

View Code? Open in Web Editor NEW
10.1K 119.0 577.0 3.39 MB

A simple server for sending and receiving messages in real-time per WebSocket. (Includes a sleek web-ui)

Home Page: https://gotify.net

License: Other

Go 65.96% Makefile 1.14% HTML 0.44% TypeScript 32.38% Dockerfile 0.08%
golang notifications api react javascript gotify selfhosted self-hosted privacy cloud hosting free-software self-hosting

server's Introduction

gotify/server

Build Status codecov Go Report Card Matrix Docker Pulls latest release

Intro

We wanted a simple server for sending and receiving messages (in real time per WebSocket). For this, not many open source projects existed and most of the existing ones were abandoned. Also, a requirement was that it can be self-hosted. We know there are many free and commercial push services out there.

Features

Gotify UI screenshot

  • send messages via REST-API
  • receive messages via WebSocket
  • manage users, clients and applications
  • Plugins
  • Web-UI -> ./ui
  • CLI for sending messages -> gotify/cli
  • Android-App -> gotify/android

Get it on Google Play Get it on F-Droid

(Google Play and the Google Play logo are trademarks of Google LLC.)


Documentation

InstallConfigurationREST-APISetup Dev Environment

Contributing

We welcome all kinds of contribution, including bug reports, feature requests, documentation improvements, UI refinements, etc. Check out CONTRIBUTING.md for guidelines.

Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository.

License

This project is licensed under the MIT License - see the LICENSE file for details

server's People

Contributors

0x111 avatar chrispruitt avatar d-rk avatar eikendev avatar eternal-flame-ad avatar foxbit19 avatar gianortiz avatar iarp avatar imgbotapp avatar jmattheis avatar jokay avatar kirbylink avatar lapin-b avatar laurencejjones avatar madding avatar mateuscelio avatar mikeshatch avatar misguidedemails avatar mrlemur avatar noamran avatar olof-nord avatar pandermusubi avatar pssgcsim avatar quthla avatar rwese avatar stewartthomson avatar tert0 avatar tessus avatar twelho avatar zlendy 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  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

server's Issues

Host field in swagger not filled correctly

I found that the host field in /swagger is always empty, however when I reviewed the source code I found this line:

ctx.Writer.WriteString(get(ctx.Request.URL.Host))

I guess that you hoped to interpolate the source host into desc.json. However, for server requests, the URL field only contained the request URI. I think you would need ctx.Request.Host instead.

Ref:

URL specifies either the URI being requested (for server requests) or the URL to access (for client requests).
https://golang.org/src/net/http/request.go#L115

For server requests Host specifies the host on which the URL is sought.
https://golang.org/src/net/http/request.go#L218

Proxy error with docker

Hi,

Now, Gotify works in my docker container.
But, I've a reverse proxy with my apache2. Sadly, I've a 502 Proxy Error.
The is my VH:

<VirtualHost *:80>                                                                
        ServerName push.blabla.fr                                               
        Redirect / https://push.blabla.fr/                                      
        ServerSignature Off                                                       
        #RewriteEngine on                                                         
        #RewriteCond %{SERVER_NAME} =push.blabla.fr                             
        #RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]  
</VirtualHost>                                                                    
                                                                                  
<VirtualHost *:443>                                                               
        ServerName push.blabla.fr                                               
        SSLEngine On                                                              
        ProxyPass "/" http://127.0.0.1:2083/ retry=0 timeout=5                    
        ProxyPassReverse / http://127.0.0.1:2083/                                 
        ServerSignature Off                                                       
                                                                                  
        CustomLog /var/log/apache2/blabla_access.log combined                       
        ErrorLog /var/log/apache2/blabla_error.log                                  
                                                                                  
        Include /etc/letsencrypt/options-ssl-apache.conf                          
        Include /etc/letsencrypt/options-ssl-apache.conf                          
        SSLCertificateFile /etc/letsencrypt/live/push.blabla.fr/fullchain.pem   
        SSLCertificateKeyFile /etc/letsencrypt/live/push.blabla.fr/privkey.pem  
</VirtualHost>        

Does anybody a idea ?

Failed to find config.yml

Gotify outputs "failed to find configuration config.yml" when a config exists in /etc/gotify/config.yml. The config library outputs this message for every path it couldn't find, so the message is not wrong but missleading.

Raspberry B+ Segmentfault

Hi, cool project. I really want to use it on my (old) Raspberry B+ (arm6). Of course it doesn't work with the arm7 binary/docker version and give me segmentfault when i run it. Is it possible to support arm6 and release a binary for it?

German:

Hi, super Projekt. Würde es sehr gerne auf mein (alten) Raspberry B+ (arm6) laufen lassen. Natürlich klappt die arm7 binary/docker version nicht und gibt Speicherzugriffsfehler zurück. Ist es möglich eine funktionieren binary zu releasen?

$ uname -a
Linux technodrom 4.14.85+ #1173 Tue Dec 4 17:45:01 GMT 2018 armv6l GNU/Linux
$ ./gotify-linux-arm-7
Speicherzugriffsfehler

Allow updating app name and description through API/UI

I could not find a way to update an application's name and description through the UI or the API. Since its possible to change the application image after creating an application, I expected to be able to change other application properties as well.

Support CORS

I am far from an expert but while attempting to write a simple chat app in Vuejs to an existing running server I had to use a proxy to access the service

"url" message parameter

It would be useful to have an optional "url" parameter (and maybe a "urltitle" parameter too for customizing the display text for it) when posting a message to display a clickable link to a URL in the notification message.

Sudo mode

Currently its possible to manage users, clients and apps with a clienttoken. This clienttoken should have a long lifetime and therefore should not have that much power.

API changes:

  • create apps/users/clients apis should require basic authentication.
  • hide token from get client/apps api
  • add a new api for getting the token from client/apps (requires basic auth)

UI Features:

  • reenter password when accessing apis which require basic auth
  • cache password for ~10 minutes (sudo mode)
  • manually delete cached password (leave sudo mode)

Add examples

Hi

Can you please add some examples of how to use the rest api and all that?

thanks

Allow swagger to be excluded from build

I discovered that swagger UI is heavy in the final binary. I tried building without it and got the following results:

Swagger + WebUI Swagger Only WebUI Only No User Interface
39M 33M (-17.9%) 28M (-28.2%) 21M(-46.1%)

I think most people would not use the Swagger UI functionality, and a nearly 30% decrease in binary size is worth doing from my point of view, this is substantial if it is running on a highly limited environment(like an OpenWrt router, etc.).

Changes Proposed

  1. Add two build tags(nowebui noswagger) to exclude Swagger UI and WebUI from builds.
  2. Permit CORS to /swagger and redirect /docs/*any to the swagger UI hosted on gotify.net page with our custom URL to /swagger.

Example: eternal-flame-AD@47a37cd

Notification sound plays twice on the phone

Hey,
this project is really nice, because I can host it myself! Thanks!

Is it normal, that my phone plays the notification sound twice, if I send one message via curl?
I use Android 8.1 on OnePlus5 with LineageOS.
Gotify runs in docker.

iOS-App

It would be great to have an iOS app for Gotify. Maybe someone from the community could contribute such an app as I do not have any experience with iOS/swift.

https though reverse proxy

Hello,

Thanks for your work on gotify, I was looking for an alternative to FCM for my android device (which has not google play services) and it seems to be a good one :)

I installed the server and tested to connect from the android application, it works fine :

  • directly to http port of gotify
  • directly to https port of gotify
  • through nginx proxy on http port of gotify

Sadly, I did not manage to make it work through nginx reverse proxy with https. I got the following error from android application :

Request to 'https://notif.mydomain.com/version' failed with status code 0

Indeed, I use nginx to serve all my web services securely via https and I would like to do the same for gotify to avoid to open a specific port for gotify over internet.

The problem is I don't understand why it does not work and I hope you could help me.

Here is my gotify config :

server:
  port: 3080 # the port for the http server
  ssl:
    enabled: true # if https should be enabled
    redirecttohttps: false # redirect to https if site is accessed by http
    port: 3443 # the https port
    certfile: /tmp/fullchain.pem # the cert file (leave empty when using letsencrypt)
    certkey: /tmp/privkey.pem # the cert key (leave empty when using letsencrypt)
    letsencrypt:
      enabled: false # if the certificate should be requested from letsencrypt
      accepttos: false # if you accept the tos from letsencrypt
      cache: data/certs # the directory of the cache from letsencrypt
      hosts: # the hosts for which letsencrypt should request certificates
      - mydomain.com
database: # for database see (configure database section)
  dialect: sqlite3
  connection: data/gotify.db
defaultuser: # on database creation, gotify creates an admin user
  name: admin # the username of the default user
  pass: admin # the password of the default user
passstrength: 10 # the bcrypt password strength (higher = better but also slower)
uploadedimagesdir: data/images # the directory for storing uploaded images

Here is my nginx config :

server {
  listen 443 ssl http2;
  listen [::]:443 ssl http2;

  server_name notification.mydomain.com notifications.mydomain.com notif.mydomain.com notifs.mydomain.com;

  access_log  /var/log/nginx/notification.access.log;
  error_log  /var/log/nginx/notification.error.log notice;

  ssl_certificate /etc/letsencrypt/live/notification.mydomain.com/fullchain.pem;
  ssl_certificate_key /etc/letsencrypt/live/notification.mydomain.com/privkey.pem;
  ssl_trusted_certificate /etc/letsencrypt/live/notification.mydomain.com/chain.pem;

  location / {
    proxy_pass  http://127.0.0.1:3080;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Upgrade websocket;
    proxy_set_header Connection "upgrade";

    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-Host $server_name;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Ssl on;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_connect_timeout 150;
    proxy_send_timeout 100;
    proxy_read_timeout 100;
    client_max_body_size 8m;
    client_body_buffer_size 128k;
    proxy_redirect http://127.0.0.1:3080 http://$host;
  }
}

At first glance, the access to gotify through this nginx vhost works like directly :

# through nginx with HTTP (works with android app) : 
curl -i http://notification.mydomain.com/version
HTTP/1.1 200 OK
Server: nginx/1.14.0
Date: Mon, 12 Nov 2018 11:01:56 GMT
Content-Type: application/json
Content-Length: 105
Connection: keep-alive

{"version":"1.1.8","commit":"29e0857365dc6004ff91fdee568f5b478222cd5f","buildDate":"2018-11-06-21:27:31"}

# directly to gotify with HTTPS (works with android app) : 
curl -i https://notification.mydomain.com:3443/version
HTTP/2 200 
content-type: application/json
content-length: 105
date: Mon, 12 Nov 2018 11:03:01 GMT

{"version":"1.1.8","commit":"29e0857365dc6004ff91fdee568f5b478222cd5f","buildDate":"2018-11-06-21:27:31"}

# through nginx with HTTPS (does not work on android app)
curl -i https://notification.mydomain.com/version
HTTP/2 200 
server: nginx/1.14.0
date: Mon, 12 Nov 2018 11:04:21 GMT
content-type: application/json
content-length: 105

{"version":"1.1.8","commit":"29e0857365dc6004ff91fdee568f5b478222cd5f","buildDate":"2018-11-06-21:27:31"}

As you can see, the answer is the same in all cases but it does not work for the last one.

Do you have any idea ?

Thanks

character limits with sqlite3

I just got around to kicking the tires with this project. Due to a copy/paste mistake, I discovered that there are virtually no character limits in most (maybe all) fields when using sqlite. For the most part, both the web interface and the mobile app deal with 1600 characters for application name and description along with message title and message. I have a feeling that is not the intended use case, as varchar(255) is used throughout the sqlite database.

Doing some digging, I learned that sqlite3 will allow the of use VARCHAR during creation, but it will only treat it as TEXT without the limit. See the sqlite section of this page. The sqlite documentation on limits state that sqlite3_limit needs to be used at run time to set SQLITE_LIMIT_LENGTH or it needs to be set at compile time. Looks like the run time option is possible with go-sqlite3.

FYI, my testing was done with the gotify/server docker container and sqlite3 3.26.0. Here is as high as my testing got:

$ sqlite3 gotify.db 'select length(message) from messages where id=17;'
46846

Websocket not picked up after connection error

I have the situation that gotify works reliably when I reload it's web-ui or android app, but will not receive anymore notifications after the websocket connection has been "disturbed" (which happens quite often). I can confirm that other websocket connections on the same server run without any issue.

It seems like the websocket connection is not reliably re-established. I'm happy to provide further (debug) information if pointed into a direction to debug.

Paginate Message APIs

Adjust APIs:

  • GET /application/{id}/message
  • GET /message

New Query Parameter:

  • limit=uint the amount of messages to return
  • since=date return all messages before this date (limited by limit)
  • since=id return all messages before the given message id

Expected Response:

{
    "paging": {
       "limit": 50,
       "next": "https://requesturl.com/message?limit=from-request&since=message-id"
    },
    "data": [
          {"id":12183,"appid":1,"message":"mymsg","title":"mytitle","priority":0,"date":"2018-03-20T19:30:51.596354+01:00"}
    ]
}

System authentication

Similar to issue #20 I would love to have the option to use my Linux system users to login to gotify. As a bonus maybe only those that belong to a certain group.

panic: pq: SSL is not enabled

I get an error when running the server with the following configuration:

server:
  port: 8001 # the port for the http server
  ssl:
    enabled: false # if https should be enabled
    redirecttohttps: true # redirect to https if site is accessed by http
    port: 8002 # the https port
    certfile: /etc/letsencrypt/live/doronbehar.com/fullchain.pem # the cert file (leave empty when using letsencrypt)
    certkey: /etc/letsencrypt/live/doronbehar.com/privkey.pem # the cert key (leave empty when using letsencrypt)
    letsencrypt:
      enabled: false # if the certificate should be requested from letsencrypt
      accepttos: false # if you accept the tos from letsencrypt
      cache: data/certs # the directory of the cache from letsencrypt
      hosts: # the hosts for which letsencrypt should request certificates
      - doronbehar.com
database: # for database see (configure database section)
  dialect: postgres
  connection: host=localhost port=5432 user=gotify dbname=gotify password=xxx

defaultuser: # on database creation, gotify creates an admin user
  name: admin # the username of the default user
  pass: admin # the password of the default user
passstrength: 10 # the bcrypt password strength (higher = better but also slower)
uploadedimagesdir: data/images # the directory for storing uploaded images

Error message:

Starting Gotify version 1.2.0@2018-11-24-11:06:13
Failed to find configuration config.yml
panic: pq: SSL is not enabled on the server

goroutine 1 [running]:
main.main()
        /home/travis/gopath/src/github.com/gotify/server/app.go:44 +0x425

The same error appears when enabling and disabling ssl.

Command line push client for Gotify

I created a command line push client, written in python, for Gotify that makes creating notifications from the CLI or from scripts a little easier. My client uses default values for each notification parameter, but parameters can be overridden by supplying the respective arguments.

Check it out at: https://github.com/schwma/gotify-push
Feel free to give me feedback on what to improve or create a pull request.

Sorry, I realize that this is not an issue with the server, but this is the best place I could think of to place this.

Accept POST messages without title

I'd like to use the requests for a application without always specifying a title for it. The title should not a mandatory field and if no title got specified we should always pick the application name for it. This also reduces the minimum size of a API request.

Pluggable extensions

It would be nice to have pluggable extensions for Gotify. This could f.ex. be used for polling the GitHub Notification API.

  • Golang Plugin API or some kind of JavaScript engine to enable pluggable code
  • ? Allow adding routes something like /plugin/:name/... (overkill ?!?)
    • Could be useful for webhooks
  • ? Users can enable plugins
  • ? Key-Value per user for configuration (f.ex authentication token)

Actionable notifications

This looks like a really cool project and something I've been looking for for a while.

Please correct me if I'm wrong on this but from the documentation it doesn't look like you support actionable notifications i.e. notifications containing one or two buttons underneath which perform the respective action when clicked.

An example use case of this is that my home automation system may send a notification telling me that I left my garage door open and provide a button to close the door.

I think the simplest/most flexible way to implement the action part would be via a webhook, so the sending application would need to specify both the label text and a callback URL for when the action is clicked.

Thanks again for the great project.

E2E Encryption support?

This would be a great feature to go along with the self-hosted aspect of this. By the way, love this tool!

Correctly show message newlines in Web-UI

Currently newline characters seem to be replaced by spaces in the messages Web-UI.

Example curl:
curl -X POST "http://localhost/message?token=<token>" -H "accept: application/json" -H "Content-Type: application/json" -d "{ \"message\": \"This\nis\na\n\ntest\", \"priority\": 0, \"title\": \"Test\"}"

data not saving

I can't get the app to create a database when running in docker. On restart, everything is back to default

Also, how do you correctly map the volume to config? -v /etc/config:/etc/config seems to be the only possibly way (yet it still says (failed to find configuration config.yml) but it works.

docker run -p 8456:80 -v /etc/gotify:/etc/gotify gotify/server

In the config, it wants data/gotify.db. However, no matter how I map it with -v , it does not save a file.

Loop rebooting with docker

Hi !

I've a little issue (I guess) with my yaml file.
I've created a docker-compose file with that:

version: '3'

services:
    gotify:
        image: gotify/server
        ports:
                - '127.0.0.1:2083:443'
        volumes:
                - /etc/gotify:/app/data
        restart: always
        environment:
                - GOTIFY_SERVER_SSL_ENABLED=true
                - GOTIFY_SERVER_SSL_REDIRECTTOHTTPS=true
                - GOTIFY_SERVER_SSL_PORT=443
                - GOTIFY_SERVER_SSL_LETSENCRYPT_ENABLED=false
                - GOTIFY_SERVER_SSL_LETSENCRYPT_ACCEPTTOS=false
                - GOTIFY_SERVER_SSL_LETSENCRYPT_CACHE=certs
                - GOTIFY_SERVER_SSL_LETSENCRYPT_HOSTS=- push.blabla.fr
                - GOTIFY_DATABASE_DIALECT=sqlite3
                - GOTIFY_DATABASE_CONNECTION=gotify.db
                - GOTIFY_DEFAULTUSER_NAME=monsieurpouet
                - GOTIFY_DEFAULTUSER_PASS=blabla
                - GOTIFY_UPLOADEDIMAGESDIR=images

But, when I launch my docker-compose, I see, in my docker logs, this error.
And my container, reboot constatly.

Starting Gotify version 1.2.1@2018-12-12-21:08:19
Started Listening on port 443
Started Listening on port 80
open : no such file or directory

Any ideas perhaps ?

Reverse proxy configuration (nginx)

Could someone please share his working reverse proxy configuration for nginx?

I am currently running gotify under it's own subdomain using a reverse proxy with nginx,
but my client keeps reconnecting a lot. I assume there is something wrong with my timeouts,
but I don't really know which values to chose.

Mark messages as read

  • Read bool to model.Message
  • POST /message/read Body: []uint
  • POST /message/unread Body: []uint

OAuth2 Authentication

  • make clientId, clientSecret and authoritzation server configurable
  • if user doesn't exist in the Gotify user management, try the oauth2 server

Bind to IP address

I would love to have the option to bind the gotify server to an IP address (in my case 127.0.0.1).

I run it behind an nginx reverse proxy under its own subdomain. Nginx takes care of HTTPS, so I only have HTTP enabled in gotify. I would like to only allow the localhost to connect to gotify.

I could easily do this with iptables (and I probably will until this is implemented) but I think a solution in the server would be more elegant.

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.