diff --git a/CONFIGURATION.md b/CONFIGURATION.md index 6d36d4d..980afa6 100644 --- a/CONFIGURATION.md +++ b/CONFIGURATION.md @@ -1,7 +1,6 @@ -`twins` requires a configuration file to operate. By default, it is loaded from -`~/.config/twins/config.yaml`. You may specify a different location via the -`--config` argument. - +`twins` requires a configuration file to operate. It is loaded from +`~/.config/twins/config.yaml` by default. You may specify a different location +via the `--config` argument. # Configuration options @@ -140,4 +139,4 @@ hosts: - path: / root: /home/twins/data/home -``` \ No newline at end of file +``` diff --git a/README.md b/README.md index 70d5438..a30ac4e 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ Breaking changes may be made. ## Features - Serve static files - - Directory listing may be enabled + - Directory listing (when enabled) - Serve the output of system commands - Reverse proxy requests @@ -37,3 +37,6 @@ Please share issues and suggestions [here](https://gitlab.com/tslocum/twins/issu ## Dependencies - [go-gemini](https://github.com/makeworld-the-better-one/go-gemini) +- [go-shellquote](https://github.com/kballard/go-shellquote) +- [filetype](https://github.com/h2non/filetype) +- [yaml](https://github.com/go-yaml/yaml/tree/v3) diff --git a/server.go b/server.go index 3e804b0..0c70564 100644 --- a/server.go +++ b/server.go @@ -140,12 +140,9 @@ func serveDirectory(c net.Conn, request *url.URL, dirPath string) { func serveFile(c net.Conn, request *url.URL, requestData, filePath string, listDir bool) { fi, err := os.Stat(filePath) - if os.IsNotExist(err) { + if err != nil { writeStatus(c, gemini.StatusNotFound) return - } else if err != nil { - writeStatus(c, gemini.StatusTemporaryFailure) - return } originalPath := filePath @@ -329,7 +326,7 @@ func handleConn(c net.Conn) { log.Printf("> %s\n", requestData) } - if len(requestData) > 1024 || !utf8.ValidString(requestData) { + if len(requestData) > gemini.URLMaxLength || !utf8.ValidString(requestData) { writeStatus(c, gemini.StatusBadRequest) return }