type Hook func(http.ResponseWriter, *http.Request) bool
type HostCfg struct {
+ MIMEs map[string]string
Root string
ECDSATLS *TLSCfg
EdDSATLS *TLSCfg
GOSTTLS *TLSCfg
- DirList bool
- WebDAV bool
- Hooks []Hook
Auth *AuthCfg
+ Hooks []Hook
Indices []string
Readmes []string
- MIMEs map[string]string
+
+ DirList bool
+ WebDAV bool
}
var Hosts = make(map[string]*HostCfg)
}
if *doSetGID != 0 {
- if err := syscall.Setregid(*doSetGID, *doSetGID); err != nil {
+ if err = syscall.Setregid(*doSetGID, *doSetGID); err != nil {
log.Fatal(err)
}
}
if *doSetGIDs == "" {
if *doSetGID != 0 {
- if err := syscall.Setgroups([]int{*doSetGID}); err != nil {
+ if err = syscall.Setgroups([]int{*doSetGID}); err != nil {
log.Fatal(err)
}
}
} else {
gids := []int{}
for _, g := range strings.Split(*doSetGIDs, ",") {
- gid, err := strconv.Atoi(g)
+ var gid int
+ gid, err = strconv.Atoi(g)
if err != nil {
log.Fatalln(err)
}
gids = append(gids, gid)
}
- if err := syscall.Setgroups(gids); err != nil {
+ if err = syscall.Setgroups(gids); err != nil {
log.Fatal(err)
}
}
if *doSetUID != 0 {
- if err := syscall.Setreuid(*doSetUID, *doSetUID); err != nil {
+ if err = syscall.Setreuid(*doSetUID, *doSetUID); err != nil {
log.Fatal(err)
}
}
}
type DirListFile struct {
- Idx int
Name string
Size string
- IsDir bool
Type string
ModTime string
Symlink string
+ Idx int
+ IsDir bool
}
func dirList(
err = DirListTmpl.Execute(fd, struct {
Root string
Dir string
- Files []DirListFile
Readme string
+ Files []DirListFile
}{
Root: root,
Dir: dir,
- Files: files,
Readme: readme,
+ Files: files,
})
if err != nil {
fd.Close()
"errors"
"fmt"
"io"
+ "io/fs"
"log"
"net"
"net/http"
IndexLookuped:
if fi.IsDir() {
if cfg.DirList {
- entries, err := os.ReadDir(pth)
+ var entries []fs.DirEntry
+ entries, err = os.ReadDir(pth)
if err != nil {
printErr(http.StatusInternalServerError, err)
http.Error(w, "internal error", http.StatusInternalServerError)
} else {
for _, index := range append(cfg.Indices, Index) {
p := path.Join(pth, index)
- if _, err := os.Stat(p); err == nil {
+ if _, err = os.Stat(p); err == nil {
pth = p
fi, err = os.Stat(pth)
if err != nil {
const MIMEDir = "mime"
-var (
- //go:embed mime
- mimes embed.FS
-)
+//go:embed mime
+var mimes embed.FS
type MIMEEntry struct {
ext string
cert = HostToEdDSACertificate[chi.ServerName]
} else {
if CHIHasEdDSA(chi) {
- if cert := HostToEdDSACertificate[chi.ServerName]; cert != nil {
+ if cert = HostToEdDSACertificate[chi.ServerName]; cert != nil {
return cert, nil
}
}