From 58a4ecd958f5e5fbefc35ae15acc01809d07940a Mon Sep 17 00:00:00 2001 From: Trevor Slocum Date: Thu, 19 Nov 2020 08:57:28 -0800 Subject: [PATCH] Rename HiddenFiles as Hidden --- CONFIGURATION.md | 30 +++++++++++++++--------------- README.md | 13 +++++++------ config.go | 6 +++--- go.mod | 2 +- go.sum | 4 ++-- server.go | 2 +- 6 files changed, 29 insertions(+), 28 deletions(-) diff --git a/CONFIGURATION.md b/CONFIGURATION.md index 35e188d..8b506ad 100644 --- a/CONFIGURATION.md +++ b/CONFIGURATION.md @@ -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 diff --git a/README.md b/README.md index 36781ad..cf7c3c3 100644 --- a/README.md +++ b/README.md @@ -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). diff --git a/config.go b/config.go index 87a6e8e..9c5b43f 100644 --- a/config.go +++ b/config.go @@ -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 diff --git a/go.mod b/go.mod index 0066bd0..e1d0db6 100644 --- a/go.mod +++ b/go.mod @@ -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 ) diff --git a/go.sum b/go.sum index b6a42db..2ece2a7 100644 --- a/go.sum +++ b/go.sum @@ -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= diff --git a/server.go b/server.go index 6cda9af..96e4fe5 100644 --- a/server.go +++ b/server.go @@ -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