Update Redbean help.txt (#492)

Fix typos and add previously undocumented functions:

- GetHttpReason
- IsHiddenPath
- IsAcceptablePath
- IsReasonablePath
- ProgramTimeout
This commit is contained in:
Wiebe 2022-07-16 18:00:28 +00:00 committed by GitHub
parent ea04d00752
commit 4700984456
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -356,7 +356,7 @@ REPL
#!/usr/bin/redbean -i #!/usr/bin/redbean -i
print('hello world') print('hello world')
However UNIX operating systems usually require that interperters be However UNIX operating systems usually require that interpreters be
encoded in its preferred executable format. You can assimilate your encoded in its preferred executable format. You can assimilate your
redbean into the local format using the following commands: redbean into the local format using the following commands:
@ -523,7 +523,7 @@ HOOKS
OnHttpRequest() OnHttpRequest()
If this function is defined in the global scope by your /.init.lua If this function is defined in the global scope by your /.init.lua
then redbean will call it at the ealiest possible moment to then redbean will call it at the earliest possible moment to
hand over control for all messages (with the exception of OPTIONS hand over control for all messages (with the exception of OPTIONS
*). See functions like Route which asks redbean to do its default *). See functions like Route which asks redbean to do its default
thing from the handler. thing from the handler.
@ -1159,6 +1159,10 @@ FUNCTIONS
HTTP/0.9, 10 for HTTP/1.0, or 11 for HTTP/1.1. HTTP/0.9, 10 for HTTP/1.0, or 11 for HTTP/1.1.
Also available as GetVersion (deprecated). Also available as GetVersion (deprecated).
GetHttpReason(code:int) → str
Returns a string describing the HTTP reason phrase.
See gethttpreason.c
GetRandomBytes([length:int]) → str GetRandomBytes([length:int]) → str
Returns string with the specified number of random bytes (1..256). Returns string with the specified number of random bytes (1..256).
If no length is specified, then a string of length 16 is returned. If no length is specified, then a string of length 16 is returned.
@ -1181,6 +1185,9 @@ FUNCTIONS
Programs redbean / listing page to not display any paths beginning Programs redbean / listing page to not display any paths beginning
with prefix. This function should only be called from /.init.lua. with prefix. This function should only be called from /.init.lua.
IsHiddenPath(path:str) → bool
Returns true if the prefix of the given path is set with HidePath.
IsPublicIp(uint32) → bool IsPublicIp(uint32) → bool
Returns true if IP address is not a private network (10.0.0.0/8, Returns true if IP address is not a private network (10.0.0.0/8,
172.16.0.0/12, 192.168.0.0/16) and is not localhost (127.0.0.0/8). 172.16.0.0/12, 192.168.0.0/16) and is not localhost (127.0.0.0/8).
@ -1256,6 +1263,14 @@ FUNCTIONS
like data:opaque, better in fact than most things which claim to like data:opaque, better in fact than most things which claim to
be URI parsers. be URI parsers.
IsAcceptablePath(str) → bool
Returns true if path doesn't contain ".", ".." or "//" segments
See isacceptablepath.c
IsReasonablePath(str) → bool
Returns true if path doesn't contain "." or ".." segments.
See isreasonablepath.c
EncodeUrl(URL) → str EncodeUrl(URL) → str
This function is the inverse of ParseUrl. The output will always This function is the inverse of ParseUrl. The output will always
be correctly formatted. The exception is if illegal characters are be correctly formatted. The exception is if illegal characters are
@ -1314,6 +1329,11 @@ FUNCTIONS
as Content-Range and Date, which are abstracted by the transport as Content-Range and Date, which are abstracted by the transport
layer. layer.
ProgramTimeout(milliseconds:int|seconds:int)
Default timeout is 60000ms. Minimal value of timeout is 10(ms).
Negative values (<0) sets the keepalive in seconds.
This should only be called from /.init.lua.
ProgramPort(uint16) ProgramPort(uint16)
Hard-codes the port number on which to listen, which can be any Hard-codes the port number on which to listen, which can be any
number in the range 1..65535, or alternatively 0 to ask the number in the range 1..65535, or alternatively 0 to ask the
@ -1325,7 +1345,7 @@ FUNCTIONS
default is very conservatively set to 65536 so this is default is very conservatively set to 65536 so this is
something many people will want to increase. This limit is something many people will want to increase. This limit is
enforced at the transport layer, before any Lua code is enforced at the transport layer, before any Lua code is
called, because right now redbean stores and forewards called, because right now redbean stores and forwards
messages. (Use the UNIX API for raw socket streaming.) Setting messages. (Use the UNIX API for raw socket streaming.) Setting
this to a very high value can be useful if you're less this to a very high value can be useful if you're less
concerned about rogue clients and would rather have your Lua concerned about rogue clients and would rather have your Lua
@ -1421,7 +1441,7 @@ FUNCTIONS
ProgramLogPath(str) ProgramLogPath(str)
Same as the -L flag if called from .init.lua for setting the log Same as the -L flag if called from .init.lua for setting the log
file path on the local file system. It's created if it doesn't file path on the local file system. It's created if it doesn't
exist. This is called before de-escalating the uesr / group id. exist. This is called before de-escalating the user / group id.
The file is opened in append only mode. If the disk runs out of The file is opened in append only mode. If the disk runs out of
space then redbean will truncate the log file if has access to space then redbean will truncate the log file if has access to
change the log file after daemonizing. change the log file after daemonizing.
@ -1679,7 +1699,7 @@ FUNCTIONS
associated with hostname. If no such entry is found, a DNS lookup is associated with hostname. If no such entry is found, a DNS lookup is
performed using the system configured (e.g. /etc/resolv.conf) DNS performed using the system configured (e.g. /etc/resolv.conf) DNS
resolution service. If the service returns multiple IN A records resolution service. If the service returns multiple IN A records
then only the first one is reutrned. then only the first one is returned.
The returned address is word-encoded in host endian order. For The returned address is word-encoded in host endian order. For
example, 1.2.3.4 is encoded as 0x01020304. The `FormatIp` function example, 1.2.3.4 is encoded as 0x01020304. The `FormatIp` function
@ -1957,7 +1977,7 @@ MAXMIND MODULE
──────────────────────────────────────────────────────────────────────────────── ────────────────────────────────────────────────────────────────────────────────
ARGON2 MODULE ARGON2 MODULE
This module implemeents a password hashing algorithm based on blake2b This module implements a password hashing algorithm based on blake2b
that won the Password Hashing Competition. that won the Password Hashing Competition.
It can be used to securely store user passwords in your SQLite It can be used to securely store user passwords in your SQLite
@ -2249,7 +2269,7 @@ UNIX MODULE
`env` is a string list table. Values are coerced to strings. No `env` is a string list table. Values are coerced to strings. No
ordering requirement is imposed. By convention, each string has its ordering requirement is imposed. By convention, each string has its
key and value divided by an equals sign without spaces. If this key and value divided by an equals sign without spaces. If this
paremeter is not specified, it'll default to the C/C++ `environ` parameter is not specified, it'll default to the C/C++ `environ`
variable which is inherited from the shell that launched redbean. variable which is inherited from the shell that launched redbean.
It's the responsibility of the user to supply a sanitized environ It's the responsibility of the user to supply a sanitized environ
when spawning untrusted processes. when spawning untrusted processes.
@ -3988,7 +4008,7 @@ UNIX MODULE
File birth time. File birth time.
This field should be accurate on Apple, Windows, and BSDs. On Linux This field should be accurate on Apple, Windows, and BSDs. On Linux
this is the mimimum of atim/mtim/ctim. On Windows NT nanos is only this is the minimum of atim/mtim/ctim. On Windows NT nanos is only
accurate to hectonanoseconds. accurate to hectonanoseconds.
Here's an example of how you might print a file timestamp: Here's an example of how you might print a file timestamp: