Skip to content

Commit

Permalink
Merge pull request #351 from dOpensource/v0.641
Browse files Browse the repository at this point in the history
V0.641
  • Loading branch information
mackhendricks committed Feb 21, 2021
2 parents e7eac57 + 6c7532c commit 3772718
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 14 deletions.
26 changes: 24 additions & 2 deletions dsiprouter.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1944,6 +1944,22 @@ function setCredentials {
ROOT_DB_USER=${SET_ROOT_DB_USER:-$ROOT_DB_USER}
ROOT_DB_PASS=${SET_ROOT_DB_PASS:-$ROOT_DB_PASS}
ROOT_DB_NAME=${SET_ROOT_DB_NAME:-$ROOT_DB_NAME}

if [[ -n "${CREATE_KAM_DB_USER}" ]]; then
CREATE_KAM_DB_SQL+=("create user '${SET_KAM_DB_USER}'@'%' IDENTIFIED by '${SET_KAM_DB_PASS}';")
CREATE_KAM_DB_SQL+=("grant all privileges ON ${KAM_DB_NAME}.* TO '${SET_KAM_DB_USER}'@'%' with grant option;")
CREATE_KAM_DB_SQL+=("flush privileges;")
for i in "${CREATE_KAM_DB_SQL[@]}"
do
mysql -u${ROOT_DB_USER} -p${ROOT_DB_PASS} -h${KAM_DB_HOST} -e "$i"
if (( $? == 1 )); then
printerr 'The database user could not be created'
exit
fi
done
printwarn "The database user: ${SET_KAM_DB_USER} was created"

fi
else
printerr 'Connection to DB failed'
cleanupAndExit 1
Expand Down Expand Up @@ -2123,7 +2139,7 @@ EOF
# for centos7 and debian we have to update it 'manually'
elif [[ "$DISTRO" == "centos" ]]; then
/etc/update-motd.d/00-dsiprouter > /etc/motd
cronAppend "0/5 * * * * /etc/update-motd.d/00-dsiprouter > /etc/motd"
cronAppend "*/5 * * * * /etc/update-motd.d/00-dsiprouter > /etc/motd"
fi
}

Expand Down Expand Up @@ -2591,7 +2607,7 @@ function usageOptions {
"resetpassword" "[-debug|-all|--all|-dc|--dsip-creds|-ac|--api-creds|-kc|--kam-creds|-ic|--ipc-creds|-fid|--force-instance-id]"
printf "%-30s %s\n%-30s %s\n%-30s %s\n%-30s %s\n" \
"setcredentials" "[-debug|-dc <[user][:pass]>|--dsip-creds=<[user][:pass]>|-ac <token>|--api-creds=<token>|" \
" " "-kc <[user[:pass]@]dbhost[:port][/dbname]>|--kam-creds=<[user[:pass]@]dbhost[:port][/dbname]>|" \
" " "-kc <[user[:pass]@]dbhost[:port][/dbname]>|--kam-creds=<[user[:pass]@]dbhost[:port][/dbname]> [-createdbuser]|" \
" " "-mc <[user][:pass]>|--mail-creds=<[user][:pass]>|-ic <token>|--ipc-creds=<token>]|" \
" " "-dac <[user][:pass][/dbname]>|--db-admin-creds=<[user][:pass][/dbname]>"
printf "%-30s %s\n" \
Expand Down Expand Up @@ -3470,7 +3486,13 @@ function processCMD {
DB_CONN_URI="$1"
shift
fi

if (( "$1" == "-createdbuser" )); then

CREATE_KAM_DB_USER=1
shift

fi
# sanity check
if [[ -z "${DB_CONN_URI}" ]]; then
printerr "Credentials must be given for option $OPT"
Expand Down
11 changes: 8 additions & 3 deletions gui/modules/api/api_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ def reloadKamailio():
# it should be renamed and changed to use POST method
# TODO: the last lease id/username generated must be tracked (just query DB)
# and used to determine next lease id, otherwise conflicts may occur
@api.route("/api/v1/endpoint/lease", methods=['GET'])
@api.route("/api/v1/lease/endpoint", methods=['GET'])
@api_security
def getEndpointLease():
db = DummySession()
Expand All @@ -198,6 +198,11 @@ def getEndpointLease():
if ttl is None:
raise http_exceptions.BadRequest("time to live (ttl) parameter is missing")

# Convert TTL to Seconds
r = re.compile('\d*m|M')
if r.match(ttl):
ttl = 60 * int(ttl[0:(len(ttl)-1)])

# Generate some values
rand_num = random.randint(1, 200)
name = "lease" + str(rand_num)
Expand All @@ -207,7 +212,7 @@ def getEndpointLease():

# Set some defaults
host_addr = ''
strip = ''
strip = 0
prefix = ''

# Add the Gateways table
Expand Down Expand Up @@ -245,7 +250,7 @@ def getEndpointLease():
db.close()


@api.route("/api/v1/endpoint/lease/<int:leaseid>/revoke", methods=['DELETE'])
@api.route("/api/v1/lease/endpoint/<int:leaseid>/revoke", methods=['DELETE'])
@api_security
def revokeEndpointLease(leaseid):
db = DummySession()
Expand Down
2 changes: 1 addition & 1 deletion gui/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
# dSIPRouter internal settings

VERSION = '0.641'
DEBUG = True
DEBUG = False
# '' (default) = handle inbound with domain mapping from endpoints, inbound from carriers and outbound to carriers
# 'outbound' = act as an outbound proxy only (no domain routing)
# 'inout' = inbound from carriers and outbound to carriers only (no domain routing)
Expand Down
12 changes: 6 additions & 6 deletions kamailio/defaults/dr_gw_lists.csv
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
null;41,42,43,44,45,46,47,48;name:Twilio NA Inbound CarrierGroup,type:8
null;45,46,47,48,49,50,51;name:Twilio NA Inbound CarrierGroup,type:8
null;1,2,3,4,5,6,7,8,9,10,11;name:Skyetel CarrierGroup,type:8
null;12,13,14,15;name:Flowroute CarrierGroup,type:8
null;16,17,18,19,20,21;name:Voxbone CarrierGroup,type:8
null;22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37;name:VoIP Innovations Inbound IP's CarrierGroup,type:8
null;38;name:Thinq CarrierGroup,type:8
null;39;name:Voxtelesys CarrierGroup,type:8
null;40;name:Les.net CarrierGroup,type:8
null;49,50,51;name:ThinkTel CarrierGroup,type:8
null;52,53,54,55;name:VoIP Innovations Outbound Conversational IP's CarrierGroup,type:8
null;39,40,41;name:VoIP Innovations Outbound Conversational IP's CarrierGroup,type:8
null;42;name:Thinq CarrierGroup,type:8
null;43;name:Voxtelesys CarrierGroup,type:8
null;44;name:Les.net CarrierGroup,type:8
null;53,54,55;name:ThinkTel CarrierGroup,type:8
7 changes: 5 additions & 2 deletions kamailio/kamailio_dsiprouter.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -2067,8 +2067,11 @@ route[SET_RECORD_ROUTE] {
if isflagset(FLT_DST_INTERNAL_IP) {
record_route_advertised_address("INTERNAL_IP_ADDR");
}
else if ("OUTBOUND_NLB_FQDN" != "") {
record_route_advertised_address("OUTBOUND_NLB_FQDN");
else if ("OUTBOUND_NLB_FQDN" != "") && ("INBOUND_NLB_FQDN" != "") {
record_route_preset("OUTBOUND_NLB_FQDN","INBOUND_NLB_FQDN");
}
else if ("OUTBOUND_NLB_FQDN" == "") && ("INBOUND_NLB_FQDN" != "") {
record_route_advertised_address("INBOUND_NLB_FQDN");
}
else {
record_route();
Expand Down

0 comments on commit 3772718

Please sign in to comment.