Skip to content

Commit

Permalink
Merge pull request #185 from nickvsnetworking/pre_1_0_1
Browse files Browse the repository at this point in the history
Changes for 1.0.1
  • Loading branch information
davidkneipp authored Jan 21, 2024
2 parents 213f43f + 03e8c17 commit be6cfcb
Show file tree
Hide file tree
Showing 14 changed files with 837 additions and 487 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Gx RAR now dynamically creates TFT up to 512k based on UE request.
- SQN Resync now propogates via Geored when enabled
- Renamed sh_profile to xcap_profile in ims_subscriber
- Rebuilt keys using unique namespace for redis-sentinel / stateless compatibility.

### Fixed

Expand All @@ -31,6 +32,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Control of outbound roaming S6a AIR and ULA responses through roaming_rule and roaming_network objects.
- Roaming management on a per-subscriber basis, through subscriber.roaming_enabled and subscriber.roaming_rule_list.
- Support for Gx and Rx auth of unknown subscribers attaching via SOS.
- Preliminary support for SCTP.

## [1.0.0] - 2023-09-27

Expand Down
32 changes: 23 additions & 9 deletions config.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
## HSS Parameters
hss:
hss:
# Transport Type. "TCP" and "SCTP" are valid options.
# Note: SCTP works but is still experimental. TCP has been load-tested and performs in a production environment.
transport: "TCP"
#IP Addresses to bind on (List) - For TCP only the first IP is used, for SCTP all used for Transport (Multihomed).
bind_ip: ["0.0.0.0"]
Expand Down Expand Up @@ -70,6 +72,12 @@ hss:
# Whether or not to a subscriber to connect to an undefined network when outbound roaming.
allow_undefined_networks: True

# SCTP Socket Parameters
sctp:
rtoMax: 5000
rtoMin: 500
rtoInitial: 1000


api:
page_size: 200
Expand All @@ -95,7 +103,6 @@ logging:
diameter_logging_file: /var/log/pyhss_diameter.log
geored_logging_file: /var/log/pyhss_geored.log
metric_logging_file: /var/log/pyhss_metrics.log
log_to_terminal: True
sqlalchemy_sql_echo: False
sqlalchemy_pool_recycle: 15
sqlalchemy_pool_size: 30
Expand All @@ -113,7 +120,7 @@ database:
webhooks:
enabled: False
endpoints:
- http://127.0.0.1:8181
- 'http://127.0.0.1:8181'

## Geographic Redundancy Parameters
geored:
Expand All @@ -123,16 +130,23 @@ geored:
- 'http://hss01.mnc001.mcc001.3gppnetwork.org:8080'
- 'http://hss02.mnc001.mcc001.3gppnetwork.org:8080'

#Redis is required to run PyHSS. A locally running instance is recommended for production.
#Redis is required to run PyHSS. An instance running on a local network is recommended for production.
redis:
# Whether to use a UNIX socket instead of a tcp connection to redis. Host and port is ignored if useUnixSocket is True.
useUnixSocket: False
# Which connection type to attempt. Valid options are: tcp, unix, sentinel
# tcp - Connection via a standard TCP socket to a given host and port.
# unix - Connect to redis via a unix socket, provided by unixSocketPath.
# sentinel - Connect to one or more redis sentinel hosts.
connectionType: "tcp"
unixSocketPath: '/var/run/redis/redis-server.sock'
host: localhost
port: 6379
# [Deprecated] Additional peers to query for roaming SOS subscribers
additionalPeers:
- "redis2.mnc001.mcc001.3gppnetwork.org:6379"
sentinel:
masterName: exampleMaster
hosts:
- exampleSentinel.mnc001.mcc001.3gppnetwork.org:
port: 6379
password: ''


prometheus:
enabled: False
Expand Down
221 changes: 212 additions & 9 deletions lib/database.py

Large diffs are not rendered by default.

588 changes: 284 additions & 304 deletions lib/diameter.py

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions lib/diameterAsync.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import math
import asyncio
import yaml
import socket
from messagingAsync import RedisMessagingAsync


Expand Down Expand Up @@ -41,7 +42,7 @@ def __init__(self, logTool):
self.redisMessaging = RedisMessagingAsync(host=self.redisHost, port=self.redisPort, useUnixSocket=self.redisUseUnixSocket, unixSocketPath=self.redisUnixSocketPath)

self.logTool = logTool

self.hostname = socket.gethostname()

#Generates rounding for calculating padding
async def myRound(self, n, base=4):
Expand Down Expand Up @@ -246,7 +247,7 @@ async def getConnectedPeersByType(self, peerType: str) -> list:
if peerType not in peerTypes:
return []
filteredConnectedPeers = []
activePeers = await(self.redisMessaging.getValue(key="ActiveDiameterPeers"))
activePeers = await(self.redisMessaging.getValue(key="ActiveDiameterPeers", usePrefix=True, prefixHostname=self.hostname, prefixServiceName='diameter'))

for key, value in activePeers.items():
if activePeers.get(key, {}).get('peerType', '') == 'pgw' and activePeers.get(key, {}).get('connectionStatus', '') == 'connected':
Expand Down
6 changes: 4 additions & 2 deletions lib/logtool.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import logging
import logging.handlers as handlers
import os, sys, time
import socket
from datetime import datetime
sys.path.append(os.path.realpath('../'))
import asyncio
Expand Down Expand Up @@ -41,6 +42,7 @@ def __init__(self, config: dict):

self.redisMessagingAsync = RedisMessagingAsync(host=self.redisHost, port=self.redisPort, useUnixSocket=self.redisUseUnixSocket, unixSocketPath=self.redisUnixSocketPath)
self.redisMessaging = RedisMessaging(host=self.redisHost, port=self.redisPort, useUnixSocket=self.redisUseUnixSocket, unixSocketPath=self.redisUnixSocketPath)
self.hostname = socket.gethostname()

async def logAsync(self, service: str, level: str, message: str, redisClient=None) -> bool:
"""
Expand All @@ -55,7 +57,7 @@ async def logAsync(self, service: str, level: str, message: str, redisClient=Non
timestamp = time.time()
dateTimeString = datetime.fromtimestamp(timestamp).strftime("%m/%d/%Y %H:%M:%S %Z").strip()
print(f"[{dateTimeString}] [{level.upper()}] {message}")
await(redisClient.sendLogMessage(serviceName=service.lower(), logLevel=level, logTimestamp=timestamp, message=message, logExpiry=60))
await(redisClient.sendLogMessage(serviceName=service.lower(), logLevel=level, logTimestamp=timestamp, message=message, logExpiry=60, usePrefix=True, prefixHostname=self.hostname, prefixServiceName='log'))
return True

def log(self, service: str, level: str, message: str, redisClient=None) -> bool:
Expand All @@ -71,7 +73,7 @@ def log(self, service: str, level: str, message: str, redisClient=None) -> bool:
timestamp = time.time()
dateTimeString = datetime.fromtimestamp(timestamp).strftime("%m/%d/%Y %H:%M:%S %Z").strip()
print(f"[{dateTimeString}] [{level.upper()}] {message}")
redisClient.sendLogMessage(serviceName=service.lower(), logLevel=level, logTimestamp=timestamp, message=message, logExpiry=60)
redisClient.sendLogMessage(serviceName=service.lower(), logLevel=level, logTimestamp=timestamp, message=message, logExpiry=60, usePrefix=True, prefixHostname=self.hostname, prefixServiceName='diameter')
return True

def setupFileLogger(self, loggerName: str, logFilePath: str):
Expand Down
Loading

0 comments on commit be6cfcb

Please sign in to comment.