all repos — flounder @ 904a619b566e69eac12b9d7e2822b24dc4f74263

A small site builder for the Gemini protocol

add hidden folder
alex wennerberg alex@alexwennerberg.com
Sat, 21 Nov 2020 14:03:32 -0800
commit

904a619b566e69eac12b9d7e2822b24dc4f74263

parent

7c81f713a773d2463dc971fcb7981abfaf3ad08f

4 files changed, 13 insertions(+), 0 deletions(-)

jump to
M gemini.gogemini.go

@@ -43,6 +43,9 @@ userName := filepath.Clean(strings.Split(r.URL.Host, ".")[0]) // clean probably unnecessary

fileName := filepath.Clean(r.URL.Path) if fileName == "/" { fileName = "index.gmi" + } else if strings.HasPrefix(fileName, ".hidden") { + w.WriteStatus(gmi.StatusNotFound) + return } log.Println("Request for gemini file", fileName, "for user", userName)
M go.sumgo.sum

@@ -25,7 +25,9 @@ github.com/mattn/go-sqlite3 v1.14.4/go.mod h1:WVKg1VTActs4Qso6iwGbiFih2UIHo0ENGwNd0Lj+XmI=

golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20200115085410-6d4e4cb37c7d h1:2+ZP7EfsZV7Vvmx3TIqSlSzATMkTAKqM14YGFPoSKjI= golang.org/x/crypto v0.0.0-20200115085410-6d4e4cb37c7d/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3 h1:0GoQqolDA55aaLxZyTzK/Y2ePZzZTUrRacwib7cNsYQ= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
M http.gohttp.go

@@ -434,6 +434,9 @@ userName := filepath.Clean(strings.Split(r.Host, ".")[0]) // clean probably unnecessary

p := filepath.Clean(r.URL.Path) if p == "/" { p = "index.gmi" + } else if strings.HasPrefix(p, "/.hidden") { + renderError(w, "404: file not found", 404) + return } fileName := path.Join(c.FilesDirectory, userName, p) extension := path.Ext(fileName)
M main.gomain.go

@@ -22,6 +22,8 @@ )

var c Config // global var to hold static configuration +const HIDDEN_FOLDER = ".hidden" + type File struct { // also folders Creator string Name string // includes folder

@@ -100,6 +102,9 @@ err := filepath.Walk(c.FilesDirectory, func(thepath string, info os.FileInfo, err error) error {

if err != nil { log.Printf("Failure accessing a path %q: %v\n", thepath, err) return err // think about + } + if info.IsDir() && info.Name() == HIDDEN_FOLDER { + return filepath.SkipDir } // make this do what it should if !info.IsDir() {