summaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
authorRichard Mudgett <rmudgett@digium.com>2017-12-22 19:50:34 -0600
committerRichard Mudgett <rmudgett@digium.com>2018-01-16 12:50:34 -0600
commit8494e78010d8917a4165d877045be34ddc2dda22 (patch)
treeb1ecd89e12d5925258d337e67e966164b044f99c /contrib
parent2f392bedb3987ee3c587bd8b046299320b84d5c5 (diff)
res_pjsip: Split type=identify to IP address and SIP header matching priorities
The type=identify endpoint identification method can match by IP address and by SIP header. However, the SIP header matching has limited usefulness because you cannot specify the SIP header matching priority relative to the IP address matching. All the matching happens at the same priority and the order of evaluating the identify sections is indeterminate. e.g., If you had two type=identify sections where one matches by IP address for endpoint alice and the other matches by SIP header for endpoint bob then you couldn't predict which endpoint is matched when a request comes in that matches both. * Extract the SIP header matching criteria into its own "header" endpoint identification method so the user can specify the relative priority of the SIP header and the IP address matching criteria in the global endpoint_identifier_order option. The "ip" endpoint identification method now only matches by IP address. ASTERISK-27491 Change-Id: I9df142a575b7e1e3471b7cda5d3ea156cef08095
Diffstat (limited to 'contrib')
-rw-r--r--contrib/ast-db-manage/config/versions/52798ad97bdf_add_pjsip_identify_by_header.py57
1 files changed, 57 insertions, 0 deletions
diff --git a/contrib/ast-db-manage/config/versions/52798ad97bdf_add_pjsip_identify_by_header.py b/contrib/ast-db-manage/config/versions/52798ad97bdf_add_pjsip_identify_by_header.py
new file mode 100644
index 000000000..ab5939cfe
--- /dev/null
+++ b/contrib/ast-db-manage/config/versions/52798ad97bdf_add_pjsip_identify_by_header.py
@@ -0,0 +1,57 @@
+"""add pjsip identify by header
+
+Revision ID: 52798ad97bdf
+Revises: e2f04d309071
+Create Date: 2018-01-08 12:16:02.782277
+
+"""
+
+# revision identifiers, used by Alembic.
+revision = '52798ad97bdf'
+down_revision = 'e2f04d309071'
+
+from alembic import op
+import sqlalchemy as sa
+
+
+def column_upgrade(table_name, column_name, enum_name):
+ if op.get_context().bind.dialect.name != 'postgresql':
+ if op.get_context().bind.dialect.name == 'mssql':
+ op.drop_constraint('ck_ps_endpoints_identify_by_pjsip_identify_by_values',
+ table_name)
+ op.alter_column(table_name, column_name, type_=sa.String(80))
+ return
+
+ # Postgres requires a few more steps
+ op.execute('ALTER TABLE ' + table_name + ' ALTER COLUMN ' + column_name +
+ ' TYPE varchar(80) USING identify_by::text::' + enum_name)
+
+ op.execute('DROP TYPE ' + enum_name)
+
+
+def column_downgrade(table_name, column_name, enum_name, enum_values):
+ if op.get_context().bind.dialect.name != 'postgresql':
+ op.alter_column(table_name, column_name,
+ type_=sa.Enum(*enum_values, name=enum_name))
+ return
+
+ # Postgres requires a few more steps
+ updated = sa.Enum(*enum_values, name=enum_name)
+ updated.create(op.get_bind(), checkfirst=False)
+
+ op.execute('ALTER TABLE ' + table_name + ' ALTER COLUMN ' + column_name +
+ ' TYPE ' + enum_name + ' USING identify_by::text::' + enum_name)
+
+
+def upgrade():
+ # The ps_endpoints identify_by column has always been a comma separated
+ # list of enum values. This is better represented as a string anyway to
+ # avoid database compatibility issues. Also future changes are likely
+ # to allow loadable endpoint identifier names and negating fixed enum
+ # benefits.
+ column_upgrade('ps_endpoints', 'identify_by', 'pjsip_identify_by_values')
+
+
+def downgrade():
+ column_downgrade('ps_endpoints', 'identify_by', 'pjsip_identify_by_values',
+ ['username', 'auth_username', 'ip'])