Add /statusz page to redbean plus other enhancements

redbean improvements:

- Explicitly disable corking
- Simulate Python regex API for Lua
- Send warmup requests in main process on startup
- Add Class-A granular IPv4 network classification
- Add /statusz page so you can monitor your redbean's health
- Fix regressions on OpenBSD/NetBSD caused by recent changes
- Plug Authorization header into Lua GetUser and GetPass APIs
- Recognize X-Forwarded-{For,Host} from local reverse proxies
- Add many additional functions to redbean Lua server page API
- Report resource usage of child processes on `/` listing page
- Introduce `-a` flag for logging child process resource usage
- Introduce `-t MILLIS` flag and `ProgramTimeout(ms)` init API
- Introduce `-H "Header: value"` flag and `ProgramHeader(k,v)` API

Cosmopolitan Libc improvements:

- Make strerror() simpler
- Make inet_pton() not depend on sscanf()
- Fix OpenExecutable() which broke .data section earlier
- Fix stdio in cases where it overflows kernel tty buffer
- Fix bugs in crash reporting w/o .com.dbg binary present
- Add polyfills for SO_LINGER, SO_RCVTIMEO, and SO_SNDTIMEO
- Polyfill TCP_CORK on BSD and XNU using TCP_NOPUSH magnums

New netcat clone in examples/nc.c:

While testing some of the failure conditions for redbean, I noticed that
BusyBox's `nc` command is pretty busted, if you use it as an interactive
tool, rather than having it be part of a pipeline. Unfortunately this'll
only work on UNIX since Windows doesn't let us poll on stdio and sockets
at the same time because I don't think they want tools like this running
on their platform. So if you want forbidden fruit, it's here so enjoy it
This commit is contained in:
Justine Tunney 2021-04-23 10:45:19 -07:00
parent 4effa23528
commit b107d2709f
163 changed files with 4425 additions and 2104 deletions

View file

@ -1,2 +0,0 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon c,C_IRGRP,0000040,0000040,0000040,0000040,0000040,0

View file

@ -1,2 +0,0 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon c,C_IROTH,0000004,0000004,0000004,0000004,0000004,0

View file

@ -1,2 +0,0 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon c,C_IRUSR,0000400,0000400,0000400,0000400,0000400,0

View file

@ -1,2 +0,0 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon c,C_ISBLK,0060000,0060000,0060000,0060000,0060000,0

View file

@ -1,2 +0,0 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon c,C_ISCHR,0020000,0020000,0020000,0020000,0020000,0

View file

@ -1,2 +0,0 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon c,C_ISCTG,0110000,0110000,0110000,0110000,0110000,0

View file

@ -1,2 +0,0 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon c,C_ISDIR,0040000,0040000,0040000,0040000,0040000,0

View file

@ -1,2 +0,0 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon c,C_ISFIFO,0010000,0010000,0010000,0010000,0010000,0

View file

@ -1,2 +0,0 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon c,C_ISGID,0002000,0002000,0002000,0002000,0002000,0

View file

@ -1,2 +0,0 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon c,C_ISLNK,0120000,0120000,0120000,0120000,0120000,0

View file

@ -1,2 +0,0 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon c,C_ISREG,0100000,0100000,0100000,0100000,0100000,0

View file

@ -1,2 +0,0 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon c,C_ISSOCK,0140000,0140000,0140000,0140000,0140000,0

View file

@ -1,2 +0,0 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon c,C_ISUID,0004000,0004000,0004000,0004000,0004000,0

View file

@ -1,2 +0,0 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon c,C_ISVTX,0001000,0001000,0001000,0001000,0001000,0

View file

@ -1,2 +0,0 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon c,C_IWGRP,0000020,0000020,0000020,0000020,0000020,0

View file

@ -1,2 +0,0 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon c,C_IWOTH,0000002,0000002,0000002,0000002,0000002,0

View file

@ -1,2 +0,0 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon c,C_IWUSR,0000200,0000200,0000200,0000200,0000200,0

View file

@ -1,2 +0,0 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon c,C_IXGRP,0000010,0000010,0000010,0000010,0000010,0

View file

@ -1,2 +0,0 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon c,C_IXOTH,0000001,0000001,0000001,0000001,0000001,0

View file

@ -1,2 +0,0 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon c,C_IXUSR,0000100,0000100,0000100,0000100,0000100,0

View file

@ -1,2 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon errno,EADDRINUSE,98,48,48,48,48,0x2740
.syscon errno,EADDRINUSE,98,48,48,48,48,10048

View file

@ -1,2 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon errno,EADDRNOTAVAIL,99,49,49,49,49,0x2741
.syscon errno,EADDRNOTAVAIL,99,49,49,49,49,10049

View file

@ -1,2 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon errno,EAFNOSUPPORT,97,47,47,47,47,0x273f
.syscon errno,EAFNOSUPPORT,97,47,47,47,47,10047

View file

@ -1,2 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon errno,EAGAIN,11,35,35,35,35,0x2733
.syscon errno,EAGAIN,11,35,35,35,35,10035

View file

@ -1,2 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon errno,EALREADY,114,37,37,37,37,0x2735
.syscon errno,EALREADY,114,37,37,37,37,10037

View file

@ -1,2 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon errno,ECONNABORTED,103,53,53,53,53,0x2745
.syscon errno,ECONNABORTED,103,53,53,53,53,10053

View file

@ -1,2 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon errno,ECONNREFUSED,111,61,61,61,61,0x274d
.syscon errno,ECONNREFUSED,111,61,61,61,61,10061

View file

@ -1,2 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon errno,ECONNRESET,104,54,54,54,54,0x2746
.syscon errno,ECONNRESET,104,54,54,54,54,10054

View file

@ -1,2 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon errno,EDESTADDRREQ,89,39,39,39,39,0x2737
.syscon errno,EDESTADDRREQ,89,39,39,39,39,10039

View file

@ -1,2 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon errno,EDQUOT,122,69,69,69,69,0x2755
.syscon errno,EDQUOT,122,69,69,69,69,10069

View file

@ -1,2 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon errno,EHOSTDOWN,112,64,64,64,64,0x2750
.syscon errno,EHOSTDOWN,112,64,64,64,64,10064

View file

@ -1,2 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon errno,EHOSTUNREACH,113,65,65,65,65,0x2751
.syscon errno,EHOSTUNREACH,113,65,65,65,65,10065

View file

@ -1,2 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon errno,EINPROGRESS,115,36,36,36,36,0x2734
.syscon errno,EINPROGRESS,115,36,36,36,36,10036

View file

@ -1,2 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon errno,EISCONN,106,56,56,56,56,0x2748
.syscon errno,EISCONN,106,56,56,56,56,10056

View file

@ -1,2 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon errno,ELOOP,40,62,62,62,62,0x274e
.syscon errno,ELOOP,40,62,62,62,62,10062

View file

@ -1,2 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon errno,EMSGSIZE,90,40,40,40,40,0x2738
.syscon errno,EMSGSIZE,90,40,40,40,40,10040

View file

@ -1,2 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon errno,ENAMETOOLONG,36,63,63,63,63,0x274f
.syscon errno,ENAMETOOLONG,36,63,63,63,63,10063

View file

@ -1,2 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon errno,ENETDOWN,100,50,50,50,50,0x2742
.syscon errno,ENETDOWN,100,50,50,50,50,10050

View file

@ -1,2 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon errno,ENETRESET,102,52,52,52,52,0x2744
.syscon errno,ENETRESET,102,52,52,52,52,10052

View file

@ -1,2 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon errno,ENETUNREACH,101,51,51,51,51,0x2743
.syscon errno,ENETUNREACH,101,51,51,51,51,10051

View file

@ -1,2 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon errno,ENOBUFS,105,55,55,55,55,0x2747
.syscon errno,ENOBUFS,105,55,55,55,55,10055

View file

@ -1,2 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon errno,ENOPROTOOPT,92,42,42,42,42,0x273a
.syscon errno,ENOPROTOOPT,92,42,42,42,42,10042

View file

@ -1,2 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon errno,ENOTCONN,107,57,57,57,57,0x2749
.syscon errno,ENOTCONN,107,57,57,57,57,10057

View file

@ -1,2 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon errno,ENOTSOCK,88,38,38,38,38,0x2736
.syscon errno,ENOTSOCK,88,38,38,38,38,10038

View file

@ -1,2 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon errno,ENOTSUP,95,45,45,91,86,0x273d
.syscon errno,ENOTSUP,95,45,45,91,86,10045

View file

@ -1,2 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon errno,EOPNOTSUPP,95,102,45,45,45,0x273d
.syscon errno,EOPNOTSUPP,95,102,45,45,45,10045

View file

@ -1,2 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon errno,EPFNOSUPPORT,96,46,46,46,46,0x273e
.syscon errno,EPFNOSUPPORT,96,46,46,46,46,10046

View file

@ -1,2 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon errno,EPROTONOSUPPORT,93,43,43,43,43,0x273b
.syscon errno,EPROTONOSUPPORT,93,43,43,43,43,10043

View file

@ -1,2 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon errno,EPROTOTYPE,91,41,41,41,41,0x2739
.syscon errno,EPROTOTYPE,91,41,41,41,41,10041

View file

@ -1,2 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon errno,EREMOTE,66,71,71,71,71,0x2757
.syscon errno,EREMOTE,66,71,71,71,71,10071

View file

@ -1,2 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon errno,ESHUTDOWN,108,58,58,58,58,0x274a
.syscon errno,ESHUTDOWN,108,58,58,58,58,10058

View file

@ -1,2 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon errno,ESOCKTNOSUPPORT,94,44,44,44,44,0x273c
.syscon errno,ESOCKTNOSUPPORT,94,44,44,44,44,10044

View file

@ -1,2 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon errno,ESTALE,116,70,70,70,70,0x2756
.syscon errno,ESTALE,116,70,70,70,70,10070

View file

@ -1,2 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon errno,ETIMEDOUT,110,60,60,60,60,0x274c
.syscon errno,ETIMEDOUT,110,60,60,60,60,10060

View file

@ -1,2 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon errno,ETOOMANYREFS,109,59,59,59,59,0x274b
.syscon errno,ETOOMANYREFS,109,59,59,59,59,10059

View file

@ -1,2 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon errno,EUSERS,87,68,68,68,68,0x2754
.syscon errno,EUSERS,87,68,68,68,68,10068

View file

@ -1,2 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon compat,EWOULDBLOCK,11,35,35,35,35,0x2733
.syscon compat,EWOULDBLOCK,11,35,35,35,35,10035

View file

@ -1,2 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon ip,IP_MINTTL,21,0,66,0x20,0x20,0
.syscon ip,IP_MINTTL,21,0,66,32,24,0

View file

@ -1,2 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon ip,IP_PKTINFO,8,26,0,0,0,19
.syscon ip,IP_PKTINFO,8,26,0,0,25,19

View file

@ -1,2 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon ip,IP_RECVTTL,12,24,65,31,31,21
.syscon ip,IP_RECVTTL,12,24,65,31,23,21

View file

@ -1,2 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon tcp,TCP_CORK,3,0,0,0,0,0
.syscon tcp,TCP_CORK,3,4,4,16,0,0

View file

@ -1,2 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon tcp,TCP_FASTOPEN,23,261,0x0401,0,0,15
.syscon tcp,TCP_FASTOPEN,23,0,0x0401,0,0,15

View file

@ -1,2 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon tcp,TCP_INFO,11,0,0x20,0,0,0
.syscon tcp,TCP_INFO,11,0,0x20,0,9,0

View file

@ -1,2 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon tcp,TCP_KEEPCNT,6,0x102,0x400,0,0,0
.syscon tcp,TCP_KEEPCNT,6,0x102,0x400,0,6,0

View file

@ -1,2 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon tcp,TCP_KEEPIDLE,4,0,0x100,0,0,0
.syscon tcp,TCP_KEEPIDLE,4,0,0x100,0,3,0

View file

@ -1,2 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon tcp,TCP_KEEPINTVL,5,0x101,0x200,0,0,0
.syscon tcp,TCP_KEEPINTVL,5,0x101,0x200,0,5,0

View file

@ -1,2 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon tcp,TCP_MD5SIG,14,0,0x10,4,4,0
.syscon tcp,TCP_MD5SIG,14,0,0x10,4,16,0

View file

@ -1,52 +1,25 @@
#ifndef COSMOPOLITAN_LIBC_SYSV_CONSTS_C_H_
#define COSMOPOLITAN_LIBC_SYSV_CONSTS_C_H_
#include "libc/runtime/symbolic.h"
#ifndef COSMOPOLITAN_LIBC_SYSV_CONSTS_CPIO_H_
#define COSMOPOLITAN_LIBC_SYSV_CONSTS_CPIO_H_
#define C_IRGRP SYMBOLIC(C_IRGRP)
#define C_IROTH SYMBOLIC(C_IROTH)
#define C_IRUSR SYMBOLIC(C_IRUSR)
#define C_ISBLK SYMBOLIC(C_ISBLK)
#define C_ISCHR SYMBOLIC(C_ISCHR)
#define C_ISCTG SYMBOLIC(C_ISCTG)
#define C_ISDIR SYMBOLIC(C_ISDIR)
#define C_ISFIFO SYMBOLIC(C_ISFIFO)
#define C_ISGID SYMBOLIC(C_ISGID)
#define C_ISLNK SYMBOLIC(C_ISLNK)
#define C_ISREG SYMBOLIC(C_ISREG)
#define C_ISSOCK SYMBOLIC(C_ISSOCK)
#define C_ISUID SYMBOLIC(C_ISUID)
#define C_ISVTX SYMBOLIC(C_ISVTX)
#define C_IWGRP SYMBOLIC(C_IWGRP)
#define C_IWOTH SYMBOLIC(C_IWOTH)
#define C_IWUSR SYMBOLIC(C_IWUSR)
#define C_IXGRP SYMBOLIC(C_IXGRP)
#define C_IXOTH SYMBOLIC(C_IXOTH)
#define C_IXUSR SYMBOLIC(C_IXUSR)
#define C_IXOTH 0000001
#define C_IWOTH 0000002
#define C_IROTH 0000004
#define C_IXGRP 0000010
#define C_IWGRP 0000020
#define C_IRGRP 0000040
#define C_IXUSR 0000100
#define C_IWUSR 0000200
#define C_IRUSR 0000400
#define C_ISVTX 0001000
#define C_ISGID 0002000
#define C_ISUID 0004000
#define C_ISFIFO 0010000
#define C_ISCHR 0020000
#define C_ISDIR 0040000
#define C_ISBLK 0060000
#define C_ISREG 0100000
#define C_ISCTG 0110000
#define C_ISLNK 0120000
#define C_ISSOCK 0140000
#if !(__ASSEMBLER__ + __LINKER__ + 0)
COSMOPOLITAN_C_START_
extern const long C_IRGRP;
extern const long C_IROTH;
extern const long C_IRUSR;
extern const long C_ISBLK;
extern const long C_ISCHR;
extern const long C_ISCTG;
extern const long C_ISDIR;
extern const long C_ISFIFO;
extern const long C_ISGID;
extern const long C_ISLNK;
extern const long C_ISREG;
extern const long C_ISSOCK;
extern const long C_ISUID;
extern const long C_ISVTX;
extern const long C_IWGRP;
extern const long C_IWOTH;
extern const long C_IWUSR;
extern const long C_IXGRP;
extern const long C_IXOTH;
extern const long C_IXUSR;
COSMOPOLITAN_C_END_
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_LIBC_SYSV_CONSTS_C_H_ */
#endif /* COSMOPOLITAN_LIBC_SYSV_CONSTS_CPIO_H_ */