Skip to content
Snippets Groups Projects
  1. Oct 25, 2017
    • Ben Ford's avatar
      http.c: Fix http header send content. · 3821be1c
      Ben Ford authored
      Currently ast_http_send barricades a portion of the content that
      needs to be sent in order to establish a connection for things
      like the ARI client. The conditional and contents have been changed
      to ensure that everything that needs to be sent, will be sent.
      
      ASTERISK-27372
      
      Change-Id: I8816d2d8f80f4fefc6dcae4b5fdfc97f1e46496d
      3821be1c
  2. Jul 11, 2017
    • George Joseph's avatar
      http.c: Reduce log spam · 303f935a
      George Joseph authored
      Messages like "fwrite() failed: Connection reset by peer" are no
      help whatsoever, especially since they can be caused simply by a
      client disconnecting.
      
      * Make those WARNINGs DEBUGs.
      * Check the return from ast_iostream_printf of headers.
      
      Change-Id: I17bd5f3621514152a7b2b263c801324c5e96568b
      303f935a
  3. Mar 20, 2017
    • Sean Bright's avatar
      thread safety: Don't use getprotobyname() · fc71c18a
      Sean Bright authored
      POSIX does not require getprotobyname() to be thread safe and some
      implementations use static memory which causes issues when multiple
      threads are used.
      
      Further, our usage of it today is just to ultimately get IPPROTO_TCP
      for calls to setsockopt(). So instead we just use IPPROTO_TCP directly.
      
      Change-Id: I2e14e58674808f7ce99b2f5e900d0f90d0d8da48
      fc71c18a
  4. Feb 16, 2017
  5. Dec 07, 2016
    • Mark Michelson's avatar
      http: Send headers and body in one write. · 50300612
      Mark Michelson authored
      This is a semi-regression caused by the iostreams change. Prior to
      iostreams, HTTP headers were written to a FILE handle using fprintf.
      Then the body was written using a call to fwrite(). Because of internal
      buffering, the result was that the HTTP headers and body would be sent
      out in a single write to the socket.
      
      With the change to iostreams, the HTTP headers are written using
      ast_iostream_printf(), which under the hood calls write(). The HTTP body
      calls ast_iostream_write(), which also calls write() under the hood.
      This results in two separate writes to the socket.
      
      Most HTTP client libraries out there will handle this change just fine.
      However, a few of our testsuite tests started failing because of the
      change. As a result, in order to reduce frustration for users, this
      change alters the HTTP code to write the headers and body in a single
      write operation.
      
      ASTERISK-26629 #close
      Reported by Joshua Colp
      
      Change-Id: Idc2d2fb3d9b3db14b8631a1e302244fa18b0e518
      50300612
  6. Nov 15, 2016
    • Timo Teräs's avatar
      Implement internal abstraction for iostreams · 070a51bf
      Timo Teräs authored
      fopencookie/funclose is a non-standard API and should not be used
      in portable software. Additionally, the way FILE's fd is used in
      non-blocking mode is undefined behaviour and cannot be relied on.
      
      This introduces internal abstraction for io streams, that allows
      implementing the desired virtualization of read/write operations
      with necessary timeout handling.
      
      ASTERISK-24515 #close
      ASTERISK-24517 #close
      
      Change-Id: Id916aef418b665ced6a7489aef74908b6e376e85
      070a51bf
  7. Oct 27, 2016
    • Corey Farrell's avatar
      Remove ASTERISK_REGISTER_FILE. · a6e5bae3
      Corey Farrell authored
      ASTERISK_REGISTER_FILE no longer has any purpose so this commit removes
      all traces of it.
      
      Previously exported symbols removed:
      * __ast_register_file
      * __ast_unregister_file
      * ast_complete_source_filename
      
      This also removes the mtx_prof static variable that was declared when
      MTX_PROFILE was enabled.  This variable was only used in lock.c so it
      is now initialized in that file only.
      
      ASTERISK-26480 #close
      
      Change-Id: I1074af07d71f9e159c48ef36631aa432c86f9966
      a6e5bae3
  8. Aug 19, 2016
    • Torrey Searle's avatar
      res_ari: Add http prefix to generated docs · c1b6a796
      Torrey Searle authored
      updated the uri handler to include the url prefix of the http server
      this enables res_ari to add it to the uris when generating docs
      
      Change-Id: I279335a2625261a8492206c37219698f42591c2e
      (cherry picked from commit 6f448f32)
      c1b6a796
  9. Jun 20, 2016
    • Alexander Traud's avatar
      http: leverage 'bindaddr' for TLS in http.conf · f72ffc1f
      Alexander Traud authored
      The internal HTTP/WebSocket server supports both TCP and TLS, which can be
      activated separately via the file http.conf. The source code intends to re-use
      the TCP parameter 'bindaddr' for TLS, even if 'tlsbindaddr' is not specified
      explicitly. This did not work because of a typo. This change resolves this typo.
      
      ASTERISK-26126 #close
      
      Change-Id: I5efb0409ae12044dfb3495b6b97b6d40a8c9c51f
      f72ffc1f
  10. Jun 08, 2016
    • Timo Teräs's avatar
      Fixes to include signal.h · 39b69ab5
      Timo Teräs authored
      POSIX defines signal.h. sys/signal.h should not be used as it is
      c-library internal header which may or may not exist. Notably with
      musl it generates warning of being incorrect.
      
      Change-Id: Ia56b0aa1d84b5c590114867b1b384a624f39a6fc
      39b69ab5
  11. Feb 03, 2016
    • Joshua Colp's avatar
      AST-2016-001 http: Provide greater control of TLS and set modern defaults. · 0de74fad
      Joshua Colp authored
      This change exposes the configuration of various aspects of the TLS
      support and sets the default to the modern standards.
      
      The TLS cipher is now set to the best values according to the
      Mozilla OpSec team, different TLS versions can now be disabled, and
      the cipher order can be forced to be that of the server instead of
      the client.
      
      ASTERISK-24972 #close
      
      Change-Id: I0a10f2883f7559af5e48dee0901251dbf30d45b8
      0de74fad
  12. Apr 13, 2015
    • Matt Jordan's avatar
      git migration: Refactor the ASTERISK_FILE_VERSION macro · 4a582616
      Matt Jordan authored
      Git does not support the ability to replace a token with a version
      string during check-in. While it does have support for replacing a
      token on clone, this is somewhat sub-optimal: the token is replaced
      with the object hash, which is not particularly easy for human
      consumption. What's more, in practice, the source file version was often
      not terribly useful. Generally, when triaging bugs, the overall version
      of Asterisk is far more useful than an individual SVN version of a file. As a
      result, this patch removes Asterisk's support for showing source file
      versions.
      
      Specifically, it does the following:
      
      * Rename ASTERISK_FILE_VERSION macro to ASTERISK_REGISTER_FILE, and
        remove passing the version in with the macro. Other facilities
        than 'core show file version' make use of the file names, such as
        setting a debug level only on a specific file. As such, the act of
        registering source files with the Asterisk core still has use. The
        macro rename now reflects the new macro purpose.
      
      * main/asterisk:
        - Refactor the file_version structure to reflect that it no longer
          tracks a version field.
        - Remove the "core show file version" CLI command. Without the file
          version, it is no longer useful.
        - Remove the ast_file_version_find function. The file version is no
          longer tracked.
        - Rename ast_register_file_version/ast_unregister_file_version to
          ast_register_file/ast_unregister_file, respectively.
      
      * main/manager: Remove value from the Version key of the ModuleCheck
        Action. The actual key itself has not been removed, as doing so would
        absolutely constitute a backwards incompatible change. However, since
        the file version is no longer tracked, there is no need to attempt to
        include it in the Version key.
      
      * UPGRADE: Add notes for:
        - Modification to the ModuleCheck AMI Action
        - Removal of the "core show file version" CLI command
      
      Change-Id: I6cf0ff280e1668bf4957dc21f32a5ff43444a40e
      4a582616
  13. Mar 26, 2015
  14. Feb 21, 2015
  15. Feb 11, 2015
    • Richard Mudgett's avatar
      HTTP: Stop accepting requests on final system shutdown. · e2d3215b
      Richard Mudgett authored
      There are three CLI commands to stop and restart Asterisk each.
      
      1) core stop/restart now - Hangup all calls and stop or restart Asterisk.
      New channels are prevented while the shutdown request is pending.
      
      2) core stop/restart gracefully - Stop or restart Asterisk when there are
      no calls remaining in the system.  New channels are prevented while the
      shutdown request is pending.
      
      3) core stop/restart when convenient - Stop or restart Asterisk when there
      are no calls in the system.  New calls are not prevented while the
      shutdown request is pending.
      
      ARI has made stopping/restarting Asterisk more problematic.  While a
      shutdown request is pending it is desirable to continue to process ARI
      HTTP requests for current calls.  To handle the current calls while a
      shutdown request is pending, a new committed to shutdown phase is needed
      so ARI applications can deal with the calls until the system is fully
      committed to shutdown.
      
      * Added a new shutdown committed phase so ARI applications can deal with
      calls until the final committed to shutdown phase is reached.
      
      * Made refuse new HTTP requests when the system has reached the final
      system shutdown phase.  Starting anything while the system is actively
      releasing resources and unloading modules is not a good thing.
      
      * Split the bridging framework shutdown to not cleanup the global bridging
      containers when shutting down in a hurry.  This is similar to how other
      modules prevent crashes on rapid system shutdown.
      
      * Moved ast_begin_shutdown(), ast_cancel_shutdown(), and
      ast_shutting_down().  You should not have to include channel.h just to
      access these system functions.
      
      ASTERISK-24752 #close
      Reported by: Matthew Jordan
      
      Review: https://reviewboard.asterisk.org/r/4399/
      ........
      
      Merged revisions 431692 from http://svn.asterisk.org/svn/asterisk/branches/13
      
      
      git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@431694 65c4cc65-6c06-0410-ace0-fbb531ad65f3
      e2d3215b
  16. Jan 30, 2015
  17. Dec 17, 2014
  18. Jul 07, 2014
  19. Jul 03, 2014
    • Richard Mudgett's avatar
      HTTP: Add persistent connection support. · dbec5e0d
      Richard Mudgett authored
      Persistent HTTP connection support is needed due to the increased usage of
      the Asterisk core HTTP transport and the frequency at which REST API calls
      are going to be issued.
      
      * Add http.conf session_keep_alive option to enable persistent
      connections.
      
      * Parse and discard optional chunked body extension information and
      trailing request headers.
      
      * Increased the maximum application/json and
      application/x-www-form-urlencoded body size allowed to 4k.  The previous
      1k was kind of small.
      
      * Removed a couple inlined versions of ast_http_manid_from_vars() by
      calling the function.  manager.c:generic_http_callback() and
      res_http_post.c:http_post_callback()
      
      * Add missing va_end() in ast_ari_response_error().
      
      * Eliminated unnecessary RAII_VAR() use in http.c:auth_create().
      
      ASTERISK-23552 #close
      Reported by: Scott Griepentrog
      
      Review: https://reviewboard.asterisk.org/r/3691/
      ........
      
      Merged revisions 417880 from http://svn.asterisk.org/svn/asterisk/branches/12
      
      
      git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@417901 65c4cc65-6c06-0410-ace0-fbb531ad65f3
      dbec5e0d
  20. Jun 13, 2014
  21. Jun 12, 2014
    • Richard Mudgett's avatar
      AST-2014-007: Fix DOS by consuming the number of allowed HTTP connections. · 4ca5745d
      Richard Mudgett authored
      Simply establishing a TCP connection and never sending anything to the
      configured HTTP port in http.conf will tie up a HTTP connection.  Since
      there is a maximum number of open HTTP sessions allowed at a time you can
      block legitimate connections.
      
      A similar problem exists if a HTTP request is started but never finished.
      
      * Added http.conf session_inactivity timer option to close HTTP
      connections that aren't doing anything.  Defaults to 30000 ms.
      
      * Removed the undocumented manager.conf block-sockets option.  It
      interferes with TCP/TLS inactivity timeouts.
      
      * AMI and SIP TLS connections now have better authentication timeout
      protection.  Though I didn't remove the bizzare TLS timeout polling code
      from chan_sip.
      
      * chan_sip can now handle SSL certificate renegotiations in the middle of
      a session.  It couldn't do that before because the socket was non-blocking
      and the SSL calls were not restarted as documented by the OpenSSL
      documentation.
      
      * Fixed an off nominal leak of the ssl struct in
      handle_tcptls_connection() if the FILE stream failed to open and the SSL
      certificate negotiations failed.
      
      The patch creates a custom FILE stream handler to give the created FILE
      streams inactivity timeout and timeout after a specific moment in time
      capability.  This approach eliminates the need for code using the FILE
      stream to be redesigned to deal with the timeouts.
      
      This patch indirectly fixes most of ASTERISK-18345 by fixing the usage of
      the SSL_read/SSL_write operations.
      
      ASTERISK-23673 #close
      Reported by: Richard Mudgett
      ........
      
      Merged revisions 415841 from http://svn.asterisk.org/svn/asterisk/branches/1.8
      ........
      
      Merged revisions 415854 from http://svn.asterisk.org/svn/asterisk/branches/11
      ........
      
      Merged revisions 415896 from http://svn.asterisk.org/svn/asterisk/branches/12
      
      
      git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@415907 65c4cc65-6c06-0410-ace0-fbb531ad65f3
      4ca5745d
  22. Jun 05, 2014
    • Kevin Harwell's avatar
      res_http_websocket: Create a websocket client · e763d704
      Kevin Harwell authored
      Added a websocket server client in Asterisk. Asterisk has a websocket server,
      but not a client. The ability to have Asterisk be able to connect to a websocket
      server can potentially be useful for future work (for instance this could allow
      ARI to connect back to some external system, although more work would be needed
      in order to incorporate that).
      
      Also a couple of things to note - proxy connection support has not been
      implemented and there is limited http response code handling (basically, it is
      connect or not).
      
      Also added an initial new URI handling mechanism to core.  Internet type URI's
      are parsed into a data structure that contains pointers to the various parts of
      the URI.
      
      (closes issue ASTERISK-23742)
      Reported by: Kevin Harwell
      Review: https://reviewboard.asterisk.org/r/3541/
      
      
      git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@415223 65c4cc65-6c06-0410-ace0-fbb531ad65f3
      e763d704
  23. May 09, 2014
  24. Apr 23, 2014
  25. Apr 21, 2014
  26. Apr 04, 2014
  27. Mar 28, 2014
  28. Mar 18, 2014
  29. Mar 10, 2014
  30. Jan 17, 2014
  31. Dec 24, 2013
  32. Dec 13, 2013
  33. Nov 27, 2013
    • David M. Lee's avatar
      ari:Add application/json parameter support · fccb427c
      David M. Lee authored
      The patch allows ARI to parse request parameters from an incoming JSON
      request body, instead of requiring the request to come in as query
      parameters (which is just weird for POST and DELETE) or form
      parameters (which is okay, but a bit asymmetric given that all of our
      responses are JSON).
      
      For any operation that does _not_ have a parameter defined of type
      body (i.e. "paramType": "body" in the API declaration), if a request
      provides a request body with a Content type of "application/json", the
      provided JSON document is parsed and searched for parameters.
      
      The expected fields in the provided JSON document should match the
      query parameters defined for the operation. If the parameter has
      'allowMultiple' set, then the field in the JSON document may
      optionally be an array of values.
      
      (closes issue ASTERISK-22685)
      Review: https://reviewboard.asterisk.org/r/2994/
      
      
      git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@403177 65c4cc65-6c06-0410-ace0-fbb531ad65f3
      fccb427c
  34. Nov 08, 2013
  35. Sep 06, 2013
  36. Aug 21, 2013
  37. Jul 21, 2013
    • Matthew Jordan's avatar
      Tolerate presence of RFC2965 Cookie2 header by ignoring it · bdb1c6bf
      Matthew Jordan authored
      This patch modifies parsing of cookies in Asterisk's http server by doing an
      explicit comparison of the "Cookie" header instead of looking at the first
      6 characters to determine if the header is a cookie header. This avoids
      parsing "Cookie2" headers and overwriting the previously parsed "Cookie"
      header.
      
      Note that we probably should be appending the cookies in each "Cookie"
      header to the parsed results; however, while clients can send multiple
      cookie headers they never really do. While this patch doesn't improve
      Asterisk's behavior in that regard, it shouldn't make it any worse either.
      
      Note that the solution in this patch was pointed out on the issue by the
      issue reporter, Stuart Henderson.
      
      (closes issue ASTERISK-21789)
      Reported by: Stuart Henderson
      Tested by: mjordan, Stuart Henderson
      ........
      
      Merged revisions 394899 from http://svn.asterisk.org/svn/asterisk/branches/1.8
      ........
      
      Merged revisions 394900 from http://svn.asterisk.org/svn/asterisk/branches/11
      
      
      git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@394901 65c4cc65-6c06-0410-ace0-fbb531ad65f3
      bdb1c6bf
  38. Jul 18, 2013
    • Matthew Jordan's avatar
      Tweak debug statements · 3a2a12ca
      Matthew Jordan authored
      This patch does two things:
      1. It moves the debug statement that shows the HTTP sub-protocols being
         compared after the string length calculation such that it shows the correct
         string length in the output
      2. It adds some additional debug that displays when it matches on a
         sub-protocol and when it fails
      
      
      
      git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@394701 65c4cc65-6c06-0410-ace0-fbb531ad65f3
      3a2a12ca
  39. Jul 03, 2013
    • David M. Lee's avatar
      ARI authentication. · 9ba976b1
      David M. Lee authored
      This patch adds authentication support to ARI.
      
      Two authentication methods are supported. The first is HTTP Basic
      authentication, as specified in RFC 2617[1]. The second is by simply
      passing the username and password as an ?api_key query parameter
      (which allows swagger-ui[2] to authenticate more easily).
      
      ARI usernames and passwords are configured in the ari.conf file
      (formerly known as stasis_http.conf). The user may be set to
      `read_only`, which will prohibit the user from issuing POST, DELETE,
      etc. Also, the user's password may be specified in either plaintext,
      or encrypted using the crypt() function.
      
      Several other notes about the patch.
      
       * A few command line commands for seeing ARI config and status were
         also added.
       * The configuration parsing grew big enough that I extracted it to
         its own file.
      
       [1]: http://www.ietf.org/rfc/rfc2617.txt [2]:
       https://github.com/wordnik/swagger-ui
      
      (closes issue ASTERISK-21277)
      Review: https://reviewboard.asterisk.org/r/2649/
      
      
      
      git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@393530 65c4cc65-6c06-0410-ace0-fbb531ad65f3
      9ba976b1
  40. Jun 25, 2013
    • Matthew Jordan's avatar
      Fix memory/ref counting leaks in a variety of locations · 13b470d7
      Matthew Jordan authored
      This patch fixes the following memory leaks:
       * http.c: The structure containing the addresses to bind to was not being
         deallocated when no longer used
       * named_acl.c: The global configuration information was not disposed of
       * config_options.c: An invalid read was occurring for certain option types.
       * res_calendar.c: The loaded calendars on module unload were not being
         properly disposed of.
       * chan_motif.c: The format capabilities needed to be disposed of on module
         unload. In addition, this now specifies the default options for the
         maxpayloads and maxicecandidates in such a way that it doesn't cause the
         invalid read in config_options.c to occur.
      
      (issue ASTERISK-21906)
      Reported by: John Hardin
      patches:
        http.patch uploaded by jhardin (license 6512)
        named_acl.patch uploaded by jhardin (license 6512)
        config_options.patch uploaded by jhardin (license 6512)
        res_calendar.patch uploaded by jhardin (license 6512)
        chan_motif.patch uploaded by jhardin (license 6512)
      ........
      
      Merged revisions 392810 from http://svn.asterisk.org/svn/asterisk/branches/11
      
      
      git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@392812 65c4cc65-6c06-0410-ace0-fbb531ad65f3
      13b470d7
Loading