Commit graph

3953 commits

Author SHA1 Message Date
Matt Jordan
1475604eff res_pjsip_endpoint_identifier_ip: Add an option to match requests by header
This patch adds a new features to the endpoint identifier module,
'match_header'. When set, inbound requests are matched by a provided SIP
header: value pair. This option works in conjunction with the existing
'match' configuration option, such that if any 'match*' attribute
matches an inbound request, the request is associated with the specified
endpoint.

Since this module now identifies by more than just IP address,
appropriate renaming of the module and/or variables can be done in a
non-release branch.

ASTERISK-26863 #close

Change-Id: Icfc14835c962f92e35e67bbdb235cf0589de5453
(cherry picked from commit 30f52d79d7)
2017-03-15 07:51:35 -06:00
George Joseph
71cc3fd969 Merge "res_pjsip_endpoint_identifier_ip: Clean up a spaces/tabs issue" 2017-03-15 08:47:36 -05:00
zuul
c152329932 Merge "res_pjsip_transport_websocket: Add support for IPv6." 2017-03-14 21:22:26 -05:00
Matt Jordan
2d7e68c075 res_pjsip_endpoint_identifier_ip: Clean up a spaces/tabs issue
Tabs > spaces. Always.

Change-Id: I899ff662361c7ab0327173bd7851a67b53dd65f1
2017-03-14 07:00:02 -06:00
Daniel Journo
b14724adb3 res_musiconhold: moh general section is a class and issues warning
* res_musiconhold.c: Ensure the general section is not treated as
a moh class.

ASTERISK-26353 #close

Change-Id: Ia3dbd11ea2b43ab3e6c820a9827811dd24bea82d
2017-03-09 10:36:35 -06:00
Joshua Colp
4e3b0cedba res_pjsip_transport_websocket: Add support for IPv6.
This change adds a PJSIP patch (which has been contributed upstream)
to allow the registration of IPv6 transport types.

Using this the res_pjsip_transport_websocket module now registers
an IPv6 Websocket transport and uses it for the corresponding
traffic.

ASTERISK-26685

Change-Id: Id1f9126f995b31dc38db8fdb58afd289b4ad1647
2017-03-08 15:09:59 -06:00
Mark Michelson
5d0371d743 res_http_websocket: Fix faulty read logic.
When doing some WebRTC testing, I found that the websocket would
disconnect whenever I attempted to place a call into Asterisk. After
looking into it, I pinpointed the problem to be due to the iostreams
change being merged in.

Under certain circumstances, a call to ast_iostream_read() can return a
negative value. However, in this circumstance, the websocket code was
treating this negative return as if it were a partial read from the
websocket. The expected length would get adjusted by this negative
value, resulting in the expected length being too large.

This patch simply adds an if check to be sure that we are only updating
the expected length of a read when the return from a read is positive.

ASTERISK-26842 #close
Reported by Mark Michelson

Change-Id: Ib4423239828a013d27d7bc477d317d2f02db61ab
2017-03-07 13:38:17 -06:00
Joshua Colp
e9b2360d17 Merge "res_pjsip WebRTC/websockets: Fix usage of WS vs WSS." 2017-03-01 17:24:43 -06:00
Jørgen H
7922f26cb0 res_pjsip WebRTC/websockets: Fix usage of WS vs WSS.
According to the RFC[1] WSS should only be used in the Via header
for secure Websockets.

* Use WSS in Via for secure transport.

* Only register one transport with the WS name because it would be
ambiguous.  Outgoing requests may try to find the transport by name and
pjproject only finds the first one registered.  This may mess up unsecure
websockets but the impact should be minimal.  Firefox and Chrome do not
support anything other than secure websockets anymore.

* Added and updated some debug messages concerning websockets.

* security_events.c: Relax case restriction when determining security
transport type.

* The res_pjsip_nat module has been updated to not touch the transport
on Websocket originating messages.

[1] https://tools.ietf.org/html/rfc7118

ASTERISK-26796 #close

Change-Id: Ie3a0fb1a41101a4c1e49d875a8aa87b189e7ab12
2017-03-01 09:53:18 -06:00
Sean Bright
1dacf317f3 res_config_pgsql: Make 'require' return consistent with other backends
res_config_pgsql should match the behavior of other realtime backend
drivers so that queue_log can disable adaptive logging.

ASTERISK-25628 #close
Reported by: Dmitry Wagin

Change-Id: Ic1fb1600c7ce10fdfb1bcdc43c5576b7e0014372
2017-03-01 07:27:50 -06:00
Joshua Colp
10d12b277c Merge "res_config_pgsql: Release table locks where appropriate" 2017-02-28 19:37:36 -06:00
Joshua Colp
063af910eb Merge "res_pjsip_outbound_registration: Subscribe to network change events" 2017-02-28 19:25:04 -06:00
Joshua Colp
5e5aff04ec Merge "res_pjsip_pubsub: Remove unneeded endpoint unref" 2017-02-28 17:32:25 -06:00
Joshua Colp
0986998f2f Merge "config: Improve documentation and behavior of outbound_proxy option." 2017-02-28 14:44:29 -06:00
Joshua Colp
9c714b03f9 Merge "res_pjsip: Fix crash when contact has no status" 2017-02-28 10:24:45 -06:00
Sean Bright
e5b44c26b4 res_config_pgsql: Release table locks where appropriate
The find_table() functions NULL or a locked table pointer. We are
not consistently calling release_table() in failure paths.

Change-Id: I6f665b455799c84b036e5b34904b82b05eab9544
2017-02-28 09:44:09 -06:00
George Joseph
fb68db87b1 res_pjsip_pubsub: Remove unneeded endpoint unref
When a subscription was being recreated and the endpoint wasn't
found, we were trying to unref the endpoint.  This was causing
FRACKs.  Removed the unref.

ASTERISK-26823 #close

Change-Id: If86d2aecff8fe853c7f38a1bfde721fcef3cd164
2017-02-27 20:09:36 -06:00
Jørgen H
ee0a123f43 res_pjsip: Fix crash when contact has no status
This change fixes an assumption in res_pjsip that a contact will
always have a status. There is a race condition where this is
not true and would crash. The status will now be unknown when
this situation occurs.

ASTERISK-26623 #close

Change-Id: Id52d3ca4d788562d236da49990a319118f8d22b5
2017-02-27 15:16:57 -06:00
George Joseph
22242fef5d res_pjsip_outbound_registration: Subscribe to network change events
Outbound registration now subscribes to network change events
published by res_stun_monitor and refreshes all registrations
when an event happens.

The 'pjsip send (un)register' CLI commands were updated to accept
'*all' as an argument to operate on all registrations.

The 'PJSIP(Un)Register' AMI commands were also updated to
accept '*all'.

ASTERISK-26808 #close

Change-Id: Iad58a9e0aa5d340477fca200bf293187a6ca5a25
2017-02-27 15:10:48 -06:00
Joshua Colp
2046743938 config: Improve documentation and behavior of outbound_proxy option.
This change updates the documentation for the outbound_proxy option
to ensure it is consistently stated that a full SIP URI must be
provided for the option.

The res_pjsip_outbound_registration module has also been changed so
that the provided outbound_proxy value is checked to ensure it is a
URI and if not an error is output stating so.

ASTERISK-26782

Change-Id: I6c239a32274846fd44e65b44ad9bf6373479b593
2017-02-24 14:05:17 -06:00
Joshua Colp
e4ba07f1a6 Merge "pjproject_bundled: Update for pjproject 2.6" 2017-02-24 12:49:07 -06:00
George Joseph
a537dae6d0 pjproject_bundled: Update for pjproject 2.6
* Removed all 2.5.5 functional patches.
 * Updated usages of pj_release_pool to be "safe".
 * Updated configure options to disable webrtc.
 * Updated config_site.h to disable webrtc in pjmedia.
 * Added Richard Mudgett's recent resolver patches.

Change-Id: Ib400cc4dfca68b3d07ce14d314e829bfddc252c7
2017-02-23 16:23:53 -06:00
Sean Bright
0f4b349d37 res_config_pgsql: Fix thread safety problems
* A missing AST_LIST_UNLOCK() in find_table()

* The ESCAPE_STRING() macro uses pgsqlConn under the hood and we were
  not consistently locking before calling it.

* There were a handful of other places where pgsqlConn was accessed
  directly without appropriate locking.

Change-Id: Iea63f0728f76985a01e95b9912c3c5c6065836ed
2017-02-23 14:56:53 -06:00
Sean Bright
e57961db84 res_config_ldap: Various code improvements
The initial motivation for this patch was to properly handle memory
allocation failures - we weren't checking the return values from the
various LDAP library allocation functions.

In the process, because update_ldap() and update2_ldap() were
substantially the same code, they've been consolidated.

Change-Id: Iebcfe404177cc6860ee5087976fe97812221b822
2017-02-22 17:37:52 -06:00
Joshua Colp
8f248f7a1c Merge "realtime: Centralize some common realtime backend code" 2017-02-22 05:53:50 -06:00
zuul
911252d7b5 Merge "res_pjsip_authenticator_digest.c: Fix sorcery's immutable contract violation." 2017-02-21 23:13:44 -06:00
zuul
1774f778f6 Merge "res_pjsip: Update artificial auth whenever default_realm changes." 2017-02-21 22:55:13 -06:00
zuul
ac6e0fdcdb Merge "res_pjsip: Update authentication realm documentation." 2017-02-21 22:39:09 -06:00
zuul
26d1bd2490 Merge "pjsip_distributor.c: Update some debug messages to get transaction name." 2017-02-21 20:01:08 -06:00
zuul
d90047fec3 Merge "res_config_ldap: Don't try to delete non-existent attributes" 2017-02-21 18:58:28 -06:00
zuul
fa7803e697 Merge "res_config_ldap: Remove extraneous line numbers from log messages" 2017-02-21 18:58:27 -06:00
zuul
66e3edada9 Merge "res_config_ldap: Make memory allocation more consistent" 2017-02-21 18:58:26 -06:00
zuul
da2ba22248 Merge "res_config_ldap: Fix configuration inheritance from _general" 2017-02-21 18:24:05 -06:00
zuul
d5e25d8e3d Merge "res_config_ldap: Fix erroneous LDAP_MOD_REPLACE in LDAP modify" 2017-02-21 17:57:24 -06:00
Joshua Colp
16b0bb39c1 Merge changes from topic 'sdp_state_beginnings'
* changes:
  Add SDP translator and PJMEDIA implementation.
  Add initial SDP options.
2017-02-21 13:37:03 -06:00
Sean Bright
6e6c96d713 realtime: Centralize some common realtime backend code
All of the realtime backends create artificial ast_categorys to pass
back into the core as query results. These categories have no filename
or line number information associated with them and the backends differ
slightly on how they create them. So create a couple helper macros to
help make things more consistent.

Also updated the call sites to remove redundant error messages about
memory allocation failure.

Note that res_config_ldap sets the category filename to the 'table name'
but that is not read by anything in the core, so I've dropped it.

Change-Id: I3a1fd91e0c807dea1ce3b643b0a6fe5be9002897
2017-02-21 10:53:17 -06:00
zuul
144b09ab41 Merge "realtime: Fix LIKE escaping in SQL backends" 2017-02-21 06:26:30 -06:00
Richard Mudgett
6f15500ced res_pjsip_authenticator_digest.c: Fix sorcery's immutable contract violation.
The inbound authentication object is supposed to be immutable when it is
stored in sorcery.  However, the immutable property is violated if the
authentication object does not have a realm set.

The immutable contract violation has a different effect depending upon
what sorcery back end is used.  If it is the config file back end you
would get the same object back until res_pjsip is reloaded.  If it is the
real-time or AstDB back end you would get a new object on each query.  If
it is cached you would get the same object back until it is refreshed from
the database.

Once an inbound authentication object has its realm set it may or may not
get updated again if the default_realm changes.

If the same authentication object is used for inbound and outbound
authentication then the immutable violation can make it very hard to
determine why the outbound authentication now fails.  The only diagnostic
message is a complaint about no realms matching when it had worked
earlier.  It fails because of the difference in behaviour for an empty
realm setting between inbound and outbound authentication objects.

* Fixed the sorcery object immutable violation by creating a new object
and setting the default_realm on it instead.  The new object is a shallow
copy for speed.

* The auth_store thread storage no longer holds an auth ref.  It
interferes with the shallow copy and never needed a ref anyway.

ASTERISK-26799 #close

Change-Id: I2328a52f61b78ed5fbba38180b7f183ee7e08956
2017-02-20 22:24:31 -06:00
Richard Mudgett
6400f5f309 res_pjsip: Update artificial auth whenever default_realm changes.
There was code attempting to update the artificial authentication object
whenever the default_realm changed.  However, once the artificial
authentication object was created it would never get updated.  The
artificial authentication object would require a system restart for a
change to the default_realm to take effect.

ASTERISK-26799

Change-Id: Id59036e9529c2d3ed728af2ed904dc36e7094802
2017-02-20 22:24:31 -06:00
Richard Mudgett
0b660c9989 res_pjsip: Update authentication realm documentation.
Using the same auth section for inbound and outbound authentication is not
recommended.  There is a difference in meaning for an empty realm setting
between inbound and outbound authentication uses.

An empty inbound auth realm represents the global section's default_realm
value when the authentication object is used to challenge an incoming
request.  An empty outgoing auth realm is treated as a don't care wildcard
when the authentication object is used to respond to an incoming
authentication challenge.

ASTERISK-26799

Change-Id: Id3952f7cfa1b6683b9954f2c5d2352d2f11059ce
2017-02-20 22:24:31 -06:00
Richard Mudgett
54812f18b5 pjsip_distributor.c: Update some debug messages to get transaction name.
* Removed overloaded unmatched response ignore.  We obviously sent the
request so we shouldn't ignore it because it isn't new work.

ASTERISK-26669
ASTERISK-26738

Change-Id: I55fb5cadc83a8e6699b347c6dc7fa32c5a617d37
2017-02-20 16:27:54 -06:00
zuul
10ef644d66 Merge "pjproject cli: Add object count after object lists" 2017-02-20 16:25:34 -06:00
zuul
e5897c92ff Merge "res_config_sqlite3: Properly create missing columns when necessary" 2017-02-20 15:43:16 -06:00
George Joseph
ffa7d69766 pjproject cli: Add object count after object lists
When listing a container, we now print the number of objects
in the container at the end of the list.

Change-Id: I791cbc3ee9da9a2af9adc655164b5d32953df812
2017-02-20 08:07:31 -06:00
Sean Bright
e84353b8a8 res_config_ldap: Don't try to delete non-existent attributes
OpenLDAP will raise an error when we try to delete an LDAP attribute
that doesn't exist. We need to filter out LDAP_MOD_DELETE requests
based on which attributes the current LDAP entry actually has. There
is of course a small window of opportunity for this to still fail,
but it is much less likely now.

Change-Id: I3fe1b04472733e43151563aaf9f8b49980273e6b
2017-02-20 07:06:00 -05:00
Sean Bright
9f392574f9 res_config_ldap: Remove extraneous line numbers from log messages
Extraneous line numbers were being output in many log messages. These
have been removed.

Change-Id: Ice9efa3d252ee87f37fa8f5ea852fda482675431
2017-02-20 07:05:54 -05:00
Sean Bright
ef0944395e res_config_ldap: Make memory allocation more consistent
The code in update_ldap() and update2_ldap() was using both Asterisk's
memory allocation routines as well as OpenLDAP's. I've changed it so
that everything that is passed to OpenLDAP's functions are allocated
with their routines.

Change-Id: Iafec9c1fd8ea49ccc496d6316769a6a426daa804
2017-02-20 07:05:47 -05:00
Sean Bright
dd3efdf525 res_config_ldap: Fix configuration inheritance from _general
The "_general" configuration section allows administrators to provide
both general configuration options (host, port, url, etc.) as well as a
global realtime-to-LDAP-attribute mapping that is a fallback if one of
the later sections do not override it. This neglected to exclude the
general configuration options from the mapping. As an example, during
my testing, chan_sip requested 'port' from realtime, and because I did
not have it defined, it pulled in the 'port' configuration option from
"_general." We now filter those out explicitly.

Change-Id: I1fc61560bf96b8ba623063cfb7e0a49c4690d778
2017-02-20 07:05:41 -05:00
Sean Bright
d6d86f1c09 res_config_ldap: Fix erroneous LDAP_MOD_REPLACE in LDAP modify
We always treat the first change of our modification batch as a
replacement when it sometimes is actually a delete. So we have to pass
the correct arguments to the OpenLDAP library.

ASTERISK-26580 #close
Reported by: Nicholas John Koch
Patches:
	res_config_ldap.c-11.24.1.patch (license #6833) patch uploaded
	by Nicholas John Koch

Change-Id: I0741d25de07c9539f1edc6eff3696165dfb64fbe
2017-02-20 07:05:31 -05:00
Sean Bright
44abe214d2 res_config_sqlite3: Fix crash when loading with invalid config
When ast_config_load() fails with CONFIG_STATUS_FILEINVALID, it has
already destroyed the ast_config struct for us. Trying to do it again
results in a crash.

Change-Id: If6a5c0ca718ad428e01a1fb25beb209a9ac18bc6
2017-02-18 12:19:37 -06:00