Commit Graph

60 Commits (master)
 

Author SHA1 Message Date
OpenGnSys Support Team 87ece3976b handler: no need to parse trailer when processing request
No need to parse HTTP header trailer in TIP_CLIENT_PROCESSING_REQUEST.

src/handler.c:62:14: warning: variable ‘trailer’ set but not used [-Wunused-but-set-variable]
   62 |  const char *trailer, *x_redirect;
      |              ^~~~~~~

tip_client_state_recv_hdr() already validates header trailer is present.
2024-01-11 12:45:18 +01:00
OpenGnSys Support Team db1e0f1799 handler: syslog error if file does not exist
Report via syslog that file does not exist.
2024-01-11 12:38:14 +01:00
tiptorrent development team 98d358c9d8 allow to test 10/1 setups 2022-02-22 10:45:21 +01:00
Jose M. Guisado 93eb1de2a7 main: fix -r and -t options
Add -t option to optstring.

Check for optarg when using -r. Fixes max_redirect initializing to
the same value of max_clients when using short option -r.
2022-02-16 21:10:36 +01:00
Jose M. Guisado c80bd1c525 tidy up tests
Use TOTAL_CLIENTS to specify total number of clients to set up.

Replace copy and paste lines with for loops.
2022-02-11 09:58:38 +01:00
tiptorrent development team 6b7810d3f5 increase number of chunks to 64 2022-02-10 23:19:50 +01:00
tiptorrent development team fe463612ae limit server and client bandwidth in tests 2022-02-10 23:19:09 +01:00
tiptorrent development team 95a6724e1d allow -r/--redirect 0
Disable redirections in this case.
2022-02-10 15:39:37 +01:00
tiptorrent development team 8b6f56c76e display options in logging 2022-02-10 15:33:01 +01:00
tiptorrent development team b377975a13 fix -r/--redirect optional argument 2022-02-10 15:29:02 +01:00
tiptorrent development team 64d45f4237 use getopt_long option definition
instead of numeric value.
2022-02-10 15:27:20 +01:00
tiptorrent development team 2f834d6628 do not use redirection in case of direct download after pending state
honor the allow_redirection flag after activating client from pending state.
2022-02-08 15:52:55 +01:00
tiptorrent development team 6c910f2652 update tests to specify maximum number of redirections 2022-02-08 13:46:26 +01:00
tiptorrent development team f6f3984be7 allow to specify maximum number of redirections with -r
For example, -r/--redirect 3 specifies that the maximum number of redirections
per client is 3.

if -r/--redirect is specified with no argument, then the argument specified by
-n/--max-clients is used.

If -n/--max-clients is not specified and -r/--redirect is specifed with no
argument, then default value is 3.
2022-02-08 12:09:39 +01:00
tiptorrent development team 28d7a25a89 add -d/--daemon option 2022-01-19 11:45:04 +01:00
tiptorrent development team 298f9da0de revert workaround for file chunks
The client now uses fallocate() to store a single file.
2021-12-23 18:52:15 +01:00
tiptorrent development team b18630a920 do not create redirect if client unexpectedly closes connection
Close the socket without creating the redirection, this client did not
successfully downloaded the image file.

Moreover, check for connection closed by client in all of the possible read
states.
2021-12-22 12:28:45 +01:00
tiptorrent development team 7bf3eebb98 update maximum uri length to 255 chars
file with a large name might easily reach the existing 32 chars limit.
2021-10-05 19:35:32 +02:00
tiptorrent development team 138539485c tiptorrent is released under AGPL3+ 2021-09-29 15:52:14 +02:00
tiptorrent development team 669089d6b1 prioritize redirections over direct server download
testbed shows 95% use of redirections for data transfers.
2021-09-29 15:49:32 +02:00
tiptorrent development team 9c338ce302 use strrchr to take last dot that specifies the chunk number
file might have a extension starting by dot, use strrchr to get the
last dot that specifies the chunk number
2021-09-29 15:49:25 +02:00
tiptorrent development team a82dc99a86 use int32_t for chunk index
cli->chunk = -1 shortcircuits the runtime file split in chunk
2021-09-29 15:49:23 +02:00
tiptorrent development team 6010fe62fd download checksum file directly from server
Remove assumption on small file to shortcircuit the redirect logic.
2021-09-29 15:49:21 +02:00
tiptorrent development team 6a81079dc1 Revert "prioritize direct download for non existing redirections"
This reverts commit 4b97101f747e114253467ce4568cbced18f4c2d1.

This patch is broken, cli->path refers to the absolute file, not
the chunks, and it should check for this->state, not cli->state.
2021-09-29 15:49:19 +02:00
tiptorrent development team 8e939e3905 skip runtime chunk split if --redirect is not set 2021-09-29 15:49:17 +02:00
tiptorrent development team 2f120d9cd2 fix chunk size split logic
Add remainder bytes to the last chunk instead.
2021-09-29 15:49:15 +02:00
tiptorrent development team 97fc159ff1 add basic uri sanitization
disallow .. in uri.
2021-09-29 15:49:13 +02:00
tiptorrent development team 324fdcfd58 runtime split original file into chunks
No need to split the original file on the server side.
2021-09-29 15:49:11 +02:00
tiptorrent development team e39f7f8e3c systemd: add service template
To launch a tiptorrent service instance with /home/foobar as root:

	systemctl start tiptorrent@home-foobar

For systemd string escaping for unit names see systemd-escape(1).
2021-09-29 15:49:09 +02:00
tiptorrent development team cc5e4dca6a no need for root to run tiptorrent 2021-09-29 15:49:07 +02:00
tiptorrent development team 3e0254bf3c prioritize direct download for non existing redirections
allocate the direct download slot from server if there are no
redirections and no other client is currently downloading this file
already.
2021-09-29 15:49:05 +02:00
tiptorrent development team 88e02d424b activate pending clients only for close direct download
if a client is redirected, do not exercise the client activation loop.
2021-09-29 15:49:03 +02:00
tiptorrent development team 7b938edee2 do not stop activating clients when direct download starts
Do not break the loop after activating one client.

Keep activating clients that can be redirected. If no redirection is
found, then start direct download for this client (only one) but keep
looping for clients that can be redirected.
2021-09-29 15:49:01 +02:00
tiptorrent development team 44287f9e67 do not activate clients without redirection via POST
update 4573deb8cb3 to skip clients without redirection after
receiving POST notification.
2021-09-29 15:48:59 +02:00
tiptorrent development team 21e905a387 rise redirection timeout to 3600 seconds 2021-09-29 15:48:57 +02:00
tiptorrent development team 8fa2479f8f increase timeout for redirections
available redirections expire after 5 minutes.
2021-09-29 15:48:44 +02:00
tiptorrent development team 16cc92dab6 allow to report that a client allows redirection with POST method
If clients sends POST /test, it notifies the server that it is
available for receive redirections from file 'test'.

Test it with wget:

  wget --post-data '' http://localhost:9999/TEST -O /dev/null
2021-09-29 15:48:43 +02:00
tiptorrent development team dab82c806f do not shadow global redirect variable 2021-09-29 15:48:40 +02:00
tiptorrent development team e46be236c7 fix bogus error if clients closes connection unexpectly
Reports a bogus:

unknown read state 5, critical internal error for 127.0.0.1:60610
2021-09-29 15:48:38 +02:00
tiptorrent development team 353c5d3660 remove duplicate log when resuming from pending and being redirected 2021-09-29 15:48:36 +02:00
tiptorrent development team 610a1e48e4 another log rewrite 2021-09-29 15:48:32 +02:00
tiptorrent development team 6d1828c375 extend tests
a bit of copy and paste, generalize it later.
2021-09-29 15:48:30 +02:00
tiptorrent development team 94c45d5d36 improve logging
Report "client %s:%hu starts download for %s" when the file transfer
really starts.

Replace log when redirection after pending state is not available
2021-09-29 15:48:28 +02:00
tiptorrent development team a23722910e specify current state when displaying unknown error 2021-09-29 15:48:26 +02:00
tiptorrent development team 5a7d9644e4 allow to reuse redirections
A redirection can be reused up to max_clients times.
2021-09-29 15:48:24 +02:00
tiptorrent development team 0be142b8c9 disarm timer on release
This is a repeat timer, if not stopped, it will run again triggering UAF.
2021-09-29 15:48:22 +02:00
tiptorrent development team 1e0b3880f9 fix client timeout
as described by man(3) ev, to make it work with ev_timer_again().
2021-09-29 15:48:20 +02:00
tiptorrent development team 21aa4a9315 check sendfile error 2021-09-29 15:48:18 +02:00
tiptorrent development team 7a04638c32 update num_clients and redirection only for large files
Skip num_clients and redirection update for small files.
2021-09-29 15:48:16 +02:00
tiptorrent development team cbcc71db72 add support for HEAD method 2021-09-29 15:48:14 +02:00