Skip to content

smswithoutborders/RelaySMS-Gateway-Server

Repository files navigation

SMSWithoutBorders Gateway Server

API References

Requirements

Dependencies

On Ubuntu, install the following dependencies:

sudo apt install python3-dev libmysqlclient-dev apache2 apache2-dev make libapache2-mod-wsgi-py3

Note

The gateway server has strong dependencies on the Backend User Databases.

Linux Environment Variables

Variables used for the Project:

  • MYSQL_HOST
  • MYSQL_USER
  • MYSQL_PASSWORD
  • MYSQL_DATABASE
  • SHARED_KEY
  • HASHING_SALT
  • ORIGINS
  • HOST
  • PORT
  • RMQ_HOST
  • RABBITMQ_DEFAULT_USER
  • RABBITMQ_DEFAULT_PASS
  • IMAP_SERVER
  • IMAP_PORT
  • IMAP_USERNAME
  • IMAP_PASSWORD
  • MAIL_FOLDER
  • FTP_USERNAME
  • FTP_PASSWORD
  • FTP_IP_ADDRESS
  • FTP_PORT
  • FTP_PASSIVE_PORTS
  • FTP_READ_LIMIT
  • FTP_WRITE_LIMIT
  • FTP_MAX_CON
  • FTP_MAX_CON_PER_IP
  • FTP_DIRECTORY
  • DEKU_CLOUD_URL
  • DEKU_CLOUD_PROJECT_REF
  • DEKU_CLOUD_SERVICE_ID
  • DEKU_CLOUD_ACCOUNT_SID
  • DEKU_CLOUD_AUTH_TOKEN
  • SSL_CERTIFICATE
  • SSL_KEY

Installation

Clone the Repository

Clone the SMSWithoutBorders Gateway Server repository from GitHub:

git clone https://github.com/smswithoutborders/SMSWithoutBorders-Gateway-Server.git
cd SMSWithoutBorders-Gateway-Server

Install all Python packages:

Pip

python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt

Build and Run with Docker

  1. Build Docker Image:

    Ensure you have Docker installed on your system. Then, navigate to the root directory of the cloned repository and run the following command to build the Docker image:

    docker build -t smswithoutborders-gateway-server .

    Replace smswithoutborders-gateway-server with your desired image name.

  2. Run Docker Container:

    After the image is built, run a Docker container using the following command:

    docker run -d -p 5000:5000 --name gateway-server smswithoutborders-gateway-server

    Adjust the port mapping (-p) and container name (--name) as needed.

  3. Verify Container:

    Verify that the container is running by checking its status:

    docker ps

    This should display the running containers, including the SMSWithoutBorders Gateway Server container.

Running

For quicker development, you can integrate the BE Dependencies databases.

In cases where the BE Database and Gateway server share the same database:

MYSQL_HOST=host \
MYSQL_PORT=port \
MYSQL_USERNAME=username \
MYSQL_DATABASE=dbname \
flask --debug --app src.main run

In cases where the BE Database and Gateway server don't share the same database:

MYSQL_HOST=host \
MYSQL_PORT=port \
MYSQL_USERNAME=username \
MYSQL_DATABASE=dbname \
MYSQL_BE_HOST=host \
MYSQL_BE_PORT=port \
MYSQL_BE_USERNAME=username \
MYSQL_BE_DATABASE=dbname \
flask --debug --app src.main run

Use cases

Synchronization

Synchronization prepares the app for secured conversation using shared keys.

Synchronization flow

  1. Begin by requesting a new session: GET /<api-version>/sync/users/<user-id>

    This returns a URL string, which can be connected to by websocket clients. 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 (defaults = 15 seconds).

    The total number of changes per frequency can be changed (defaults = 3 times).

    Response:

    • 200: session created
    • 500: some error occurred, check debug logs
  2. Once a sync URL is connected and begins processing, the websocket sends a pause text 201- pause. The user begins authenticating themselves and adding their security policies to their record on the server.

  3. Once the user has performed the necessary handshake and the information exchange has begun, the websocket sends an acknowledgment text 200- ack.

Reliability Tests

The Reliability Tests CLI (rt_cli) can be used to trigger and view reliability tests for gateway clients. Refer to the Reliability Tests CLI documentation for usage and installation instructions.

Gateway Clients Management

The Gateway Clients CLI (gc_cli) provides functionality to create, view, and update gateway client records. Check out the Gateway Clients CLI documentation for more details on usage and installation.

Testing

python -m unittest gateway_server/test/UTestUsers.py

Install websocat and jq:

Manjaro:

sudo pacman -S websocat jq

Test websocket:

websocat ws://localhost:6996/v2/sync/init/111/000
python -m unittest test/security_rsa.py
  • Testing Entire Handshake process: This will require pem files. Copy them into the test/ directory to allow the test run.
./test/handshake.sh

Scripts

FTP Server

MYSQL_HOST= \
MYSQL_USER= \
MYSQL_PASSWORD= \
MYSQL_DATABASE= \
FTP_USERNAME= \
FTP_PASSWORD= \
FTP_IP_ADDRESS= \
FTP_PORT= \
FTP_PASSIVE_PORTS= \
FTP_READ_LIMIT= \
FTP_WRITE_LIMIT= \
FTP_MAX_CON= \
FTP_MAX_CON_PER_IP= \
FTP_DIRECTORY= \
SSL_CERTIFICATE= \
SSL_KEY= \
python3 -m src.ftp_server

IMAP Listener

MYSQL_HOST= \
MYSQL_USER= \
MYSQL_PASSWORD= \
MYSQL_DATABASE= \
IMAP_SERVER= \
IMAP_PORT= \
IMAP_USERNAME= \
IMAP_PASSWORD= \
MAIL_FOLDER= \
SSL_CERTIFICATE= \
SSL_KEY= \
python3 -m src.imap_listener

About

Gateway-servers enables the users to synchronize and communicate with the publisher module

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published