Commit Graph

215 Commits

Author SHA1 Message Date
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 d5a32c2dab use the correct opcode for PONG.
djees i can't hex.
2017-01-30 22:17:47 +01:00
Joris Vink 7510834968 initial fudging to add websockets to python 2017-01-29 22:57:34 +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 f56938283d Merge branch 'master' of github.com:jorisvink/kore 2017-01-25 22:23:34 +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 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
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 552d59248c constify delim in kore_split_string(). 2016-10-06 16:50:41 +02:00
Joris Vink 8b723479ec bump 2016-08-01 15:01:19 +02:00
Joris Vink 441cc34f31 bump to release 2016-08-01 09:38:40 +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 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 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 a8917e355a Add prototype for kore_onload(). 2016-07-07 13:18:41 +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 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
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
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
Joris Vink 0c0393fc64 constify 2016-02-13 14:33:06 +01:00
Joris Vink fcc2010117 Make debug builds build again. 2016-02-13 14:20:31 +01:00
Joris Vink 40f69924bb Move shared file reading code to kore_read_line() 2016-02-01 22:10:10 +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
Stig Telfer 7963a2deaa Added cleanup for the module handlers and validators 2016-02-01 12:13:22 +00:00
Stig Telfer 2ac6e7d41d Merge branch 'master' into oneswig 2016-01-24 13:46:38 +00:00
Stig Telfer ec73c35952 Add missing C library headers 2016-01-22 11:08:13 +00: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 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 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 c4b1206ae3 Bump copyright to 2016. 2016-01-04 12:58:51 +01:00
Stig Telfer 0c51d9da53 Add resource management as part of the kore shutdown process. 2015-12-29 19:39:39 +00: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 d3332d5921 Add kore_platform_schedule_write(). 2015-12-09 21:29:44 +01:00
Joris Vink 3c0cc79e6b More incompatible changes incoming, make it clear
Semver demands it.
2015-12-09 16:29:35 +01:00
Joris Vink d7bbb54424 Remove zlib.h 2015-12-04 14:12:06 +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 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 963bdfdb2c Move towards 1.3.0-devel target, skipping 1.2.4.
Mostly done due to incoming library changes.
2015-11-12 09:20:14 +01:00
Joris Vink 656931380c Bump to 1.2.4-rc1 2015-09-17 12:33:40 +02: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 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