Commit Graph

990 Commits

Author SHA1 Message Date
Joris Vink 60a3f60a92 Allow MSG framework to pass 0 byte messages. 2017-02-27 21:27:50 -08:00
Joris Vink 0fe570ef41 cleanse any intermediate buffers for keymgr. 2017-02-27 21:05:56 -08:00
Joris Vink 6ba7390cc9 Add rand_file configuration option for keymgr.
This option allows the user to specify a file to be used for
seeding the PRNG initially and to write random bytes at exit.

The option is only available if kore has TLS enabled (by default).

If you enable this option Kore will refuse to start if there is
a problem with the file specified (not found, not a file, invalid size, etc).

While here let the keymgr process call RAND_poll() every half hour
to grab more system entropy and seed it into the PRNG.
2017-02-27 20:58:04 -08:00
Joris Vink 27da1dd741 fix semantics for kore_calloc().
We were not returning zeroed out memory from kore_calloc() which goes
against what calloc() does. Skip performance for now and simply just
memset() the returned pointer from kore_malloc().

This should be sufficient enough for now.
2017-02-27 19:50:06 -08:00
Joris Vink 7f11e37161 Add kore_sockopt().
Use it where we before were using setsockopt().
2017-02-22 13:23:30 -08:00
Joris Vink 00ce970efe Be less noisy about module reloading.
No longer show "not reloading foo" if timestamps didn't change.
Be more clear about a module forcing us to not reload it.
2017-02-22 12:48:06 -08:00
Joris Vink d09eb5e107 bump copyright 2017-02-22 21:37:14 +01:00
Joris Vink e89e644d10 call PyErr_Clear() before PyImport_ReloadModule(). 2017-02-22 20:54:57 +01:00
Joris Vink 93ab52dcf5 Add a reload command to the cli tool.
This will look at the kore.pid file in the current directory
and send a SIGHUP signal to it. It's mostly a handy shortcut
since you could of course do a kill -HUP `cat kore.pid` easily.
2017-02-22 20:38:24 +01:00
Joris Vink 970356a3e9 always write the pidfile even in foreground 2017-02-22 20:38:07 +01:00
Joris Vink 6e6d2f005d Remove leftover feature defines from kodev. 2017-02-22 20:13:59 +01:00
Joris Vink ead0a4199c add little hint for kodev. 2017-02-22 20:09:11 +01:00
Joris Vink 541870c10a Improve keymgr_await_data().
Before this function would block client I/O and existing HTTP requests
until the keymgr process responsed with a result.

This commit changes that behaviour and makes this function call
the http_process() function if we end up waiting for the keymgr.

This means that while waiting for a response we at least start
making headway with existing HTTP requests if the response is
not immediate.
2017-02-22 18:30:50 +01:00
Joris Vink c6ca68f3f2 export http_body_path via python 2017-02-22 17:52:57 +01:00
Joris Vink 2f670ce777 don't log failure if unlinking fails with ENOENT 2017-02-22 17:52:38 +01:00
Joris Vink fc6b3bf740 Split up kore cli tools into new binary.
Having the create, build, run tools baked into the kore binary
made things harder then they had to be for multiple projects with
each different build flavors.

So move away this functionality into a new "kodev" (name may change)
binary that is installed next to kore.

The new build tools will automatically pick up the correct flavors
the kore binary it points to is installed with. Or for single builds
what flavors where enabled.

The new tool also will honor looking into PREFIX for the kore binary
when doing a `kodev run`.

Additionally add a new command "info" that shows some basic info
about your project and how it will be built. For example it will
show you the flavors of the kore binary installed on the system
or the flavors you configured for a single binary build.

Obligitory, hacking on a plane comment.
2017-02-19 00:52:29 -05:00
Joris Vink a0c545884f even more ssl to tls terminology. 2017-02-11 21:33:09 +01:00
Joris Vink 98f0c41f38 more ssl -> tls wording 2017-02-11 21:30:38 +01:00
Joris Vink 9be3c22196 like other flavors, log if python is enabled. 2017-02-09 13:38:09 +01:00
Joris Vink 37443df6b0 Slightly change kore_parent_configure() again.
- Call it before loading configurations when built as single binaries.
- Call it right before forking workers when built as a dso.
2017-02-09 13:36:08 +01:00
Joris Vink 311e658d57 call to kore_parent_configure() before config. 2017-02-09 13:29:33 +01:00
Joris Vink 625d50b8dd use rootdir when making paths to features/ldflags. 2017-02-09 11:45:11 +01:00
Joris Vink e895446dfa Improve single binary builds.
Allow kore build to pickup the required libraries for kore when
building single binaries so that you no longer have to manually
add them to ldflags.
2017-02-09 11:30:44 +01:00
Joris Vink d2cfc2b554 shuffle headers around. 2017-02-07 23:21:18 +01:00
Joris Vink 4e9399d553 use SSL_OP_SINGLE_ECDH_USE. 2017-02-07 23:17:11 +01:00
Joris Vink e9b4f966c2 expose new cookie stuff to python.
req.populate_cookies()
value = req.cookie("name")
2017-02-07 22:54:42 +01:00
Joris Vink b8c6cddc3d Revert "TAILQ_FOREACH_SAFE() exists so use it."
Because some asshole distributions claim to have a sane queue.h
implementation while they do not.
2017-02-07 22:44:20 +01:00
Joris Vink 0ea911140e TAILQ_FOREACH_SAFE() exists so use it. 2017-02-07 22:35:09 +01:00
Joris Vink 233d5d1708 remove unneeded NULL check before calling free. 2017-02-07 22:08:04 +01:00
Joris Vink 1296802e06 fixup isspace arguments. 2017-02-07 22:06:14 +01:00
Joris Vink 8b9ea825eb cookie improvements.
- split up writing of cookies into its own function.
- turn maxage into a signed int and use -1 for it not being set.
- lots of style fixes
- remove HTTP_COOKIE_DEFAULT, just pass 0 if you don't want flags.
2017-02-07 22:03:06 +01:00
Stanislav Yudin f4ac8c2955 Cookies and arguments parsing improvements (#166)
Add new cookie API for handling of cookies.
2017-02-07 21:49:10 +01:00
Joris Vink 5a16bdbe65 whitespace 2017-02-06 22:53:09 +01:00
Joris Vink f80a9cbc6c actually urldecode parameter names. 2017-02-06 22:47:32 +01:00
Joris Vink 604fae3a01 unfuck parsing http_body_max. 2017-02-06 21:28:33 +01:00
Joris Vink c25c1c5281 pgsql: don't do a PQcancel() if it's not needed. 2017-02-06 20:01:16 +01:00
Joris Vink 09b0ae6d42 rename local sin to avoid potential conflicts. 2017-02-06 19:54:50 +01:00
Joris Vink b8b8373702 when exiting clear any lingering python exceptions. 2017-02-06 16:54:38 +01:00
Joris Vink 01e3ef6cd3 no need to log ignored signals. 2017-02-06 12:13:34 +01:00
Joris Vink 6592eddcfb add stdint.h 2017-02-06 12:13:29 +01:00
Joris Vink ace8c4e80c Add asynchronous pgsql query support to python.
This commit adds the ability to use python "await" to suspend
execution of your page handler until the query sent to postgresql
has returned a result.

This is built upon the existing asynchrous query framework Kore had.

With this you can now write stuff like:

async def page(req):
	result = await req.pgsql("db", "SELECT name FROM table");
	req.response(200, json.dumps(result).encode("utf-8"))

The above code will fire off a query and suspend itself so Kore can
take care of business as usual until the query is successful at which
point Kore will jump back into the handler and resume.

This does not use threading, it's purely based on Python's excellent
coroutines and generators and Kore its built-in pgsql support.
2017-02-06 11:42:53 +01:00
Joris Vink 80698ee40a add kore_mem_cleanup() to cleanup pools at exit. 2017-02-06 11:42:23 +01:00
Joris Vink de7a6d4855 pgsql improvements.
- adds new cleanup function that workers will call.
- adds kore_pgsql_nfields() to return number of fields in result.
- add kore_pgsql_fieldname() to return name of a given field.

This commit also changes the behaviour of pgsql_conn_release() in
that it will now cancel the active query before releasing the connection.

This makes sure that if long running queries are active they are hopefully
cancelled if an http request is removed while such queries are still running.
2017-02-06 11:40:33 +01:00
Joris Vink c3d2984939 fix parameters to kore_log(). 2017-02-06 11:39:50 +01:00
Joris Vink 6578fc6589 expose http_file interface to python. 2017-02-01 21:23:56 +01:00
Joris Vink 0250c8ecba style 2017-02-01 21:20:43 +01:00
Joris Vink 3d8e0dabc0 expose kore_server_bind() and fatal() to python 2017-02-01 17:12:52 +01:00
Joris Vink 0c0a9371bd Change kore_preload() and kore_onload().
Renamed both of them:
	kore_preload -> kore_parent_configure
	kore_onload  -> kore_worker_configure

These functions will now always be called if they are defined in any module
regardless of your application being built as a single binary or not.
2017-02-01 17:12:11 +01:00
Joris Vink bb9dbbec12 typo. 2017-01-30 22:47:41 +01:00
Joris Vink 006f764d96 when getting OP_CLOSE disable reads. 2017-01-30 22:35:34 +01:00
Joris Vink 587a663f31 reorder ws disconnect order a bit. 2017-01-30 22:25:08 +01:00
Joris Vink 8b26ecdf14 more websocket improvements.
- send a CLOSE opcode if we haven't yet when removing a ws client.
- ignore unsolicited PONG.
2017-01-30 22:21:57 +01:00
Joris Vink 30666618f8 expose kore_websocket_send() to python. 2017-01-30 22:00:03 +01:00
Joris Vink e4d87b72a0 websocket improvements.
- properly send a CLOSE control frame back if the client sent us one.
- make sure we can send messages that are exactly USHRT_MAX bytes long.
2017-01-30 21:52:22 +01:00
Joris Vink 6bfba49ba5 cleanup data if required. 2017-01-30 21:50:36 +01:00
Joris Vink f78e8f2fd2 allow None as source for kore.websocket_broadcast.
This allows kore.websocket_broadcast() to be used to relay the
messages back to all clients rather then all except the sender.
2017-01-30 21:48:58 +01:00
Joris Vink 6a43dd529c export WEBSOCKET_OP_TEXT and WEBSOCKET_OP_BINARY. 2017-01-30 21:02:58 +01:00
Joris Vink 7bc8bb42e2 implement kore_websockat_broadcast. 2017-01-30 20:30:42 +01:00
Joris Vink 7510834968 initial fudging to add websockets to python 2017-01-29 22:57:34 +01:00
Joris Vink 1ecb777d41 only remove the pgsql if it was scheduled.
fixes #172.
2017-01-29 10:34:53 +01:00
Joris Vink c06ecf1c70 Teach single binaries about SIGHUP.
Make sure kore_onload() and kore_preload() can be called
either in native or python runtime.
2017-01-26 13:26:55 +01:00
Joris Vink 3023ca0e57 Allow single binaries to load modules again. 2017-01-26 13:13:23 +01:00
Joris Vink dcb5fd842f Expose get/post params via req.argument for python. 2017-01-26 12:01:28 +01:00
Joris Vink 1db3cd96d8 allow reloading of python modules on SIGHUP. 2017-01-26 11:13:09 +01:00
Joris Vink 21f9c29f31 style + move pyhttp_dealloc() into !KORE_NO_HTTP. 2017-01-25 22:33:39 +01:00
Joris Vink f56938283d Merge branch 'master' of github.com:jorisvink/kore 2017-01-25 22:23:34 +01:00
Joris Vink 5d09214591 only rebuild with "kore build" when we can. 2017-01-25 22:21:40 +01:00
Joris Vink a9537bc6ec add python flavor string to -v 2017-01-25 22:21:30 +01:00
Joris Vink 9976022a47 let python use kore backed memory allocators. 2017-01-25 22:07:58 +01:00
Joris Vink e47806c669 allow memory allocators to deal with 0 bytes.
we just increase the lenght requested to 8 bytes if we get a 0 byte request.

additionally when kore_realloc() is called check if we actually have
to do the work, if not just return the original pointer.
2017-01-25 22:07:08 +01:00
Joris Vink 620cc231dc validators now work in python. 2017-01-25 21:17:12 +01:00
Joris Vink 7c74a0824b push all integers exported to python in a struct. 2017-01-25 20:56:57 +01:00
Joris Vink bbcdec82fc Add initial python support.
Based on work done by Stanislav Yudin.
2017-01-24 20:18:12 +01:00
Yorick de Wid f7e8954609 BSD required AF_INET* headers (#171) 2017-01-18 22:24:49 +01:00
Joris Vink 98148155dc bump copyright year 2017-01-18 10:27:44 +01:00
Joris Vink 2f8c173042 Improve ipv6 host parsing if we get a literal.
Fixes #169.
2017-01-18 10:27:04 +01:00
Yorick de Wid 86d85dd10b Message shutdown request (#168)
* Set server version

* Message shutdown request

* Update messaging example

* Set server verion in generic example

* Allow shutdown with NOHTTP=1
2017-01-17 18:18:01 +01:00
Yorick de Wid 565bf5bdec Set server version (#157) 2017-01-13 13:03:47 +01:00
Joris Vink 57840a8366 Deal with the Host header in a way IPv6 hosts work
Fixes #164.
2017-01-11 11:01:58 +01:00
Joris Vink 10929189a0 make sure we can call pgsql_conn_cleanup() properly. 2017-01-10 15:29:03 +01:00
Joris Vink f5ad76a2c3 better description. 2016-12-29 20:15:01 +01:00
Joris Vink fe7237fd74 Take over linker from env if present. 2016-12-29 20:14:16 +01:00
Joris Vink 6faed21a24 Revert "Invoke platform alternatives #158 (#160)"
This reverts commit 857a3cfb79.
2016-12-29 20:12:46 +01:00
Yvan Sraka 857a3cfb79 Invoke platform alternatives #158 (#160) 2016-12-28 09:29:13 +01:00
Joris Vink c16461c6c1 adjust format after changing it earlier. 2016-12-27 09:45:27 +01:00
Joris Vink be5d1f310f initialize mime_types when swapping flavors as well. 2016-12-27 09:39:06 +01:00
Joris Vink 8b528e0334 Add asset_sha1_* and asset_serve_* to assets.h. 2016-12-27 09:22:13 +01:00
Joris Vink 4f9044c6e0 fix count in kore_pgsql_query_params().
should fix #159.
2016-12-27 09:10:31 +01:00
Joris Vink 31d14d028a add compile-time configurable mime types.
these types are used for the new builtin asset_serve_* functions.

must be defined in conf/build.conf.
2016-12-26 23:37:05 +01:00
Joris Vink d783a1d22d Add auto generated serving functions for assets.
These functions are created by the cli tool when building
and follow the naming format: asset_serve_<name>_<ext>().

Those serving functions can be used directly in handlers and
callthrough to a http_serveable() function that uses the SHA1
of the asset as its ETag and automatically checks for if-none-match.
2016-12-26 21:15:03 +01:00
Joris Vink facc8b9d6c set req->owner to NULL when the connection removes it. 2016-12-26 20:08:53 +01:00
Joris Vink 543a329ef6 run the connection timeout test per event loop. 2016-12-26 20:03:01 +01:00
Joris Vink 194b575ebf Add SHA1 digests for assets. 2016-12-22 19:44:35 +01:00
Joris Vink 583d75edcb remove unneeded parenthesis. 2016-12-05 14:45:29 +01:00
Joris Vink ae28f51d56 ERR_clear_error() in front of SSL_accept as well. 2016-12-05 14:44:58 +01:00
Joris Vink cb13190e0d Call ERR_clear_error() before SSL_read() and SSL_write() calls. 2016-12-05 14:24:22 +01:00
Joris Vink 16166d37bd remove debug macro 2016-12-04 16:52:11 +01:00
Joris Vink 652833a979 set worker_active_connections to 0 always.
fixes a bug where if a worker died it contained garbled data...
2016-12-04 16:49:42 +01:00
Joris Vink cb62a6a8a8 Clamp netwait to maximum 100ms. 2016-12-04 12:16:27 +01:00
Tobias Kortkamp 950977f2be Fix fd leak in cli_buildopt_parse() (#156)
The build.conf file is left open when using kore run.
2016-12-01 09:01:51 +01:00
Tobias Kortkamp 7eced6f035 Fix #153 (#155)
Compiling with Clang 3.9 on FreeBSD raises the following error (see [1]):
```
src/pgsql.c:222:17: error: passing an object that undergoes default argument promotion to 'va_start'
      has undefined behavior [-Werror,-Wvarargs]
        va_start(args, count);
                       ^
src/pgsql.c:217:45: note: parameter of type 'u_int8_t' (aka 'unsigned char') is declared here
    const char *query, int result, u_int8_t count, ...)
```
More information about this warning can be found on [2].

To solve this we can change the type of `count` to `int` in
`kore_pgsql_query_params()` and `kore_pgsql_v_query_params()`. This
also matches the signatures of both `PQexecParams()` [3] and
`PQsendQueryParams()` [4].

[1] https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=214639
[2] https://www.securecoding.cert.org/confluence/display/cplusplus/EXP58-CPP.+Pass+an+object+of+the+correct+type+to+va_start
[3] https://www.postgresql.org/docs/9.2/static/libpq-exec.html
[4] https://www.postgresql.org/docs/9.2/static/libpq-async.html
2016-11-19 12:56:51 +01:00
Joris Vink 5b379a9185 add a kore_preload() call for single binaries.
This is run on the parent before workers are spawned.
2016-11-17 10:05:16 +01:00
Joris Vink 5abb56d6fb remove unused define. 2016-11-04 09:21:09 +01:00
Joris Vink 5e1cb53f13 use a copy of args when falling back to vasprintf. 2016-11-04 09:16:05 +01:00
Joris Vink 552d59248c constify delim in kore_split_string(). 2016-10-06 16:50:41 +02:00
Joris Vink 4a72877f4e count active connections properly 2016-10-06 16:50:02 +02:00
Tobias Kortkamp c071d64bdd Fix #144. Always initialize va_list in kore_pgsql_query_params. (#146) 2016-09-05 16:22:46 +02:00
Joris Vink db4f6cf01f align pointers from kore_malloc() properly. 2016-07-28 14:52:15 +02:00
Joris Vink 0b92afe53d Explicitly set offset to 0 for http_file. 2016-07-27 16:43:05 +02:00
Raphaël Monrouzeau 06d9ca96da JSONRPC Updated to last kore_buf* commit 2016-07-15 13:17:30 +02:00
Raphaël Monrouzeau 32ac27d4c3 JSONRPC Reverted explicit deallocation calls
The possibility to call jsonrpc_destroy_request was left. Someone may
want to abruptly interrupt the process of its request for some odd
reason, in that case an exlicit call still would be to be made.
2016-07-15 13:08:08 +02:00
Raphaël Monrouzeau 7a4e4223c4 JSONRPC If support compiled in log it at start 2016-07-15 13:08:08 +02:00
Raphaël Monrouzeau a818555c96 JSONRPC use size_t to get in line with last commit
Kore now uses size_t for kore_buf and http_response() so response size
check is useless and u_int32_t variables should be converted.
2016-07-15 13:08:08 +02:00
Raphaël Monrouzeau 016dc27346 JSONRPC Made request destruction explicit
Caller has now to destroy jsonrpc_request after use. This permits them
to read / inspect it after having responded.
2016-07-15 13:08:08 +02:00
Raphaël Monrouzeau 8c78b28be3 JSONRPC Removed upload size limit check
A true application dependant limit check would require stream parsing.
As the limit enforcement was done, it added nothing of value compared
to HTTP request limit check, which is in Kore already.
2016-07-15 13:08:08 +02:00
Raphaël Monrouzeau 3366ec6573 Required params to be structured as per spec 2016-07-15 13:08:08 +02:00
Raphaël Monrouzeau 4ffe43cf87 Compliantly don't return anything to notifications
And don't return anything either if protocol doesn't match.
2016-07-15 13:08:08 +02:00
Raphaël Monrouzeau db02e990ea JSON-RPC support for Kore.
The API surface is very limited. Jsonrpc support reads request from HTTP
body and such can't be activated if NOHTTP=1. At the moment there is no
websocket support either (which is a shame). It depends upon the
third-party Yajl library.

Errors can be emitted using jsonrpc_error() and results using
jsonrpc_result(), for the later you'll have to provide a callback which
will write the inner of the result object.

If errors happen during the response write process, no further error
output will be attempted and an HTTP error 500 will be returned.

Read the provided example for getting a better idea of the API.
2016-07-15 13:08:08 +02:00
Joris Vink 00b64033ca More buf improvements.
- make sure kore_buf_alloc() and kore_buf_init() buffers behave
  the same way in regards to calling kore_buf_release() and what not.
2016-07-14 12:41:39 +02:00
Joris Vink 43fec8678e kore_buf_create -> kore_buf_alloc. 2016-07-14 12:34:29 +02:00
Joris Vink b28b60c2ff buf API changes.
- rename kore_buf_destroy() to kore_buf_cleanup().
- rename kore_buf_create() to kore_buf_alloc().
2016-07-14 12:33:13 +02:00
Joris Vink 3b0477cf97 kore_mem_free -> kore_free 2016-07-14 12:29:49 +02:00
Joris Vink 7cf73b5fa5 Merge branch 'kore_buf_noalloc' of https://github.com/raphaelmonrouzeau/kore into raphaelmonrouzeau-kore_buf_noalloc 2016-07-14 12:28:51 +02:00
Joris Vink 33c0b3c753 Make pools thread-safe if built with TASKS.
Use CAS to implement primitive spinlock ontop of the pool
if we have been built with TASKS=1.

This allows tasks to safely use kore_malloc() and kore_free()
since those are now backed by pools.
2016-07-12 16:30:57 +02:00
Joris Vink 3c43d1203c Move towards size_t in the pool API. 2016-07-12 14:01:02 +02:00
Joris Vink 4ad50caa29 Large changes to the memory subsystem in kore.
- Change pools to use mmap() for allocating regions.
- Change kore_malloc() to use pools for commonly sized objects.
  (split into multiple of 2 buckets, starting at 8 bytes up to 8192).
- Rename kore_mem_free() to kore_free().

The preallocated pools will hold up to 128K of elements per block size.

In case a larger object is to be allocated kore_malloc() will use
malloc() instead.
2016-07-12 13:54:14 +02:00
Raphaël Monrouzeau db3cf28d22 Added kore_buf no alloc functions.
kore_buf_create and kore_buf_free do use kore_malloc. But sometimes you
may embed a kore_buf inside a structure and would like a single way to
initialize / destroy it.
2016-07-09 12:30:24 +02:00
Joris Vink d30921103b Code cleanup, several API breaking changes in here 2016-07-08 10:03:41 +02:00
Joris Vink e96ed9ad66 Change default domain for kore create skeleton. 2016-07-07 12:36:08 +02:00
Joris Vink d2c30fd70b for single binaries use progname as the log id. 2016-07-06 22:02:10 +02:00
Joris Vink 9abf15a498 Make kore_onload() to be done per worker.
Mimics the behaviour of dso builds.
2016-07-06 21:59:17 +02:00
Joris Vink 39a5f21986 Allow "kore build" to produce single binaries.
Producing single binaries can now be done with building with
"kore build". To get started edit your build.conf and add the
following directives:

single_binary = yes
kore_source = /path/to/kore

optionally you can add kore_flavor to instruct how kore should
be built:

kore_flavor = NOTLS=1

When doing this your build.conf must also include the correct
linking options as the linking is now done fully by kore build.

The binary produced will include your configuration and takes
over a few of kore its command line flags (such as -f, -n or -r).
2016-07-06 16:16:15 +02:00
Joris Vink 27acc51241 Improve kore_strlcpy().
Make it return the original length of the input string so the caller
can check for truncation. Also guard against len being 0 as this would
not do anything with the destination string (not even NUL terminate it).
2016-07-04 11:41:37 +02:00
Joris Vink 589c7667be Cleanup cli.c a bit.
- Define CXXFLAGS_MAX as CFLAGS_MAX as we use CFLAGS_MAX usually.
- Fix formatting of a few blocks of code.
2016-06-29 16:25:52 +02:00
Corbin Hughes 91d29a9914 Better name consistency and only print CXXFLAGS if compiling C++ 2016-06-27 22:33:51 -05:00
Corbin Hughes 698b3f374f Compile and link C++ with g++ instead of gcc 2016-06-26 15:49:59 -05:00
Joris Vink 8d92dd2af4 Allow building against libressl again. 2016-06-26 11:36:33 +02:00
Joris Vink 43a726c02d Use sys/types.h instead of sys/param.h for assets. 2016-06-23 16:18:36 +02:00
Joris Vink 89f81a8b5a Revert "Throw a handshake failure if we cannot find the given SNI hostname."
This reverts commit afd4182975.
2016-06-09 13:52:37 +02:00
Joris Vink afd4182975 Throw a handshake failure if we cannot find the given SNI hostname. 2016-06-08 16:46:28 +02:00
Joris Vink f62430d1fa Isolate ECDSA keys in keymgr as well. 2016-06-08 16:31:14 +02:00
Joris Vink ae31ec01ac Separate private keys from worker processes.
Kore will now isolate RSA private keys to a separate process (keymgr).

Worker processes that require RSA signing for TLS connections will
communicate with this keymgr process in order to do so.

This behaviour cannot be disabled and is always turned on.
2016-06-08 13:56:38 +02:00
Raphaël Monrouzeau 159de3960d Added new function kore_pgsql_v_query_params().
Same as kore_pgsql_query_params but takes a va_list as last parameter
(non-v version takes a variable list of parameters).

Lets people write easier to call wrappers around the query calls. I use
it in a wrapper that takes next states (error, current, continue) as
arguments in a handler with multiple async queries.
2016-06-07 13:12:31 +02:00
Joris Vink 2dfd22a79a Change kore_buf_stringify() a bit.
Takes a size_t pointer as its second argument now, if not
NULL this will be populated with the length of the string
that is being returned.
2016-06-02 07:08:19 +02:00
Joris Vink 3b43df5536 remove useless cast. 2016-05-16 09:45:27 +02:00
Joris Vink 3c9d2d5948 missing va_end() in kore_pgsql_query_params().
from @fahlgren.
2016-05-16 09:25:37 +02:00
Joris Vink 5fe9512828 spacing. 2016-05-05 15:29:43 +02:00
Joris Vink be28c77c6d Merge pull request #118 from wtfuzz/master
cast difference between pointers as unsigned in kore_mem_find()
2016-05-05 15:28:59 +02:00
Elliot Schlegelmilch d37ecf9649 If we're iterating over rlimits, we should use rlim_t.
> error: comparison of integers of different signs: 'size_t' (aka 'unsigned long') and 'rlim_t' (aka 'long') [-Werror,-Wsign-compare]
2016-04-27 18:18:21 -07:00
Matt Thompson 43d3e0e746 double tab variable name 2016-04-01 17:55:43 +00:00
Matt Thompson 43a5703456 changed needle length type to size_t in kore_mem_find(). updated function prototype in kore.h. Use tab instead of space indentation 2016-04-01 17:54:10 +00:00
Matt Thompson 3ef8562bac use offset variable instead of pointer arithmetic 2016-03-31 12:55:23 -05:00
Matt Thompson 61eaaccd30 cast difference between pointers as unsigned in kore_mem_find() 2016-03-21 23:30:28 +00:00
Joris Vink fb6512259c small style changes. 2016-03-21 15:30:11 +01:00
Ángel González 1bda217d57 Based on #115 pull request, adds http_method_text, similar to http_status_text 2016-03-21 15:12:27 +01:00
Joris Vink 4a69657dce Don't call close on an fd that is -1. 2016-02-25 22:04:24 +01:00
Joris Vink f7b0b7c7ac Sometimes content_length wasn't properly updated. 2016-02-22 14:08:21 +01:00
Joris Vink 0294212a3c Do not free results from http_request_header(). 2016-02-21 18:29:06 +01:00
Joris Vink 318647945f more consistency in fatal messages. 2016-02-13 15:45:33 +01:00
Joris Vink 8fcf4762f4 Improve http_body_recv().
- If we fail to write to our temporary file error instead of fatal.
- Return KORE_RESULT_ERROR on other errors as well.
2016-02-13 15:41:37 +01:00
Joris Vink c83abd5afb If ele is 0 return 0 instead of fataling. 2016-02-13 15:27:02 +01:00
Joris Vink 1c8836b2e1 Add precaution against calling kore_split_string with ele == 0 2016-02-13 14:35:11 +01:00
Joris Vink 0c0393fc64 constify 2016-02-13 14:33:06 +01:00
Joris Vink c91fa9ab70 don't be dumb. 2016-02-13 14:13:59 +01:00
Joris Vink 9340d132db don't bother with empty things in kore_text_trim. 2016-02-13 14:02:10 +01:00
Daniel Fahlgren 04aec1c2dd Fix typo in log message 2016-02-12 08:57:58 +01:00
Joris Vink 12e1820a4f Unbreak normal POST parsing.
It was broken for > 2 fields due to recent large changes,
unfortunately i didn't catch this until now.
2016-02-06 15:32:23 +01:00
Joris Vink d4435bec8d Correct pretty bad typo. 2016-02-06 14:59:54 +01:00
Joris Vink 40f69924bb Move shared file reading code to kore_read_line() 2016-02-01 22:10:10 +01:00
Joris Vink 17e311dba9 constify kore_parse_config_file() parameter. 2016-02-01 21:59:31 +01:00
Joris Vink ac864a7419 Update output message to match others. 2016-02-01 21:54:09 +01:00
Joris Vink 3b1204d599 Make sure certkey and certfile are NULL after freeing.
From oneswig but I accidentally removed it during the merge.
2016-02-01 21:42:33 +01:00
Joris Vink d0e9441b60 remove debug. 2016-02-01 21:41:25 +01:00
Joris Vink c8484ee9ab Redo config parsing a bit.
No longer just call kore_string_split() on the line
but separate out the configuration directive and let
the appropriate callbacks parse things on their own.
2016-02-01 21:33:51 +01:00
Joris Vink 82a9e6ef59 Formatting and unbreaking NOHTTP builds. 2016-02-01 20:02:02 +01:00
Joris Vink f4d00645ed Merge pull request #99 from oneswig/master
Add resource management as part of the kore shutdown process.
2016-02-01 19:51:27 +01:00
Joris Vink 1f5e482b8a Build option changes.
- Build with -O2 unless NOOPT is set to 1.
- Hide -g behind DEBUG instead of always building with it.
- Explicitely set the standard used to c99, use pedantic.
2016-02-01 15:33:40 +01:00
Stig Telfer 7963a2deaa Added cleanup for the module handlers and validators 2016-02-01 12:13:22 +00:00
Stig Telfer 55d2451b90 Add cleanup of http_body_path pool 2016-02-01 10:10:04 +00:00
Stig Telfer bd975541dd Merge branch 'master' into oneswig 2016-02-01 10:04:59 +00:00
Joris Vink f2f5a3742f Let SIGTERM properly shutdown Kore as well. 2016-01-31 16:48:17 +01:00
Joris Vink cb489ce80f Define WAIT_ANY if not defined previously. 2016-01-31 16:47:00 +01:00
Joris Vink 3284265b74 Remove the -v stuff and always show cflags and ldflags. 2016-01-27 21:37:59 +01:00
Joris Vink b777ea65cd Long day .. actually add the new build flavor code. 2016-01-27 21:32:57 +01:00
Stig Telfer 2ac6e7d41d Merge branch 'master' into oneswig 2016-01-24 13:46:38 +00:00
Stig Telfer fd0ddca46c Add cleanup function for platform_event on BSD systems 2016-01-22 11:26:56 +00:00
Stig Telfer ec73c35952 Add missing C library headers 2016-01-22 11:08:13 +00:00
Joris Vink 192f458f97 remove unused variable. 2016-01-18 11:43:44 +01:00
Joris Vink a2216c84b0 Properly check if path was already set. 2016-01-18 11:43:10 +01:00
Joris Vink fcb86ddb8b Massive rework of HTTP layer.
This commit is a flag day, your old modules will almost certainly
need to be updated in order to build properly with these changes.

Summary of changes:

- Offload HTTP bodies to disk if they are large (inspired by #100).
  (disabled by default)
- The http_argument_get* macros now takes an explicit http_request parameter.
- Kore will now throw 404 errors almost immediately after an HTTP request
  has come in instead of waiting until all data has arrived.

API changes:

- http_argument_get* macros now require an explicit http_request parameter.
  (no more magic invokations).
- http_generic_404() is gone
- http_populate_arguments() is gone
- http_body_bytes() is gone
- http_body_text() is gone
- http_body_read() has been added
- http_populate_post() has been added
- http_populate_get() has been added
- http_file_read() has been added
- http_file_rewind() has been added
- http_file_lookup() no longer takes name, fname, data and len parameters.
- http_file_lookup() now returns a struct http_file pointer.
- http_populate_multipart_form() no longer takes an secondary parameter.

New configuration options:

- http_body_disk_offload:
	Number of bytes after which Kore will offload the HTTP body to
	disk instead of retaining it in memory. If 0 this feature is
	disabled. (Default: 0)

- http_body_disk_path:
	The path where Kore will store temporary HTTP body files.
	(this directory does not get created if http_body_disk_offload is 0).

New example:

The upload example has been added, demonstrating how to deal with file
uploads from a multipart form.
2016-01-18 11:30:22 +01:00
Joris Vink 96641d3caa Merge branch 'master' of /opt/git/kore 2016-01-18 11:29:47 +01:00
Joris Vink 0dcd6087cf Add kore_buf_stringify().
NUL-terminates a kore_buf and returns a char pointer.
2016-01-18 11:26:55 +01:00
Joris Vink 3c40168e50 Deal with SSL_ERROR_SYSCALL properly. 2016-01-14 10:50:46 +01:00
Ansen Dong 490163de4a if read() return EINTER,retry 2016-01-14 03:02:53 -05:00
Joris Vink ed8110f109 Paranoia about overflows. 2016-01-09 13:51:50 +01:00
Carl Ekerot 53e8220ff6 Fix off-by-one error when reallocing buffer
There was an invalid boundary check when appending to a buffer. The
consequence of this was that the POST data buffer was deterministically
realloced.
2016-01-09 01:57:59 +01:00
Joris Vink e580e6678e Simplify checking filename component. 2016-01-08 21:19:37 +01:00
Joris Vink ce874f09ea Cut memory usage for incoming HTTP bodies in half.
Kore pre-allocates a kore_buf for the full size of the
incoming HTTP body ... but also was passing the full
size to the net_recv_reset() function.

Instead of this, properly read smaller chunks from the
network and append them to the body buffer as they roll in.
2016-01-08 20:56:21 +01:00
Joris Vink 0647901ef5 Improve http_body_max directive a bit.
Allow setting it to 0 which will disable HTTP requests
that have a body (POST/PUT).

Reduce default http_body_max to 1MB by default, 10MB seems large.

Revisit to this code inspired by #100.
2016-01-08 17:54:40 +01:00
Joris Vink 0c47574fe9 If a body is too large send a 413 instead of 411. 2016-01-08 17:47:15 +01:00
Joris Vink f2d8834e8e After receiving a body, prime the netbuf again.
Not doing this results in nothing being read anymore
from the connection after a POST with a content-length of > 0.

Found by Xuning Niu.
2016-01-07 10:40:33 +01:00
Joris Vink e9b56c81a5 Do not fatal if no listeners are defined. 2016-01-07 10:09:44 +01:00
Joris Vink 2f4387e0cd correct headers. 2016-01-07 09:24:45 +01:00
Joris Vink 07ed037a00 Reduce memory footprint for NOTLS builds. 2016-01-07 09:20:09 +01:00
Stig Telfer 18d3cc032d rename *_fini to *_cleanup 2016-01-04 21:40:14 +00:00
Joris Vink 2fc326c0ce Remove whitespace. 2016-01-04 13:09:45 +01:00
Joris Vink c4b1206ae3 Bump copyright to 2016. 2016-01-04 12:58:51 +01:00
Joris Vink a281fd5713 Introduce synchronous pgsql queries.
Semantics for using pgsql API have changed quite heavily
with this commit. See the examples for more information.

Based on Github issue #95 by PauloMelo (paulo.melo@vintageform.pt)
with several modifications by me.
2016-01-04 11:12:43 +01:00
Stig Telfer 223c5c4c28 net_send_queue: Handle case where new data exactly fits available buffer. 2015-12-29 22:07:24 +00:00
Stig Telfer ac45e8cd62 Revert incorrect parameter validation 2015-12-29 21:29:35 +00:00
Stig Telfer 0c51d9da53 Add resource management as part of the kore shutdown process. 2015-12-29 19:39:39 +00:00
Joris Vink 4356c3e628 Allow domain wildcards in the configuration. 2015-12-16 19:51:06 +01:00
Joris Vink 519c3c16d4 Do not run kore_split_string() on original cookie
This broke after http_request_header() started returning
a pointer to the actual header value instead of a copy.

Reminded by PauloMelo via github.
2015-12-14 18:48:48 +01:00
PauloMelo a6ccf2bae9 correct tabsize 2015-12-11 22:31:14 +00:00
PauloMelo d811bf71dc add kore_buf_reset 2015-12-11 21:31:59 +00:00
Joris Vink 8a6f4a935e Set handle function pointer for message callbacks. 2015-12-10 09:26:24 +01:00
Joris Vink 6ac15d37cb Make sure user agent is still set properly. 2015-12-10 09:25:22 +01:00
Joris Vink d3332d5921 Add kore_platform_schedule_write(). 2015-12-09 21:29:44 +01:00
Dmitrii Golub 3eaa325eb5 fix typo: -r for skip privs 2015-12-08 04:42:16 +03:00
Dmitrii Golub ab391df7ff Better CFLAGS and CFLAGS limit 2015-12-04 17:16:56 +03:00
Joris Vink b4611ee38d Kill off zlib_dict.c 2015-12-04 14:11:37 +01:00
Joris Vink 77364e49cd Do not call handle if not set, similar to bsd.c. 2015-12-02 21:57:16 +01:00
Joris Vink 961a2e3685 Allow apps to override connection handling.
Setting the handle callback allows your application
to take care of network events for the connection.

Look at the connection state and flags to determine
if read/write is possible and go from there.

See kore_connection_handle() for more details.
2015-12-01 20:55:00 +01:00
Joris Vink 428802afc8 More cleanup after introducing NOHTTP=1.
* The cli tools must know when building as KORE_NO_HTTP.
* Reshuffle some structs around to avoid forward declarations.
* Move wscbs under !KORE_NO_HTTP as its for websockets.
* Remove unused members from struct connection.

Applications that use the connect callbacks for new connections
must now set the connection state themselves, see nohttp example.
2015-11-30 16:23:34 +01:00
Joris Vink 4fd6d8a7a4 Correct usage of http_request_header().
Since latest change we no longer need free its result.
2015-11-29 17:22:30 +01:00
Joris Vink 7bdae240cf Change semantics for http_request_header().
The result returned by this function no longer needs to
be freed by the caller.
2015-11-29 14:19:44 +01:00
Joris Vink fd52d4c39d Spacing 2015-11-27 18:12:08 +01:00
Joris Vink 769c78a6e8 Introduce NOHTTP=1 build option.
This basically turns off the HTTP layer for Kore. It does not
compile in anything for HTTP.

This allows Kore to be used as a network application platform as well.
Added an example for this called nohttp.

Other changes that sneaked in while hacking on this:
* Use calloc(), kill pendantic malloc option.
* Killed off SPDY/3.1 support completely, will be superseded by http2

Note that comes with massive changes to a lot of the core API
functions provided by Kore, these might break your application.
2015-11-27 16:22:50 +01:00
Joris Vink a88e56ae25 Do not call TAILQ_INIT() on domain list twice. 2015-11-27 11:15:36 +01:00
Shih-Yuan Lee (FourDollars) 384ac824ee Fix typos. 2015-11-04 09:54:55 +08:00
Joris Vink 7b3224ad30 Remove 'behind' argument from timers.
Also calculate next run for a timer as now + interval
instead of last nextrun + interval - delta.
2015-08-06 08:20:41 +02:00
Joris Vink a20fb00789 req can be NULL if we are coming from an error path. 2015-08-02 16:53:40 +02:00
Joris Vink a572a9eeae Always correctly add websocket frame length.
In certain scenarios the addition frame length
would not be set, found the hard way.
2015-07-16 06:55:44 +02:00
Joris Vink 1003cbcd50 Just point hldr_extra to kw->id.
Not sure what state of crazy my mind was in for writing
the previous code like that.
2015-07-07 16:11:40 +02:00
Joris Vink 0281fb7b99 Update the msg->dst member accordingly when sending.
This way the worker will always receive a message with
the correct destination set instead of KORE_MSG_WORKER_ALL.
2015-07-06 21:16:22 +02:00
Joris Vink 064f2095b0 Update message framework with src/dst for workers.
One can now send messages to specific workers and
receiving workers can see the origin of the messages.
2015-07-06 21:08:36 +02:00
Joris Vink d8508f4a7b Add the actual task changes for last commit. 2015-07-01 11:03:54 +02:00
Joris Vink be3fa17201 Do not send connection:close for websocket upgrades. 2015-06-30 16:43:21 +02:00
Joris Vink a4e462b36c Merge pull request #68 from Indrikoterio/master
Make sure we set connection to upgrade only in websocket responses.
2015-06-30 16:37:15 +02:00
Cleve Lendon 18becccd5a Fix indentation. 2015-06-30 18:07:45 +09:00
Joris Vink 4dff0b57ae Add openssl paths for homebrew/ports for osx.
These are the default paths openssl should be installed under
for both projects. This at least kills the need for user CFLAGS
for a normal build.

Inspired by #70.
2015-06-28 13:43:01 +02:00
Cleve Lendon fef3ee8efe Fix websockets. Connection must be Upgrade, not keep-alive, Upgrade 2015-06-26 12:14:01 +09:00
Joris Vink a64808c6b0 Improvements to our message framework.
Change the callback prototypes to:
	void callback(struct kore_msg *msg, const void *data);

This allows the callbacks to receive the full kore_msg data structure
as sent over the wire (including length and id). Useful for future
additions to the kore_msg structure (such as worker origin).

Several other improvements:
	* Accesslog now uses the msg framework as well.
	* Websocket WEBSOCKET_BROADCAST_GLOBAL now works.

Small websocket improvement in this commit:
	* Build the frame to be sent only once when broadcasting
	 instead of per connection we are broadcasting towards.
2015-06-23 18:17:14 +02:00
Joris Vink 0e3271cf9d Add EV_CLEAR to the bsd event code for kqueue.
This was missing and makes dealing with events easier.
2015-06-23 18:16:19 +02:00
Joris Vink c322bbd3c8 Kill the websocket message type. We're not there yet. 2015-06-22 22:20:42 +02:00
Joris Vink 28e48727a5 Kill TCP_NODELAY warnings for socketpair() fds. 2015-06-22 22:11:03 +02:00
Joris Vink 7100ab0dd3 Remove useless log message. 2015-06-22 21:21:03 +02:00
Joris Vink 49ca95f390 Add our messaging framework.
With this framework apps can now send messages between worker processes.

A new API function exists:
	int kore_msg_register(u_int8_t id, void (*cb)(const void *, u_int32_t);

This API call allows your app to register a new message callback for a given ID.

You can then send messages on this ID to other workers using:
	void kore_msg_send(u_int8_t id, void *data, u_int32_t length);

This framework will interally be used for a few things such as allowing
websocket data to broadcasted between all workers, adding unified caching
and hopefully eventually moving the access log to this as well.

Some internals have changed with this commit:
	* worker_clients has been called connections.
	* the parent now initializes the net, and event subsystems.
	* kore_worker_websocket_broadcast() is dead.
2015-06-22 21:13:32 +02:00
Joris Vink 63b0c0a903 Fix typo. 2015-06-14 17:21:16 +02:00
Joris Vink db198578c6 Allow Kore to function under DragonflyBSD.
From David Carlier
2015-06-14 16:54:44 +02:00
Joris Vink 9217fb0bd8 Fix typo. 2015-06-14 16:50:10 +02:00
Joris Vink 13795ead63 NetBSD fixes, from David Carlier. 2015-06-14 16:44:37 +02:00
Joris Vink 512e305e20 When building assets, skip empty files. 2015-06-11 19:33:30 +02:00
Joris Vink 81d119ff93 Let kore build pickup any environment CFLAGS. 2015-06-11 19:20:08 +02:00
Joris Vink 1d604643b5 Add task_threads configuration option.
Before Kore would spawn a task thread per task started
if none were available. This was an obvious bad idiom
but never really hit me hard until now.

Kore will now only spawn as many task threads as configured
by "task_threads" and queue up any newly started tasks ontop
of already running threads if the limit was hit.
2015-06-04 10:29:22 +02:00
Joris Vink 854b916597 Update usage text. 2015-05-28 22:20:43 +02:00
Geenz 0f5b39c977 Small tweak to kore's output when running a module 2015-05-27 09:34:47 -04:00
Geenz 817b916e1f Call it NOTLS instead.
Per @jorisvink's feedback.
2015-05-25 09:42:34 -04:00
Geenz c44de3f629 Rename BENCHMARK to reflect its actual function.
NO_SSL makes a bit more sense, especially for people who proxy their requests via nginx, apache, or similar.
2015-05-25 09:28:13 -04:00
Joris Vink 20a4cd80c5 Kill own definition of be64toh() for openbsd. 2015-05-21 11:01:50 +02:00
Joris Vink 02e06b8bb6 Stop client initiated TLS renegotiations completely. 2015-05-20 16:36:13 +02:00
Joris Vink ff2574899d small style fix. 2015-05-20 11:36:02 +02:00
Joris Vink cdefb66ed8 Spacing. 2015-05-20 11:34:57 +02:00
Thordur Bjornsson d8ccf3c7bf Gunk the default runas/chroot values.
Fatal in the config setup if running without skip_{chroot,runas} and
no values specified.
2015-05-20 11:08:51 +02:00
Thordur Bjornsson e47df37230 Make runas behave similarly to chroot.
Add new command line knob '-r', that disables runas similar to '-n',
it's implied as well for kore command runs.

Add default runas (nobody) user and chroot (/var/empty) path, if none
are specified, fallback to these.
2015-05-20 10:28:19 +02:00
Quentin PEREZ e2e5631b8c add noreturn attribute
fix false-positive warning
2015-05-19 09:45:04 +02:00
Joris Vink a97e18bbe9 Shuffle some HTTP_REQUEST_NO_CONTENT_LENGTH around 2015-05-19 09:13:29 +02:00
Joris Vink e33710b26a Wrap expression with some additional parenthesis. 2015-05-19 09:04:46 +02:00
Quentin Perez ff4faa98b7 fix-null-dereference
http.c:1214, req->method
http.c:1272, req->flags
2015-05-18 23:42:50 +02:00
Joris Vink 5228fe1cbc Fix typo in configuration option worker_accept_treshold.
There is no backwards comptabile option available.

Fixes #53
2015-05-18 12:20:28 +02:00
Joris Vink 875b3a46e6 SPDY stream changes.
Allow callers to set an onclose callback method for SPDY streams
so they can get notified when a stream is closed.

Also add SPDY_NO_CLOSE which tells the underlying Kore layer
to not send a FIN for a SPDY stream until a module does it itself.
2015-05-15 19:17:09 +02:00
Joris Vink 1dd7407a41 Close SPDY streams if len == 0 and SPDY_NO_CLOSE is not set. 2015-05-15 19:16:35 +02:00
Joris Vink cefeaf7992 HTTP layer improvements.
Add HTTP_REQUEST_NO_CONTENT_LENGTH which can be set by
a handler before calling http_response() to avoid Kore
from setting the content-length altogether.

If we are on a SPDY connection do not close the stream
if we do not pass data to http_response().
2015-05-15 19:12:18 +02:00
Joris Vink 0c4dbad2fb Kore timer improvements.
Introduces kore_timer_remove() and updates kore_timer_add()
to return the newly added timer as a struct kore_timer.

Also allow arguments to be passed to timers.
2015-05-15 19:11:10 +02:00
Joris Vink e2ce032b02 Do not treat EPOLLRDHUP as a connection error. 2015-05-15 19:10:23 +02:00
Joris Vink b648c108c2 Merge pull request #50 from thorduri/janitor
fix copy pasto.
2015-05-13 09:58:10 +02:00
Joris Vink 09ed61187b Unfuck content-length changes.
We want a content-length unless its 204 or status < 200.
2015-05-13 09:16:06 +02:00
Joris Vink 7ce742f131 Merge pull request #48 from thorduri/content-length
Always write out content-length;
2015-05-13 09:02:58 +02:00
Thordur Bjornsson a62bce3e88 Always write out content-length;
Unless status is 204 or 1xx (informational).
2015-05-12 20:23:47 +02:00
Thordur Bjornsson 52e67ff4a1 fix copy pasto. 2015-05-12 13:28:18 +02:00
Joris Vink d3e3788162 Merge pull request #47 from thorduri/misc-cli
miscellaneous mask fixes
2015-05-12 08:47:17 +02:00
Thordur I. Bjornsson dcb0f458e7 set a wee bit saner umask 2015-05-09 12:14:49 +00:00
Joris Vink 4f36b534aa Reset fsm_state back to 0 after we're done with it. 2015-05-08 21:19:20 +02:00
Thordur I. Bjornsson bb6e2823a0 fix tyop 2015-05-08 14:53:59 +00:00
Thordur I. Bjornsson 9f823f345e no need to open cert/key files for read 2015-05-08 14:41:48 +00:00
Thordur I. Bjornsson 9418139c76 no need for execute bit in cli_file_open 2015-05-08 14:40:51 +00:00
Joris Vink 603e353eab Merge pull request #46 from thorduri/config
Continue on terminating '}' in a config stanza.
2015-05-07 20:34:25 +02:00
Joris Vink cd35c10224 Make clang a little bit happier. 2015-05-07 20:32:21 +02:00
Thordur I. Bjornsson 1e8e5bad7f Continue on terminating '}' in a config stanza. 2015-05-07 14:26:01 +00:00
Joris Vink b0947b73d9 Let modules decide if they want to be reloaded.
At times it seems relevant that worker their modules should not
be reloaded when receiving a SIGHUP. Developers can now control
this by returning anything else but KORE_RESULT_OK from their
initialization methods.

The parent module will always be reloaded.
2015-05-07 13:03:10 +02:00
Joris Vink 384bc8fdd6 Default to only TLSv1.2 from now on.
Add configuration setting tls_version to specify if you
either want TLSv1.2 or TLSv1.0 or both.

The configuration options ssl_cipher and ssl_dhparam
have changed name to tls_cipher and tls_dhparam. There is
no fallback so you might have to update your configs.
2015-05-06 10:59:43 +02:00
Joris Vink 48495feb43 No, I was wrong. The dh params were created in the right place. 2015-05-06 10:21:54 +02:00
Joris Vink 5b462f3ab6 Always attempt to create dh2048.pem if not present 2015-05-06 10:18:54 +02:00
Joris Vink 97bd389935 Use IPC_PRIVATE when creating our shm.
Instead of a homegrown mechanism of finding empty SHM
keys that may or may not be available.

Should fix #44
2015-04-28 10:21:15 +02:00
Joris Vink e5f6d37cd2 Make parameter validation less noisy. 2015-04-27 15:35:02 +02:00
Joris Vink b0deac577c Add new configuration option: worker_set_affinity.
Controls wether or not worker processes sets its affinity
mask to bind themselves to a single CPU.

Defaults to on (1).
2015-04-27 10:36:33 +02:00
Joris Vink b035dea3ff Make socket error messages more understandable. 2015-04-26 21:09:46 +02:00
Joris Vink ee22ec99d6 Task improvements.
Do not blindly close the sockets created by socketpair() when
finishing up or destroying a task.

Under heavy load this could turn into a race condition where
the task thread closes its endpoint when at the same time
a new task is registered and socketpair() returns the recently
closed socket back to a new task.

When the task that finished then gets destroyed it closes
the endpoint registered to a new task instead causing Kore
to fatal() out when attempting to read from said socket.
2015-04-24 14:20:02 +02:00
Joris Vink 6be54040f3 Use kevent() to schedule an event immediately.
Instead of merging it in under the kevent() call under
the event loop. Strange side effects are showing on OSX
under heavy load.
2015-04-24 11:45:00 +02:00
Joris Vink 58864005e0 Do not leak key in kore_websocket_handshake on error. 2015-04-24 09:22:32 +02:00