Commit Graph

197 Commits

Author SHA1 Message Date
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
Joris Vink 88c3a3eb98 Add http_header_max and http_postbody_max configuration variables.
- http_header_max:
	Maximum size of HTTP headers (in non SPDY connections).

- http_postbody_max:
	Maximum size of an HTTP POST body (both in SPDY and HTTP mode).

Right now Kore will simply DC the client, ideally we want to send
a 413 (entity too large) to the client however.

See modules/examples/module.conf for more.
2013-09-22 20:05:24 +02:00
Joris Vink cffe4afb91 properly count amount of arguments parsed 2013-09-10 14:05:02 +02:00
Joris Vink 25e8f93331 Add support for multipart forms.
New API functions (docs need to be updated):
	- http_file_lookup()
	- http_file_add()
	- http_argument_add()
	- kore_strip_chars()
	- kore_mem_find()

- Add an example under the example module on how files can be read.
2013-09-10 11:02:59 +02:00
Joris Vink 8566c32da8 Properly send WINDOW_UPDATE messages to the client when our window is full.
Fixes uploads > 64kb when using SPDY
2013-09-09 11:24:15 +02:00
Joris Vink c9d4f70298 - Add SPDY RST control frame handler.
- Keep HTTP requests in connection, so we can delete them if the connection
  ends before the requests do (this way we don't leak them).
- When spdy_stream_close() is called, delete the attached http request.
  (This shouldn't hurt to do, so hopefully won't cause major fallout).
- When parsing HTTP, find the first occurence of end-of-headers so uploads
  with multipart/form-data can succeed properly.
- Add a test upload page to the example module.
2013-09-09 10:59:56 +02:00
Joris Vink ee3fd3c039 Allow the user defined callback to run on workers as well. 2013-09-03 08:41:09 +02:00
Joris Vink 95c8b8e126 Add a callback that Kore can call in your module every given interval.
The callback is run from the parent process (which runs as root).

Adds kore_cb and kore_cb_interval configuration options.
2013-09-02 08:52:16 +02:00
Joris Vink 9fa9fd7402 remove useless casts 2013-08-26 08:52:56 +02:00
Joris Vink acc34e2d51 Change kore_buf_append() and kore_buf_replace_string() to take a void pointer. 2013-08-22 10:06:39 +02:00
Joris Vink a8052c7ac4 Add reason phrases and http status constants (HTTP_STATUS_* see includes/http.h)
Based on work from mendor/ymv via github.
2013-08-19 09:11:31 +02:00
Joris Vink ef9d37e54b free hdlr_extra if its set 2013-08-14 16:09:09 +02:00
Joris Vink ecefdb18ab cb_extra -> hdlr_extra and add one to struct connection as well for persistent data across requests. 2013-08-14 15:56:44 +02:00
Joris Vink 34f6d088fa set cb_extra to NULL when req is allocated 2013-08-14 15:15:18 +02:00
Joris Vink bbb245654d Pass the base for strtoll() to kore_strtonum(), breakage ensues if we depend on the "auto" detection that happens when we pass 0 to strtoll() as base. 2013-08-13 16:13:43 +02:00
Joris Vink 3075162855 Add http_argument_urldecode() which takes a string and decodes any url encoding done to it.
Change kore_strtonum() to pass 0 to strtoll by default so we can use it to convert hex numbers (prepended with 0x) as well.
2013-08-13 14:18:47 +02:00
Joris Vink ff613f4665 Use SSL_OP_CIPHER_SERVER_PREFERENCE by default. 2013-08-07 20:42:19 +02:00