Skip to content

Commit

Permalink
initial
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitry-sinina committed Aug 5, 2019
1 parent 5f343d4 commit ef20956
Show file tree
Hide file tree
Showing 7 changed files with 77 additions and 34 deletions.
24 changes: 7 additions & 17 deletions app/admin/equipment/gateways.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
:orig_use_outbound_proxy, :orig_force_outbound_proxy,
[:orig_proxy_transport_protocol_name, proc { |row| row.orig_proxy_transport_protocol.try(:name) }],
:orig_outbound_proxy,
:dialog_nat_handling, # :transparent_dialog_id,
[:nat_handling_mode_name, proc { |row| row.nat_handling_mode.try(:name) }],
[:orig_disconnect_policy_name, proc { |row| row.orig_disconnect_policy.try(:name) }],
[:transport_protocol_name, proc { |row| row.transport_protocol.try(:name) }],
[:sip_schema_name, proc { |row| row.sip_schema.try(:name) }],
Expand Down Expand Up @@ -86,7 +86,7 @@
:sip_timer_b, :dns_srv_failover_timer,
[:sdp_c_location_name, proc { |row| row.sdp_c_location.try(:name) }],
[:codec_group_name, proc { |row| row.codec_group.try(:name) }],
:anonymize_sdp, :proxy_media, :single_codec_in_200ok, :transparent_seqno, :transparent_ssrc, :force_symmetric_rtp, :symmetric_rtp_nonstop, :symmetric_rtp_ignore_rtcp, :force_dtmf_relay, :rtp_ping,
:proxy_media, :single_codec_in_200ok, :force_symmetric_rtp, :symmetric_rtp_nonstop, :symmetric_rtp_ignore_rtcp, :force_dtmf_relay, :rtp_ping,
:rtp_timeout,
:filter_noaudio_streams,
:rtp_relay_timestamp_aligning,
Expand Down Expand Up @@ -116,7 +116,7 @@
:transport_protocol, :term_proxy_transport_protocol, :orig_proxy_transport_protocol,
:rel100_mode, :rx_inband_dtmf_filtering_mode, :tx_inband_dtmf_filtering_mode,
:network_protocol_priority, :media_encryption_mode, :sip_schema,
:termination_src_numberlist, :termination_dst_numberlist, :lua_script
:termination_src_numberlist, :termination_dst_numberlist, :lua_script, :nat_handling_mode

controller do
def resource_params
Expand Down Expand Up @@ -226,8 +226,8 @@ def resource_params
column :orig_force_outbound_proxy
column :orig_proxy_transport_protocol
column :orig_outbound_proxy
column :transparent_dialog_id
column :dialog_nat_handling

column :nat_handling_mode
column :orig_disconnect_policy

column :resolve_ruri
Expand Down Expand Up @@ -279,8 +279,6 @@ def resource_params
column :anonymize_sdp
column :proxy_media
column :single_codec_in_200ok
column :transparent_seqno
column :transparent_ssrc
column :force_symmetric_rtp
column :symmetric_rtp_nonstop
column :symmetric_rtp_ignore_rtcp
Expand Down Expand Up @@ -384,6 +382,7 @@ def resource_params
f.input :sip_interface_name
f.input :incoming_auth_username
f.input :incoming_auth_password, as: :string, input_html: { autocomplete: 'off' }
f.input :nat_handling_mode
end

f.inputs 'Origination' do
Expand All @@ -393,8 +392,6 @@ def resource_params
f.input :orig_force_outbound_proxy
f.input :orig_proxy_transport_protocol, as: :select, include_blank: false
f.input :orig_outbound_proxy
f.input :transparent_dialog_id
f.input :dialog_nat_handling
f.input :orig_disconnect_policy
end
end
Expand Down Expand Up @@ -458,11 +455,8 @@ def resource_params
f.inputs 'Media settings' do
f.input :sdp_c_location, as: :select, include_blank: false
f.input :codec_group, input_html: { class: 'chosen' }
f.input :anonymize_sdp
f.input :proxy_media
f.input :single_codec_in_200ok
f.input :transparent_seqno
f.input :transparent_ssrc
f.input :force_symmetric_rtp
f.input :symmetric_rtp_nonstop
f.input :symmetric_rtp_ignore_rtcp
Expand Down Expand Up @@ -550,6 +544,7 @@ def resource_params
row :transit_headers_from_origination
row :transit_headers_from_termination
row :sip_interface_name
row :nat_handling_mode
end
end
panel 'Origination' do
Expand All @@ -560,8 +555,6 @@ def resource_params
row :orig_force_outbound_proxy
row :orig_proxy_transport_protocol
row :orig_outbound_proxy
row :transparent_dialog_id
row :dialog_nat_handling
row :orig_disconnect_policy

row :incoming_auth_username
Expand Down Expand Up @@ -628,11 +621,8 @@ def resource_params
attributes_table_for s do
row :sdp_c_location
row :codec_group, input_html: { class: 'chosen' }
row :anonymize_sdp
row :proxy_media
row :single_codec_in_200ok
row :transparent_seqno
row :transparent_ssrc
row :force_symmetric_rtp
row :symmetric_rtp_nonstop
row :symmetric_rtp_ignore_rtcp
Expand Down
8 changes: 4 additions & 4 deletions app/admin/routing/lnp_cache.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@

acts_as_export :id, :dst, :lrn, :tag, :created_at, :expires_at

includes :database
includes :database, :routing_tag

index do
selectable_column
id_column
actions
column :dst
column :lrn
column :tag
column :routing_tag
column :data
column :database
column :created_at
Expand All @@ -28,7 +28,7 @@
filter :id
filter :dst
filter :lrn
filter :tag
filter :routing_tag
filter :data
filter :database

Expand All @@ -37,7 +37,7 @@
row :id
row :dst
row :lrn
row :tag
row :routing_tag
row :data
row :database
row :created_at
Expand Down
11 changes: 11 additions & 0 deletions app/models/equipment/gateway_nat_handling_mode.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# == Schema Information
#
# Table name: class4.gateway_nat_handling_modes
#
# id :integer not null, primary key
# name :string not null
#

class Equipment::GatewayNatHandlingMode < Yeti::ActiveRecord
self.table_name = 'class4.gateway_nat_handling_modes'
end
5 changes: 3 additions & 2 deletions app/models/gateway.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# frozen_string_literal: true

# == Schema Information
#
# Table name: gateways
Expand Down Expand Up @@ -121,6 +120,7 @@
# termination_dst_numberlist_id :integer
# lua_script_id :integer
# use_registered_aor :boolean default(FALSE), not null
# nat_handling_mode_id :integer default(1), not null
#

require 'resolv'
Expand Down Expand Up @@ -153,6 +153,7 @@ class Gateway < Yeti::ActiveRecord
belongs_to :termination_dst_numberlist, class_name: 'Routing::Numberlist', foreign_key: :termination_dst_numberlist_id
belongs_to :termination_src_numberlist, class_name: 'Routing::Numberlist', foreign_key: :termination_src_numberlist_id
belongs_to :lua_script, class_name: 'System::LuaScript', foreign_key: :lua_script_id
belongs_to :nat_handling_mode, class_name: 'Equipment::GatewayNatHandlingMode', foreign_key: :nat_handling_mode

has_many :customers_auths, class_name: 'CustomersAuth', dependent: :restrict_with_error
has_many :dialpeers, class_name: 'Dialpeer', dependent: :restrict_with_error
Expand Down Expand Up @@ -182,7 +183,7 @@ class Gateway < Yeti::ActiveRecord

validates_numericality_of :fake_180_timer, greater_than: 0, less_than_or_equal_to: PG_MAX_SMALLINT, allow_nil: true, only_integer: true
validates_presence_of :transport_protocol, :term_proxy_transport_protocol, :orig_proxy_transport_protocol,
:network_protocol_priority, :media_encryption_mode, :sdp_c_location, :sip_schema
:network_protocol_priority, :media_encryption_mode, :sdp_c_location, :sip_schema, :nat_handling_mode

validates_presence_of :incoming_auth_username, :incoming_auth_password,
if: proc { |gw|
Expand Down
22 changes: 12 additions & 10 deletions app/models/lnp/cache.rb
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
# frozen_string_literal: true

# == Schema Information
#
# Table name: class4.lnp_cache
#
# id :integer not null, primary key
# dst :string not null
# lrn :string not null
# created_at :datetime
# updated_at :datetime
# expires_at :datetime
# database_id :integer
# data :string
# tag :string
# id :integer not null, primary key
# dst :string not null
# lrn :string not null
# created_at :datetime
# updated_at :datetime
# expires_at :datetime
# database_id :integer
# data :string
# tag :string
# routing_tag_id :integer
#

class Lnp::Cache < Yeti::ActiveRecord
self.table_name = 'class4.lnp_cache'

belongs_to :database, class_name: 'Lnp::Database', foreign_key: :database_id
belongs_to :routing_tag, class_name: 'Routing::RoutingTag', foreign_key: :routing_tag_id

end
3 changes: 2 additions & 1 deletion config/initializers/pg_dump.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@
'-T', 'auth_log.auth_log_2*',
'-T', 'rtp_statistics.streams_*',
'-T', 'pgq.*',
'-T', 'pgq_ext.*'
'-T', 'pgq_ext.*',
'-T', 'logs.api_requests_2*'
]
38 changes: 38 additions & 0 deletions db/migrate/20190805174853_new_nat_handling_mode.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
class NewNatHandlingMode < ActiveRecord::Migration[5.2]
#TODO:
# remove tag from lnp_cache
# remove transparent_dialor_id from gateways
# remove dialog_nat_handling from gateways
# column :transparent_seqno
# column :transparent_ssrc
#
def up
execute %q{
create table class4.gateway_nat_handling_modes (
id smallint primary key,
name varchar not null unique
);
insert into class4.gateway_nat_handling_modes( id,name) values (0, 'Disabled');
insert into class4.gateway_nat_handling_modes( id,name) values (1, 'Learn next hop from incoming requests');
insert into class4.gateway_nat_handling_modes( id,name) values (2, 'Use R-Uri as next hop(Ignore incoming contact)');
alter table class4.gateways
add nat_handling_mode_id smallint not null default 1 references class4.gateway_nat_handling_modes(id);
alter table class4.lnp_cache
add routing_tag_id smallint;
}
end


def down
execute %q{
-- drop schema switch19 cascade;
alter table class4.gateways drop column nat_handling_mode_id;
drop table class4.gateway_nat_handling_modes;
alter table class4.lnp_cache drop column routing_tag_id;
}
end
end

0 comments on commit ef20956

Please sign in to comment.