174 Commits

Author SHA1 Message Date
Joris Vink
175b2e2c9b kore flavor -> kodev flavor 2017-03-06 23:18:16 +01:00
Joris Vink
f1d33ab91b kore -> kodev where appropriate 2017-03-06 11:00:53 +01:00
Joris Vink
3e84502235 Adjust examples after recent changes.
- New kodev tool generates config with server.pem/key.pem.
- Use proper formats for kore_log().
- Update to new websocket api.
2017-02-25 17:02:39 -08: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
7c78dea211 more cookie example improvements.
- remove unneed headers.
- rename local to avoid shadowing.
2017-02-07 22:12:56 +01:00
Joris Vink
4e556dbd8f rename example cookies source file. 2017-02-07 22:06:31 +01:00
Joris Vink
36e99072f3 cookie example improvements. 2017-02-07 22:04:00 +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
21bf7f9583 rework base example a bit. 2017-02-06 12:21:40 +01:00
Joris Vink
9f3046bae7 add README 2017-02-06 11:52:24 +01:00
Joris Vink
0bf36b763a add new python-pgsql example 2017-02-06 11:51:49 +01:00
Joris Vink
d3f84db4b8 small fixes. 2017-02-01 21:36:53 +01:00
Joris Vink
7fb47da586 add http_file example to python example. 2017-02-01 21:35:44 +01:00
Joris Vink
261fb3c3fa flesh out python example a bit more. 2017-02-01 17:15:18 +01:00
Joris Vink
8629419253 the example uses tls by default, so use it. 2017-01-31 09:21:06 +01:00
Joris Vink
6e7de9ab93 update python ws example. 2017-01-30 22:40:59 +01:00
Joris Vink
3d3d705b98 flesh out the python stuff a bit more. 2017-01-30 20:47:24 +01:00
Joris Vink
7bc8bb42e2 implement kore_websockat_broadcast. 2017-01-30 20:30:42 +01:00
Joris Vink
5485967547 add websocket example to python 2017-01-29 22:57:55 +01:00
Joris Vink
7510834968 initial fudging to add websockets to python 2017-01-29 22:57:34 +01:00
Joris Vink
829066dc23 i can't port. 2017-01-26 22:02:11 +01:00
Joris Vink
4940f97079 remove stuff that is not ready yet and add README. 2017-01-26 22:01:23 +01:00
Joris Vink
ef441fb9a1 bah, be gone. 2017-01-25 22:38:43 +01:00
Joris Vink
ff48aed926 initial python example.
don't look too much into this yet.
2017-01-25 22:38:06 +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
john721
f15558ed98 Fix no response in case kore was built with NOTLS=1. (#142) 2016-08-16 10:19:07 +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
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
43fec8678e kore_buf_create -> kore_buf_alloc. 2016-07-14 12:34:29 +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
Joris Vink
d30921103b Code cleanup, several API breaking changes in here 2016-07-08 10:03:41 +02:00
Joris Vink
7ac1ea379d Unbreak json_yajl example. 2016-07-06 09:23:41 +02:00
Corbin Hughes
698b3f374f Compile and link C++ with g++ instead of gcc 2016-06-26 15:49:59 -05:00
Joris Vink
4503b4756b remove lies. 2016-02-13 15:38:00 +01:00
Joris Vink
b777ea65cd Long day .. actually add the new build flavor code. 2016-01-27 21:32:57 +01:00
Joris Vink
c5ce707a91 Introduce build flavors.
Kore applications now get a build.conf which may contain different
build flavors. Each flavor can get its own cflags or ldflags.

This was in parts inspired by #106.

A new cli command has been added:
kore flavor

This command allows you to see all flavors and switch between them.
The kore build command now also takes a -v argument which if given
dumps the used CFLAGS and LDFLAGS out to stdout.

For existing applications the build.conf is automatically generated
next time you run kore build or kore run.

Also fixed a bug in the json_yajl example, sneaky change here.
2016-01-27 21:29:59 +01:00
Joris Vink
340bcb3b0d Properly queue net events for tls-proxy example 2016-01-22 15:07:33 +01:00
Joris Vink
a958627837 Unlink correct file in upload example. 2016-01-20 10:33:32 +01:00
Joris Vink
d67b5aaa04 Properly do config for upload example 2016-01-18 11:51:44 +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
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
Joris Vink
c3401fe348 Make the TLS proxy example much better.
Now allows multiple backends based on SNI that was
set during TLS handshake.

The connection phase for the backends is now fully
non blocking.
2015-12-09 21:29:53 +01:00
Joris Vink
1ed96b12a9 correct certificate path in example 2015-12-02 21:53:42 +01:00
Joris Vink
d02f9e549f Add TLS proxy example. 2015-12-02 21:52:26 +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