Skip to content

Commit

Permalink
Merge pull request #582 from devopsec/v0.75
Browse files Browse the repository at this point in the history
v0.75
  • Loading branch information
mackhendricks authored Jul 30, 2024
2 parents bd712ae + f1800b7 commit 40e1746
Show file tree
Hide file tree
Showing 25 changed files with 691 additions and 646 deletions.
6 changes: 4 additions & 2 deletions dsiprouter.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1320,12 +1320,14 @@ function configureKamailioDB() {
${PROJECT_DSIP_DEFAULTS_DIR}/dr_rules.csv > /tmp/defaults/dr_rules.csv

# import default carriers
withRootDBConn mysqlimport \
--fields-terminated-by=';' --ignore-lines=0 -L $KAM_DB_NAME /tmp/defaults/address.csv
withRootDBConn mysqlimport \
--fields-terminated-by=';' --ignore-lines=0 -L $KAM_DB_NAME /tmp/defaults/dr_gw_lists.csv
withRootDBConn mysqlimport \
--fields-terminated-by=';' --ignore-lines=0 -L $KAM_DB_NAME /tmp/defaults/address.csv
withRootDBConn mysqlimport \
--fields-terminated-by=';' --ignore-lines=0 -L $KAM_DB_NAME /tmp/defaults/dr_gateways.csv
withRootDBConn mysqlimport \
--fields-terminated-by=',' --ignore-lines=0 -L $KAM_DB_NAME ${PROJECT_DSIP_DEFAULTS_DIR}/dispatcher.csv
withRootDBConn mysqlimport \
--fields-terminated-by=';' --ignore-lines=0 -L $KAM_DB_NAME /tmp/defaults/dr_rules.csv

Expand Down
33 changes: 27 additions & 6 deletions gui/database/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from enum import Enum
from datetime import datetime, timedelta
from sqlalchemy import create_engine, MetaData, Table, Column, String, exc as sql_exceptions, Integer, event
from sqlalchemy.orm import registry, sessionmaker, scoped_session
from sqlalchemy.orm import registry, sessionmaker, scoped_session, validates
from sqlalchemy.sql import text
import settings
from shared import IO, debugException, dictToStrFields, rowToDict, objToDict
Expand Down Expand Up @@ -106,6 +106,12 @@ class GatewayGroups(object):

id = Column(UnsignedInt, primary_key=True, autoincrement=True, nullable=False)

class FILTER(Enum):
ENDPOINT = f'type:{settings.FLT_PBX}(,|$)'
CARRIER = f'type:{settings.FLT_CARRIER}(,|$)'
MSTEAMS = f'type:{settings.FLT_MSTEAMS}(,|$)'
ENDPOINT_OR_CARRIER = f'type:({settings.FLT_PBX}|{settings.FLT_CARRIER})(,|$)'

def __init__(self, name, gwlist=[], type=settings.FLT_CARRIER, dlg_timeout=None):
description = {'name': name, 'type': type}
if dlg_timeout is not None:
Expand Down Expand Up @@ -465,7 +471,11 @@ def __init__(self, domain, did=None, last_modified=datetime.utcnow()):
self.did = did
self.last_modified = last_modified

pass
@validates("domain")
def __validateDomain(self, key, domain):
if domain == '':
raise ValueError('empty string is an invalid domain')
return domain


class DomainAttrs(object):
Expand Down Expand Up @@ -511,21 +521,32 @@ class Dispatcher(object):
'SKIP_DNS': 16
}

def __init__(self, setid, destination, flags=None, priority=None, description='', attrs=None, rweight=0, signalling='proxy', media='proxy'):
# TODO: setting attrs directly will be removed in the future and each possible attribute identified
def __init__(self, setid, destination, flags=None, priority=None, attrs=None, rweight=0, signalling='proxy', media='proxy',
name=None, gwid=None):
self.setid = setid
self.destination = safeFormatSipUri(destination)
self.flags = flags
self.priority = priority
if attrs:
if attrs is not None:
self.attrs = attrs
else:
self.attrs = Dispatcher.buildAttrs(rweight, signalling, media)
self.description = description
self.description = Dispatcher.buildDescription(name, gwid)

@staticmethod
def buildAttrs(rweight=0, signalling='proxy', media='proxy'):
attrs = {'signalling': signalling, 'media': media, 'rweight': str(rweight)}
return ';'.join('{}={}'.format(x, str(y)) for x, y in attrs.items())
return dictToStrFields(attrs, delims=(';', '='))

@staticmethod
def buildDescription(name=None, gwid=None):
description = {}
if name is not None:
description['name'] = name
if gwid is not None:
description['gwid'] = str(gwid)
return dictToStrFields(description, delims=(';', '='))

def attrsToDict(self):
attrs = {}
Expand Down
Loading

0 comments on commit 40e1746

Please sign in to comment.