savoirfairelinux / opendht

OpenDHT: a C++17 Distributed Hash Table implementation
GNU General Public License v3.0
1.03k stars 172 forks source link

Supports Push notifications for mobile clients #225

Closed AmarOk1412 closed 6 years ago

AmarOk1412 commented 7 years ago

Problem

On some platforms (like iOs), you can't really have a node running in background h24. We currently have the proxy, but we need to maintain the connection for listeningoperations.

Solution

Have the possibility to supports push notifications on the proxy node.

Warning

This option must be disabled by default. It breaks the distribution... because the proxy should have the certif for the app.

How

Add SUBSCRIBEand UNSUBSCRIBE to DhtProxyServer. Subscribe will perform a Listen on the DHT and send values for the device (he must have a key) and return a token. Unsubscribe will do a cancelListen.

Because a client can not call unsubscribe we must have a timeout to remove old listen operations.

When the proxy server receives a value, it will send a push notification. To avoid tools like Firebase, we can host our own push notification server like https://github.com/appleboy/gorush. Sadly, it will use GCM or FCM for android and APN for iOs (if anyone know another viable solution)...

For Fdroid, this option must be disabled, and we will use listen like before (with or without DHT Proxy).

Things to determine

  1. Which alternative for push notification server? Currently gorush because it's under MIT License, looks like popular and active.
  2. Subscribe and Unsubscribe should be done on the same node to works. So we have a problem if we use a load balancer. Maybe we will need a new message on the DHT to cancel

screenshot-2017-11-29 https mermaidjs github io 1

AmarOk1412 commented 6 years ago

Ok.

What I developped is basically the same system described https://matrix.org/docs/spec/push_gateway/unstable.html. The only difference is we also pass encrypted values in the notification and they just use the notification as a wake-up notification. (We also use it has a wake up notification to enable the daemon and decrypt the data on the phone).

AmarOk1412 commented 6 years ago

screenshot-2017-12-15 https mermaidjs github io