summaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
authorJoshua Colp <jcolp@digium.com>2017-10-24 15:33:57 +0000
committerJoshua Colp <jcolp@digium.com>2017-10-25 18:13:26 +0000
commit7385d1e017e562afe64431606e857e704f86a16d (patch)
treee73d8cc4691607c4ba43a3012710cddea60d1158 /contrib
parente7d8b4ebe7d2f0cd9d83fdd44613a8d3ac1b7315 (diff)
res_pjsip: Add 'ip' as a valid option to 'identify_by' on endpoint.
When the identify_by option on an endpoint is set to ip it will only be identified using the res_pjsip_endpoint_identifier_ip module. This ensures that it is not mistakenly matched using the username of the From header. To ensure behavior has not changed the default has been changed to "username,ip" for the identify_by option. ASTERISK-27206 Change-Id: I2170b86a7f7e221b4f00bf14aa1ef1ac5b050bbd
Diffstat (limited to 'contrib')
-rw-r--r--contrib/ast-db-manage/config/versions/20abce6d1e3c_add_pjsip_identify_by_ip.py46
1 files changed, 46 insertions, 0 deletions
diff --git a/contrib/ast-db-manage/config/versions/20abce6d1e3c_add_pjsip_identify_by_ip.py b/contrib/ast-db-manage/config/versions/20abce6d1e3c_add_pjsip_identify_by_ip.py
new file mode 100644
index 000000000..d457c9233
--- /dev/null
+++ b/contrib/ast-db-manage/config/versions/20abce6d1e3c_add_pjsip_identify_by_ip.py
@@ -0,0 +1,46 @@
+"""add pjsip identify by ip
+
+Revision ID: 20abce6d1e3c
+Revises: a1698e8bb9c5
+Create Date: 2017-10-24 15:44:06.404774
+
+"""
+
+# revision identifiers, used by Alembic.
+revision = '20abce6d1e3c'
+down_revision = 'a1698e8bb9c5'
+
+from alembic import op
+import sqlalchemy as sa
+
+
+def enum_update(table_name, column_name, enum_name, enum_values):
+ 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', 'ps_endpoints')
+ op.alter_column(table_name, column_name,
+ type_=sa.Enum(*enum_values, name=enum_name))
+ return
+
+ # Postgres requires a few more steps
+ tmp = enum_name + '_tmp'
+
+ op.execute('ALTER TYPE ' + enum_name + ' RENAME TO ' + tmp)
+
+ 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)
+
+ op.execute('DROP TYPE ' + tmp)
+
+
+def upgrade():
+ enum_update('ps_endpoints', 'identify_by', 'pjsip_identify_by_values',
+ ['username', 'auth_username', 'ip'])
+
+
+def downgrade():
+ enum_update('ps_endpoints', 'identify_by', 'pjsip_identify_by_values',
+ ['username', 'auth_username'])