tinyblocks-socket, -ssl, -http e -archive: internet e arquivos compactados em blocos
socket: conexao TCP como TbStream (fluxo com classe read/write/close) e blocos para conectar, enviar, receber e resolver endereco. ssl: embrulha um TbStream TCP em TLS (OpenSSL), com SNI e certificado conferido pelo sistema e pelo nome do host. http: cliente HTTP/1.1 so sobre TbStream; https:// quando a ssl esta carregada; Content-Length, chunked e redirecionamentos; GET e POST de texto e download em segundo plano (.parte ate terminar) com progresso. archive: lista e extrai .tar e .tar.gz (zlib), nomes longos GNU/pax; recusa entradas com "../" ou caminho absoluto. As camadas se acham pelas tabelas no lib_userdata, sem linkar umas com as outras. test-http usa um servidor local (e a internet, se houver); test-archive cria os arquivos com tar e Python. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
05fdb094ed
commit
066bb295ed
20 files changed
+1689
-3
No files matched your search
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* TinyBlocks - tb_ssl.h
|
||||
* Library tinyblocks-ssl: TLS (dependencia de terceiros: OpenSSL). Registra
|
||||
* a categoria "SSL".
|
||||
*
|
||||
* Embrulha um TbStream TCP (tinyblocks-socket) num TbStream TLS: ler e
|
||||
* escrever passam a ser cifrados, e quem usa o fluxo (ex.: a
|
||||
* tinyblocks-http, para o https://) nao muda nada. O certificado do
|
||||
* servidor e conferido com os certificados do sistema e com o nome do host
|
||||
* (SNI + verificacao do nome).
|
||||
*
|
||||
* Tabela TbSslApi no lib_userdata da library (tb_ssl_api(rt)).
|
||||
*/
|
||||
#ifndef TINYBLOCKS_SSL_H
|
||||
#define TINYBLOCKS_SSL_H
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <tinyblocks/tinyblocks.h>
|
||||
#include "tb_socket.h"
|
||||
|
||||
#define TB_SSL_LIB "tinyblocks-ssl"
|
||||
#define TB_SSL_API_VERSION 1
|
||||
|
||||
typedef struct TbSslApi {
|
||||
int version; /* TB_SSL_API_VERSION */
|
||||
/* Faz o aperto de mao TLS sobre tcp (fica dono dele: fecha junto).
|
||||
NULL em erro (tcp ja fechado; mensagem em err). */
|
||||
TbStream* (*wrap)(TbStream* tcp, const char* host, char* err, size_t cap);
|
||||
const char* (*version_text)(void); /* "OpenSSL 3.0.13 ..." */
|
||||
} TbSslApi;
|
||||
|
||||
TB_API const TinyBlocks_LibraryDescriptor* tb_ssl_get_library(void);
|
||||
|
||||
static inline const TbSslApi* tb_ssl_api(TinyBlocks* rt) {
|
||||
TinyBlocks_LibraryBlock* lib = tb_rt_find_library(rt, TB_SSL_LIB);
|
||||
const TbSslApi* api = lib ? (const TbSslApi*)lib->lib_userdata : NULL;
|
||||
return api && api->version == TB_SSL_API_VERSION ? api : NULL;
|
||||
}
|
||||
|
||||
#endif /* TINYBLOCKS_SSL_H */
|
||||
Reference in new issue
Block a user