Commit Graph

20 Commits

Author SHA1 Message Date
Érico Nogueira cd14bff782 Add support for pastebin.stratumzero.date.
- use -s flag to enable it
- required support for Content-Type: multipart/form-data
2021-12-09 03:19:22 -03:00
Érico Rolim 4b3f41d0f9 Extend localization support.
Localize purr.c so both main executables are localized, plus some
library code. Refactor some message printing so localization is easier.
2020-11-11 01:36:40 -03:00
Érico Rolim 86f7a1575d Implement ALPN properly.
There was a misconception about how the ALPN API worked. It was actually
necessary to force a handshake so ALPN could be negotiated and
br_ssl_engine_get_selected_protocol() could possibly return any
information.

send_and_receive() now has a small diagnostics output for ALPN
and purr itself now forces the handshake before assembling the HTTP
requests, so it can use the ALPN results for that. The requests were
also reworked a bit.
2020-10-19 03:52:33 -03:00
Érico Rolim b85aaae164 Fix memory leak with redirect_link.
It should be duplicated by who's going to use it, otherwise the
duplicated string will simply leak. Add function to free it, because why
not.

This also fixes a compiler warning about losing the const qualifier.
2020-10-15 22:29:48 -03:00
Érico Rolim 90c99403f5 Replace write() loops with fwrite() calls.
This was enabled by duplicating the socket fd and creating a write
stream for it using fdopen(). Pushing the write() error checking to libc
is much better than avoiding the additional allocation.
2020-10-01 16:25:43 -03:00
Érico Rolim 27d1e68ae8 Add gemini error code parsing, deal with redirects
Redirects are implemented as a callback_header function pointer, so each
application using "PURRLIB" can have its own callbacks. However, when
and how the callbacks are called is defined by ssl_to_mmap, according to
the protocol.
2020-09-25 02:03:33 -03:00
Érico Rolim 01eaa937fe Split scheme detection logic, use where possible.
Avoid parsing URLs in multiple places.
2020-09-24 05:05:34 -03:00
Érico Rolim a39d94dd32 Add very simple gemini client.
Probably won't continue work on this, since I discovered.
https://github.com/MasterQ32/gurl . It also can't use TOFU, depends on
proper certificate chain.

Also fixed up makefile.

The changes here at least make it possible to support protocols other
than HTTP in the receiving functions.
2020-09-18 19:52:42 -03:00
Érico Rolim 18c10894ce Add ALPN to SSL communication.
Haven't managed to get a successful result with it, unfortunately.
2020-09-18 17:02:29 -03:00
Érico Rolim db88355cd2 Add proper scheme parsing.
- Allows showing the scheme correctly.
- Deals with hash properties in links correctly: doesn't send them to
  server.
2020-09-17 15:04:35 -03:00
Érico Rolim 06eb9d4222 Split mmap_file implementation.
Also add some useful definitions.
2020-09-14 00:32:16 -03:00
Érico Rolim f13c0c2e3e Add decryption for recv.
A few fixes and hacks all around, but can now do:

  ./purr -e recv (./purr -e send makefile)

And output the original page.
2020-09-13 20:17:58 -03:00
Érico Rolim e20d8ae124 Add get_encryption_params.
This function is used to split the links to encrypted content into
useful parts.
2020-09-13 20:17:03 -03:00
Érico Rolim b70d741b03 Enable IV randomization. 2020-09-13 18:08:52 -03:00
Érico Rolim 94f8f4f61d Enable encrypted pastes properly.
Add base64 encoding per the pattern expected by the web interface.

Fix some pointers and file size things in purr/files.

TODO: files are cut off at random points, despite the efforts to remove
verification of null characters in libbaseencode.
2020-09-13 18:05:43 -03:00
Érico Rolim baa013afae Move to mmap implementation.
Using FILE* is error prone and limited.
2020-09-13 13:32:28 -03:00
Érico Rolim 32f9910ece Fix encryption function.
Fix pointer parameters as function returns.
Add file clean-up as an atexit functionality.
2020-09-13 01:06:39 -03:00
Érico Rolim 5b7ec3ead5 Implement print_hex to print byte buffers.
Also add tests for it.
2020-09-12 23:30:13 -03:00
Érico Rolim dd30aa72a8 Split encrypt.c and fix use-after-free.
UAF from genalloc and stralloc frees.

Also remove randomization of IV, not used in bsd.ac.
2020-09-12 23:28:49 -03:00
Érico Rolim f3069bb932 Split functionality into different files. 2020-09-10 23:33:52 -03:00