Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
130 commits
Select commit Hold shift + click to select a range
7f83be2
tools/hss_Async_client: fix parsing config twice
osmith42 Sep 26, 2025
d462970
lib/S6a_crypt: remove unused config loading
osmith42 Oct 9, 2025
cb9e8d0
tools/MIB_generator: remove unused config loading
osmith42 Oct 9, 2025
a3343fb
tools/databaseUpgrade/alembic/env: config -> alembic_config
osmith42 Oct 9, 2025
c71b0c7
Rework loading of config.yaml
osmith42 Oct 9, 2025
66bf348
lib/milenage: remove unused sys.path.append
osmith42 Oct 9, 2025
31a6719
Fix running services outside of source tree
osmith42 Oct 9, 2025
33ee7a3
services: add main() functions
osmith42 Sep 26, 2025
4362227
pyproject.toml: new file
osmith42 Sep 26, 2025
0fc7ac4
GSUP: fix responding to unhandled requests
osmith42 Nov 10, 2025
940c6e7
Merge pull request #272 from osmith42/fix-gsup-unhandled-requests
Takuto88 Nov 10, 2025
a3d35ce
feat(docker): one container per service
Takuto88 Oct 31, 2025
e6952c3
feat(docker): add docker ignore file
Takuto88 Nov 5, 2025
6557fbf
docs(docker): Document docker compose + configuration
Takuto88 Nov 6, 2025
6c2899f
docs(changelog): Add docker images in the unreleased section
Takuto88 Nov 6, 2025
e8c2cb0
chore(ci): delete unused workflow file
Takuto88 Nov 6, 2025
01c016e
fix(ci): Update CI commands to build the new image
Takuto88 Nov 6, 2025
1537be1
fix(docker): Ensure irrelevant dirs are omitted
Takuto88 Nov 7, 2025
e4c959f
fix(docker): Ensure log directory is app writable
Takuto88 Nov 7, 2025
75b864c
GSUP: Update Location Request: no destination name
osmith42 Nov 14, 2025
d8f0a31
Merge pull request #273 from osmith42/osmith/no-dest-name-ie
Takuto88 Nov 16, 2025
94105a6
Merge pull request #269 from Takuto88/feat/docker-compose
osmith42 Nov 18, 2025
10eb458
Merge pull request #258 from osmith42/osmith/rework-config-loading
osmith42 Nov 18, 2025
cf6ebbe
systemd: remove extra empty line before [Service]
osmith42 Nov 18, 2025
f26f89f
systemd/pyhss_api.service: move API service here
osmith42 Nov 18, 2025
3c4c7ea
docs/API: update command for starting API service
osmith42 Nov 18, 2025
20d0b8a
debian: initial
osmith42 Mar 21, 2025
6189741
chore(docker): improve IDE experience
Takuto88 Nov 19, 2025
f0b1ec4
docs(readme): Document how to run through the IDE in docker
Takuto88 Nov 19, 2025
7e0ab82
github: add workflow for the debian package
osmith42 Nov 19, 2025
9a303c2
FIXUP Readme
Takuto88 Nov 19, 2025
7afa965
Merge pull request #276 from Takuto88/chore/docker-ide-improvements
osmith42 Nov 19, 2025
92e3ad2
GSUP: don't merge pdp_info IEs
osmith42 Nov 20, 2025
753810f
GSUP: msg builder with pdp: remove empty qos
osmith42 Nov 20, 2025
dd076c8
Merge pull request #278 from osmith42/osmith/gsup-dont-merge-pgp-info…
Takuto88 Nov 21, 2025
6a1518a
Merge pull request #279 from osmith42/osmith/remove-empty-qos
Takuto88 Nov 21, 2025
48f6620
refactor(gsup): make SubscriberInfo generic + fix APNs
Takuto88 Nov 19, 2025
16e9423
refactor(ulr): use generic base transaction
Takuto88 Nov 19, 2025
09de6fc
refactor(ulr): centralize ISD creation
Takuto88 Nov 19, 2025
8d0a03a
chore(ulr): fix imports + typehints
Takuto88 Nov 19, 2025
5735707
feat(gsup): Update subscriber on change
Takuto88 Nov 19, 2025
3e5e52a
fix: use monotonic clock
Takuto88 Nov 21, 2025
3f0e2dd
fix(gsup): always add CN domain to ISD
Takuto88 Nov 21, 2025
fd1852b
fix(gsup): add stack trace to log
Takuto88 Nov 21, 2025
e2b3816
fix(gsup): use APN DB ID as PDP context id
Takuto88 Nov 21, 2025
ae3cc4b
fix(gsup): only include imsi IE once in ULA
Takuto88 Nov 21, 2025
7b07236
chore(gsup): move CN IE to end
Takuto88 Nov 24, 2025
22886eb
Merge pull request #277 from Takuto88/feat/gsup-msisdn
Takuto88 Nov 24, 2025
29bd4ec
feat(ci): publish debian packages on release
Takuto88 Nov 24, 2025
b767882
github: temporarily disable publishing debian pkg
osmith42 Nov 25, 2025
271111e
Merge pull request #275 from osmith42/osmith/debian-packaging
Takuto88 Nov 25, 2025
b796835
Revert "github: temporarily disable publishing debian pkg"
Takuto88 Nov 26, 2025
f6eef01
Merge pull request #281 from Takuto88/chore/enable-debian-package
osmith42 Nov 26, 2025
281ef8c
fix(debian): use correct tag scheme
Takuto88 Nov 26, 2025
3b90433
Merge pull request #282 from Takuto88/fix/tag-scheme
osmith42 Nov 26, 2025
be43f4d
tests: add pytest configs and fixtures
osmith42 Nov 21, 2025
a660ed2
tests/test_Diameter: fix test_A_Instantiate
osmith42 Nov 21, 2025
3461d96
tests/test_Diameter: rework test_B_Recv_AIR
osmith42 Nov 21, 2025
2e43f3f
tests/test_gsup_air: run with pytest
osmith42 Nov 21, 2025
59be2c6
tests/test_gsup_air: add asserts for response msgs
osmith42 Nov 21, 2025
ce96641
tests/test_API: rename from tests_API
osmith42 Nov 24, 2025
c00617d
tests/test_API: remove 'global log' line
osmith42 Nov 24, 2025
a3a385a
tests/test_API: use pytest fixtures
osmith42 Nov 24, 2025
83b1215
tests/test_API: use localhost:8080
osmith42 Nov 24, 2025
e5da94d
tests/test_API: compare without last_modified
osmith42 Nov 24, 2025
ad1e3ef
tests/test_API: APN_Tests: update payload
osmith42 Nov 24, 2025
a5d5686
tests/test_API: AUC_Tests: add missing algo
osmith42 Nov 24, 2025
cc60b03
tests/test_API: unset unittest.TestCase.maxDiff
osmith42 Nov 24, 2025
7942ebf
tests/test_API: Subscriber: update payload
osmith42 Nov 24, 2025
353a777
tests/test_API: GeoRed_MME: update payload
osmith42 Nov 24, 2025
269d9a6
tests/test_API: GeoRed_MME: fix patch payloads
osmith42 Nov 24, 2025
1498838
tests/test_API: GeoRed_IMS: update payload
osmith42 Nov 24, 2025
62d5f21
services/apiService: fix error code paths
osmith42 Nov 24, 2025
b4971e9
tests/test_database: split from lib/database
osmith42 Nov 25, 2025
bb7bc9e
tests/test_database: fix call to Database()
osmith42 Nov 25, 2025
e22caa3
tests/test_database: create auc: use bytes.hex
osmith42 Nov 25, 2025
743d043
lib/database: fix declarative_base warning
osmith42 Nov 21, 2025
24451bc
lib/database: fix inspector warning
osmith42 Nov 21, 2025
68d97af
lib/database: fix Query.get() warning
osmith42 Nov 26, 2025
96a4aa4
README: describe how to run tests
osmith42 Nov 24, 2025
92c0a6c
gitignore: add .venv
osmith42 Nov 27, 2025
833284b
github/workflows/test: new workflow
osmith42 Nov 24, 2025
f39aea6
tests/fixtures: proper error if redis is not installed
osmith42 Nov 27, 2025
1e80e96
tests: remove code for running standalone
osmith42 Nov 27, 2025
82ae231
Merge pull request #280 from osmith42/osmith/tests-in-ci
Takuto88 Nov 27, 2025
8e4a1da
config: remove unused hss.test_sub_imsi
osmith42 Nov 27, 2025
11d41e8
config: remove unused hss.SLh_enabled
osmith42 Nov 27, 2025
0bb77b8
config: remove duplicate hss.client_socket_timeout
osmith42 Nov 27, 2025
3c1a08b
config: remove unused hss.Insert_Subscriber_Data_Force
osmith42 Nov 27, 2025
dd6be14
config: remove unused prometheus section
osmith42 Nov 27, 2025
f0cfa9e
config: remove unused hss.Default_iFC
osmith42 Nov 28, 2025
7a2fac9
config: remove unused redis.sentinel
osmith42 Nov 28, 2025
5a5623d
Merge pull request #284 from osmith42/osmith/remove-test-sub-imsi
osmith42 Nov 28, 2025
a449baa
feat(gsup): implement RAT restriction check
Takuto88 Nov 26, 2025
e6dc73d
feat(diameter): implement RAT restriction
Takuto88 Nov 27, 2025
566d433
fix(diameter): remove incorrect kwargs
Takuto88 Nov 29, 2025
9c5a740
fix(diameter): use the orign hostname as redis key
Takuto88 Nov 29, 2025
dedb5e7
fix: install strenum on earlier python versions
Takuto88 Nov 29, 2025
c62d90f
apiService: drop a lot of print()
lynxis Dec 1, 2025
c39d478
Merge pull request #287 from lynxis/feat/api-reduce-print
osmith42 Dec 2, 2025
cc61ccd
lib/{lte,milenage}: update copyright and license
osmith42 Dec 1, 2025
a37a510
treewide: update copyright and license lines
osmith42 Dec 1, 2025
7f946d1
tests: add new license headers test
osmith42 Dec 1, 2025
caf99c1
tests/test_API: ChargingRule: remove last_modified
osmith42 Dec 2, 2025
4668928
Merge pull request #288 from osmith42/osmith/test-charging-rule-last-…
Takuto88 Dec 3, 2025
34eac3c
fix: consistent behavior if RAT type IE is missing
Takuto88 Dec 8, 2025
8f87ff7
Merge pull request #283 from Takuto88/feat/rat-restrictions
Takuto88 Dec 9, 2025
d22be1a
README: link to matrix room
osmith42 Dec 9, 2025
44b828d
config: remove readCache{Enabled,Interval} options
osmith42 Dec 9, 2025
423220d
config: database: default to sqlite
osmith42 Dec 9, 2025
0d7fdda
tests/config: remove DB server, username, password
osmith42 Dec 9, 2025
120c351
tests/config: remove redis/sentinel options
osmith42 Dec 9, 2025
c4c9914
README: update supported databases
osmith42 Dec 9, 2025
8148360
CHANGELOG: make formatting consistent
osmith42 Dec 9, 2025
57dc048
CHANGELOG: update
osmith42 Dec 9, 2025
b7ac56d
gitignore: add hss.db
osmith42 Dec 9, 2025
72fd79a
Merge pull request #291 from osmith42/sqlite-default
osmith42 Dec 10, 2025
7cf7673
Merge pull request #286 from osmith42/osmith/license-headers
Takuto88 Dec 10, 2025
fba2f03
Merge pull request #290 from osmith42/readme-matrix-room
Takuto88 Dec 10, 2025
cb28c4f
lib/rat: update license header
osmith42 Dec 10, 2025
83c7bbf
Merge pull request #292 from osmith42/osmith/license-test-fix
Takuto88 Dec 10, 2025
511a21a
docker: use sqlite
osmith42 Dec 10, 2025
4e723e7
docker/docker-compose: speed up start checks
osmith42 Dec 10, 2025
e610c79
Merge pull request #293 from osmith42/osmith/wip-docker-sqlite
Takuto88 Dec 11, 2025
876904c
services: add #!/usr/bin/env python3
osmith42 Dec 11, 2025
866b039
Merge pull request #294 from osmith42/fix-service-executables
Takuto88 Dec 16, 2025
0deef69
Add SQN resync to REST api
bjoern-r Dec 17, 2025
bd4224e
Merge pull request #295 from bjoern-r/SQN-resync-api
osmith42 Dec 17, 2025
058e836
fix typo on log init message
bjoern-r Dec 17, 2025
90ad750
Merge pull request #296 from bjoern-r/bugfix/log-typos
osmith42 Dec 17, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
.github
.git
.gitignore
.idea


docs
README.md
systemd
tests
tools
config.yaml

venv

docker/Dockerfile
docker/docker-compose.yaml
47 changes: 0 additions & 47 deletions .github/docker-publish.yaml

This file was deleted.

56 changes: 56 additions & 0 deletions .github/workflows/debian-package.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Debian package

on:
push:
branches: [ "master" ]
tags:
- "*"
pull_request:
branches: [ "master" ]

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- uses: jtdor/build-deb-action@v1
env:
DEB_BUILD_OPTIONS: noautodbgsym
with:
buildpackage-opts: --build=binary --no-sign

- name: Archive build artifacts
uses: actions/upload-artifact@v4
with:
name: debian-package
path: "debian/artifacts/*.deb"

release:
name: Upload Debian package to GitHub Release
runs-on: ubuntu-latest
permissions:
contents: write
needs: build
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')

steps:
- uses: actions/checkout@v3
- name: Debug GitHub context
run: |
echo "repository=${{ github.repository }}"
echo "actor=${{ github.actor }}"
echo "ref=${{ github.ref }}"
- name: Download Debian package artifact
uses: actions/download-artifact@v4
with:
name: debian-package
path: debian/artifacts
- name: Upload .deb to GitHub Release
uses: ncipollo/release-action@v1
with:
tag: ${{ github.ref_name }}
artifacts: debian/artifacts/*.deb
bodyFile: 'CHANGELOG.md'
token: '${{ secrets.GITHUB_TOKEN }}'
2 changes: 1 addition & 1 deletion .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ jobs:
steps:
- uses: actions/checkout@v3
- name: Build the Docker image
run: cd docker && docker build . --file Dockerfile --tag my-image-name:$(date +%s)
run: docker build . --file docker/Dockerfile --tag pyhss-imagebuild-test:$(date +%s)
2 changes: 1 addition & 1 deletion .github/workflows/docker-publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
- uses: actions/checkout@v2

- name: Build image
run: cd docker && docker build . --file Dockerfile --tag $IMAGE_NAME
run: docker build . --file docker/Dockerfile --tag $IMAGE_NAME

- name: Log into registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login docker.pkg.github.com -u ${{ github.actor }} --password-stdin
Expand Down
34 changes: 34 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Run tests

on: [push, pull_request]

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version:
- "3.9" # Debian 10
- "3.13" # Debian 13

steps:
- uses: actions/checkout@v6

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies (apt)
run: |
sudo apt-get -q install -y redis libsctp-dev

- name: Install dependencies (pip)
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt -r requirements-test.txt

- name: Run PyHSS tests
run: |
export PYTEST_ADDOPTS="--color=yes"
pytest -xvv
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,9 @@ lib/__pycache__/milenage.cpython-36.pyc
.gitignore
.vscode/settings.json
.cspell/custom-dictionary-workspace.txt
pyhss.egg-info

!tests/config.yaml
tests/.pyhss.db
.venv
hss.db
32 changes: 30 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,34 @@ All notable changes to PyHSS are documented in this file, beginning from [Servic
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Added

- 2G / 3G support via Osmocom GSUP.
- Support for running PyHSS services in Docker containers and provide official Docker images.
- Database types postgresql and sqlite.
- Config loading from `/etc/pyhss/config.yaml`, `/usr/share/pyhss/config.yaml`,
the `PYHSS_CONFIG` env var, or (old behavior) `config.yaml` at the top of the
source tree, depending on which is available.
- Running services outside of the source tree.
- Building PyHSS with `python3 -m build` and as debian package.
- RAT restriction checking for subscribers.

### Changed

- Set the default database backend to SQLite.

### Removed

- Unused options from config.yaml.
- Debug prints in API service.

### Fixed

- Fix unit tests and run them with pytest in CI.
- Let services/apiService return HTTP status code 500 on errors instead of 200.

## [1.0.2] - 2024-07-03

### Added
Expand All @@ -23,8 +51,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [1.0.1] - 2024-01-23


### Removed

- Assert on missing "IMS Services" for AAA/Audio Request

### Changed
Expand Down Expand Up @@ -97,4 +125,4 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

[1.0.0]: https://github.com/nickvsnetworking/pyhss/releases/tag/1.0.0
[1.0.1]: https://github.com/nickvsnetworking/pyhss/releases/tag/1.0.1
[1.0.2]: https://github.com/nickvsnetworking/pyhss/releases/tag/1.0.2
[1.0.2]: https://github.com/nickvsnetworking/pyhss/releases/tag/1.0.2
86 changes: 84 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ This includes support for acting as:
- Generate BSF Credentials
- Gateway Mobile Location Centre

Supported database backends include `MySQL`, `Postgresql`, `SQLite`, `Orcale`, `MS-SQL` and more, all provisioned through a Swagger based [RESTful API](docs/API.md) for easy, safe CRUD operations on the subscriber data.
Supported database backends are `MySQL`, `PostgreSQL` and `SQLite`, all provisioned through a Swagger based [RESTful API](docs/API.md) for easy, safe CRUD operations on the subscriber data.

The software supports full monitoring through `Prometheus`, and has been tested to over 1m subscribers.

Expand All @@ -37,7 +37,11 @@ The underlying library - ``diameter.py`` can be easily worked with to add suppor

## Usage

Basic configuration is set in the ``config.yaml`` file,
Basic configuration is set in the `config.yaml` file, which gets loaded from:
* The path in the `PYHSS_CONFIG` environment variable (if set)
* `/etc/pyhss/config.yaml`
* `/usr/share/pyhss/config.yaml`
* The same directory as this `README.md`

You will need to set the IP address to bind to (IPv4 or IPv6), the Diameter hostname, realm, your PLMN and transport type to use (SCTP or TCP).

Expand All @@ -52,6 +56,63 @@ If you're provisioning the HSS for the first time, you'll also want to run:

The rest of the services aren't strictly necessary, however your own configuration will dictate whether or not they are required.

### Using Docker (compose)

A docker-compose file is provided to make spinning up PyHSS quick and easy. For development purposes, you can simply run:

```shell
cd docker && docker compose up --build -d
```

This will start the following services, bound to 127.0.0.1 to avoid exposing them to the network by default:

- PyHSS Diameter Service (Port 3868/tcp)
- PyHSS HSS Service
- PyHSS API Service (Port 8080/tcp)
- PyHSS GSUP Service (Port 4222/tcp)
- Redis (Port 6379/tcp)
- MySQL (Port 3306/tcp)

For production, just pull the following image:

```shell
docker pull ghcr.io/nickvsnetworking/pyhss/pyhss:latest
```

The `latest` tag is automatically built from current master. For configuration, please reference `docker/config.yaml`.
Every option in the configuration can be changed through environment variables, which are documented in the `docker/.env` file.

Each container needs a `CONTAINER_ROLE` variable as well with one of the following values:

- diameter
- hss
- api
- geored
- logs
- metrics
- gsup
- database

See the `docker/docker-compose.yaml` file for an example of how to set this up. This variable determines which service the container will run.

### For developers: Configuring your IDE to run / debug inside the docker container

Should you desire to run / debug PyHSS through your IDE like PyCharm to Run / Debug services through docker, you can.

1. Create a Python interpreter on docker (not docker compose) that uses the image `ghcr.io/nickvsnetworking/pyhss/pyhss:development`
2. Prepare the docker image by running `cd docker && docker compose build`. You'll need to rebuild only if requirements.txt changes.
3. Create a Run configuration for each script:
* Select the docker interpreter as runtime
* Be sure to configure the env vars to use the `docker/.env` file
* Setup these additional env vars: `CONFIG_TEMPLATE=/opt/pyhss/docker/config.yaml;PYHSS_CONFIG=/tmp/config.yaml;PYTHONUNBUFFERED=1`
* Be sure that the container run options look like this: `--entrypoint=/opt/pyhss/docker/launch-container.sh -v /home/YOUR_USER/git/pyhss:/opt/pyhss -p 127.0.0.1:4222:4222 --network docker_default --rm`
* NOTE: The port example is for the GSUP daemon. Refer to the compose file for the relevant ports of your daemon
* NOTE: the path `/home/YOUR_USER/git/pyhss` is meant to point to your local source tree
* NOTE: The `--network docker_default` might need to be replaced with the network that is used by compose
4. Start the entire environment with `docker compose up -d`
5. Stop the service you'd like to manually run / debug. For instance: `docker compose stop pyhss_api`
6. Use your IDE run configuration to launch the desired service

## Structure

PyHSS uses a queued microservices model. Each service performs a specific set of tasks, and uses redis messages to communicate with other services.
Expand All @@ -73,6 +134,14 @@ The [RESTful API](docs/API.md) allows for easy, safe CRUD operations on the subs
If REST isn't your jam and you instead want to interact directly with Python, `database.py` can be imported into your project and contains all the same hooks as the API.

## Installation

Create and activate a virtual environment:

```shell
python3 -m venv .venv
source .venv/bin/activate
```

Dependencies can be installed using Pip3:

```shell
Expand All @@ -99,6 +168,16 @@ Historically stats were collected through Redis counters and exposed via an SNMP

More info about the legacy monitoring the system is available in [SNMP Readme](docs/monitoring.md).

## Running tests

Activate the virtual environment (see [installation](#installation), then
install test dependencies and execute the tests as follows:

```shell
pip3 install -r requirements-test.txt
pytest
```

## About

This software was written to address the limited options for lightweight HSS platforms out there, particularly those implementing IMS HSS functionality.
Expand All @@ -108,3 +187,6 @@ It is now deployed by several mid-tier operators, private LTE networks and lab n
Any contributions are welcome, just submit a PR or contact me.

You can contact me at nick (at) nickvsnetworking.com or via my blog at [nickvsnetworking.com](https://nickvsnetworking.com)

A matrix room for discussing PyHSS is available at:
[#pyhss:matrix.org](https://matrix.to/#/#pyhss:matrix.org)
Loading