Skip to content

Commit

Permalink
improve headers array input for orig_append_headers_reply (#1534)
Browse files Browse the repository at this point in the history
* improve headers array input for orig_append_headers_reply, term_append_headers_req, orig_append_headers_req
* upgrade rexml
* gw api resource remove filters by append headers
  • Loading branch information
dmitry-sinina authored Aug 24, 2024
1 parent c93fd83 commit d75ed22
Show file tree
Hide file tree
Showing 12 changed files with 3,232 additions and 39 deletions.
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -715,7 +715,7 @@ GEM
responders (3.0.1)
actionpack (>= 5.0)
railties (>= 5.0)
rexml (3.3.4)
rexml (3.3.6)
strscan
rspec (3.10.0)
rspec-core (~> 3.10.0)
Expand Down
18 changes: 12 additions & 6 deletions app/admin/equipment/gateways.rb
Original file line number Diff line number Diff line change
Expand Up @@ -397,8 +397,8 @@ def resource_params

f.inputs 'Origination' do
f.input :orig_next_hop
f.input :orig_append_headers_req
f.input :orig_append_headers_reply, as: :array_of_strings
f.input :orig_append_headers_req, as: :newline_array_of_headers
f.input :orig_append_headers_reply, as: :newline_array_of_headers
f.input :orig_use_outbound_proxy
f.input :orig_force_outbound_proxy
f.input :orig_proxy_transport_protocol, as: :select, include_blank: false
Expand Down Expand Up @@ -433,7 +433,7 @@ def resource_params
f.input :term_next_hop_for_replies
f.input :term_next_hop
f.input :term_disconnect_policy, input_html: { class: 'chosen' }, include_blank: true
f.input :term_append_headers_req
f.input :term_append_headers_req, as: :newline_array_of_headers
f.input :sdp_alines_filter_type, as: :select, include_blank: false
f.input :sdp_alines_filter_list
f.input :ringing_timeout
Expand Down Expand Up @@ -589,8 +589,12 @@ def resource_params
panel 'Origination' do
attributes_table_for s do
row :orig_next_hop
row :orig_append_headers_req
row :orig_append_headers_reply
row :orig_append_headers_req do |row|
pre row.orig_append_headers_req.join("\r\n")
end
row :orig_append_headers_reply do |row|
pre row.orig_append_headers_reply.join("\r\n")
end
row :orig_use_outbound_proxy
row :orig_force_outbound_proxy
row :orig_proxy_transport_protocol
Expand Down Expand Up @@ -629,7 +633,9 @@ def resource_params
row :term_next_hop_for_replies
row :term_next_hop
row :term_disconnect_policy
row :term_append_headers_req
row :term_append_headers_req do |row|
pre row.term_append_headers_req.join("\r\n")
end
row :sdp_alines_filter_type
row :sdp_alines_filter_list
row :ringing_timeout
Expand Down
18 changes: 14 additions & 4 deletions app/models/gateway.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@
# max_30x_redirects :integer(2) default(0), not null
# max_transfers :integer(2) default(0), not null
# name :string not null
# orig_append_headers_reply :string is an Array
# orig_append_headers_req :string
# orig_append_headers_reply :string default([]), not null, is an Array
# orig_append_headers_req :string default([]), not null, is an Array
# orig_force_outbound_proxy :boolean default(FALSE), not null
# orig_next_hop :string
# orig_outbound_proxy :string
Expand Down Expand Up @@ -82,7 +82,7 @@
# sst_session_expires :integer(4) default(50)
# suppress_early_media :boolean default(FALSE), not null
# symmetric_rtp_nonstop :boolean default(FALSE), not null
# term_append_headers_req :string
# term_append_headers_req :string default([]), not null, is an Array
# term_force_outbound_proxy :boolean default(FALSE), not null
# term_next_hop :string
# term_next_hop_for_replies :boolean default(FALSE), not null
Expand Down Expand Up @@ -394,10 +394,20 @@ def rtp_acl=(value)
end

def orig_append_headers_reply=(value)
value = value.split(',').map(&:strip).reject(&:blank?) if value.is_a? String
value = value.split("\r\n").map(&:strip).reject(&:blank?) if value.is_a? String
self[:orig_append_headers_reply] = value
end

def orig_append_headers_req=(value)
value = value.split("\r\n").map(&:strip).reject(&:blank?) if value.is_a? String
self[:orig_append_headers_req] = value
end

def term_append_headers_req=(value)
value = value.split("\r\n").map(&:strip).reject(&:blank?) if value.is_a? String
self[:term_append_headers_req] = value
end

def host=(value)
self[:host] = self.class.normalize_host(value)
end
Expand Down
9 changes: 7 additions & 2 deletions app/resources/api/rest/admin/gateway_resource.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class Api::Rest::Admin::GatewayResource < ::BaseResource
:dst_rewrite_rule, :dst_rewrite_result, :auth_enabled, :auth_user, :auth_password, :auth_from_user,
:auth_from_domain, :term_use_outbound_proxy, :term_force_outbound_proxy, :term_outbound_proxy,
:term_next_hop_for_replies, :term_next_hop, :term_append_headers_req,
:orig_append_headers_req, :orig_append_headers_reply,
:sdp_alines_filter_list, :ringing_timeout, :relay_options, :relay_reinvite, :relay_hold, :relay_prack,
:relay_update, :suppress_early_media, :fake_180_timer, :transit_headers_from_origination,
:transit_headers_from_termination, :sip_interface_name, :allow_1xx_without_to_tag, :sip_timer_b,
Expand Down Expand Up @@ -97,8 +98,10 @@ class Api::Rest::Admin::GatewayResource < ::BaseResource
ransack_filter :termination_capacity, type: :number
ransack_filter :term_next_hop, type: :string
ransack_filter :orig_next_hop, type: :string
ransack_filter :orig_append_headers_req, type: :string
ransack_filter :term_append_headers_req, type: :string
# Disabled because there is no support for arrays in ransack_filter
# ransack_filter :orig_append_headers_req, type: :array_of_strings
# ransack_filter :orig_append_headers_reply, type: :array_of_strings
# ransack_filter :term_append_headers_req, type: :array_of_strings
ransack_filter :dialog_nat_handling, type: :boolean
ransack_filter :orig_force_outbound_proxy, type: :boolean
ransack_filter :orig_use_outbound_proxy, type: :boolean
Expand Down Expand Up @@ -207,6 +210,8 @@ def self.updatable_fields(_context)
term_next_hop
term_disconnect_policy
term_append_headers_req
orig_append_headers_req
orig_append_headers_reply
sdp_alines_filter_list
ringing_timeout
relay_options
Expand Down
1 change: 1 addition & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@

en:
hint_array_of_strings: "Comma-separated array of strings"
hint_newline_array_of_headers: "Newline separated array of Header: Value elements"
date:
formats:
long: "%Y-%m-%d"
Expand Down
Loading

0 comments on commit d75ed22

Please sign in to comment.