forked from tslocum/twins
1
0
Fork 0

Rename HiddenFiles as Hidden

This commit is contained in:
Trevor Slocum 2020-11-19 08:57:28 -08:00
parent cac10df2f6
commit 58a4ecd958
6 changed files with 29 additions and 28 deletions

View File

@ -111,25 +111,11 @@ Cache duration (in seconds). Set to `0` to disable caching entirely. This is an
out-of-spec feature. See [PROPOSALS.md](https://gitlab.com/tslocum/twins/blob/master/PROPOSALS.md)
for more information.
##### Log
Path to log file. Requests are logged in [Apache format](https://httpd.apache.org/docs/2.2/logs.html#combined),
excluding IP address and query.
##### SymLinks
When enabled, symbolic links may be accessed. This attribute is disabled by default.
##### HiddenFiles
##### Hidden
When enabled, hidden files and directories may be accessed. This attribute is
disabled by default.
##### List
When enabled, directories without an index file will serve a list of their
contents. This attribute is disabled by default.
##### Input
Request text input from user.
@ -138,6 +124,20 @@ Request text input from user.
Request sensitive text input from the user. Text will not be shown as it is entered.
##### List
When enabled, directories without an index file will serve a list of their
contents. This attribute is disabled by default.
##### Log
Path to log file. Requests are logged in [Apache format](https://httpd.apache.org/docs/2.2/logs.html#combined),
excluding IP address and query.
##### SymLinks
When enabled, symbolic links may be accessed. This attribute is disabled by default.
##### Type
Content type is normally detected automatically. This attribute forces a

View File

@ -12,6 +12,8 @@ This page is also available at [gemini://twins.rocketnine.space](gemini://twins.
## Features
- Serve static files
- Detect content type
- Specify content type for files with matching extension
- List files and directories (when enabled)
- Reverse proxy requests
- TCP
@ -25,20 +27,19 @@ twins includes features that are not yet part of the Gemini specification. See [
## Download
twins is written in [Go](https://golang.org). Run the following command to
download and build twins from source.
```bash
go get gitlab.com/tslocum/twins
```
The resulting binary is available as `~/go/bin/twins`.
## Configure
See [CONFIGURATION.md](https://gitlab.com/tslocum/twins/blob/master/CONFIGURATION.md)
## Run
```bash
twins
```
## Support
Please share issues and suggestions [here](https://gitlab.com/tslocum/twins/issues).

View File

@ -35,7 +35,7 @@ type pathConfig struct {
SymLinks bool
// Serve hidden files and directories
HiddenFiles bool
Hidden bool
// List directory
List bool
@ -173,8 +173,8 @@ func readconfig(configPath string) error {
if defaultPath.SymLinks {
serve.SymLinks = defaultPath.SymLinks
}
if defaultPath.HiddenFiles {
serve.HiddenFiles = defaultPath.HiddenFiles
if defaultPath.Hidden {
serve.Hidden = defaultPath.Hidden
}
if defaultPath.List {
serve.List = defaultPath.List

2
go.mod
View File

@ -6,6 +6,6 @@ require (
github.com/h2non/filetype v1.1.0
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51
github.com/yookoala/gofast v0.4.1-0.20201013050739-975113c54107
golang.org/x/tools v0.0.0-20201117021029-3c3a81204b10 // indirect
golang.org/x/tools v0.0.0-20201117152513-9036a0f9af11 // indirect
gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776
)

4
go.sum
View File

@ -34,8 +34,8 @@ golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGm
golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20200908211811-12e1bf57a112/go.mod h1:Cj7w3i3Rnn0Xh82ur9kSqwfTHTeVxaDqrfMjpcNT6bE=
golang.org/x/tools v0.0.0-20201117021029-3c3a81204b10 h1:epqY6OjPdDktZ8Cbnv7rUhy89e44hYWhxmhdecJr4cg=
golang.org/x/tools v0.0.0-20201117021029-3c3a81204b10/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/tools v0.0.0-20201117152513-9036a0f9af11 h1:gqcmLJzeDSNhSzkyhJ4kxP6CtTimi/5hWFDGp0lFd1w=
golang.org/x/tools v0.0.0-20201117152513-9036a0f9af11/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=

View File

@ -145,7 +145,7 @@ func servePath(c *tls.Conn, request *url.URL, serve *pathConfig) (int, int64) {
resolvedPath = strings.Join(requestSplit[pathSlashes:], "/")
}
if !serve.HiddenFiles {
if !serve.Hidden {
for _, piece := range requestSplit {
if len(piece) > 0 && piece[0] == '.' {
return writeStatus(c, statusNotFound), -1