Return 'Not found' on stat error
This commit is contained in:
parent
8465ad9871
commit
b4876f8756
3 changed files with 10 additions and 11 deletions
|
@ -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
|
||||
```
|
||||
```
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue