Commit Graph

713 Commits

Author SHA1 Message Date
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
Joris Vink b869041a14 Introduce new config option worker_accept_treshold
This configuration option limits the maximum number
of connections a worker process can accept() in a single
event loop.

It can be used to more evenly spread out incoming connections
across workers when new connections arrive in a burst.
2015-04-23 10:24:00 +02:00
Joris Vink dc6e6fb1b4 Kill NETBUF_CALL_CB_ALWAYS for incoming HTTP body
Do not let the NETBUF_CALL_CB_ALWAYS flag linger in
the netbuf we reset for the incoming HTTP body.
2015-04-21 11:30:59 +02:00
Joris Vink 4c39ac43fb Properly deal with accept() failing.
In cases where accept() failed Kore would not relinquish the
lock towards other worker processes.

This becomes evident when dealing with a high number of concurrent
connections to the point the fd table gets full. In this scenario
the worker with the full fd table will spin on attempt to accept
newer connections.

As a bonus, Kore now has allows exactly up to worker_max_connections
of connections per worker before no longer attempting to grab the
accept lock.
2015-04-20 15:17:42 +02:00
Joris Vink dfea3cf483 Place path and host in http_request into pools.
Also change the amount of times we end of doing unneccessairy strlen() calls.
2015-04-15 12:40:15 +02:00
Joris Vink 6c2e4dd831 Task improvements.
* Always start listening on the task its socket endpoint when
  called kore_task_run() instead of at kore_task_bind_request().

* Disable read events on the task its socket endpoint when
  kore_task_handle() is called for a finished task. Stops us
  from entering a busy loop until kore_task_destroy() is called.
2015-04-14 09:01:36 +02:00
Joris Vink 097a1166df Improve very heavy load handling.
Introduces two new configuration knobs:
	* socket_backlog (backlog for listen(2))
	* http_request_limit

The second one is the most interesting one.

Before, kore would iterate over all received HTTP requests
in its queue before returning out of http_process().

Under heavy load this queue can cause Kore to spend a considerable
amount of time iterating over said queue. With the http_request_limit,
kore will process at MOST http_request_limit requests before returning
back to the event loop.

This means responses to processed requests are sent out much quicker
and allows kore to handle any other incoming requests more gracefully.
2015-04-09 15:29:44 +02:00
Joris Vink b0ff041709 call setrlimit() before we drop privs. 2015-04-09 10:06:18 +02:00
Joris Vink 5f1238c2dc Merge pull request #40 from Geenz/master
Support PUT, DELETE, and HEAD methods in configs.
2015-04-09 10:00:42 +02:00
Joris Vink dc4f856c5c Use UINT_MAX for limit of worker_max_connections. 2015-04-09 08:56:12 +02:00
Geenz 2b907545ca Support PUT, DELETE, and HEAD methods in cofigs.
The primary usecase for this is RESTful APIs where PUT, DELETE, and HEAD can be useful methods to support.
2015-04-08 19:46:27 -04:00
Joris Vink af865abede Bump copyright to 2015 2015-04-07 13:08:26 +02:00
Joris Vink 1fae259603 Use stat(2) to figure out type of directory entry.
readdir(2) might not be able to give back the correct
type in the d_type member and we should properly handle
the DT_UNKNOWN value anyway.

Fixes #39.
2015-04-07 09:27:58 +02:00
Joris Vink d6ab1d7445 Add rudimentary timers to Kore.
Timers are in ms resolution and are added using
kore_timer_add(cb, interval, flags).

Both oneshot timers and continious timers are supported.
2015-04-06 18:54:35 +02:00
Joris Vink cf028f20b6 Rename kore_auth() to kore_auth_run(). 2015-04-02 13:45:42 +02:00
Joris Vink 3b7d8b29e6 Initialize has_cpp to 0. 2015-04-02 13:34:51 +02:00
Joris Vink 3a608a99bb Formatting and slight C++ build improvements.
Do not link against libstdc++ when not having any C++ files.
Let the compiler decide what subprocess to use for compiling
certain files, thus killing the CXX need. Can be overwritten
in the same old default in CC.
2015-04-02 13:33:52 +02:00
Geenz 6bd0da171d Always enable C++ support.
Per @jorisvink's suggestion.
2015-04-02 05:43:07 -04:00
Geenz 93fe8e6b42 Update Readmes 2015-04-01 21:39:40 -04:00
Geenz eab769af6b Add support for selecting C++ dialect and lib.
Otherwise, assume libstdc++ and the compiler's default dialect.
2015-04-01 20:05:09 -04:00
Geenz ba031d15de Sleep deprived typos are the best typos. 2015-04-01 19:28:26 -04:00
Geenz 5af3411513 Code style cleanup in C++ example. 2015-04-01 09:35:05 -04:00
Geenz 97ec644a9a Explicitly link libstdc++. 2015-04-01 08:32:24 -04:00
Geenz 86daf3f1b0 Add support for setting the C++ compiler.
Also make args a bit bigger.
2015-04-01 08:09:09 -04:00
Geenz 6b7f79f733 Wrap C++ support with KORE_CPP_SUPPORT 2015-04-01 07:02:53 -04:00
Geenz 45e9d26f48 Separate C and C++ files into their own lists. 2015-04-01 03:28:03 -04:00
Geenz faa1cf60c4 Add a few useful C++ specific warnings. 2015-03-31 23:09:09 -04:00
Geenz 6e52c31d59 Include .cpp files when building.
This probably isn't an ideal way to add support for also compiling C++ in a project, but for now it works for my needs.
2015-03-31 03:17:33 -04:00
Joris Vink b234b7ed65 Add HTTP_REQUEST_RETAIN_EXTRA flag to http_request
Signals Kore to not free any pointer set in req->hdlr_extra.
Useful in certain scenarios where you have data per request
bound to something in memory but do not want to lose it when
the request is freed by Kore.

Set this flag before your handler returns.
2015-03-27 23:23:21 +01:00
Joris Vink eb235b3e01 shmat() returns (void *)-1 upon error. 2015-03-25 19:42:24 +01:00
Joris Vink a4a86494b8 Bring net_recv_expand() in line with others. 2015-03-16 16:52:40 +01:00
Joris Vink a4298206a7 Fix lies in fatal message. 2015-03-16 16:50:33 +01:00
Joris Vink ad5d662556 Use net_recv_reset() if more body bytes are coming.
Unbreaks clients that send the headers first and the
actual HTTP body after X amount of time.
2015-03-16 16:45:13 +01:00
Joris Vink f8a9ece9a6 Set the x509 callback when initializing the SSL_CTX.
While here, fix a format string error.
2015-02-20 10:49:14 +01:00
Joris Vink f975453565 Set X509 verification callback and log errors.
When using client certificates Kore now calls
domain_x509_verify() and logs any certificate
verification errors that might occur.

CRL validity errors are ignored.
2015-02-20 10:43:31 +01:00
Joris Vink 0288902a1b Set crlfile to NULL when initializing. 2015-02-20 10:11:15 +01:00
Joris Vink 91c44af6f0 Always include includeSubDomains for HSTS. 2015-02-10 17:14:07 +01:00
Joris Vink 1507f88ec7 Respect keepalive when throwing HTTP errors.
Report from github issue #34
2015-02-06 10:59:15 +01:00
Joris Vink 6d90291405 Set rootdir earlier in cli_create(). 2015-02-06 09:02:52 +01:00
Joris Vink 12c07b79e6 Kill a warning when building with BENCHMARK 2015-02-04 19:40:49 +01:00
Joris Vink 6eec8166c6 "request" auth blocks should set their own response. 2015-02-04 12:04:07 +01:00
Joris Vink 2049bc72dc By default Kore now uses ECDH/DHE for TLS key exchanges.
This commit disables RSA key exchanges for TLS completely, while
introducing the requirement for always having DH parameters (ssl_dhparam).

Judging from ciphersuites most modern browsers now prefer this
change should be more than ok.
2015-02-03 13:17:59 +01:00
Joris Vink b1e5a806a6 No need to assign ret when failing here. 2015-01-19 15:32:52 +01:00
Joris Vink 67efb9b04a better brackets around some if statements. 2015-01-19 15:31:36 +01:00
Joris Vink 2ee72657e1 Brackets would be great here. 2015-01-19 15:26:53 +01:00
Joris Vink 6005c95ee6 Fix compiling under openbsd 2014-12-12 19:09:44 +01:00
Joris Vink dbe301e58c Add a patch level to our version number. 2014-12-12 13:06:41 +01:00
Andreas Pfohl 24e1d3928d Added ability to set path prefix during make. 2014-12-12 10:15:30 +01:00
Joris Vink c494126720 Make worker_clients available everywhere. 2014-12-03 20:40:44 +01:00
Joris Vink 7b286f2f70 Set correct timeout start for websockets 2014-11-25 20:00:33 +01:00
Joris Vink f867882f43 Add websocket support to Kore.
Introduces a few new api functions:

- kore_websocket_handshake(struct http_request *):
	Performs the handshake on an HTTP request (coming from page handler)

- kore_websocket_send(struct connection *, u_int8_t, void *, size_t):
	Sends data to a websocket connection.

- kore_websocket_broadcast(struct connection *, u_int8_t, void *, size_t, int):
	Broadcast the given websocket op and data to all connected
	websocket clients on the worker. Note that as of right now
	the WEBSOCKET_BROADCAST_GLOBAL scope option does not work
	yet and messages broadcasted will be restricted to workers
	only.

- kore_worker_websocket_broadcast(struct connection *, void *, void *):
	Backend function used by kore_websocket_broadcast().
	Could prove useful for developers to have access to.

A simple example is given under examples/websocket.

Known issues:
	Kore does not support PING or CONT frames just yet.
2014-11-24 11:08:34 +01:00
Joris Vink a1e6588085 Repopulate now when we are doing idle timer checks.
Otherwise in a weird scenario the idle timer could
be started with a more recent time then the time we
test against causing a connection to disconnect
before its idle timer was over.
2014-11-21 16:38:23 +01:00
Joris Vink 9184257d97 Properly order linker arguments.
Fixes broken linkages with LDFLAGS on certain platforms see #23.
2014-11-19 14:20:31 +01:00
Joris Vink 27b4447a30 Allow workers to bind to specific CPUs on FreeBSD. 2014-10-26 22:41:55 +01:00
Joris Vink 9512805c04 spacing 2014-10-26 22:11:13 +01:00
Joris Vink 6de0f8568a Rework net, worker and some http internals.
- The net code no longer has a recv_queue, instead reuse same recv buffer.
- Introduce net_recv_reset() to reset the recv buffer when needed.
- Have the workers spread the load better between them by slightly
  delaying their next accept lock and giving them an accept treshold
  so they don't go ahead and keep accepting connections if they end
  up winning the race constantly between the workers.
- The kore_worker_acceptlock_release() is no longer available.

- Prepopulate the HTTP server response header that is added to each
  response in both normal HTTP and SPDY modes.
- The path and host members of http_request are now allocated on the heap.

These changes overall result better performance on a multicore machine,
especially the worker load changes shine through.
2014-10-22 21:16:49 +02:00
Thordur Bjornsson e980dcdd5c Simplify environment variables, abide by POLA.
KORE_COMPILER => CC
KORE_LDFLAGS => LDFLAGS
2014-10-22 17:44:43 +02:00
Joris Vink 9bb7001813 Make sure we can still compile with BENCHMARK=1 2014-10-18 02:38:21 +02:00
Joris Vink b49622bb1a Add CRL support.
Allow Kore to use per domain CRLs when requiring client certificates.
The require_client_cert configuration option has been renamed to a more
sane client_certificates and can optionally take a second argument
which is the CRL in pem format.

You'll need a restart in case the CRLs get updated.
2014-10-18 02:32:05 +02:00
Joris Vink 523bc521c7 Generate certs with sha256 digests from now on. 2014-10-18 01:28:47 +02:00
Joris Vink 79b3ccfe7d kqueue event list should hold worker_max_connections * 2 2014-10-16 21:45:43 +02:00
Joris Vink 693a07250f bump copyright years 2014-10-14 16:18:23 +02:00
Joris Vink 16f2d00d37 No more SSLv3 allowed. 2014-10-14 15:03:04 +02:00
Joris Vink 5855a88862 Increase frequency of idle_check. 2014-10-13 16:34:42 +02:00
Joris Vink 2b2e765fe6 Allow 0 parameters for kore_pgsql_query_params() 2014-10-12 01:17:35 +02:00
Joris Vink a603b77e24 Add PUT/DELETE/HEAD methods (finally).
This commit renames certain POST centric variable and configuration
naming to the correct HTTP body stuff.

API changes include http_postbody_text() and http_postbody_bytes() to
have become http_body_text() and http_body_bytes().

The developer is still responsible for validating the method their
page handler is called with. Hopefully this becomes a configuration
option soon enough.
2014-10-08 11:03:14 +02:00
James Turner 215a4d2da2 Add required header for proper OpenBSD checking 2014-10-01 13:08:38 -04:00
Joris Vink e1be630b84 Add kore_pgsql_getlength() which will return length of a column. 2014-09-28 23:03:49 +02:00
Joris Vink 3b09683f5c Add kore_pgsql_query_params().
This function uses PQsendQueryParams() instead of the normal PQsendQuery()
allowing you to pass binary data in a cleaner fashion.

A basic call would look something like:

char *mydata = "Hello";
size_t mydata_len = strlen(mydata);

kore_pgsql_query_params(&pgsql, req,
    "INSERT INTO foo VALUES($1::text)", KORE_PGSQL_FORMAT_TEXT, 1
    mydata, mydata_len, KORE_PGSQL_FORMAT_TEXT);

kore_pgsql_query_params() is variadic, allowing you to pass any
count of parameters where each parameter has the following:
	data pointer, data length, type of parameter.
2014-09-28 21:39:16 +02:00
Joris Vink 0909e6bac1 Write our assets.h with a fixed include guard. 2014-09-26 15:50:56 +02:00
Joris Vink 1c83af511d Make kore_mem_free() behave like free() and don't do anything if NULL is passed in. 2014-09-25 22:20:47 +02:00
Joris Vink e3417dea16 Remove the pgsql simple layer again.
I rather keep the old idioms instead of adding more complex things
on top of the async ones. Especially since the simple layer would
interfear with existing http state machines from your handler.
2014-09-19 15:53:22 +02:00
Joris Vink f73557c545 Use proper error message 2014-09-19 15:01:56 +02:00
Joris Vink efec7bf8cf No need to set l here 2014-09-19 15:01:45 +02:00
Joris Vink c0c3e9fb05 Use s instead of req->stream. 2014-09-19 15:01:25 +02:00
Joris Vink c4c60e1960 Oops, make sure the new simple api can handle > 1 request without borking. 2014-09-19 14:49:12 +02:00
Joris Vink f6f37437da In pgsql_simple_state_result() be sure to progress the sql state.
Drop back into waiting after our result so we can properly read out
the completed state.
2014-09-19 12:51:37 +02:00
Joris Vink 8e9c3da764 Add a new "simple query" layer to our pgsql api.
This simple query allows you to ditch rolling your own
state machine for handling async pgsql states and instead
asks you to provide 3 functions:
	- init
	- results
	- done

You can see the different in complexity in the pgsql example,
which now contains a pgsql_simple.c holding the same asynchronous
query as in pgsql.c but using the simple pgsql api.

You can of course still roll your own in case you want more control.
2014-09-19 12:32:49 +02:00
Joris Vink 73055662de Remove start from pgsql_job 2014-09-18 10:49:15 +02:00
Joris Vink 59a1a05afe No need to set now at the start, thanks clang. 2014-09-18 08:42:41 +02:00
Joris Vink 49e97ae6f8 Call kore_connection_disconnect() when draining connections.
This way the disconnect callbacks are called properly when
workers are exiting.
2014-09-17 08:46:55 +02:00
Joris Vink 7771adbec2 Allow applications to create new connections in our event loop. 2014-09-17 08:25:45 +02:00
Joris Vink f3e863a482 Properly end headers when doing status codes only. 2014-08-25 10:58:34 +02:00
Joris Vink fa69f2a49c Attempt vsnprintf() up to BUFSIZ in kore_buf_appendv().
If the result was too large fall back to vasprintf instead.
2014-08-22 14:40:19 +02:00
Joris Vink 0542d70a71 Use a single header_buf in http_response_normal()
Avoids constantly allocating and freeing buffers all the time.
This can be done safely due to the fact workers are single threaded.
2014-08-22 14:38:48 +02:00
Joris Vink 71fb54aab7 Replace - as well when building asset names 2014-08-21 23:06:54 +02:00
Joris Vink 7e74cd6e62 Introduce a wait queue for our pgsql code.
Instead of letting http_requests spin, if we cannot allocate
a connection for the request we will queue them up put them to sleep.

When a connection becomes available, we'll wake up a request that
was waiting for a connection and let it continue.

This completely avoids consuming massive amounts of cpu time
when dealing with thousands of requests waiting for a pgsql
worker to become ready.
2014-08-21 16:36:12 +02:00
Joris Vink c063dd52f6 epoll improvements.
* check for EPOLLRDHUP
* in kore_platform_schedule_read() don't use EPOLLET
2014-08-21 16:33:11 +02:00
Joris Vink d3149a2a71 We need at most 2 tokens here 2014-08-18 21:13:16 +02:00
Joris Vink 69f98ef158 Add root/src/includes as an include path when building 2014-08-18 18:56:22 +02:00
Joris Vink 68e0697f2e s/appl/rootdir in cli_compile_file 2014-08-18 15:31:10 +02:00
Joris Vink 83a16763c8 Always NUL-terminate an asset its data.
This way developers can cast assets to char * without first
having to convert it to a proper C string.

The NUL character is NOT included in the length of the asset.
2014-08-18 13:57:06 +02:00
Joris Vink 105804e325 Make http_status_text() return a const char 2014-08-18 10:37:13 +02:00
Joris Vink 873c68b515 Make http_status_text() available everywhere 2014-08-18 10:34:47 +02:00
Joris Vink 8565b47800 Attach tasks/pgsqls to http_requests once more.
This way if an http request is removed while tasks or
pgsqls are still active they are free'd out and cancelled
properly.
2014-08-14 22:05:34 +02:00
Joris Vink f021c8db44 pgsql improvements
* set pgsql->result to NULL when we freed it
* drain the connection pipe just in case in pgsql_conn_release()
2014-08-14 16:43:40 +02:00
Joris Vink 9ea1e3cb57 Properly release pgsql connection if needed 2014-08-14 14:46:21 +02:00
Joris Vink f93747828c Major pgsql rework.
Gone is the ugly KORE_PGSQL macro that hid an overly complex
state machine for the pgsql api.
Gone is the pgsql array that was attached to http_requests.
Gone are the callback hacks inside the pgsql api.

Instead, I strongly encourage people to use the new state machine
api Kore offers to properly deal with asynchronous queries.

The pgsql example in examples/pgsql has been updated to reflect
these changes.
2014-08-14 14:34:23 +02:00
Joris Vink 856d7b0cb2 Rename HTTP_STATE_OK to HTTP_STATE_CONTINUE 2014-08-14 11:20:04 +02:00
Joris Vink 210fb05a35 Add a hopefully easy to use and optional fsm for page handlers
In order to use this, define states for your page handler:

struct http_state mystates[] = {
	{ "PAGE_STATE_INIT",	page_init },
	{ "PAGE_STATE_RESULT",	page_result },
};

In your page handler you can then simply call http_state_run() with
your states and http_request. This will cause Kore to start calling
your state callbacks beginning at index 0.

State callbacks have the same prototype as page handlers:

int	func(struct http_request *);

However, unlike page handlers they MUST return one of the following:

- HTTP_STATE_OK:	All good, just continue the fsm.
- HTTP_STATE_ERROR:	Abort fsm and return KORE_RESULT_OK to Kore
			(This will cancel the http request).
- HTTP_STATE_RETRY:	Return KORE_RESULT_RETRY to Kore.
			(Kore will retry your page handler next event loop).
- HTTP_STATE_COMPLETE:	The fsm completed, break out cleanly.

Note that using this is completely optional and you can still
use the traditional way of writing page handlers.

The fsm is designed to get rid of the clutter that exists today
in Kore when dealing with non blocking tasks or pgsql calls.
2014-08-13 23:34:30 +02:00
Joris Vink 2e7d6a12a9 closedir() when we're ready traversing it 2014-08-13 14:32:57 +02:00
Joris Vink 29afdd0b21 Make sure opt always contains what we want 2014-08-13 14:32:49 +02:00
Joris Vink 0b907312ef let kore build generate certs with a more unique issuer
also fix spacing and asset print information.
2014-08-11 16:11:37 +02:00
Joris Vink d74f039a0c When building assets replace bad characters with an underscore 2014-08-11 13:08:26 +02:00
Joris Vink 97c17f724b Add kore_snprintf() as a wrapper around snprintf(). 2014-08-11 10:45:10 +02:00
Joris Vink 4a4fa4889e Another round of spdy/3.1 improvements.
* Implement flow control window updates if we're receiving data (POSTs)
2014-08-10 21:39:47 +02:00
Joris Vink c665b7d926 Add a callback to http_response_stream().
This way we can get our code called whenever a stream is
completed. This cb handler does stand alone from an http_request
and is passed a netbuf data structure.
2014-08-10 18:46:44 +02:00
Joris Vink 10284d59b6 Another round of spdy/3.1 improvements.
* Always make sure we end the stream properly
* Check for SPDY_FLOW_WINDOW_MAX on window frame updates
* Kill SPDY_STREAM_BLOCKING, once flow control kicks in its per session
2014-08-10 18:18:27 +02:00
Joris Vink 5cca2f1f78 properly implement spdy/3.1 flow control 2014-08-08 14:18:15 +02:00
Joris Vink d2c65b4f62 Change http_response_stream() to only take a base + len 2014-08-07 14:31:45 +02:00
Joris Vink cda09b6065 Add http_response_stream() which can stream data from a buffer to the client. 2014-08-07 14:23:26 +02:00
Joris Vink e3ae1b4e2d Implement some great SPDY improvements.
* Bump spdy announcement to the correct draft version
* When receiving a RST, clean out the netbuf chain of that stream
2014-08-07 10:22:54 +02:00
Joris Vink 966ed3d20d Rename the two functions used to read/set headers.
Rename http_request_header_get() to http_request_header().
Rename http_response_header_add() to http_response_header().
2014-08-05 14:26:31 +02:00
Joris Vink 0413de6a8f fatal if the return value from a page handler isn't what we want. 2014-08-05 14:17:23 +02:00
Joris Vink b27322933b The default pid file is kore.pid so no need to set that explicitely 2014-08-05 13:11:53 +02:00
Joris Vink 577462379d Deprecate ssl_no_compression config option, its always on. 2014-08-05 13:07:32 +02:00
Joris Vink b0700162c4 Make http_post_data_bytes() and http_post_data_text() available 2014-08-04 21:03:26 +02:00
Joris Vink 9b3ff7db53 Lowercase the HTTP headers sent in normal HTTP responses.
SPDY already had this, as required by the spec.
2014-08-04 20:12:31 +02:00
Joris Vink 4010bdd58d Remove kore_cb and its related settings.
After revisiting why this exists in Kore I decided it
does not belong in this platform and instead of letting
it sit there staring at me I rather just kill it.
2014-08-04 19:54:32 +02:00
Joris Vink 0b36877736 Change kore_buf_appendv() to use vasprintf(). 2014-08-04 18:59:59 +02:00
Joris Vink 7b9b1d5c2c sprinkle more const chars 2014-08-04 12:40:21 +02:00
Joris Vink 31eac77cd2 sprinkle const char where appropriate 2014-08-04 09:48:41 +02:00
Joris Vink d39246e0e2 static.h -> assets.h 2014-08-03 18:22:12 +02:00
Joris Vink 3bb77bbb9f Even if we skip files to be built, they still gotta be linked in 2014-08-03 18:18:48 +02:00
Joris Vink e906aab445 Be careful that f isn't uninitialized 2014-08-03 17:50:04 +02:00
Joris Vink f4f8b1e8b0 Allow users to set ldflags via KORE_LDFLAGS 2014-08-03 17:44:29 +02:00
Joris Vink 2b40672ba1 When compiling with PGSQL, note the include dir for "kore build" 2014-08-03 17:33:40 +02:00
Joris Vink 73b0569fe0 Missing fclose() 2014-08-03 17:17:11 +02:00
Joris Vink 8bcfb6cbb3 Be consistent with the help text 2014-08-03 17:11:02 +02:00
Joris Vink 93fd33e00e Big changes to how we handle "static" files.
* Rename static files to assets
* static_* has become asset_*
* Always generate asset.h with the right external symbols
2014-08-03 16:55:16 +02:00
Joris Vink 380b7dc1d7 Improvement on the cli commands a bit.
* kore build will now only rebuild what was changed (checking on
  last modified timestamp, not 100% accurate but it'll do).

* introduce kore clean which cleans out object files and the
  resulting .so file
2014-08-03 16:36:16 +02:00
Joris Vink e74921222c Check if conf/appl.conf exists before continuing with build or run 2014-08-03 15:30:53 +02:00
Joris Vink f538e92172 Correct typo 2014-08-03 15:22:08 +02:00
Joris Vink 0e2f478c75 Fix http_argument_get_*() integer functions. 2014-08-03 15:20:20 +02:00
Joris Vink a2897f790c Better sane defaults for kore build (gen certs + ssl_no_compression) 2014-08-03 15:17:03 +02:00
Joris Vink 5b8c880a62 Don't write the static output to a tmp buf, just write it to disk 2014-08-01 20:25:02 +02:00
Joris Vink 6495e84005 Show the uri to the running kore instance in foreground mode 2014-08-01 20:00:09 +02:00
Joris Vink 23164f636f Sprinkle KORE_BENCHMARK through cli.c 2014-08-01 17:17:34 +02:00
Joris Vink 38edc7d23b Add a warning about the generated certificates 2014-08-01 17:13:38 +02:00
Joris Vink 47ad4fbc28 Have "kore build" generate temp certs as well 2014-08-01 17:10:47 +02:00
Joris Vink 448f1a7912 Don't run cli_cleanup_files() in cli_fatal if theres no rootdir 2014-08-01 16:39:12 +02:00
Joris Vink 5fa964c5c0 gettimeofday() requires sys/time.h 2014-08-01 16:10:37 +02:00
Joris Vink 67c3bd84ba Make cli compile under freebsd 2014-08-01 16:01:33 +02:00
Joris Vink e29a5461ca Allow kore build to compile static files 2014-08-01 15:55:09 +02:00
Joris Vink 61f56b8da0 Bump copyright 2014-08-01 14:14:46 +02:00
Joris Vink 5d8c29af13 Allow kore build to take compiler via KORE_COMPILER 2014-08-01 14:09:57 +02:00
Joris Vink ea5b89d20b Move orbit functionality into kore directly.
Makes more sense and reads easier:

kore create myapp
kore build myapp
kore run myapp

Note that kore retains its cli options (if no command was given),
meaning you can still start kore in the traditional way as well.

The command options are simply to make development easier.
2014-08-01 13:59:47 +02:00
Joris Vink 818dd84acd No longer generate .objs as a default for orbit create. 2014-08-01 12:45:31 +02:00
Joris Vink e57a91a4e0 Create .objs when doing orbit build if it doesnt exist 2014-08-01 12:40:37 +02:00
Joris Vink 0c21c08b6d Hook orbit into the build 2014-08-01 10:46:50 +02:00
Joris Vink a2a87adf19 Euhm, revert last commit. 2014-08-01 10:33:26 +02:00
Joris Vink cee7d34020 Properly check for EWOULDBLOCK as well 2014-08-01 10:32:31 +02:00
Joris Vink c2e4d55235 Add a BENCHMARK compile option which compiles without OpenSSL.
Personally use this for testing Kore its performance without
letting the OpenSSL stack get in the way too much.

Note that it leaves data structures as is, and just removes
any calls to OpenSSL (and removes the linking vs OpenSSL).
2014-08-01 10:22:32 +02:00
Joris Vink 8ff870a352 Remove the ability to pass libs on the cli again.
Sorry, this no longer makes sense in terms of what
orbit is suppose to be doing.
2014-08-01 09:39:09 +02:00
Joris Vink d6f0b8f8fe Start kore from inside the rootdir when doing orbit run 2014-08-01 09:05:14 +02:00
Joris Vink 65a28e3db3 Allow orbit to build things under OSX 2014-07-31 23:19:18 +02:00
Joris Vink 7a038fce91 Add initial orbit code.
Orbit is a tool used to create/build/run kore code
in a more straight forward way.

Right now, orbit can do the following:

orbit create myapp
orbit build myapp
orbit run myapp

All in the motivation of making it easier to get
started with building Kore libraries and making
life easier on the people hacking Kore things.
2014-07-31 23:12:14 +02:00
Joris Vink b17eefde1f Allow developers to pass the lib to load on the cli.
When running in -f (foreground) you can now specify
the library Kore needs to load on the command line:

kore -fnc module.conf myapp.so

This has the benefit that your configuration file no
longer needs the load directive when hacking on your code.

Note that you can still specify load in your config file
regardless, if you so chose.

All of this is being done in order to try and move away
from the backwards way of getting up and running with Kore.
2014-07-31 17:15:51 +02:00
Joris Vink 105fb272a0 In foreground mode don't show kore_log() in fatal 2014-07-31 15:12:05 +02:00
Joris Vink 20e2447c90 When running Kore in foreground mode, log to stdout 2014-07-31 14:26:51 +02:00
Joris Vink ef49a0d4e1 Don't use pidfile if we're in foreground mode 2014-07-31 14:02:33 +02:00
Joris Vink a664e2a655 Make some configuration options fallback to defaults.
* If no runas_user is given, use current user.
* If no chroot path is given, don't complain if -n
* If no workers is set, use the default 1.
2014-07-31 13:59:42 +02:00
Joris Vink 9b76afc5fb Whoops, remove KORE_BENCHMARK that sneaked in 2014-07-31 13:35:39 +02:00
Joris Vink 8812d6989a Allow Kore to be started in foreground mode (-f)
Sending SIGINT or Ctrl-c will reap all workers and
exit again. Useful for development.
2014-07-31 13:27:04 +02:00
Joris Vink 22e1e1c425 Add worker_rlimit_nofiles as a configurable option. 2014-07-31 09:14:03 +02:00
Joris Vink 26d4d5d63b Rework the accept lock.
Kore no longer passes the accept lock to the "next in line"
worker but instead all workers will attempt to grab the lock
if they can.

Also remember if we had the lock previous iteration of the
event loop and don't constantly disable/enable the accepting sockets.

Makes Kore scale even better across multiple cpu's.
2014-07-30 15:20:09 +02:00
Joris Vink 83f890e89e No longer preallocate worker_max_connections for the http pools.
Instead use 10% of worker_max_connections up to a maximum of 1000.
2014-07-30 13:20:27 +02:00
Joris Vink cb3322cd9f Make accesslogs optional 2014-07-30 09:11:21 +02:00
Joris Vink a895250e97 Make sure l and c are initialized 2014-07-30 09:00:19 +02:00
Joris Vink fe0149ad24 Have workers always pass the accept lock after handling their events.
Provides a nice performance boost when scaling across multiple cpu's.
2014-07-29 13:14:34 +02:00
Joris Vink 478c008c99 Missing parts from last commit 2014-07-28 23:35:12 +02:00
Joris Vink 8313a31eba If we do not own the accept lock, reduce timeout for platform wait.
This way multiple workers won't stall when passing the accept lock
around for at maximum 100 ms (time spent in epoll/kqueue waits).
2014-07-28 23:27:58 +02:00
Joris Vink ea07ddef34 Properly send out early HTTP errors via the appropriate SPDY stream 2014-07-27 21:59:25 +02:00
Joris Vink c1bc0ce13f Check return value for pthread_mutex_init() 2014-07-27 21:47:18 +02:00
Joris Vink 257486d74a Remove req from http_requests before other things 2014-07-27 21:01:14 +02:00
Joris Vink 8c22f0f004 In http_request_free() remove the req from the owner connection. 2014-07-27 21:00:17 +02:00
Joris Vink c9f39c9c9d Set module->ocb to NULL 2014-07-22 10:47:12 +02:00
Joris Vink fbfabf6f04 Add missing stdint.h header 2014-07-22 09:53:44 +02:00
Joris Vink 341a111a2f Rework kore_strtonum64() so we can catch overflows for u_int64_t.
Seems that strtoull() if a negative string is supplied rather just
wraps the value, which I don't want here.
2014-07-21 01:51:51 +02:00
Joris Vink 25cf8dc659 Wrong comparison in kore_strtonum64(), fix. 2014-07-21 01:19:39 +02:00
Joris Vink d4cec3427e Properly convert 64bit parameters.
Introduces kore_strtonum64() for just this purpose as to
not taint kore_strtonum() too much.
2014-07-21 01:16:03 +02:00
Joris Vink ac345410dc Add support for fetching parameters as 64bit integers. 2014-07-20 00:43:32 +02:00
Joris Vink a5806d91f8 Pull in pg_config.h correctly, fixes compilation for pgsql under OpenBSD 2014-07-18 15:59:07 +02:00
Joris Vink 19d146a09e Introduce http_request_sleep() and http_request_wakeup().
These 2 functions can be used to move an HTTP request
from/to the active http_requests list. Effectively
putting them to "sleep" or "waking them up".

Sprinkle this through the pgsql and task code.

If used correctly greatly reduces overhead for
managing sleeping tasks.
2014-07-04 16:51:19 +02:00
Joris Vink 7b6c03ca5b Task improvements.
Synchronize access to state/result properly so one
can access these from inside the task as well.

Introduce KORE_TASK_STATE_ABORT which will be set
when a task needs to be abort. You can use this
to create tasks that run in a loop until aborted.
2014-07-04 11:28:17 +02:00
Joris Vink baac693f2f Change type for data to void * 2014-07-04 11:25:05 +02:00
Joris Vink 423d57b08d Add -v to dump out version and compiled in features 2014-07-04 09:25:18 +02:00
Joris Vink 1ad9f039ab Add pgsql_conn_max configuration parameter.
Allows you to tune how many pgsql connections kore
will make at one time.
2014-07-04 09:14:05 +02:00
Joris Vink 8b20dec081 Add missing pg_config.h header 2014-07-04 09:03:19 +02:00
Joris Vink 8e0ab8cc61 Check for pg version >= 90200 before using PGRES_SINGLE_TUPLE 2014-07-03 22:58:04 +02:00
Joris Vink 2c6b5e6b0f Normalize kore_*.h headers 2014-07-03 22:14:46 +02:00
Joris Vink 2bf43fe5f8 Unfuck boundary snprintf check, broke multipart forms 2014-07-03 20:10:55 +02:00
Joris Vink be4b1c7e7b Move actual code out of contrib into src/. 2014-07-02 12:19:38 +02:00
Joris Vink a54d04eb8a Add task glue for BSD as well 2014-06-30 14:43:34 +02:00
Joris Vink 723c99b65e Move kore_pgsql.h into includes/ directly.
Much like kore_tasks.h
2014-06-30 08:42:18 +02:00
Joris Vink dbd74c4551 Don't call module onloads until after everything is initialized.
This means the onload functions for a module are now called
after a worker has started and never from the parent ever again.
2014-06-29 21:15:23 +02:00
Joris Vink b9bd2e9a14 Move tasks away from http_requests.
Instead if a task is used from inside a request
you MUST call kore_task_bind_request() on it.

This way we can move forward for tasks that
don't belong to page handlers.

Also, some bug fixes for removing http_requests
that are indeed linked to a currently running task.
2014-06-29 20:20:13 +02:00
Joris Vink 146a0189ab More work on the background task implementation.
Tasks are now assigned to available threads instead
of a global task list.

You can now pass messages between your page handler
and the created task using the kore_task_channel_*
functions.

Only one task per time can be assigned to a request
but I feel this is probably a bad design choice.

Preferably we'd want to be able to start tasks
regardless of being in a page handler or not,
this not only ads flexibility but seems like
a better choice overall as it opens a lot more
possibilities about how tasks can be used.
2014-06-29 14:15:40 +02:00
Joris Vink cf700b34f7 Add initial stab at asynchronous background tasks.
More to follow.
2014-06-28 16:17:18 +02:00
Joris Vink 437f2e9ed2 Be paranoia when it comes to using client supplied integers 2014-05-06 12:24:21 +02:00
Joris Vink 0cb983adc0 Correct snprintf() usage 2014-04-23 16:29:58 +02:00
Joris Vink 27ec8a1d58 Don't let kore_strlcpy() overflow a buffer that is 1 byte long 2014-04-23 14:48:29 +02:00
Joris Vink f3fe543358 Add integer overflow checks to kore_calloc 2014-04-23 14:26:28 +02:00
Joris Vink fd7f547013 Fix accesslog under SPDY connections 2014-04-23 13:18:37 +02:00
Joris Vink 2cc6730cba Improve base64 decoding 2014-04-23 12:32:54 +02:00
Joris Vink 4f31d53e76 Allow KORE_RESULT_RETRY from authentication blocks 2014-04-22 23:07:24 +02:00
Joris Vink 332e8f4ba0 Do a better job at base64 decoding stuff 2014-04-22 21:45:26 +02:00
Joris Vink c14f3031ff Allow us to include config files with "include" 2014-04-22 13:15:19 +02:00
Joris Vink 2bdc9210a0 Wrap with KORE_PEDANTIC_MALLOC 2014-04-22 13:05:16 +02:00
Joris Vink d98d56fb20 Add KORE_PENDANTIC_MALLOC option.
This option tells Kore to zero out memory when allocated, freed or
when get/put from the pools.
2014-04-22 12:46:23 +02:00
Joris Vink 39dd9d7972 Change kore_buf_appendv() to take a va_list 2014-04-22 12:16:21 +02:00
Joris Vink d2618db525 Kill __packed__ attributes on some data structs 2014-04-18 17:41:56 +02:00
Joris Vink d6d6f96ca0 Kore pgsql improvements.
Don't wait for a full event loop until we call the page handler
for a received pgsql result. This speeds up page loads using
KORE_PGSQL by quite a lot, especially on a non busy server.
2014-04-17 10:49:48 +02:00
Joris Vink c206f3be89 Check if req is NULL before dereferencing it. 2014-04-16 22:15:22 +02:00
Joris Vink 52a0764812 HTTP Post improvements for handlers.
Don't crash if we get a Content-length:0 on POST and our
handlers call http_populate_arguments().
2014-04-15 21:18:23 +02:00
Joris Vink 1c685cce90 Comment on why/how we're disabling freelists.
OpenBSD was clever enough to throw these out so no need to
munge the freelist stuff there anymore.
2014-04-11 08:46:50 +02:00
Joris Vink 95819d2dc2 Take away SSL_MODE_RELEASE_BUFFERS for now.
Prevents the weird freelist munging that happens when we're
actually freeing memory (which we should be forcing it to do
by setting freelist_max_len to 0).
2014-04-10 22:52:23 +02:00
Joris Vink 41d1456cb8 Don't leak version on error 2014-04-09 14:45:51 +02:00
Joris Vink 76383f2353 Close fp after reading configuration 2014-04-09 14:43:23 +02:00
Joris Vink 250a1e1ad1 Fix use after free 2014-04-09 14:35:14 +02:00
Joris Vink 630d8ece05 Fuck it, force OpenSSL to not use its freelists no matter what. 2014-04-09 14:14:09 +02:00
Joris Vink 41aed45e4f Do not miscalculate end_headers. 2014-04-09 09:21:22 +02:00
Joris Vink 89b603c247 Support postgresl under the bsds 2014-04-02 00:06:24 +02:00
Joris Vink 61b6f823c5 Improvements to pgsql contrib code.
Including but not limited to:
- Correctly use PQerrorMessage() in case we cleanup with PQfinish
- If we get a network error, cleanup the connection
- No longer call the page handler from inside kore_pgsql_handle()
  but instead just put it to sleep in case we don't need it.
  This does grow the http_requests list quite a bit with sleeping
  connections and can perhaps be improved later on.
- Allow us to on error return OK from a page handler from inside
  the completetion block for KORE_PGSQL().
- Count the cummulative time for a request to finish instead
  of the latest run time for the handler.
2014-03-31 00:57:00 +02:00
Joris Vink 2f044cc7eb Initial stab at entering postgresql contrib code.
Has support for full async pgsql queries. Most of the logic
is hidden behind a KORE_PGSQL() macro allowing you to insert
these pgsql calls in your page handlers without blocking the
kore worker while the query is going off.

There is place for improvement here, and perhaps KORE_PGSQL won't
stay as I feel this might overcomplicate things instead of making
them simpler as I thought it would.
2014-03-30 23:54:35 +02:00
Joris Vink 8003bad094 Missing sys/stat.h, from James Turner 2014-03-07 09:55:28 +01:00
Joris Vink d40fd489f8 s/ptr/entry 2014-03-06 08:21:58 +01:00
Joris Vink 69f26823b9 Double check the element is free in kore_pool_get(). 2014-03-06 08:20:05 +01:00
Joris Vink 1375190936 Improvements for client certificates.
Double check we actually get a certificate if we are asking for one.
Even though we set SSL_VERIFY_FAIL_IF_NO_PEER_CERT it's a sane thing to do.

Start logging the CN for the received client certificate in the access logs.

As a bonus re-arrange some accesslog stuff for sanity.
2014-03-05 11:38:47 +01:00
Joris Vink 75c4bb0754 Error out when we get an unknown NPN result. 2014-03-05 11:07:21 +01:00
Joris Vink becfc8d586 Add request as an authentication_type.
request can be used for when you want to validate something for
authentication bmanually. Youur validator will receive the http_reques
passed down.

A practical use of this is doing IP based ACL's.
2014-03-01 19:18:30 +01:00
Joris Vink cb17c0d610 When returning a 405 append an Allow header as per rfc 2014-02-27 22:24:28 +01:00
Joris Vink 634bb482d6 Pass the http_request responsible for calling the validator. 2014-02-01 17:47:58 +01:00
Joris Vink 6e4b403662 Don't force the year in a HTTP-date to be the current year. 2014-01-29 22:59:58 +01:00
Joris Vink f0a9c1fe73 Major improvements to HTTP/1.1 behaviour, error reporting and handling.
This comes with changes to http_response() (no longer returns a result).
2014-01-29 22:48:51 +01:00
Joris Vink a80808d779 Add header as an option for authentication blocks 2014-01-22 23:11:52 +01:00
Joris Vink 9a8092bf41 Add authentication blocks for Kore.
Using authentication blocks one can define "authentication" mechanisms
in Kore for page handlers.

This can be used to require a session cookie (validated by your own validator)
for certain page handlers, and hopefully in the future provide a framework
for adding more authentication things (like HTTP Auth).

Right now only cookie checking is available.
2014-01-22 22:55:10 +01:00
Joris Vink 7e8371366f Make sure we properly close a SPDY stream if there's no data. 2014-01-14 22:22:26 +01:00
Joris Vink b64f674db2 Handle SPDY streams better when sending data. 2014-01-14 21:43:45 +01:00
Joris Vink 517de46790 Kore can now do query strings without lots of dynamic handler voodoo.
Any handler can receive query strings, however if you do not specify
parameters allowed in a param {} block Kore will discard them.
2014-01-13 20:21:20 +01:00
Joris Vink ef4289689f Only call module onload if its present 2014-01-11 01:35:44 +01:00
Joris Vink d22405cea7 Call the onload function whenever a module is loaded/reload.
Allows one to teardown whatever they setup properly when
the module gets a full reload. See example module for how it works.
2013-12-21 13:37:34 +01:00
Joris Vink 84d2c7fa0d ULONG_MAX -> LONG_MAX 2013-12-16 18:00:33 +01:00
Joris Vink 21b148e3a5 Allow Kore to load multiple modules at once. 2013-12-15 01:11:56 +01:00
Joris Vink f2aa206f3b Add support for client certificates 2013-12-14 16:31:07 +01:00
Joris Vink be48cd56e1 ULONG_MAX -> LLONG_MAX 2013-12-12 01:15:40 +01:00
Joris Vink c7dcdbcd82 Rework the way validation and param extraction works.
- Parameter validation is now done only when http_process_*()
  is called and upon http_argument_add().
- You MUST have defined your params in a param block or they will
  be filtered out.
- http_argument_lookup() is dead, welcome http_argument_get() and
  its brothers and sisters:
	http_argument_get_string()
	http_argument_get_uint16()
	http_argument_get_int16()
	http_argument_get_uint32()
	http_argument_get_int32()

  They will automatically do bounds checking on integers for you
  and return proper integers or a NUL-terminated string.

- The http_argument_get* functions no longer create an additional
  copy of the string which you need to free. Easier going.
- http_multiple_args() is dead, byebye
- Make some stuff we don't want to share with the modules static.
2013-12-12 00:58:32 +01:00
Joris Vink b4c54f9dc0 indent 2013-12-11 19:13:50 +01:00
Joris Vink 0f28b4a62d Enter versioning, starting at 1.0-current 2013-12-10 16:43:19 +01:00
Joris Vink fc243835c9 Update last_cb_run after we call cb here as well 2013-12-09 11:42:22 +01:00
Joris Vink 02351e1ab4 Update last_cb_run after we call the cb.
Makes sure we don't fall into cascading calls to the cb
if it takes longer to complete then the interval set.
2013-12-09 11:40:59 +01:00
Joris Vink 10aa4a28fe Multipart forms are now also validated via params 2013-12-05 20:28:07 +01:00
Joris Vink 79aea48757 Don't stop passing the accept lock even when workers are very busy.
If a worker reached worker_max_connections and it was its turn to
grab the accept lock it would've gotten stuck and no new connections
would be handled even if other workers would be less busy.

Instead, we now skip the lock if we're too busy and pass it along
in the hopes other workers are less busy.
2013-11-27 23:02:15 +01:00
Joris Vink 6f311a06cf Do not get stuck processing HTTP requests, found by Thorduri 2013-11-25 14:21:47 +01:00
Thordur Bjornsson 06abae3967 The access log need not be executable.
While there use the nice defines rather then straight up mode
numbers.
2013-11-19 17:27:14 +01:00
Joris Vink 269e5cb007 Strip out port from HTTP host request if its present. 2013-11-18 00:53:08 +01:00
Joris Vink afeb213260 Kore no longer requires root to be started. 2013-11-18 00:42:57 +01:00
Joris Vink 1e250c1473 Kore now supports GET parameters and automatic validation of GET/POST parameters.
Kore will automatically removes invalid parameters as a security measure.

See modules/examples/module.conf for an example of how this works.
2013-11-10 15:17:15 +01:00
Joris Vink 34c2f31a93 Add validators to kore, specified in the configuration using 'validator' keyword.
Example:
	validator	v_id	function	v_id_function
	validator	v_url	regex		^/url/path/[a-z]*$

You can then call these using kore_validator_run(char *, char *), example:

	if (!kore_validator_run("v_url", req->path))
		[req->path is bad];
2013-11-09 16:21:52 +01:00
Joris Vink c80e1d3767 If there's only a single worker, do not block after accept treshold has been
reached
2013-11-01 22:37:59 +01:00
Joris Vink 2aa4edb04e Kill unused vars 2013-10-26 00:59:03 +02:00
Joris Vink f17242262b Improve on sending data to the client.
- Attempt to chain as much as we can in the send netbufs
  (keeps down the SSL_write calls, silly seeing it go out with 8 bytes)
- Change NETBUF_SEND_PAYLOAD_MAX to 4K
- Call SSL_write() with max NETBUF_SEND_PAYLOAD_MAX in size
- Go back to flushing the send buffers after each request
- No more need for a fixed pool for nb->buf, go back to the heap for now
- Disable Nagle, we're doing the chaining now anyway
2013-10-26 00:48:09 +02:00
Joris Vink 4247d3139c Chain our sending netbufs together. Gives us a lot less SSL_write() calls. 2013-10-25 14:22:29 +02:00
Joris Vink 4922171d96 Change net_send_queue() in preparation for improving send performance.
No longer takes callbacks, flags, or *out arguments.

Update rest of the code that called these callbacks whenever sending
was completed, instead call them right away now.
2013-10-25 11:10:03 +02:00
Joris Vink ac025adaa7 Make kore_worker_acceptlock_release() available to loaded modules.
This allows us to move the accept lock manually to another Kore worker
in case we own it and are about to do some heavy lifting on the current
Kore worker.
2013-10-24 09:05:46 +02:00
Joris Vink e10486fa10 Change urldecode back to 0 2013-10-24 08:56:17 +02:00
Joris Vink c30ff58b93 control characters have nothing to do inside a URL. 2013-10-18 12:43:20 +02:00
Joris Vink 5d027b7a21 Decode all url encoded components properly. 2013-10-18 12:32:00 +02:00
Joris Vink ca05fb74d1 Properly calculate GMT time in kore_date_to_time() 2013-10-15 15:06:19 +02:00
Joris Vink 49df7a313b Make sure d cannot be used uninitialized. 2013-10-15 13:10:30 +02:00
Joris Vink c64d3e7854 Add http_keepalive_time configuration parameter.
Allows you to configure maximum amount of seconds an HTTP connection
can stay open (does not affect SPDY connections). If set to 0 it will
disable keep-alive all together.

Add some inttypes fluff.
2013-10-15 11:10:45 +02:00
Joris Vink 07079dc8c0 Do not kill a connection if nb->len is 0 when sending data. 2013-10-15 11:09:33 +02:00
Joris Vink 8b47863cd4 Add http_hsts_enable (enabled by default with max-age=31536000) to Kore's configuration file.
If enabled Kore adds the HSTS header to every response.

- Additionally, fix some typos in the example configuration.
- Change default SSL cipher list again, no more RC4 and almost PFS for all browsers.
2013-10-15 10:44:56 +02:00
Joris Vink 9426906225 Long overdue, let Kore pick its own shm key if the default KORE_SHM_KEY is already taken. 2013-10-14 11:26:11 +02:00
Joris Vink 1fb3c013ff Use kore_mem_find() in kore_buf_replace_string(), fixes certain crashes
that could occur when calling kore_buf_replace_string() with patterns
that would be found at the end or start of the buffer.
2013-09-26 16:49:44 +02:00
Joris Vink 3359be363f add limits.h so we can compile in 32-bit systems. 2013-09-24 09:15:31 +02:00
Joris Vink 0a49f29e10 Add support for ECDH and provide a better ssl_cipher set by default. 2013-09-24 08:58:05 +02:00
Joris Vink dde4f9f75a Be more verbose when configuration errors pop up. 2013-09-22 20:11:56 +02:00