Updated docs, moved lua into its own thread
This commit is contained in:
@@ -1,5 +1,9 @@
|
||||
# Overview
|
||||
|
||||
> :warning:
|
||||
> Not all of this is presently implemented. See the [README](../README.md) for details
|
||||
> on implementation status.
|
||||
|
||||
The lua script must have the following form:
|
||||
|
||||
```lua
|
||||
@@ -99,4 +103,24 @@ You can test the version using either `.version`, which returns either 4 or 6, o
|
||||
`.is_v4` and `.is_v6`. If you need the IPv6-mapped version of a v4 address, (i.e.,
|
||||
`::ffff:0.0.0.0`), this is available through `.to_v6`
|
||||
|
||||
This is probably most useful in conjunction with `stftpd.Cidr`
|
||||
This is probably most useful in conjunction with `stftpd.Cidr`
|
||||
|
||||
# Examples
|
||||
|
||||
Probably the most useful starting point for your own script will be the following:
|
||||
|
||||
```lua
|
||||
return function(path, client, size)
|
||||
if path:match("^/?^/?https?://") then
|
||||
if path:sub(1,1) == "/" then
|
||||
path = path:sub(2)
|
||||
end
|
||||
return resource.HTTP(path)
|
||||
end
|
||||
return resource.FILE(path)
|
||||
end
|
||||
```
|
||||
|
||||
This detects HTTP (or HTTPS) urls, and transparently proxies them to the appropriate HTTP server.
|
||||
Some TFTP clients automatically insert a leading `/`, so this function strips it if given.
|
||||
If the given path doesn't look like an HTTP URL, this example tries to handle it as a file.
|
||||
Reference in New Issue
Block a user