Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
dwilkie committed Sep 8, 2024
1 parent f9377c7 commit 0554d9e
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 13 deletions.
13 changes: 9 additions & 4 deletions components/gateway/public_gateway/opensips.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,11 @@ route{
exit;
}

if ( get_source_group( $var(group)) ) {
# do something with $var(group)
xlog("group is $var(group)\n");
};

# Some UAC send a Route Header
# with a local proxy IP in an initial INVITE Request
# According to https://opensips.org/html/docs/modules/3.4.x/rr.html#func_loose_route
Expand Down Expand Up @@ -229,18 +234,18 @@ route{
xlog("L_NOTICE", "Load balancing request on port $rp\n");

if ($rp == "SIP_PORT") {
xlog("L_NOTICE", "Starting LB with resources: gw\n");
xlog("L_NOTICE", "Starting LB on group $var(group) with resources: gw\n");

if ( !lb_start(1,"gw")) {
if ( !lb_start($var(group),"gw")) {
send_reply(500,"No Destination available");
exit;
}
}

if ($rp == "SIP_ALTERNATIVE_PORT") {
xlog("L_NOTICE", "Starting LB with resources: gwalt\n");
xlog("L_NOTICE", "Starting LB on group $var(group) with resources: gwalt\n");

if ( !lb_start(1,"gwalt")) {
if ( !lb_start($var(group),"gwalt")) {
send_reply(500,"No Destination available");
exit;
}
Expand Down
4 changes: 2 additions & 2 deletions components/testing/tests/public_gateway/inbound_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ media_server="$(dig +short freeswitch)"
public_gateway="$(dig +short public_gateway)"

reset_db
create_load_balancer_entry "gw" "5060"
create_address_entry $(hostname -i)
create_load_balancer_entry "gw" "5060" "2"
create_address_entry "$(hostname -i)" "2"
reload_opensips_tables

sipp -sf $scenario public_gateway:5060 -s 1234 -m 1 -trace_msg > /dev/null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ reload_opensips_tables () {

create_address_entry () {
ip="$1"
grp="$2"
grp="${grp:=1}"

psql -q $DATABASE_URL -c "INSERT INTO address (ip) VALUES('$ip');"
psql -q $DATABASE_URL -c "INSERT INTO address (ip, grp) VALUES('$ip', '$grp');"
}
4 changes: 3 additions & 1 deletion components/testing/tests/support/test_helpers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ set -e
create_load_balancer_entry () {
gateway_identifier="$1"
port="$2"
group_id="$3"
group_id="${group_id:=1}"
psql -q $DATABASE_URL \
-c "INSERT INTO load_balancer (group_id, dst_uri, resources, probe_mode) VALUES('1', 'sip:freeswitch:$port', '$gateway_identifier=fs://:secret@freeswitch:8021', 2);"
-c "INSERT INTO load_balancer (group_id, dst_uri, resources, probe_mode) VALUES('$group_id', 'sip:freeswitch:$port', '$gateway_identifier=fs://:secret@freeswitch:8021', 2);"
}

assert_in_file () {
Expand Down
17 changes: 12 additions & 5 deletions infrastructure/modules/switch/sg.tf
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,13 @@ resource "aws_security_group_rule" "ingress_http" {
cidr_blocks = ["0.0.0.0/0"]
}

# TODO: this might be wrong for new VPC

resource "aws_security_group_rule" "ingress_freeswitch_event_socket" {
type = "ingress"
to_port = 8021
protocol = "TCP"
from_port = 8021
security_group_id = aws_security_group.this.id
cidr_blocks = [var.region.vpc.vpc_cidr_block]
cidr_blocks = ["0.0.0.0/0"]
}

resource "aws_security_group_rule" "ingress_sip" {
Expand All @@ -33,7 +31,7 @@ resource "aws_security_group_rule" "ingress_sip" {
protocol = "UDP"
from_port = var.sip_port
security_group_id = aws_security_group.this.id
cidr_blocks = [var.region.vpc.vpc_cidr_block]
cidr_blocks = ["0.0.0.0/0"]
}

resource "aws_security_group_rule" "ingress_sip_alternative" {
Expand All @@ -42,7 +40,16 @@ resource "aws_security_group_rule" "ingress_sip_alternative" {
protocol = "UDP"
from_port = var.sip_alternative_port
security_group_id = aws_security_group.this.id
cidr_blocks = [var.region.vpc.vpc_cidr_block]
cidr_blocks = ["0.0.0.0/0"]
}

resource "aws_security_group_rule" "icmp" {
type = "ingress"
to_port = -1
protocol = "icmp"
from_port = -1
security_group_id = aws_security_group.this.id
cidr_blocks = ["0.0.0.0/0"]
}

resource "aws_security_group_rule" "egress" {
Expand Down

0 comments on commit 0554d9e

Please sign in to comment.