Solderpunk
308b8fe128
Make timeouts configurable.
2025-02-08 19:05:48 +01:00
Alex Kotov
2068c3b02a
Allow to disable directory listing
...
Signed-off-by: Solderpunk <solderpunk@posteo.net>
2023-08-20 14:30:51 +02:00
Solderpunk
64a4ff72f0
Remove debugging Println.
2023-04-09 15:24:34 +02:00
Solderpunk
1b7d661abd
Type trashing to fix last commit.
2023-04-09 14:24:39 +02:00
Solderpunk
051df29604
Add a write deadline with maximum allowed download time derived from filesize. See #35 .
2023-04-09 14:12:38 +02:00
Solderpunk
6f0865447d
Adds leaky token bucket rate limiting with bans for non-compliant clients.
2023-04-09 13:57:59 +02:00
Solderpunk
4b54eb6134
Set 30 second deadline for reading requests. See #35 .
2023-03-19 11:51:44 +01:00
Solderpunk
4b9a7e8ad5
Correctly implement bans for clients exceeding hard limit.
2023-03-19 10:30:08 +01:00
Solderpunk
efde852c54
Refactor rate limiting to have soft and hard limits, block clients exceeding hard limits for one hour.
2023-03-18 16:40:23 +01:00
Solderpunk
3c5835f033
Continue to increment drips once bucket is overflowing.
2023-03-18 15:45:35 +01:00
Solderpunk
a6170a355d
Make rate limiting configurable.
2023-03-17 19:52:39 +01:00
Solderpunk
5016f40edb
Initial implementation of leaky bucket rate limiting.
2023-03-16 20:27:45 +01:00
Solderpunk
c4866d2965
Check for a CGI path prefix before insisting that an exact path exists on disk. Closes #36 .
2023-03-16 19:23:32 +01:00
Solderpunk
e30f39b196
Fix typo in error message.
2023-03-02 19:43:24 +01:00
Solderpunk
d3d415b612
Add missing return.
2023-02-26 19:42:49 +01:00
Solderpunk
f9585ff2b7
Rearrange the logic of handling requests without changing behaviour.
...
The new order handles certificate zones and redirects defined in the
system-wide config file as well as SCGI paths as early as possible
without doing any unecessary filesystem operations and especially
without the potentially expensive search for .molly files.
2023-02-25 12:06:34 +01:00
Solderpunk
eb85a6e94c
Another big refactor, splitting the Config struct in two.
...
The split reflects that between variables which can and cannot be
overridden by .molly files, and this greatly simplifies the
processing of said files, getting rid of the need for lots of
ugly temporary variable thrashing.
2023-02-25 11:29:13 +01:00
Solderpunk
40203a8856
Use net/http.DetectContentType as a last resort for MIME, rather than hardcoding application/octet-stream.
2023-02-21 19:22:19 +01:00
Solderpunk
7a89b307a1
Just use the log package's default logger as the error log.
2023-02-19 15:04:34 +01:00
Solderpunk
8372142843
Add support for chroot()ing server early after startup, more work toward issue #16 .
2023-02-15 21:10:22 +01:00
Solderpunk
06c6d190a6
Guard against symbolic links escaping the document base.
2023-02-13 22:15:42 +01:00
Solderpunk
5258b29c6b
Big ol' gofmt.
2023-02-10 17:19:21 +01:00
Solderpunk
17d17a1629
Catch SIGTERM and shutdown gracefully.
2023-02-08 19:56:27 +01:00
Solderpunk
733e518392
Accept requests where the URL has a FQDN hostname with a trailing dot. Closes #20 .
2023-01-29 12:29:01 +01:00
Solderpunk
a41898b012
Add DefaultEncoding option to config/.molly files. Closes #19 .
2023-01-29 12:07:52 +01:00
Solderpunk
f05bab2b73
Make test of request URL hostname against configured hostname case insensitive. Closes #29 .
2023-01-28 19:22:31 +01:00
Solderpunk
16ed9e5cff
Allow redirects to other hosts. Closes #26 .
2023-01-28 19:16:11 +01:00
Solderpunk
e06f8bddbc
Fix infinite redirect bug.
...
Previously, URLs without trailing slashes in the path which
resolved to directories caused infinite redirects if there was
anything in the URL after the path (like a query).
Thanks to both Luke Emmet and Stephane Bortzmeyer for reporting
this!
2021-01-24 16:27:53 +01:00
makeworld
c6c6e544d6
Use io.Copy over ioutil.ReadFile
2020-12-09 17:59:00 -05:00
Solderpunk
48aed1398d
Log remote IP address when reading a request fails.
2020-07-03 11:16:07 +02:00
Solderpunk
37e177fbe0
Move .molly file parsing function into config.go.
2020-07-01 23:05:49 +02:00
Solderpunk
3cd4a072fd
More and better error logging.
2020-07-01 22:58:07 +02:00
Solderpunk
f7e588dfae
More and better error logging.
2020-07-01 20:15:52 +02:00
Solderpunk
821a862036
Use standard library logging facilities for error log.
2020-07-01 19:57:39 +02:00
Solderpunk
2a263e5e70
Rewrite SCGI support to use prefixes, not regexps, and provide the same SCRIPT_PATH / PATH_INFO break as CGI.
2020-07-01 16:40:51 +02:00
Solderpunk
d87ecfd20f
gofmt.
2020-07-01 16:19:38 +02:00
Solderpunk
f4f14320df
Expand CGI path globs once on startup, not for each request.
2020-07-01 16:18:49 +02:00
Solderpunk
35bf4d16c3
Handle all requests which don't involve the filesystem before all which do.
2020-07-01 16:05:39 +02:00
Solderpunk
9bce54882a
Consolidate some quick-failing path tests.
2020-07-01 16:05:09 +02:00
Solderpunk
f291e5863c
Enforce certificate zones before anything else.
2020-07-01 14:16:27 +02:00
Solderpunk
4ae154faed
Convert CGIPath handling from regexs to prefixes.
2020-07-01 14:10:20 +02:00
Solderpunk
cc5410494e
Handle redirects using regular expressions, not just literal paths.
2020-07-01 11:13:38 +02:00
Solderpunk
b30fc0923b
Handle CGI requests with URI components after the script.
2020-07-01 10:38:31 +02:00
Solderpunk
68398ef0be
Extensive refactor, trying to keep the main request handling function relatively simple.
2020-06-30 22:25:37 +02:00
Solderpunk
fd31094cb6
Allow .molly files to set certificate zones.
2020-06-30 20:39:26 +02:00
Solderpunk
1794ff643b
Allow .molly files to configure redirects.
2020-06-30 20:19:13 +02:00
Solderpunk
d7663ab688
Removing debugging print.
2020-06-30 19:34:01 +02:00
Solderpunk
e43fc7877c
Big rearrange: resolve URL to filesystem earlier, so we can check for .molly files ASAP, so that they can handle redirects, certificate zones, etc.
2020-06-30 19:31:27 +02:00
Solderpunk
990b7071d0
gofmt fixes.
2020-06-30 19:13:02 +02:00
Solderpunk
44af303de6
Fix silly mistake in hasty port checking fix.
2020-06-30 19:11:49 +02:00