Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

send acls with ports - 4.3 #6436

Merged
merged 1 commit into from
Apr 1, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 16 additions & 8 deletions applications/ecallmgr/src/ecallmgr_fs_xml.erl
Original file line number Diff line number Diff line change
Expand Up @@ -821,12 +821,12 @@ is_custom_sip_header(_) -> 'false'.
-spec arrange_acl_node({kz_term:ne_binary(), kz_json:object()}, orddict:orddict()) -> orddict:orddict().
arrange_acl_node({_, JObj}, Dict) ->
AclList = kz_json:get_value(<<"network-list-name">>, JObj),

NodeEl = acl_node_el(kz_json:get_value(<<"type">>, JObj), kz_json:get_value(<<"cidr">>, JObj)),

Type = kz_json:get_value(<<"type">>, JObj),
CIDR = kz_json:get_value(<<"cidr">>, JObj),
Ports = kz_json:get_value(<<"ports">>, JObj),
NodeEl = acl_node_el(Type, CIDR, Ports),
case orddict:find(AclList, Dict) of
{'ok', ListEl} ->
lager:debug("found existing list ~s", [AclList]),
orddict:store(AclList, prepend_child(ListEl, NodeEl), Dict);
'error' ->
lager:debug("creating new list xml for ~s", [AclList]),
Expand All @@ -848,13 +848,21 @@ context(JObj, Props) ->
%%%-----------------------------------------------------------------------------
%% XML record creators and helpers
%%%-----------------------------------------------------------------------------
-spec acl_node_el(kz_types:xml_attrib_value(), kz_types:xml_attrib_value()) -> kz_types:xml_el() | kz_types:xml_els().
acl_node_el(Type, CIDRs) when is_list(CIDRs) ->
[acl_node_el(Type, CIDR) || CIDR <- CIDRs];
acl_node_el(Type, CIDR) ->
-spec acl_node_el(kz_types:xml_attrib_value(), kz_types:xml_attrib_value(), kz_term:api_integers()) -> kz_types:xml_el() | kz_types:xml_els().
acl_node_el(Type, CIDRs, Ports) when is_list(CIDRs) ->
[acl_node_el(Type, CIDR, Ports) || CIDR <- CIDRs];
acl_node_el(Type, CIDR, 'undefined') ->
#xmlElement{name='node'
,attributes=[xml_attrib('type', Type)
,xml_attrib('cidr', CIDR)
]
};
acl_node_el(Type, CIDR, Ports) ->
BinPorts = kz_binary:join([kz_term:to_binary(P) || P <- Ports], <<",">>),
#xmlElement{name='node'
,attributes=[xml_attrib('type', Type)
,xml_attrib('cidr', CIDR)
,xml_attrib('ports', BinPorts)
]
}.

Expand Down