~ne02ptzero/pistache

Shared-library soname is now generated correctly (#809)

* Add support for interface versioning so applications don't break...

* {CMakeLists.txt,src/CMakeLists.txt}: Shared-library soname is now generated correctly...
version.txt: Added SONAME major and minor fields...
README.md: Add versioning notes. In particular, when to update interface version...
debian/changelog: Fixed lintian complaining about a malformed changelog for non-native package...
a345fcc6 — Andrey Garaev 4 years ago
Implement router static checks (#808)

* feat router: Implement static checks

* Actualize checks
f2f5a50f — Igor [hyperxor] 4 years ago
Raw buffer refactoring (#806)

* RawBuffer refactoring + tests

* apply clang-format
7b125802 — Igor [hyperxor] 4 years ago
Small refactoring in asyncWriteImpl (#801)

* Small refactoring in asyncWriteImpl

* Trigger CI

* Trigger CI
a61d3be1 — Igor [hyperxor] 4 years ago
Fix inssue #803 (#804)

4d60787d — Igor [hyperxor] 4 years ago
Change using ::gethostbyname to AddrInfo + start Address class refactoring (#802)

60ae191a — Igor [hyperxor] 4 years ago
Fix typo and constifiy variables (#800)

* Fix typo and add const

* revert one change
4ed3f8e1 — suokko 4 years ago
Cmake build improvements for find_package(Pistache) (#795)

* Set default build type using _INIT variable

Language support checking offers a standardized method to set default
build type using CMAKE_BUILD_TYPE_INIT variable. The variable must be
set before enable_language is called implicitly from project

* Enable only C++ compiler

* Let C++ compiler detection to check for standard support

Setting CMAKE_CXX_STANDARD variables before implicit call to
enable_language handles checking for standard support automatically.

* Fix pistache_shared export

Exporting targets allows find_package(Pistache) to import them
correctly. The import makes it easier to use Pistache in a porject using
cmake build system.

* Add wildcard ignore for multiple build directories

I used multiple build directories to test different configurations work.
My alternative test configuration is a Debian Stretch chroot for an old
distro test.

* Detect Threads which is implicit requirement

Static library requires PistancheConfig.cmake to detect all dependencies
to allow simple linking to imported library to work.

* Use find_package to detect OpenSSL

Add OpenSSL configure time detection for the development package.
FindOpenSSL.cmake started support IMPORTED libraries only in 3.4. The
IMPORTED library helps users to link correctly to pistache static
library.

Headers use libssl directly which forces pistache to use public
definition and library link.

* Export include directories to IMPORTED library

* Do not add pistache to global build configuration

PistacheConfig shouldn't add include directories and libraries to the
global build configuration. Imported libraries provide all required
build configurations to a depending target.

* Check if atomic library is required

Pistache should link to atomic library only if system requires the
library. The easiest method appears to be use a modified LLVM
CheckAtomic helper.

* Use target include directories for GTest

* Detect libcurl and remove pthread linking

* Update CMake Pistache example

* Add CMake ConfigVersion file

* Update the date part of version
4e48b6d3 — Mateusz Szychowski (Muttley) 4 years ago
Fix ResponseStream flush (#791)

* client, string_view: fix warnings

Discarded qualifier and implicit fallthrough

* common: http: fix ResponseStream flush
4d1ec019 — Igor [hyperxor] 4 years ago
Add test for sanitize resource + small improvements (#792)

13a92b81 — chrisvroberts 4 years ago
Ensure no epoll events are processed for closed peer files (#788)

An error existed in transport.cc where it incorrectly assumed that
it would not receive epoll events relating to a closed peer
connection. This is not the case because file descriptors can be
shared between processes e.g. on exec. When they are, events could
still be generated. The solution is to explicitly de-register our
interest in the file descriptor before we close it using
epoll_ctl(EPOLL_CTL_DEL). In addition the call to accept in
listener.cc has been updated to set CLOEXEC on the peer file
descriptors as these should not be shared with other processes
anyway.

Co-authored-by: Roberts, Chris (UK Gloucester) <chris.v.roberts@baesystems.com>
03a65a8b — Igor [hyperxor] 4 years ago
Small improvements in Listener constructor (#785)

* Small improvements in Listener constructor

* Trigger CI
88df7c35 — zhanb 4 years ago
Update transport.cc (#783)

* Update transport.cc

fix throw but no catch bug

* Update transport.cc

disconnect peers for all other errors

* adjust indent level

Co-authored-by: zhanb <zhangbo@caict.ac.cn>
70b1e068 — Dennis Jenkins 4 years ago
Attempt to fix failing travis tests that run on IPV6 hosts. (#780)

Co-authored-by: Dennis Jenkins <dennisjenkins@google.com>
059171b1 — jiankyu 4 years ago
Add middleware support (#779)

This commit partially resolves #24, which is a common requirement on
many RESTful services.

A vector of middleware handlers is added to Router, these handlers are
executed before the URL match and handler invocation, in the order of
registration.

A middleware function has the signature:

bool func(Pistache::Http::Request &request,
          Pistache::Http::ResponseWriter &response);

The first parameter is a reference to Http::Request, not Rest::Request,
at the moment middlewares are called, the request parameters are not yet
filled. This allows some generic operation on the request, such as
authentication or rate limiting.

Parameters are passed as references, to allow the middlewares be able to
modify them, such as injecting custom headers.

If a function returns true, the next function is executed, until all
middleware functions are called and all of them return true, the
registered handler is called.

If one of them returns false, this means there is no need to further
call the subsequent functions and the handler, the handling of this
request completes. Typical case is missing auth info or reaching limit.
Basically, the middleware function that returns false is responsible to
call response.send() to send the response to client.

Like Route::bind, a new method, Route::middleware(), with different
signatures, is added, to convert different callables into a middleware.

There is also requirements on the "post-handling" handlers, such as
logging response, measuring handler latency, and so on, in a centralized
place. This commit doesn't implement it: The response is passed to
handler using std::move, it's not retrievable again after handler
processing.

Signed-off-by: Jiankun Yu <yujiankun@hotmail.com>
14ecdf51 — mplellison 4 years ago
Separated macro-based logging API from impl, renamed default impl. (#777)

The separation of the impl from the API means that it is more possible
to independently test variations of the API by changing the macro
definitions in log.h.

The default StringLogger impl is now called StringToStreamLogger, and
takes an optional ostream pointer on input - this makes it more
testable. It is assumed that std::cerr will be used here nearly all of
the time in practice.
22509199 — mplellison 4 years ago
Travis fix to collect coredumps from build configuration subdirs - #720 (#776)

* Travis fix to collect coredumps from build configuration subdirs - #720

Previously, Travis would only attempt to collect coredumps from the last
directory the build script was in, or the home directory. This meant
that most coredumps were missed, and debug information was lost.

The new setup configures apport to watch for crashes on any executables
(by default it watches for executables from Ubuntu packages). These
crash dumps are picked up, extracted, and analysed using GDB to provide
a backtrace (this needs the executable to be passed to GDB as well so
that debug symbols are provided).

* Restructured .travis.yml to avoid underspecified builds.
a2215ba9 — mplellison 4 years ago
Logging api - addresses issue #771 (#775)

* Added a basic logger object and relevant macros.

* Modify logging macros for more flexibility.

Supplied logger types and sample values using macros for flexibility in
recompiling the library against a different logging engine - the macros
can be redefined to make calls to the relevant functions.

* Updated endpoint and listener to use new logging structure.

It remains to update the SSL portions of listener.cc to output SSL
errors via the new loggers.

* Add error logging for SSL errors in listener.cc.

This needed an extension to the RAII setup for SSL objects to handle BIO
objects. Also modified some exception types to ensure they get caught
and logged by existing code. Moved anonymous function definitions to the
top of listener.cc so that they are available in the entire file.

These changes don't significantly change the behaviour of the Pistache
library - it still logs errors and throws an exception for most errors
that occur internally. It would likely be more sensible to only throw
a descriptive exception and not log if the exception is expected to be
handled by the library user - this gives them better control of the
output of the software. Logging could be reserved for tracking events
and debug; when the user is not expected to provide input.

* Renamed macros and types to "string logger" and similar.

This aligns the names of the types and macros, as well as leaving space
for future logging APIs that handle different message types.
21ca7a69 — mplellison 4 years ago
Allow Pistache::Listener to load and serve certificate chains (#772)

* Update test certificate generation to use explicit cert config.

Previously, no configuration was supplied on certificate generation, so
the certificates being used for testing were completely generic. This
limited the effectiveness and transparency of testing.

* Fix listener.cc to load a cert chain and provide it for server auth.

Added test with a server cert signed by an intermediate CA.

Previously, listener.cc would only load the first cert in a cert pack
and use this to authenticate itself to clients. This meant that if the
server held a cert signed by an intermediate CA, a client trusting only
the root CA would be unable to authenticate the server's cert.

See the OpenSSL docs here:
https://www.openssl.org/docs/man1.0.2/man3/SSL_CTX_use_certificate_file.html
for an overview of the SSL_CTX_use_certificate_file() and
SSL_CTX_use_certificate_chain_file() functions.
b4e9e55e — robertomdv 4 years ago
Update listener.cc (#770)

added GetSSLContext() at line  393 to prevent compilation with OpenSSL From fail  (see issue #769)
Next
Do not follow this link