Skip to content
Snippets Groups Projects
  1. Apr 14, 2022
    • Joshua C. Colp's avatar
      func_odbc: Add SQL_ESC_BACKSLASHES dialplan function. · 88522c22
      Joshua C. Colp authored
      Some databases depending on their configuration using backslashes
      for escaping. When combined with the use of ' this can result in
      a broken func_odbc query.
      
      This change adds a SQL_ESC_BACKSLASHES dialplan function which can
      be used to escape the backslashes.
      
      This is done as a dialplan function instead of being always done
      as some databases do not require this, and always doing it would
      result in incorrect data being put into the database.
      
      ASTERISK-29838
      
      Change-Id: I152bf34899b96ddb09cca3e767254d8d78f0c83d
      88522c22
  2. Feb 25, 2022
    • Naveen Albert's avatar
      func_channel: Add lastcontext and lastexten. · 42525b0f
      Naveen Albert authored
      Adds the lastcontext and lastexten channel fields to allow users
      to access previous dialplan execution locations.
      
      ASTERISK-29840 #close
      
      Change-Id: Ib455fe300cc8e9a127686896ee2d0bd11e900307
      42525b0f
  3. Feb 24, 2022
    • Naveen Albert's avatar
      asterisk: Add macro for curl user agent. · 63db7505
      Naveen Albert authored
      Currently, each module that uses libcurl duplicates the standard
      Asterisk curl user agent.
      
      This adds a global macro for the Asterisk user agent used for
      curl requests to eliminate this duplication.
      
      ASTERISK-29861 #close
      
      Change-Id: I9fc37935980384b4daf96ae54fa3c9adb962ed2d
      63db7505
  4. Feb 23, 2022
    • Naveen Albert's avatar
      func_db: Add validity check for key names when writing. · 26141981
      Naveen Albert authored
      Adds a simple sanity check for key names when users are
      writing data to AstDB. This captures four cases indicating
      malformed keynames that generally result in bad data going
      into the DB that the user didn't intend: an empty key name,
      a key name beginning or ending with a slash, and a key name
      containing two slashes in a row. Generally, this is the
      result of a variable being used in the key name being empty.
      
      If a malformed key name is detected, a warning is emitted
      to indicate the bug in the dialplan.
      
      ASTERISK-29925 #close
      
      Change-Id: Ifc08a9fe532a519b1b80caca1aafed7611d573bf
      26141981
  5. Jan 31, 2022
    • Naveen Albert's avatar
      func_frame_drop: Fix typo referencing wrong buffer · 5df5a70d
      Naveen Albert authored
      In order to get around the issue of certain frames
      having names that could overlap, func_frame_drop
      surrounds names with commas for the purposes of
      comparison.
      
      The buffer is allocated and printed to properly,
      but the original buffer is used for comparison.
      In most cases, this wouldn't have had any effect,
      but that was not the intention behind the buffer.
      This updates the code to reference the modified
      buffer instead.
      
      ASTERISK-29854 #close
      
      Change-Id: I430b52e14e712d0e62a23aa3b5644fe958b684a7
      5df5a70d
  6. Jan 11, 2022
    • Naveen Albert's avatar
      documentation: Document built-in system and channel vars · 707f3217
      Naveen Albert authored
      Documentation for built-in special system and channel
      vars is currently outdated, and updating is a manual
      process since there is no XML documentation for these
      anywhere.
      
      This adds documentation for system vars to func_env
      and for channel vars to func_channel so that they
      appear along with the corresponding fields that would
      be accessed using a function.
      
      ASTERISK-29848 #close
      
      Change-Id: I6997f925c4a45fffe71321861f5898a8b7182fa9
      707f3217
  7. Dec 13, 2021
    • Naveen Albert's avatar
      func_json: Adds JSON_DECODE function · c0cdaf02
      Naveen Albert authored
      Adds the JSON_DECODE function for parsing JSON in the
      dialplan. JSON parsing already exists in the Asterisk
      core and is used for many different things. This
      function exposes the basic parsing capability to
      the user in the dialplan, for instance, in conjunction
      with CURL for using API responses.
      
      ASTERISK-29706 #close
      
      Change-Id: Iea60c49a7358dfdc2db60803cdc9a742f808ba2c
      c0cdaf02
  8. Dec 02, 2021
  9. Nov 30, 2021
    • Naveen Albert's avatar
      documentation: Standardize examples · bcb7aee7
      Naveen Albert authored
      Most examples in the XML documentation use the
      example tag to demonstrate examples, which gets
      parsed specially in the Wiki to make it easier
      to follow for users.
      
      This fixes a few modules to use the example
      tag instead of vanilla para tags to bring them
      in line with the standard syntax.
      
      ASTERISK-29777 #close
      
      Change-Id: I9acb6cc5faf1d220e73c6dd28592371d768d279b
      bcb7aee7
  10. Nov 18, 2021
  11. Nov 16, 2021
    • Josh Soref's avatar
      funcs: Spelling fixes · c0fafa18
      Josh Soref authored
      Correct typos of the following word families:
      
      effectively
      emitted
      expect
      anthony
      
      ASTERISK-29714
      
      Change-Id: Ic16f9ec855bb6d14ec8e170b90af9a36b06d488a
      c0fafa18
  12. Oct 19, 2021
    • Sean Bright's avatar
      func_talkdetect.c: Fix logical errors in silence detection. · 8c2720e5
      Sean Bright authored
      There are 3 separate changes here:
      
      1. The documentation erroneously stated that the dsp_talking_threshold
         argument was a number of milliseconds when it is actually an energy
         level used by the DSP code to classify talking vs. silence.
      
      2. Fixes a copy paste error in the argument handling code.
      
      3. Don't erroneously switch to the talking state if we aren't actively
         handling a frame we've classified as talking.
      
      Patch inspired by one provided by Moritz Fain (License #6961).
      
      ASTERISK-27816 #close
      
      Change-Id: I5953fd570b98b49c41cee55bfe3b941753fb2511
      8c2720e5
  13. Sep 22, 2021
  14. Sep 21, 2021
  15. Sep 10, 2021
    • Naveen Albert's avatar
      func_strings: Add STRBETWEEN function · 6198c1d2
      Naveen Albert authored
      Adds the STRBETWEEN function, which can be used to insert a
      substring between each character in a string. For instance,
      this can be used to insert pauses between DTMF tones in a
      string of digits.
      
      ASTERISK-29627
      
      Change-Id: Ice23009d4a8e9bb9718d2b2301d405567087d258
      6198c1d2
    • Naveen Albert's avatar
      func_env: Add DIRNAME and BASENAME functions · 19de228e
      Naveen Albert authored
      Adds the DIRNAME and BASENAME functions, which are
      wrappers around the corresponding C library functions.
      These can be used to safely and conveniently work with
      file paths and names in the dialplan.
      
      ASTERISK-29628 #close
      
      Change-Id: Id3aeb907f65c0ff96b6e57751ff0cb49d61db7f3
      19de228e
    • Naveen Albert's avatar
      func_sayfiles: Retrieve say file names · b6b7b149
      Naveen Albert authored
      Up until now, all of the logic used to translate
      arguments to the Say applications has been
      directly coupled to playback, preventing other
      modules from using this logic.
      
      This refactors code in say.c and adds a SAYFILES
      function that can be used to retrieve the file
      names that would be played. These can then be
      used in other applications or for other purposes.
      
      Additionally, a SayMoney application and a SayOrdinal
      application are added. Both SayOrdinal and SayNumber
      are also expanded to support integers greater than
      one billion.
      
      ASTERISK-29531
      
      Change-Id: If9718c89353b8e153d84add3cc4637b79585db19
      b6b7b149
  16. Aug 19, 2021
    • Naveen Albert's avatar
      func_math: Return integer instead of float if possible · c52ef4ac
      Naveen Albert authored
      The MIN, MAX, and ABS functions all support float
      arguments, but currently return floats even if the
      arguments are all integers and the response is
      a whole number, in which case the user is likely
      expecting an integer. This casts the float to an integer
      before printing into the response buffer if possible.
      
      ASTERISK-29495
      
      Change-Id: I902d29eacf3ecd0f8a6a5e433c97f0421d205488
      c52ef4ac
    • Naveen Albert's avatar
      func_scramble: Audio scrambler function · 3eec5b8c
      Naveen Albert authored
      Adds a function to scramble audio on a channel using
      whole spectrum frequency inversion. This can be used
      as a privacy enhancement with applications like
      ChanSpy or other potentially sensitive audio.
      
      ASTERISK-29542
      
      Change-Id: I01020769d91060a1f56a708eb405f87648d1a67e
      3eec5b8c
  17. Aug 09, 2021
    • Naveen Albert's avatar
      func_frame_drop: New function · 118d8482
      Naveen Albert authored
      Adds function to selectively drop specified frames
      in the TX or RX direction on a channel, including
      control frames.
      
      ASTERISK-29478
      
      Change-Id: I8147c9d55d74e2e48861edba6b22f930920541ec
      118d8482
  18. Jun 11, 2021
    • Jaco Kroon's avatar
      func_lock: Prevent module unloading in-use module. · 6b678210
      Jaco Kroon authored
      
      The scenario where a channel still has an associated datastore we
      cannot unload since there is a function pointer to the destroy and fixup
      functions in play.  Thus increase the module ref count whenever we
      allocate a datastore, and decrease it during destroy.
      
      In order to tighten the race that still exists in spite of this (below)
      add some extra failure cases to prevent allocations in these cases.
      
      Race:
      
      If module ref is zero, an LOCK or TRYLOCK is invoked (near)
      simultaneously on a channel that has NOT PREVIOUSLY taken a lock, and if
      in such a case the datastore is created *prior* to unloading being set
      to true (first step in module unload) then it's possible that the module
      will unload with the destructor being called (and segfault) post the
      module being unloaded.  The module will however wait for such locks to
      release prior to unloading.
      
      If post that we can recheck the module ref before returning the we can
      (in theory, I think) eliminate the last of the race.  This race is
      mostly theoretical in nature.
      
      Change-Id: I21a514a0b56755c578a687f4867eacb8b59e23cf
      Signed-off-by: default avatarJaco Kroon <jaco@uls.co.za>
      6b678210
    • Jaco Kroon's avatar
      func_lock: Add "dialplan locks show" cli command. · 6f303335
      Jaco Kroon authored
      
      For example:
      
      arthur*CLI> dialplan locks show
      func_lock locks:
      Name                                     Requesters Owner
      uls-autoref                              0          (unlocked)
      1 total locks listed.
      
      Obviously other potentially useful stats could be added (eg, how many
      times there was contention, how many times it failed etc ... but that
      would require keeping the stats and I'm not convinced that's worth the
      effort.  This was useful to troubleshoot some other issues so submitting
      it.
      
      Change-Id: Ib875e56feb49d523300aec5f36c635ed74843a9f
      Signed-off-by: default avatarJaco Kroon <jaco@uls.co.za>
      6f303335
    • Jaco Kroon's avatar
      func_lock: Fix memory corruption during unload. · a3df5d7d
      Jaco Kroon authored
      
      AST_TRAVERSE accessess current as current = current->(field).next ...
      and since we free current (and ast_free poisons the memory) we either
      end up on a ast_mutex_lock to a non-existing lock that can never be
      obtained, or a segfault.
      
      Incidentally add logging in the "we have to wait for a lock to release"
      case, and remove an ineffective statement that sets memory that was just
      cleared by ast_calloc to zero.
      
      Change-Id: Id19ba3d9867b23d0e6783b97e6ecd8e62698b8c3
      Signed-off-by: default avatarJaco Kroon <jaco@uls.co.za>
      a3df5d7d
    • Jaco Kroon's avatar
      func_lock: Fix requesters counter in error paths. · 6bd741b7
      Jaco Kroon authored
      
      In two places we bail out with failure after we've already incremented
      the requesters counter, if this occured then it would effectively result
      in unload to wait indefinitely, thus preventing clean shutdown.
      
      Change-Id: I362a6c0dc424f736d4a9c733d818e72d19675283
      Signed-off-by: default avatarJaco Kroon <jaco@uls.co.za>
      6bd741b7
  19. May 26, 2021
    • Naveen Albert's avatar
      func_math: Three new dialplan functions · 9106c9d1
      Naveen Albert authored
      Introduces three new dialplan functions, MIN and MAX,
      which can be used to calculate the minimum or
      maximum of up to two numbers, and ABS, an absolute
      value function.
      
      ASTERISK-29431
      
      Change-Id: I2bda9269d18f9d54833c85e48e41fce0e0ce4d8d
      9106c9d1
    • Naveen Albert's avatar
      func_volume: Add read capability to function. · 033c2a22
      Naveen Albert authored
      Up until now, the VOLUME function has been write
      only, so that TX/RX values can be set but not
      read afterwards. Now, previously set TX/RX values
      can be read later.
      
      ASTERISK-29439
      
      Change-Id: Ia23e92fa2e755c36e9c8e69f2940d2703ccccb5f
      033c2a22
  20. Mar 16, 2021
    • Joshua C. Colp's avatar
      xml: Embed module information into core XML documentation. · 60800b03
      Joshua C. Colp authored
      This change embeds the MODULEINFO block of modules
      into the core XML documentation. This provides a shared
      mechanism for use by both menuselect and Asterisk for
      information and a definitive source of truth.
      
      ASTERISK-29335
      
      Change-Id: Ifbfd5c700049cf320a3e45351ac65dd89bc99d90
      60800b03
  21. Mar 10, 2021
  22. Feb 23, 2021
    • Jaco Kroon's avatar
      func_odbc: Introduce minargs config and expose ARGC in addition to ARGn. · bee35fe0
      Jaco Kroon authored
      
      minargs enables enforcing of minimum count of arguments to pass to
      func_odbc, so if you're unconditionally using ARG1 through ARG4 then
      this should be set to 4.  func_odbc will generate an error in this case,
      so for example
      
      [FOO]
      minargs = 4
      
      and ODBC_FOO(a,b,c) in dialplan will now error out instead of using a
      potentially leaked ARG4 from Gosub().
      
      ARGC is needed if you're using optional argument, to verify whether or
      not an argument has been passed, else it's possible to use a leaked ARGn
      from Gosub (app_stack).  So now you can safely do
      ${IF($[${ARGC}>3]?${ARGV}:default value)} kind of thing.
      
      Change-Id: I6ca0b137d90b03f6aa9c496991f6cbf1518f6c24
      Signed-off-by: default avatarJaco Kroon <jaco@uls.co.za>
      bee35fe0
  23. Jan 06, 2021
    • Jaco Kroon's avatar
      func_lock: fix multiple-channel-grant problems. · 3a230cc6
      Jaco Kroon authored
      
      Under contention it becomes possible that multiple channels will be told
      they successfully obtained the lock, which is a bug.  Please refer
      
      ASTERISK-29217
      
      This introduces a couple of changes.
      
      1.  Replaces requesters ao2 container with simple counter (we don't
          really care who is waiting for the lock, only how many).  This is
          updated undex ->mutex to prevent memory access races.
      2.  Correct semantics for ast_cond_timedwait() as described in
          pthread_cond_broadcast(3P) is used (multiple threads can be released
          on a single _signal()).
      3.  Module unload races are taken care of and memory properly cleaned
          up.
      
      Change-Id: I6f68b5ec82ff25b2909daf6e4d19ca864a463e29
      Signed-off-by: default avatarJaco Kroon <jaco@uls.co.za>
      3a230cc6
  24. Nov 20, 2020
  25. Nov 06, 2020
    • Dovid Bender's avatar
      func_curl.c: Allow user to set what return codes constitute a failure. · c635c782
      Dovid Bender authored
      Currently any response from res_curl where we get an answer from the
      web server, regardless of what the response is (404, 403 etc.) Asterisk
      currently treats it as a success. This patch allows you to set which
      codes should be considered as a failure by Asterisk. If say we set
      failurecodes=404,403 then when using curl in realtime if a server gives
      a 404 error Asterisk will try to failover to the next option set in
      extconfig.conf
      
      ASTERISK-28825
      
      Reported by: Dovid Bender
      Code by: Gobinda Paul
      
      Change-Id: I94443e508343e0a3e535e51ea6e0562767639987
      c635c782
  26. Nov 03, 2020
  27. Sep 23, 2020
    • Sean Bright's avatar
      func_curl.c: Prevent crash when using CURLOPT(httpheader) · 28c88e8f
      Sean Bright authored
      Because we use shared thread-local cURL instances, we need to ensure
      that the state of the cURL instance is correct before each invocation.
      
      In the case of custom headers, we were not resetting cURL's internal
      HTTP header pointer which could result in a crash if subsequent
      requests do not configure custom headers.
      
      ASTERISK-29085 #close
      
      Change-Id: I8b4ab34038156dfba613030a45f10e932d2e992d
      28c88e8f
  28. Apr 20, 2020
  29. Apr 14, 2020
  30. Apr 08, 2020
  31. Mar 31, 2020
  32. Feb 10, 2020
  33. Jan 13, 2020
    • Sean Bright's avatar
      func_curl: Add 'followlocation' option to CURLOPT() · 0c2bf166
      Sean Bright authored
      We allow for 'maxredirs' to be set, but this value is ignored when
      followlocation is not enabled which, by default, it is not.
      
      ASTERISK-17491 #close
      Reported by: candrews
      
      Change-Id: I96a4ab0142f2fb7d2e96ff976f6cf7b2982c761a
      0c2bf166
Loading