RelaySMS Gateway Server
Gateway-servers enables the users to synchronize and communicate with the publisher module
- How to setup and use Gateway Server
The most recent version of this guide can be found in the `github reposistory
The frontend integrates with these services. you may need to set them up depending on what section you are working on.
Requirements
- python3
Features
-
Message broker server for Gateway-Client (_see SMSWithoutBorders-OpenAPI)
-
SMSWithoutBorders-App synchronization for communication with Publisher
This should should be hosted in the same place as Publisher, because Publisher is not directly exposed to the web.
-
Forwards publishing request from Gateway-Client to Publisher
-
Authenticates Gateway-Client's request to join Publisher
Installation
https://github.com/smswithoutborders/SMSWithoutBorders-Gateway-Server.git
git submodule update --force --recursive --init --remote
cd SMSWithoutBorders-Gateway-Server
python3 -m virtualenv venv
. venv/bin/activate
pip3 install -r requirements.txt
Optionally, run make
to install git hooks
Directory structure
/gateway_server
Contains the Gateway server websocket sessions which is required to synchronize users.
Configuration
Configuring gateway's API
- Copy the config files and edit the
cp confs/example.conf.ini confs/conf.ini
Configuring gateway server
- Copy the config files and edit the
cp gateway_server/confs/example.conf.ini gateway_server/confs/conf.ini
Usage
Gateway API
Manually start Gateway API
. venv/bin/activate
python3 main.py
- Get List of available Nodes
/seeds
For example
curl localhost:6969/seeds -H "Content-Type: application/json"
Returns
[
{
"IMSI": "sample_IMSI",
"LPS": 1648206122.81431,
"MSISDN": "sample_MSISDN",
"seed_type": "seed"
}
]
- Add Gateway to active Gateways
/ping
For example
curl -X POST \
localhost:6969/seeds/ping \
-d '{"IMSI":"sample_IMSI", "MSISDN":"sample_MSISDN", "seed_type":"seed"}' \
-H "Content-Type: application/json"
Returns the LPS of current session. LPS = Last ping session
Synchronization
Synchronization is required to enable the users acquire security keys, platforms and available gateways.
Manually setup sessions websocket
. venv/bin/activate
python3 gateway_server/sessions_websocket.py
Configurations
All configurations for websockets can be done in the conf.ini
file in gateway_server
session_change_limit
: Number of times client websocket will receive session change urls
session_sleep_timeout
: Number of seconds to sleep after sending a session change url to the client
session_paused_timeout
: Number of seconds to remain in paused state before closing connection
Synchronization flow
- Begin by requesting for a new session:
GET /<api-version>/sync/users/<user-id>
This returns a string url, which can be connected to by websocket clients. The users can begin communicating with this
returned URL or scan them through the QR scan function in the app. The frequency of change of the synchronization urls depends
on the configuration settings [sync] session_sleep_timeout
(defaults = 15 seconds).
The total number of changes per frequency can be changed in [sync] session_change_limit
(defaults = 3 times)
200
session created
500
some error occured, check debug logs
-
Once a sync url is connected and begins processing, the websocket sends a pause text
201- pause
The user begins authentictating themselves and adding their security policies to their record on the server. -
Once the user has performed the necessary handshake and the information exchange has begun, the websocket sends an acknowledgment text
200- ack
Testing
- Testing Users model
python -m unittest gateway_server/test/UTestUsers.py
- Testing WebSockets
Manjaro_
sudo pacman -S websocat jq
Testing websocket_
websocat ws://localhost:6996/v2/sync/init/111/000
- Testing RSA Encryption/Decryption This will require pem files. Copy them into the test/ dir to allow test run
python -m unittest test/security_rsa.py
- Testing Entire Handshake process This will require pem files. Copy them into the test/ dir to allow test run
./test/handshake.sh