Skip to content

A push gateway between your PBX and the phones.

A phone cannot hold a SIP registration while it sleeps. The gateway holds it instead, and when a call arrives it wakes the phone with a push. You run it yourself, next to your PBX.

In testingSource

The gateway is built and in testing with the iOS and Android apps. There is no public release yet; the source is public.

What it does

It is a SIP back-to-back user agent with a REST API on the other side.

Registrations
Holds the SIP registration for each device against your registrar, so the PBX sees the phone as reachable whether or not the app is running. Transport, port, domain and registrar are set per device.
Incoming calls
Answers the PBX's INVITE with 100 Trying, then sends a push: an APNs VoIP push for iOS, a high-priority FCM data message for Android. The phone fetches the offer over HTTPS and answers through the API; the gateway completes the SIP side.
Outgoing calls
The app posts an SDP offer; the gateway sends the INVITE to the destination with the user's SIP credentials and returns the answer. Reject, hang up and BYE are API calls too.
Media
RTP flows directly between the PBX and the phone. The gateway carries signalling only.
Storage
SQLite, created on first run. No external database.
Authentication
JWT bearer tokens, issued from a user id and an API key you set in the config.
Built with
Rust: Axum for HTTP, sqlx for SQLite, and sip-5060 for SIP parsing and digest authentication, the same crate the desktop app uses.

How a call reaches a phone

The PBX talks SIP to the gateway. The phone talks HTTPS to the gateway.

The exchange below is the gateway's view of one incoming call to an iPhone. Lines in amber leave the gateway; lines in green arrive at it. The push and the two HTTP requests are the parts the PBX never sees.

INVITE for alice@pbx.example.comSIP/2.0
  1. 0.000← INVITE sip:alice@pbx.example.com from PBX
  2. 0.002→ 100 Trying to PBX
  3. 0.004→ PUSH APNs VoIP push: call_token, caller
  4. 0.611← GET /v1/calls/{token} phone wakes
  5. 0.613→ 200 SDP offer, caller info
  6. 3.870← POST /v1/calls/{token}/accept sdp_answer
  7. 3.872→ 200 OK SDP from the phone to PBX
  8. 3.901← ACK from PBX
200 OK sent; RTP now runs between the PBX and the phone

On the phone, the push is handed to CallKit or to Android's ConnectionService, so the native incoming-call screen appears before the app has finished waking. If the user declines, the app posts to/v1/calls/{token}/reject and the gateway returns 603 to the PBX.

API

Twelve routes. POST /v1/auth/token issues the bearer token the rest require; /health is open.

MethodPathWhat it does
POST/v1/auth/tokenIssue a bearer token for a user id. An API key is optional, set in the config.
POST/v1/devicesRegister a device: platform, push token, SIP account and registrar.
GET/v1/devices/{id}The device and its SIP registration status.
DELETE/v1/devices/{id}Unregister a device.
POST/v1/devices/{id}/heartbeatKeep the device's registration alive.
POST/v1/callsStart an outgoing call; the gateway sends the INVITE.
GET/v1/calls/{token}Fetch an incoming call: SDP offer and caller.
POST/v1/calls/{token}/acceptAnswer with an SDP answer.
POST/v1/calls/{token}/rejectDecline; the gateway sends 603 to the PBX.
POST/v1/calls/{token}/hangupEnd the call; the gateway sends BYE.
GET/v1/calls/{token}/statusThe call's state.
GET/healthReturns ok.

The mobile apps use this API through aria-mobile-core. Nothing stops another client from using it.

Running it

One binary, one TOML file, a SQLite database it creates itself.

Network
UDP to your SIP server for REGISTER and INVITE traffic, and outbound HTTPS to APNs and FCM.
Push credentials
An APNs authentication key (.p8) for iOS, a Firebase service account JSON for Android, or both. The gateway starts without either but cannot then deliver incoming calls.
TLS
Put it behind a reverse proxy such as nginx, Caddy or Traefik for HTTPS. The apps connect over HTTPS.
DNS
A subdomain, for example gateway.example.com, pointed at the server.
Hardware
1 vCPU and 256 MB RAM handles hundreds of concurrent registrations; about 10 MB of disk for the binary and database. Linux, macOS or anything Rust targets.

Build

cargo build --release
# binary: target/release/aria-gateway

Configure

cp gateway.example.toml gateway.toml
# set auth.secret and the push provider credentials

The example file, with the push sections filled in. Configure at least one of APNs or FCM.

[server]
listen = "0.0.0.0:8080"
public_url = "https://gateway.example.com"

[database]
url = "sqlite:gateway.db?mode=rwc"

[auth]
secret = "CHANGE-ME-TO-A-STRONG-RANDOM-SECRET"
token_expiry_secs = 2592000

[push.apns]
key_path = "/path/to/AuthKey_XXXXXXXXXX.p8"
key_id = "XXXXXXXXXX"
team_id = "XXXXXXXXXX"
bundle_id = "com.example.aria"
sandbox = false

[push.fcm]
service_account_path = "/path/to/firebase-service-account.json"
project_id = "your-firebase-project-id"

Run

./target/release/aria-gateway --config gateway.toml
# listens on 0.0.0.0:8080 by default; override with --listen
./target/release/aria-gateway --listen 0.0.0.0:443

Docker

The image builds from the parent directory of the checkout; see the Dockerfile.

# from the parent directory of the push-gateway checkout
docker build -f push-gateway/Dockerfile -t aria-gateway .
docker run -d -p 8080:8080 -v /path/to/data:/data --name aria-gateway aria-gateway
# mount gateway.toml, the APNs .p8 key and the FCM service account JSON into /data

Status

Built, in testing, not released.

In testing

The gateway is being tested with the iOS and Android apps. There are no binaries or images published yet; you can build it from source. The desktop app does not need it.

The gateway's licence is proprietary to 5060 Solutions. The crates it is built on areMIT or Apache-2.0.

Source on GitHub