smpp-receiver

command
v0.0.0-...-92d0236 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 4, 2022 License: MIT Imports: 15 Imported by: 0

README

SMPP Receiver

This simple program receive deliver_sm message and call a local hook function

Configuration

Write to configure.json file:

{
  "hook": "./send-email.py",
  "devices": [
    {
      "smsc": "target ip:target port",
      "password": "your password",
      "system_id": "tenant-1"
    },
    { "system_id": "tenant-2" }
  ]
}

Sample hook script:

#!/usr/bin/env python3
import json

import requests

payload = json.load(sys.stdin)
"""
{
    "smsc": "[login smsc address]",
    "system_id": "[login system id]",
    "system_type": "[login system type]",
    "source": "[source phone number]",
    "target": "[target phone number]",
    "message": "[merged message content]",
    "deliver_time": "[iso8601 formatted]"
}
"""

to_addresses = {
    "tenant-1": "tenant one addresses",
    "tenant-2": "tenant two addresses",
}

data = {
    "to": to_addresses[payload["system_id"]],
    "from": "%(target)s <[your from address]>" % payload,
    "subject": payload["source"],
    "text": "%(message)s\n\nDate: %(deliver_time)s" % payload
}

requests.post(
    "https://api.mailgun.net/v3/[your api domain]/messages",
    auth=("api", "your api token"),
    data=data,
)

Sample systemd service file:

[Unit]
Description=SMPP Receiver

[Service]
Type=simple
WorkingDirectory=/opt/smpp-receiver
ExecStart=/opt/smpp-receiver/smpp-receiver-linux-arm
Restart=on-failure
RestartSec=1m
Environment="TZ=Asia/Shanghai"

[Install]
WantedBy=multi-user.target

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL