"os"
"path"
"path/filepath"
+ "strconv"
"strings"
)
fsymln bool
showdot bool
indexes bool
+ timeout int
verbose bool
}{
iface: "localhost",
fsymln: false,
showdot: false,
indexes: false,
+ timeout: 60,
verbose: false,
}
cfg.showdot = strToBool(val)
case "indexes":
cfg.indexes = strToBool(val)
+ case "timeout":
+ cfg.timeout, _ = strconv.Atoi(val)
+ case "verbose":
+ cfg.verbose = strToBool(val)
default:
logger.Print("ignoring unknown config item: ", name)
}
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.indexes, "l", cfg.indexes, "allow directory listings")
+ flag.BoolVar(&cfg.indexes, "l", cfg.indexes, "allow generated directory indexes")
+ flag.IntVar(&cfg.timeout, "t", cfg.timeout, "connection read/write timeout in seconds")
flag.BoolVar(&cfg.verbose, "v", cfg.verbose, "produce verbose output")
flag.Parse()
if help {
tracer.Print("fsymln: ", cfg.fsymln)
tracer.Print("showdot: ", cfg.showdot)
tracer.Print("indexes: ", cfg.indexes)
+ tracer.Print("timeout: ", cfg.timeout)
tracer.Print("verbose: ", cfg.verbose)
}
"path/filepath"
"strings"
"syscall"
+ "time"
)
var shutting_down bool = false
func handleRequest(conn net.Conn) {
defer conn.Close()
// get request
+ conn.SetDeadline(time.Now().Add(time.Duration(cfg.timeout) * time.Second))
req, err := bufio.NewReader(conn).ReadString('\n')
if check(err, "ReadString") != nil {
return