Giter VIP home page Giter VIP logo

pennersr / shove Goto Github PK

View Code? Open in Web Editor NEW
266.0 7.0 24.0 139 KB

Asynchronous & persistent push notification service, supporting APNS, FCM, Web Push, Telegram and Email. Written in Go (Golang). Mirror of https://gitlab.com/pennersr/shove

Home Page: https://gitlab.com/pennersr/shove

License: MIT License

Go 100.00%
golang apns gcm fcm webpush-notifications webpush notifications ios-notifications android-notifications android

shove's People

Contributors

pennersr 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

shove's Issues

Email service config to support disabling of TLS

Hi, I would very like to use this project as my push notification service in production.
I'm currently using the email service. However due to some network restriction from my department, I am only able to send email without TLS.

I've looked through the implementation and saw the the email service uses https://github.com/jordan-wright/email package.
As you've already encoded the data nicely in body I can recreate the *Email object and send it using the email package.
With the extra config at the end &tls.Config{InsecureSkipVerify: true} I was able to send the email out successfully.

It would be great if we could include additional settings to configure the email client when sending out the email.
I added the snippet which I am using now. Do let me know if it make sense and whether I can help to contribute to the core codes.

func (ec EmailConfig) send(from string, to []string, body []byte, fc services.FeedbackCollector) error {
        t := time.Now()
        email, _ := jwemail.NewEmailFromReader(bytes.NewReader(body))
        err := email.SendWithStartTLS(fmt.Sprintf("%s:%d", ec.EmailHost, ec.EmailPort), nil, &tls.Config{InsecureSkipVerify: true})
        duration := time.Since(t)
        fc.CountPush(serviceID, err == nil, duration)

        if err != nil {
                ec.Log.Printf("[ERROR] Send failed: %s", err)
                return err
        }
        return nil
}

feedback API hangs and times out

Setup: Using FCM alone with shove (with and without Redis)

curl -X POST 'http://x.x.x.x:8322/api/feedback'

curl: (7) Failed to connect to x.x.x.x port 8322: Connection timed out

Using Redis queue throws 404

Apologies, if this any issue with the calling syntax.

Setup: Using FCM alone with shove

It works without Redis, but with Redis, it throws 404. Also, it misses FCM workers started message

Works without Redis

shove -api-addr x.x.x.x:8322 -fcm-api-key xxxxxx
2020/12/29 15:00:53 Using non-persistent in-memory queue
2020/12/29 15:00:53 Initializing FCM service
2020/12/29 15:00:53 Shove server started
2020/12/29 15:00:53 FCM workers started
curl  -i  --data '{"to": "XXXXX", "notification": {"title": "Hello"}}' http://x.x.x.x:8322/api/push/fcm

HTTP/1.1 202 Accepted
Date: Tue, 29 Dec 2020 14:47:44 GMT
Content-Length: 2
Content-Type: text/plain; charset=utf-8

OK

Not working with Redis

shove -api-addr x.x.x.x:8322 -queue-redis redis://redis:6379 -fcm-api-key xxxxx
2020/12/29 15:04:46 Using Redis queue at redis://redis:6379
2020/12/29 15:04:46 Initializing FCM service
2020/12/29 15:04:46 Shove server started
curl  -i  --data '{"to": "XXXXX", "notification": {"title": "Hello"}}' http://x.x.x.x:8322/api/push/fcm


HTTP/1.1 404 Not Found
Content-Type: text/plain; charset=utf-8
X-Content-Type-Options: nosniff
Date: Tue, 29 Dec 2020 15:10:09 GMT
Content-Length: 19

404 page not found

Other attempts

Instead of redis://redis:6379, tried redis://localhost:6379 and localhost:6379 too.

Redis queue docs

I think it would be really useful to provide more docs about the redis queue support in the readme, as that is the biggest feature for me.

For example, what do I need to do to add an item to the redis queue? What is the stream name?

Build / setup steps for CentOS 7

FWIW, for anyone looking to find build instruction. Below steps are tested in DigitalOcean CentOS 7 droplet.

# Prepare...
# Current directory...
[root@centos-s-1vcpu-1gb-nyc3-01 ~]# pwd
/root
# Check CentOS version...
[root@centos-s-1vcpu-1gb-nyc3-01 ~]# cat /etc/centos-release
CentOS Linux release 7.9.2009 (Core)
# go to /opt/
[root@centos-s-1vcpu-1gb-nyc3-01 ~]# cd /opt/
# Download shove source from git...
[root@centos-s-1vcpu-1gb-nyc3-01 opt]# wget https://github.com/pennersr/shove/archive/master.zip
# Rename file...
[root@centos-s-1vcpu-1gb-nyc3-01 opt]# mv master.zip shove.zip
# Unzip...
[root@centos-s-1vcpu-1gb-nyc3-01 opt]# unzip shove.zip
# Check files and folder...
[root@centos-s-1vcpu-1gb-nyc3-01 opt]# ls
shove-master  shove.zip
# Rename folder...
[root@centos-s-1vcpu-1gb-nyc3-01 opt]# mv shove-master/ shove
[root@centos-s-1vcpu-1gb-nyc3-01 opt]# ls
shove  shove.zip

# Install go...
[root@centos-s-1vcpu-1gb-nyc3-01 opt]# wget https://golang.org/dl/go1.15.6.linux-amd64.tar.gz
[root@centos-s-1vcpu-1gb-nyc3-01 opt]# tar -C /usr/local -xzf go1.15.6.linux-amd64.tar.gz
[root@centos-s-1vcpu-1gb-nyc3-01 opt]# export PATH=$PATH:/usr/local/go/bin
# Check go version...
[root@centos-s-1vcpu-1gb-nyc3-01 opt]# go version
go version go1.15.6 linux/amd64

# Install redis...
[root@centos-s-1vcpu-1gb-nyc3-01 opt]# yum install epel-release
[root@centos-s-1vcpu-1gb-nyc3-01 opt]# yum install redis
[root@centos-s-1vcpu-1gb-nyc3-01 opt]# systemctl start redis.service
# Check redis...
[root@centos-s-1vcpu-1gb-nyc3-01 opt]# redis-cli -h localhost ping
PONG

# Build shove...
[root@centos-s-1vcpu-1gb-nyc3-01 opt]# cd shove
[root@centos-s-1vcpu-1gb-nyc3-01 shove]# mkdir build
[root@centos-s-1vcpu-1gb-nyc3-01 shove]# go build -o build ./...
[root@centos-s-1vcpu-1gb-nyc3-01 shove]# cd build
[root@centos-s-1vcpu-1gb-nyc3-01 build]# chmod +x shove
[root@centos-s-1vcpu-1gb-nyc3-01 build]# mkdir -p /usr/local/shove/bin
[root@centos-s-1vcpu-1gb-nyc3-01 build]# mv shove /usr/local/shove/bin/

# Setup firewall and open port 8322; otherwise couldn't access through IP:8322
[root@centos-s-1vcpu-1gb-nyc3-01 build]# yum install firewalld
[root@centos-s-1vcpu-1gb-nyc3-01 build]# systemctl enable firewalld
[root@centos-s-1vcpu-1gb-nyc3-01 build]# reboot
[root@centos-s-1vcpu-1gb-nyc3-01 ~]# firewall-cmd --permanent --add-port=8322/tcp
success
[root@centos-s-1vcpu-1gb-nyc3-01 ~]# firewall-cmd --reload


# Now execute something like:
/usr/local/shove/bin/shove -api-addr x.x.x.x:8322 -fcm-api-key xxxxxxx

WebPush using VAPID, error: illegal base64 data at input byte 0

Hello. Launched your project to send WebPush notifications. Checking sending using VAPID.
curl -i --data '{"subscription": {"endpoint":"https://fcm.googleapis.com/fcm/send/cUGz6wv7OH0:APA91bHqwewkZFJ5oouwv0jZOYpwlsN3jg7n_83dnzbL5SCU5xNkTlcA9ozP0eOIHP3mkASJIkO1Idakd7j9atSugofRZEowo9N8YpTE9Qars6B6wCLkdpe5PKmNX0BP5fNTkKoRamZA","keys":{"auth": "ZmdkuTkUN0NTvsQqV7SUIA", "p256dh": "BBYQ484rGdY-HfEjAjGQUHH0k1KDmgsy6CnVcbr2l0SYZK1amCTVvNcbUCJazcawAMPOCcNkG0Omu3m2Scb9WoU"}}, "headers": {"ttl": 3600, "urgency": "high"}, "token": "token-1", "payload": {"hello":"world"}}' http://localhost:8322/api/push/webpush

I see an error in the console:
Shove error sending: illegal base64 data at input byte 0

If you make an error in the p256dh key, an error will occur:
Unmarshal Error: Public key is not a valid point on the curve

That is, presumably the first error occurs below this line:
https://github.com/SherClockHolmes/webpush-go/blob/358c5ab877144efa20d3e889826d31d45ea3bec2/webpush.go#L101

There may be a problem with incorrectly passing JSON to the library.

What am I doing wrong? Does WebPush using VAPID work correctly for you?

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.