Commit Graph

42 Commits (138539485cc0b679cea7b54712ecf9ab5ad9a028)
 

Author SHA1 Message Date
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
tiptorrent development team d6dbb6c979 add a close wait state
Wait for clients to close the connection, then:

- create redirection.
- activate pending clients.

Do no refresh timeout while in close wait state.
2021-09-29 15:48:11 +02:00
tiptorrent development team b7b410ddc2 extend log on unknown internal state
Specify what client has trigger the unknown internal state
2021-09-29 15:48:09 +02:00
tiptorrent development team d0c8b24985 do not display an error when recv() == 0
This is the client closing the connection with us.
2021-09-29 15:48:07 +02:00
tiptorrent development team 9cf3edf10f call shutdown() before close() 2021-09-29 15:48:05 +02:00
tiptorrent development team b07785d2d1 activate pending clients only for large files
small files should not activate pending clients, otherwise max_clients
is not fulfilled.
2021-09-29 15:48:03 +02:00
tiptorrent development team 1b890bd11b use off_t instead of size_t for file size
stat() st_size datatype is off_t which is for file size, use off_t
instead of size_t for correctness.
2021-09-29 15:48:00 +02:00
tiptorrent development team a3ea145290 Add ULL postfix to FILE_SIZE_THRESHOLD to avoid using int
Otherwise, cli->size > FILE_SIZE_THRESHOLD uses 32-bit integer which
overflows with very large files. Use ULL to enforce 64-bits.
2021-09-29 15:47:58 +02:00
tiptorrent development team 9523d7d8fd add more logging for easier debugging 2021-09-29 15:47:55 +02:00
tiptorrent development team e72dc5e1cb fix typo in tests/network-setup.sh 2021-09-29 15:47:53 +02:00
tiptorrent development team 2610239d62 initial commit 2021-09-29 15:47:43 +02:00