Skip to content

Commit

Permalink
Set correct Record-Route Port (#674)
Browse files Browse the repository at this point in the history
  • Loading branch information
dwilkie authored Jul 11, 2024
1 parent 8d41fb2 commit 6f01d5c
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 5 deletions.
6 changes: 5 additions & 1 deletion components/gateway/public_gateway/opensips.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,11 @@ route{

# record routing
# https://opensips.org/pipermail/users/2018-January/038722.html
record_route_preset("LOCAL_IP:SIP_PORT", "SIP_ADVERTISED_IP:SIP_PORT");
if ($rp == "SIP_ALTERNATIVE_PORT") {
record_route_preset("LOCAL_IP:SIP_ALTERNATIVE_PORT", "SIP_ADVERTISED_IP:SIP_ALTERNATIVE_PORT");
} else {
record_route_preset("LOCAL_IP:SIP_PORT", "SIP_ADVERTISED_IP:SIP_PORT");
}
add_rr_param(";r2=on");

do_accounting("log");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,25 @@ source $current_dir/../support/test_helpers.sh

scenario=$current_dir/../../scenarios/zamtel_inbound.xml

log_file="zamtel_inbound_*_messages.log"
rm -f "$log_file"

reset_db
create_load_balancer_entry "gwalt" "5080"
create_address_entry $(hostname -i)
reload_opensips_tables

rm -f zamtel_inbound_*_messages.log
public_gateway="$(dig +short public_gateway)"

sipp -sf $scenario public_gateway:5080 -s 7888 -m 1 -trace_msg > /dev/null
reset_db

if ! assert_in_file "zamtel_inbound_*_messages.log" "c=IN IP4 18.141.245.230"; then
# Assert correct IP in SDP
if ! assert_in_file "$log_file" "c=IN IP4 18.141.245.230"; then
exit 1
fi

# Assert correct Port in RR
if ! assert_in_file "$log_file" "Record-Route: <sip:$public_gateway:5080"; then
exit 1
fi
10 changes: 8 additions & 2 deletions components/testing/tests/public_gateway/inbound_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ source $current_dir/../support/test_helpers.sh
scenario=$current_dir/../../scenarios/smart_inbound.xml

log_file="smart_inbound_*_messages.log"
rm -f $log_file
rm -f "$log_file"

media_server="$(dig +short freeswitch)"
public_gateway="$(dig +short public_gateway)"

reset_db
create_load_balancer_entry "gw" "5060"
Expand All @@ -23,6 +24,11 @@ sipp -sf $scenario public_gateway:5060 -s 1234 -m 1 -trace_msg > /dev/null
reset_db

# Assert correct IP in SDP
if ! assert_in_file $log_file "c=IN IP4 $media_server"; then
if ! assert_in_file "$log_file" "c=IN IP4 $media_server"; then
exit 1
fi

# Assert correct Port in RR
if ! assert_in_file "$log_file" "Record-Route: <sip:$public_gateway:5060"; then
exit 1
fi

0 comments on commit 6f01d5c

Please sign in to comment.