Commit Graph

858 Commits

Author SHA1 Message Date
Joris Vink e665cc900d redirect to /uri/ if need be. 2018-07-09 06:28:28 +02:00
Joris Vink 04f4306cf2 simplify logic 2018-07-08 15:58:56 +00:00
Joris Vink 04deeeafb9 make sure we can still resolve new paths 2018-07-08 15:57:00 +00:00
Joris Vink 5eb2160269 resolve filemap paths after workers chrooted.
otherwise the paths inside chrooted workers are incorrect.
2018-07-08 17:51:35 +02:00
Joris Vink 10cf14f756 use realpath() to resolve ondisk paths. 2018-07-08 17:40:16 +02:00
Joris Vink 3ddcaf4661 typo 2018-07-07 13:34:58 +02:00
Joris Vink 71659ab197 correct includes 2018-07-07 13:23:43 +02:00
Joris Vink f02f88295c revert b5e122 for now. 2018-07-06 11:21:46 +02:00
Joris Vink 4f16a5d272 make net_read() and net_write() more sane. 2018-07-05 12:36:47 +00:00
Joris Vink 47c1a1d195 set referer to NULL in http_request_new(). 2018-07-05 05:02:49 +00:00
Joris Vink 3e4b9f4fe8 let filemaps be matched to the domains. 2018-07-04 14:26:38 +02:00
Joris Vink 04077c66b6 Add filemap_ext configuration option.
Allows you to specify the default extensions used for a file served
via a filemap, eg:
	filemap_ext	.html

Gives us ability to provide clean urls.
2018-07-03 19:58:43 +02:00
Joris Vink b5e122419b Let http_populate_post() listen to content-type 2018-07-03 08:25:06 +02:00
Joris Vink 4a8d8ab7f8 log referer in accesslog if present. 2018-06-29 22:37:48 +02:00
Joris Vink 72073701b0 Add last-modified and if-modified-since for filemaps. 2018-06-29 09:56:04 +02:00
Joris Vink cca269ff5d make sure we use fd_off in linux sendfile properly 2018-06-29 03:10:28 +00:00
Joris Vink 3e5939a8e3 make sure fileref is dropped if softremoved 2018-06-29 05:03:50 +02:00
Joris Vink 09b362ced4 remove norwegian debugging 2018-06-28 23:02:46 +02:00
Joris Vink 202234cf97 filemap and fileref improvements.
- make sure we can serve updated files even if we have an old
  fileref around.

- add filemap_index as a configuration option: allows one to specify
  what file to serve if a directory was requested (eg: index.html)
2018-06-28 23:00:42 +02:00
Joris Vink 521ff6a11d catch more bad ranges in http_argument_urldecode() 2018-06-28 15:39:03 +02:00
Joris Vink 2139527df7 run path via http_argument_urldecode(). 2018-06-28 15:28:25 +02:00
Joris Vink 70e945afb7 limit http_argument_urldecode() to sane characters 2018-06-28 15:27:55 +02:00
Joris Vink c2f66af937 better error log message 2018-06-28 14:53:43 +02:00
Joris Vink 3faf89d83d use server time. 2018-06-28 14:52:49 +02:00
Joris Vink afd76ff55d Change accesslog format to Combined Log Format. 2018-06-28 14:25:32 +02:00
Joris Vink f2c87fd130 limit filemaps to HEAD/GET requests. 2018-06-28 14:24:02 +02:00
Joris Vink d876e41ebb shuffle headers around 2018-06-28 13:45:04 +02:00
Joris Vink 80f5425698 Add filemaps.
A filemap is a way of telling Kore to serve files from a directory
much like a traditional webserver can do.

Kore filemaps only handles files. Kore does not generate directory
indexes or deal with non-regular files.

The way files are sent to a client differs a bit per platform and
build options:

default:
  - mmap() backed file transfer due to TLS.

NOTLS=1
  - sendfile() under FreeBSD, macOS and Linux.
  - mmap() backed file for OpenBSD.

The opened file descriptors/mmap'd regions are cached and reused when
appropriate. If a file is no longer in use it will be closed and evicted
from the cache after 30 seconds.

New API's are available allowing developers to use these facilities via:
  void net_send_fileref(struct connection *, struct kore_fileref *);
  void http_response_fileref(struct http_request *, struct kore_fileref *);

Kore will attempt to match media types based on file extensions. A few
default types are built-in. Others can be added via the new "http_media_type"
configuration directive.
2018-06-28 13:27:44 +02:00
Joris Vink 9be72aff57 bump size of http_version array. 2018-06-23 17:23:45 +02:00
Joris Vink 8aaf7aaf79 Alter where the version number comes from.
Now if we are a git repo we fetch the branch name and
commitid to build the version string. If there is no
git repo we'll look at the RELEASE file.
2018-06-22 14:24:42 +02:00
Joris Vink d5ca2b42c6 invoke platform specific compiler for kodev build. 2018-06-19 22:46:55 +02:00
Joris Vink 296b1693ac don't forward argc/argv for kodev create.
Means we don't have to do weird shit that doesn't work on !macos anyway.
2018-06-15 20:51:48 +02:00
Joris Vink e475bd0c92 Add configurable x509 chain validation depth.
You can now per domain configure the depth for x509 chain validation:
	client_verify_depth	1

By default this is 1.

While here change around some log messages and properly set
the callback for x509 verification rather then via hoops and loops.
2018-06-09 12:50:50 +02:00
Joris Vink 9e12b2c6dd Use sigaction() for signals.
Don't duplicate signal setup code between parent and worker processes.
2018-05-25 20:49:02 +02:00
Joris Vink 439a3b36f0 Add kore_strtodouble().
Use it for http_argument_get_float() and http_argument_get_double().
2018-05-04 15:55:35 +02:00
Joris Vink 68f5e33768 kodev improvements.
Allow KORE_SOURCE and KORE_FLAVOR to come from the environment,
overriding any configured kore_source or kore_flavor configuration
setting from the build.conf for the application.

I wanted an easier way of switching between Kore trees while hacking
on some of my apps, this is it.
2018-05-03 21:27:52 +02:00
Joris Vink 3a283cd05c let KORE_MSG_WORKER_ALL include sender. 2018-04-24 20:11:48 +02:00
Joris Vink 5487950f63 cut off port from the domain when needed. 2018-04-24 20:11:41 +02:00
Joris Vink 98af796acd Improve kodev a tiny bit.
kodev is creating x509s and writing out the dh parameters if they
do not exist in the application each time. This is annoying if
you explictly specified NOTLS=1 in the kore_flavor build options.

So just tell kodev to not do this if NOTLS=1 is present.
2018-04-18 19:51:25 +00:00
Joris Vink 658bb2936e minor style 2018-04-13 16:05:59 +02:00
Joris Vink 92bd546935 Remove unused argument. 2018-04-13 16:04:33 +02:00
Joris Vink bfd4851c85 minor style fixes 2018-04-13 07:41:22 +02:00
Sebastiaan a3cab0d97b Websocket memory leak fix when using kore_websocket_send() to send data. (#238) 2018-04-13 07:40:37 +02:00
Joris Vink f7678946a1 don't set our own exception on invalid parameters. 2018-04-11 13:32:56 +02:00
Joris Vink d73a9114c0 Improve http_response() for server side errors.
In case http_response() is called with an error code indicating
a server side error (>= 500) do not append any headers set by the
caller.
2018-04-11 13:04:26 +02:00
Joris Vink 4ab028633a If a python handler failed, don't fatal on purpose.
Instead log and send an internal error status back to the client.

This should be OK as long as the exception doesn't happen after
the caller called req.response() already.
2018-04-11 13:00:30 +02:00
Joris Vink bb210db3df let pyko skeletons setup 'appdb' if available.
If a worker can pickup PYKO_CONNINFO from the environment it will register a
new pgsql connection called 'appdb' tied to the given connection string.
2018-04-10 18:26:22 +02:00
Joris Vink a35dfc6d06 Teach kodev create about pyko applications.
Now you can create a pyko application skeleton using kodev:

	$ kodev create -p myapp

Not sure if this functionality will remain in kodev, but for now i'm undecided.
2018-04-10 16:20:50 +02:00
Joris Vink 85cff54a5f don't let kore_parse_config_file() call fclose.
It doesn't own the FILE pointer, it shouldn't call fclose() on it,
thats just confusing.
2018-04-10 14:39:57 +02:00
Joris Vink 43a0aef29f prefix HTTP defines when exporting them to python. 2018-04-10 14:35:52 +02:00