docRoot string
message string
fsymln bool
+ showdot bool
verbose bool
}{
iface: "localhost",
docRoot: ".",
message: "",
fsymln: false,
+ showdot: false,
verbose: false,
}
flag.StringVar(&cfg.message, "M", cfg.message, "index greeter message")
flag.BoolVar(&help, "h", help, "show this help page")
flag.BoolVar(&cfg.fsymln, "s", cfg.fsymln, "follow symbolic links")
+ flag.BoolVar(&cfg.showdot, "d", cfg.showdot, "allow access to dotfiles")
flag.BoolVar(&cfg.verbose, "v", cfg.verbose, "produce verbose output")
flag.Parse()
if help {
tracer.Print("TCP port: ", cfg.port)
tracer.Print("doc root: ", cfg.docRoot)
tracer.Print("fsymlinks: ", cfg.fsymln)
+ tracer.Print("showdot: ", cfg.showdot)
tracer.Print("fqdn: ", cfg.fqdn)
tracer.Print("message: ", cfg.message)
tracer.Print("verbose: ", cfg.verbose)
list += "1..\t" + updir + loc
}
for _, fi := range fi {
+ if !cfg.showdot && isDotfile(fi.Name()) {
+ continue
+ }
fmode := fi.Mode()
if fmode.IsDir() {
// create a directory reference
return
}
tracer.Print("request path: '", path, "'")
+ if !cfg.showdot && isDotfile(path) {
+ tracer.Print("skip dotfile")
+ return
+ }
// check for symbolic link
if cfg.fsymln == false {
fi, err := os.Lstat(path)
return cpath, err
}
+func isDotfile(path string) bool {
+ base := filepath.Base(path)
+ return base[:1] == "."
+}
+
func guessFiletype(path string) (string, error) {
// Open File
f, err := os.Open(path)