mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-04-26 00:34:43 +00:00
Your redbean can now interoperate with clients that require TLS crypto. This is accomplished using a protocol polyglot that lets us distinguish between HTTP and HTTPS regardless of the port number. Certificates will be generated automatically, if none are supplied by the user. Footprint increases by only a few hundred kb so redbean in MODY=tiny is now 1.0mb - Add lseek() polyfills for ZIP executable - Automatically polyfill /tmp/FOO paths on NT - Fix readdir() / ftw() / nftw() bugs on Windows - Introduce -B flag for slower SSL that's stronger - Remove mbedtls features Cosmopolitan doesn't need - Have base64 decoder support the uri-safe alternative - Remove Truncated HMAC because it's forbidden by the IETF - Add all the mbedtls test suites and make them go 3x faster - Support opendir() / readdir() / closedir() on ZIP executable - Use Everest for ECDHE-ECDSA because it's so good it's so good - Add tinier implementation of sha1 since it's not worth the rom - Add chi-square monte-carlo mean correlation tests for getrandom() - Source entropy on Windows from the proper interface everyone uses We're continuing to outperform NGINX and other servers on raw message throughput. Using SSL means that instead of 1,000,000 qps you can get around 300,000 qps. However redbean isn't as fast as NGINX yet at SSL handshakes, since redbean can do 2,627 per second and NGINX does 4.3k Right now, the SSL UX story works best if you give your redbean a key signing key since that can be easily generated by openssl using a one liner then redbean will do all the things that are impossibly hard to do like signing ecdsa and rsa certificates that'll work in chrome. We should integrate the let's encrypt acme protocol in the future. Live Demo: https://redbean.justine.lol/ Root Cert: https://redbean.justine.lol/redbean1.crt
111 lines
7.9 KiB
C
111 lines
7.9 KiB
C
#ifndef COSMOPOLITAN_LIBC_X_H_
|
|
#define COSMOPOLITAN_LIBC_X_H_
|
|
#include "libc/calls/struct/sigaction.h"
|
|
#include "libc/calls/struct/timespec.h"
|
|
#include "libc/calls/struct/timeval.h"
|
|
#include "libc/fmt/pflink.h"
|
|
#include "libc/stdio/stdio.h"
|
|
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
|
COSMOPOLITAN_C_START_
|
|
/*───────────────────────────────────────────────────────────────────────────│─╗
|
|
│ cosmopolitan § eXtended apis ─╬─│┼
|
|
╚────────────────────────────────────────────────────────────────────────────│─╝
|
|
Standard Library veneers for folks not building embedded RTOS */
|
|
|
|
#define _XPNN paramsnonnull()
|
|
#define _XRET nothrow nocallback nodiscard returnsnonnull
|
|
#define _XMAL returnspointerwithnoaliases _XRET
|
|
#define _XMALPG returnsaligned((PAGESIZE)) _XMAL
|
|
|
|
/*───────────────────────────────────────────────────────────────────────────│─╗
|
|
│ cosmopolitan § eXtended apis » system calls ─╬─│┼
|
|
╚────────────────────────────────────────────────────────────────────────────│*/
|
|
|
|
int xsigaction(int, void *, uint64_t, uint64_t, struct sigaction *);
|
|
int xwrite(int, const void *, uint64_t);
|
|
|
|
/*───────────────────────────────────────────────────────────────────────────│─╗
|
|
│ cosmopolitan § eXtended apis » memory ─╬─│┼
|
|
╚────────────────────────────────────────────────────────────────────────────│*/
|
|
|
|
void xdie(void) wontreturn;
|
|
char *xdtoa(double) _XMAL;
|
|
char *xdtoaf(float) _XMAL;
|
|
char *xdtoal(long double) _XMAL;
|
|
char *xasprintf(const char *, ...) printfesque(1) paramsnonnull((1)) _XMAL;
|
|
char *xvasprintf(const char *, va_list) _XPNN _XMAL;
|
|
char *xgetline(struct FILE *) _XPNN mallocesque;
|
|
void *xmalloc(size_t) attributeallocsize((1)) _XMAL;
|
|
void *xrealloc(void *, size_t)
|
|
attributeallocsize((2)) nothrow nocallback nodiscard;
|
|
void *xcalloc(size_t, size_t) attributeallocsize((1, 2)) _XMAL;
|
|
void *xvalloc(size_t) attributeallocsize((1)) _XMALPG;
|
|
void *xmemalign(size_t, size_t) attributeallocalign((1))
|
|
attributeallocsize((2)) _XMAL;
|
|
void *xmemalignzero(size_t, size_t) attributeallocalign((1))
|
|
attributeallocsize((2)) _XMAL;
|
|
char *xstrdup(const char *) _XPNN _XMAL;
|
|
char *xstrndup(const char *, size_t) _XPNN _XMAL;
|
|
char *xstrcat(const char *, ...) paramsnonnull((1)) nullterminated() _XMAL;
|
|
char *xstrmul(const char *, size_t) paramsnonnull((1)) _XMAL;
|
|
char *xinet_ntop(int, const void *) _XPNN _XMAL;
|
|
void *xunbinga(size_t, const char16_t *) attributeallocalign((1)) _XMAL _XRET;
|
|
void *xunbing(const char16_t *) _XMAL _XRET;
|
|
char16_t *utf8toutf16(const char *, size_t, size_t *) nodiscard;
|
|
char *utf16toutf8(const char16_t *, size_t, size_t *) nodiscard;
|
|
|
|
/*───────────────────────────────────────────────────────────────────────────│─╗
|
|
│ cosmopolitan § eXtended apis » files ─╬─│┼
|
|
╚────────────────────────────────────────────────────────────────────────────│*/
|
|
|
|
int rmrf(const char *);
|
|
int makedirs(const char *, unsigned);
|
|
char *xdirname(const char *) paramsnonnull() _XMAL;
|
|
char *xjoinpaths(const char *, const char *) paramsnonnull() _XMAL;
|
|
|
|
/*───────────────────────────────────────────────────────────────────────────│─╗
|
|
│ cosmopolitan § eXtended apis » time ─╬─│┼
|
|
╚────────────────────────────────────────────────────────────────────────────│*/
|
|
|
|
char *xiso8601i(int) mallocesque;
|
|
char *xiso8601tv(struct timeval *) mallocesque;
|
|
char *xiso8601ts(struct timespec *) mallocesque;
|
|
|
|
/*───────────────────────────────────────────────────────────────────────────│─╗
|
|
│ cosmopolitan § eXtended apis » input / output ─╬─│┼
|
|
╚────────────────────────────────────────────────────────────────────────────│*/
|
|
|
|
char *xslurp(const char *, size_t *)
|
|
paramsnonnull((1)) returnspointerwithnoaliases
|
|
returnsaligned((PAGESIZE)) nodiscard;
|
|
int xbarf(const char *, const void *, size_t);
|
|
|
|
/*───────────────────────────────────────────────────────────────────────────│─╗
|
|
│ cosmopolitan § eXtended apis » safety ─╬─│┼
|
|
╚────────────────────────────────────────────────────────────────────────────│*/
|
|
|
|
#define xstrcat(...) (xstrcat)(__VA_ARGS__, NULL)
|
|
|
|
/*───────────────────────────────────────────────────────────────────────────│─╗
|
|
│ cosmopolitan § eXtended apis » generic typing ─╬─│┼
|
|
╚────────────────────────────────────────────────────────────────────────────│*/
|
|
|
|
#if __STDC_VERSION__ + 0 >= 201112
|
|
|
|
#define xiso8601(TS) \
|
|
_Generic(*(TS), struct timeval : xiso8601tv, default : xiso8601ts)(TS)
|
|
|
|
#endif /* C11 */
|
|
|
|
/*───────────────────────────────────────────────────────────────────────────│─╗
|
|
│ cosmopolitan § eXtended apis » link-time optimizations ─╬─│┼
|
|
╚────────────────────────────────────────────────────────────────────────────│*/
|
|
|
|
#if defined(__GNUC__) && !defined(__STRICT_ANSI__)
|
|
#define xasprintf(FMT, ...) (xasprintf)(PFLINK(FMT), ##__VA_ARGS__)
|
|
#define xvasprintf(FMT, VA) (xvasprintf)(PFLINK(FMT), VA)
|
|
#endif
|
|
|
|
COSMOPOLITAN_C_END_
|
|
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
|
#endif /* COSMOPOLITAN_LIBC_X_H_ */
|