Commit Graph

33876 Commits

Author SHA1 Message Date
Joshua C. Colp
26319476e9 Revert "app_record: Add RECORD_TIME output variable."
This reverts commit 6e8dccdbbf.
2024-04-30 14:14:39 -03:00
Naveen Albert
6e8dccdbbf app_record: Add RECORD_TIME output variable.
This adds the RECORD_TIME variable to Record(),
which is set to the recording duration before
the application returns.

Resolves: #548

UpgradeNote: The RECORD_TIME variable now contains
the duration of Record() recordings in milliseconds.
2024-04-30 15:25:44 +00:00
Naveen Albert
7cffbabe5c say.c: Fix cents off-by-one due to floating point rounding.
Some of the money announcements can be off by one cent,
due to the use of floating point in the money calculations,
which is bad for obvious reasons.

This replaces floating point with simple string parsing
to ensure the cents value is converted accurately.

Resolves: #525
2024-04-30 15:17:21 +00:00
Naveen Albert
01ff5c8140 loader.c: Allow dependent modules to be unloaded recursively.
Because of the (often recursive) nature of module dependencies in
Asterisk, hot swapping a module on the fly is cumbersome if a module
is depended on by other modules. Currently, dependencies must be
popped manually by unloading dependents, unloading the module of
interest, and then loading modules again in reverse order.

To make this easier, the ability to do this recursively in certain
circumstances has been added, as an optional extension to the
"module refresh" command. If requested, Asterisk will check if a module
that has a positive usecount could be unloaded safely if anything
recursively dependent on it were unloaded. If so, it will go ahead
and unload all these modules and load them back again. This makes
hot swapping modules that provide dependencies much easier.

Resolves: #474

UserNote: In certain circumstances, modules with dependency relations
can have their dependents automatically recursively unloaded and loaded
again using the "module refresh" CLI command or the ModuleLoad AMI command.
2024-04-30 14:14:17 +00:00
Henrik Liljedahl
b267629b77 res_pjsip_sdp_rtp.c: Initial RTP inactivity check must consider the rtp_timeout setting.
First rtp activity check was performed after 500ms regardless of the rtp_timeout setting. Having a call in ringing state for more than rtp_timeout and the first rtp package is received more than 500ms after sdp negotiation and before the rtp_timeout, erronously caused the call to be hungup. Changed to perform the first rtp inactivity check after the timeout setting preventing calls to be disconnected before the rtp_timeout has elapsed since sdp negotiation.

Fixes #710
2024-04-29 19:54:58 +00:00
George Joseph
8e119a72f0 tcptls/iostream: Add support for setting SNI on client TLS connections
If the hostname field of the ast_tcptls_session_args structure is
set (which it is for websocket client connections), that hostname
will now automatically be used in an SNI TLS extension in the client
hello.

Resolves: #713

UserNote: Secure websocket client connections now send SNI in
the TLS client hello.
2024-04-29 13:24:07 +00:00
George Joseph
758ed2b9fd stir_shaken: Fix memory leak, typo in config, tn canonicalization
* Fixed possible memory leak in tn_config:tn_get_etn() where we
weren't releasing etn if tn or eprofile were null.
* We now canonicalize TNs before using them for lookups or adding
them to Identity headers.
* Fixed a typo in stir_shaken.conf.sample.

Resolves: #716
2024-04-29 13:02:11 +00:00
George Joseph
a07a16aa23 make_buildopts_h: Always include DETECT_DEADLOCKS
Since DETECT_DEADLOCKS is now split from DEBUG_THREADS, it must
always be included in buildopts.h instead of only when
ADD_CFLAGS_TO_BUILDOPTS_H is defined.  A SEGV will result otherwise.

Resolves: #719
2024-04-29 13:01:10 +00:00
Spiridonov Dmitry
7e7a603360 sorcery.c: Fixed crash error when executing "module reload"
Fixed crash error when cli "module reload". The error appears when
compiling with res_prometheus and using the sorcery memory cache for
registrations
2024-04-22 12:55:45 +00:00
Naveen Albert
c1b69d460d callerid.c: Parse previously ignored Caller ID parameters.
Commit f2f397c1a8 previously
made it possible to send Caller ID parameters to FXS stations
which, prior to that, could not be sent.

This change is complementary in that we now handle receiving
all these parameters on FXO lines and provide these up to
the dialplan, via chan_dahdi. In particular:

* If a redirecting reason is provided, the channel's redirecting
  reason is set. No redirecting number is set, since there is
  no parameter for this in the Caller ID protocol, but the reason
  can be checked to determine if and why a call was forwarded.
* If the Call Qualifier parameter is received, the Call Qualifier
  variable is set.
* Some comments have been added to explain why some of the code
  is the way it is, to assist other people looking at it.

With this change, Asterisk's Caller ID implementation is now
reasonably complete for both FXS and FXO operation.

Resolves: #681
2024-04-22 12:02:44 +00:00
George Joseph
57ce1fe01b logger.h: Add SCOPE_CALL and SCOPE_CALL_WITH_RESULT
If you're tracing a large function that may call another function
multiple times in different circumstances, it can be difficult to
see from the trace output exactly which location that function
was called from.  There's no good way to automatically determine
the calling location.  SCOPE_CALL and SCOPE_CALL_WITH_RESULT
simply print out a trace line before and after the call.

The difference between SCOPE_CALL and SCOPE_CALL_WITH_RESULT is
that SCOPE_CALL ignores the function's return value (if any) where
SCOPE_CALL_WITH_RESULT allows you to specify the type of the
function's return value so it can be assigned to a variable.
SCOPE_CALL_WITH_INT_RESULT is just a wrapper for SCOPE_CALL_WITH_RESULT
and the "int" return type.
2024-04-19 17:29:37 +00:00
Sean Bright
a358458912 app_queue.c: Properly handle invalid strategies from realtime.
The existing code sets the queue strategy to `ringall` but it is then
immediately overwritten with an invalid one.

Fixes #707
2024-04-17 14:32:45 +00:00
Naveen Albert
a0b579807c file.c, channel.c: Don't emit warnings if progress received.
Silently ignore AST_CONTROL_PROGRESS where appropriate,
as most control frames already are.

Resolves: #696
2024-04-17 14:31:46 +00:00
Sean Bright
79210720bc alembic: Correct NULLability of PJSIP id columns.
Fixes #695
2024-04-09 20:13:27 +00:00
George Joseph
70fd8f1c93 rtp_engine and stun: call ast_register_atexit instead of ast_register_cleanup
rtp_engine.c and stun.c were calling ast_register_cleanup which
is skipped if any loadable module can't be cleanly unloaded
when asterisk shuts down.  Since this will always be the case,
their cleanup functions never get run.  In a practical sense
this makes no difference since asterisk is shutting down but if
you're in development mode and trying to use the leak sanitizer,
the leaks from both of those modules clutter up the output.
2024-04-09 20:12:38 +00:00
George Joseph
52881ef6e5 manager.c: Add missing parameters to Login documentation
* Added the AuthType and Key parameters for MD5 authentication.

* Added the Events parameter.

Resolves: #689
2024-04-03 19:04:39 +00:00
Naveen Albert
bb33925d75 func_callerid: Emit warning if invalid redirecting reason set.
Emit a warning if REDIRECTING(reason) is set to an invalid
reason, consistent with what happens when
REDIRECTING(orig-reason) is set to an invalid reason.

Resolves: #683
2024-04-03 17:23:16 +00:00
Naveen Albert
0923a49cc2 chan_dahdi: Add DAHDIShowStatus AMI action.
* Add an AMI action to correspond to the "dahdi show status"
  command, allowing span information to be retrieved via AMI.
* Show span number and sig type in "dahdi show channels".

Resolves: #673
2024-04-03 17:20:02 +00:00
Sperl Viktor
0ab4a5ef6b res_pjsip_endpoint_identifier_ip: Add endpoint identifier transport address.
Add a new identify_by option to res_pjsip_endpoint_identifier_ip
called 'transport' this matches endpoints based on the bound
ip address (local) instead of the 'ip' option, which matches on
the source ip address (remote).

UserNote: set identify_by=transport for the pjsip endpoint. Then
use the existing 'match' option and the new 'transport' option of
the identify.

Fixes: #672
2024-04-03 17:18:00 +00:00
George Joseph
b23f089472 res_stir_shaken: Fix compilation for CentOS7 (openssl 1.0.2)
* OpenSSL 1.0.2 doesn't support X509_get0_pubkey so we now use
  X509_get_pubkey.  The difference is that X509_get_pubkey requires
  the caller to free the EVP_PKEY themselves so we now let
  RAII_VAR do that.
* OpenSSL 1.0.2 doesn't support upreffing an X509_STORE so we now
  wrap it in an ao2 object.
* OpenSSL 1.0.2 doesn't support X509_STORE_get0_objects to get all
  the certs from an X509_STORE and there's no easy way to polyfill
  it so the CLI commands that list profiles will show a "not
  supported" message instead of listing the certs in a store.

Resolves: #676
2024-04-03 15:28:11 +00:00
George Joseph
f6b9d9e7d7 Fix incorrect application and function documentation references
There were a few references in the embedded documentation XML
where the case didn't match or where the referenced app or function
simply didn't exist any more.  These were causing 404 responses
in docs.asterisk.org.
2024-04-01 19:02:09 +00:00
Sean Bright
2b5673b68d cli.c: core show channels concise is not really deprecated.
Fixes #675
2024-04-01 18:13:53 +00:00
Sperl Viktor
895ab9d798 res_pjsip_endpoint_identifier_ip: Endpoint identifier request URI
Add ability to match against PJSIP request URI.

UserNote: this new feature let users match endpoints based on the
indound SIP requests' URI. To do so, add 'request_uri' to the
endpoint's 'identify_by' option. The 'match_request_uri' option of
the identify can be an exact match for the entire request uri, or a
regular expression (between slashes). It's quite similar to the
header identifer.

Fixes: #599
2024-03-28 15:05:05 +00:00
Joshua Elson
c8ab570c6f Implement Configurable TCP Keepalive Settings in PJSIP Transports
This commit introduces configurable TCP keepalive settings for both TCP and TLS transports. The changes allow for finer control over TCP connection keepalives, enhancing stability and reliability in environments prone to connection timeouts or where intermediate devices may prematurely close idle connections. This has proven necessary and has already been tested in production in several specialized environments where access to the underlying transport is unreliable in ways invisible to the operating system directly, so these keepalive and timeout mechanisms are necessary.

Fixes #657
2024-03-28 06:55:38 -06:00
Naveen Albert
2de1a68339 chan_dahdi: Don't retry opening nonexistent channels on restart.
Commit 729cb1d390 added logic to retry
opening DAHDI channels on "dahdi restart" if they failed initially,
up to 1,000 times in a loop, to address cases where the channel was
still in use. However, this retry loop does not use the actual error,
which means chan_dahdi will also retry opening nonexistent channels
1,000 times per channel, causing a flood of unnecessary warning logs
for an operation that will never succeed, with tens or hundreds of
thousands of open attempts being made.

The original patch would have been more targeted if it only retried
on the specific relevant error (likely EBUSY, although it's hard to
say since the original issue is no longer available).

To avoid the problem above while avoiding the possibility of breakage,
this skips the retry logic if the error is ENXIO (No such device or
address), since this will never succeed.

Resolves: #669
2024-03-27 15:03:52 +00:00
Martin Tomec
4ebef70763 res_pjsip_refer.c: Allow GET_TRANSFERRER_DATA
There was functionality in chan_sip to get REFER headers, with GET_TRANSFERRER_DATA variable. This commit implements the same functionality in pjsip, to ease transfer from chan_sip to pjsip.

Fixes: #579

UserNote: the GET_TRANSFERRER_DATA dialplan variable can now be used also in pjsip.
2024-03-26 13:29:59 +00:00
Martin Nystroem
394ffc27ea res_ari.c: Add additional output to ARI requests when debug is enabled
When ARI debug is enabled the logs will now output http method and the uri.

Fixes: #666
2024-03-25 14:51:37 +00:00
Sean Bright
63168983aa alembic: Fix compatibility with SQLAlchemy 2.0+.
SQLAlchemy 2.0 changed the way that commits/rollbacks are handled
causing the final `UPDATE` to our `alembic_version_<whatever>` tables
to be rolled back instead of committed.

We now use one connection to determine which
`alembic_version_<whatever>` table to use and another to run the
actual migrations. This prevents the erroneous rollback.

This change is compatible with both SQLAlchemy 1.4 and 2.0.
2024-03-22 13:53:57 +00:00
jonatascalebe
988986bdc9 manager.c: Add new parameter 'PreDialGoSub' to Originate AMI action
manager.c: Add new parameter 'PreDialGoSub' to Originate AMI action

The action originate does not has the ability to run an subroutine at initial channel, like the Aplication Originate. This update give this ability for de action originate too.

For example, we can run a routine via Gosub on the channel to request an automatic answer, so the caller does not need to accept the call when using the originate command via manager, making the operation more efficient.

UserNote: When using the Originate AMI Action, we now can pass the PreDialGoSub parameter, instructing the asterisk to perform an subrouting at channel before call start. With this parameter an call initiated by AMI can request the channel to start the call automaticaly, adding a SIP header to using GoSUB, instructing to autoanswer the channel, and proceeding the outbuound extension executing. Exemple of an context to perform the previus indication:
[addautoanswer]
exten => _s,1,Set(PJSIP_HEADER(add,Call-Info)=answer-after=0)
exten => _s,n,Set(PJSIP_HEADER(add,Alert-Info)=answer-after=0)
exten => _s,n,Return()
2024-03-22 13:53:37 +00:00
Naveen Albert
4c280c21c2 menuselect: Minor cosmetic fixes.
Improve some of the formatting from
dd3f17c699
(#521).
2024-03-22 13:22:09 +00:00
Naveen Albert
fc80bed5a7 pbx_variables.c: Prevent SEGV due to stack overflow.
It is possible for dialplan to result in an infinite
recursion of variable substitution, which eventually
leads to stack overflow. If we detect this, abort
substitution and log an error for the user to fix
the broken dialplan.

Resolves: #480

UpgradeNote: The maximum amount of dialplan recursion
using variable substitution (such as by using EVAL_EXTEN)
is capped at 15.
2024-03-22 13:04:37 +00:00
Holger Hans Peter Freyther
688095c6cb res_prometheus: Fix duplicate output of metric and help text
The prometheus exposition format requires each line to be unique[1].
This is handled by struct prometheus_metric having a list of children
that is managed when registering a metric. In case the scrape callback
is used, it is the responsibility of the implementation to handle this
correctly.

Originally the bridge callback didn't handle NULL snapshots, the crash
fix lead to NULL metrics, and fixing that lead to duplicates.

The original code assumed that snapshots are not NULL and then relied on
"if (i > 0)" to establish the parent/children relationship between
metrics of the same class. This is not workerable as the first bridge
might be invisible/lacks a snapshot.

Fix this by keeping a separate array of the first metric by class.
Instead of relying on the index of the bridge, check whether the array
has an entry. Use that array for the output.

Add a test case that verifies that the help text is not duplicated.

Resolves: #642

[1] https://prometheus.io/docs/instrumenting/exposition_formats/#grouping-and-sorting
2024-03-21 18:55:23 +00:00
Naveen Albert
ef7788e0e4 manager.c: Add CLI command to kick AMI sessions.
This adds a CLI command that can be used to manually
kick specific AMI sessions.

Resolves: #485

UserNote: The "manager kick session" CLI command now
allows kicking a specified AMI session.
2024-03-21 17:05:21 +00:00
George Joseph
555a541680 .github: NightlyAdmin now calls external CloseStaleIssuesAndPRs 2024-03-20 13:07:44 -06:00
Naveen Albert
953dc3d127 chan_dahdi: Allow specifying waitfordialtone per call.
The existing "waitfordialtone" setting in chan_dahdi.conf
applies permanently to a specific channel, regardless of
how it is being used. This rather restrictively prevents
a system from simultaneously being able to pick free lines
for outgoing calls while also allowing barge-in to a trunk
by some other arrangement.

This allows specifying "waitfordialtone" using the CHANNEL
function for only the next call that will be placed, allowing
significantly more flexibility in the use of trunk interfaces.

Resolves: #472

UserNote: "waitfordialtone" may now be specified for DAHDI
trunk channels on a per-call basis using the CHANNEL function.
2024-03-20 12:49:08 +00:00
Naveen Albert
786f45d94e res_parking: Fail gracefully if parking lot is full.
Currently, if a parking lot is full, bridge setup returns -1,
causing dialplan execution to terminate without TryExec.
However, such failures should be handled more gracefully,
the same way they are on other paths, as indicated by the
module's author, here:

http://lists.digium.com/pipermail/asterisk-dev/2018-December/077144.html

Now, callers will hear the parking failure announcement, and dialplan
will continue, which is consistent with existing failure modes.

Resolves: #624
2024-03-20 12:47:58 +00:00
Sean Bright
d2b6248196 res_config_mysql.c: Support hostnames up to 255 bytes.
Fixes #654
2024-03-20 12:43:52 +00:00
Sean Bright
e5e9692738 res_pjsip: Fix alembic downgrade for boolean columns.
When downgrading, ensure that we don't touch columns that didn't
actually change during upgrade.
2024-03-20 12:09:45 +00:00
Stanislav Abramenkov
49e6661e40 Upgrade bundled pjproject to 2.14.1
Fixes: asterisk#648

UserNote: Bundled pjproject has been upgraded to 2.14.1. For more
information visit pjproject Github page: https://github.com/pjsip/pjproject/releases/tag/2.14.1
2024-03-19 20:58:28 +00:00
Sean Bright
e0d3e9da23 alembic: Quote new MySQL keyword 'qualify.'
Fixes #651
2024-03-19 20:57:56 +00:00
Maximilian Fridrich
e8cfed4516 res_pjsip_session: Reset pending_media_state->read_callbacks
In handle_negotiated_sdp the pending_media_state->read_callbacks must be
reset before they are added in the SDP handlers in
handle_negotiated_sdp_session_media. Otherwise, old callbacks for
removed streams and file descriptors could be added to the channel and
Asterisk would poll on non-existing file descriptors.

Resolves: #611
2024-03-19 20:20:39 +00:00
George Joseph
67613d19d6 res_pjsip_stir_shaken.c: Add checks for missing parameters
* Added checks for missing session, session->channel and rdata
  in stir_shaken_incoming_request.

* Added checks for missing session, session->channel and tdata
  in stir_shaken_outgoing_request.

Resolves: #645
2024-03-11 16:43:27 +00:00
George Joseph
34196f8796 .github: Add PAT to PRSubmitActions/Add Reviewers 2024-03-06 09:21:33 -07:00
Naveen Albert
320c98eec8 app_dial: Add dial time for progress/ringing.
Add a timeout option to control the amount of time
to wait if no early media is received before giving
up. This allows aborting early if the destination
is not being responsive.

Resolves: #588

UserNote: The timeout argument to Dial now allows
specifying the maximum amount of time to dial if
early media is not received.
2024-03-06 14:26:21 +00:00
Naveen Albert
b791c27385 app_voicemail: Properly reinitialize config after unit tests.
Most app_voicemail unit tests were not properly cleaning up
after themselves after running. This led to test mailboxes
lingering around in the system. It also meant that if any
unit tests in app_voicemail that create mailboxes were executed
and the module was not unloaded/loaded again prior to running
the test_voicemail_vm_info unit test, Asterisk would segfault
due to an attempt to copy a NULL string.

The load_config test did actually have logic to reinitialize
the config after the test. However, this did not work in practice
since load_config() would not reload the config since voicemail.conf
had not changed during the test; thus, additional logic has been
added to ensure that voicemail.conf is truly reloaded, after any
unit tests which modify the users list.

This prevents the SEGV due to invalid mailboxes lingering around,
and also ensures that the system state is restored to what it was
prior to the tests running.

Resolves: #629
2024-03-06 14:05:17 +00:00
Shaaah
037792b57b app_queue.c : fix "queue add member" usage string
Fixing bracket placement in the "queue add member" cli usage string.
2024-03-06 14:03:29 +00:00
Naveen Albert
b5850941b1 app_voicemail: Allow preventing mark messages as urgent.
This adds an option to allow preventing callers from leaving
messages marked as 'urgent'.

Resolves: #619

UserNote: The leaveurgent mailbox option can now be used to
control whether callers may leave messages marked as 'Urgent'.
2024-03-05 23:35:11 +00:00
Sean Bright
6291ddaf90 res_pjsip: Use consistent type for boolean columns.
This migrates the relevant schema objects from the `('yes', 'no')`
definition to the `('0', '1', 'off', 'on', 'false', 'true', 'yes', 'no')`
one.

Fixes #617
2024-03-05 23:30:39 +00:00
George Joseph
109115de3d .github: Remove timeout-minutes from gatetests 2024-03-05 15:17:55 -07:00
George Joseph
d478002ad5 attestation_config.c: Use ast_free instead of ast_std_free
In as_check_common_config, we were calling ast_std_free on
raw_key but raw_key was allocated with ast_malloc so it
should be freed with ast_free.

Resolves: #636
2024-03-05 22:16:35 +00:00