Add --redact option to hide admin prefix in log output
This commit is contained in:
parent
5167ff457e
commit
60ec29612b
|
@ -138,6 +138,7 @@ Usage:
|
|||
Flags:
|
||||
--admin-prefix string string to prepend to administrative paths
|
||||
-a, --all enable all supported file types
|
||||
--allow-empty allow specifying paths containing no supported files
|
||||
--audio enable support for audio files
|
||||
--binary-prefix use IEC binary prefixes instead of SI decimal prefixes
|
||||
-b, --bind string address to bind to (default "0.0.0.0")
|
||||
|
@ -166,6 +167,7 @@ Flags:
|
|||
--prefix string root path for http handlers (for reverse proxying) (default "/")
|
||||
--profile register net/http/pprof handlers
|
||||
-r, --recursive recurse into subdirectories
|
||||
--redact redact admin prefix in log output
|
||||
--refresh enable automatic page refresh via query parameter
|
||||
--russian remove selected images after serving
|
||||
-s, --sort enable sorting
|
||||
|
|
|
@ -14,7 +14,7 @@ import (
|
|||
|
||||
const (
|
||||
AllowedCharacters string = `^[A-z0-9.\-_]+$`
|
||||
ReleaseVersion string = "3.8.0"
|
||||
ReleaseVersion string = "3.9.0"
|
||||
)
|
||||
|
||||
var (
|
||||
|
@ -48,6 +48,7 @@ var (
|
|||
Prefix string
|
||||
Profile bool
|
||||
Recursive bool
|
||||
Redact bool
|
||||
Refresh bool
|
||||
Russian bool
|
||||
Sorting bool
|
||||
|
@ -140,6 +141,7 @@ func init() {
|
|||
rootCmd.Flags().StringVar(&Prefix, "prefix", "/", "root path for http handlers (for reverse proxying)")
|
||||
rootCmd.Flags().BoolVar(&Profile, "profile", false, "register net/http/pprof handlers")
|
||||
rootCmd.Flags().BoolVarP(&Recursive, "recursive", "r", false, "recurse into subdirectories")
|
||||
rootCmd.Flags().BoolVar(&Redact, "redact", false, "redact admin prefix in log output")
|
||||
rootCmd.Flags().BoolVar(&Refresh, "refresh", false, "enable automatic page refresh via query parameter")
|
||||
rootCmd.Flags().BoolVar(&Russian, "russian", false, "remove selected images after serving")
|
||||
rootCmd.Flags().BoolVarP(&Sorting, "sort", "s", false, "enable sorting")
|
||||
|
|
|
@ -62,7 +62,7 @@ func noFiles(w http.ResponseWriter, r *http.Request) {
|
|||
w.Write([]byte("No files found in the specified path(s).\n"))
|
||||
|
||||
if Verbose {
|
||||
fmt.Printf("%s | SERVE: Empty path notice served to %s\n",
|
||||
fmt.Printf("%s | SERVE: Empty path notification to %s\n",
|
||||
startTime.Format(logDate),
|
||||
r.RemoteAddr,
|
||||
)
|
||||
|
@ -435,6 +435,10 @@ func serveVersion() httprouter.Handle {
|
|||
func registerHandler(mux *httprouter.Router, path string, handle httprouter.Handle) {
|
||||
mux.GET(path, handle)
|
||||
|
||||
if Redact && AdminPrefix != "" {
|
||||
path = strings.ReplaceAll(path, AdminPrefix, "/<admin_prefix>")
|
||||
}
|
||||
|
||||
if Handlers {
|
||||
fmt.Printf("%s | SERVE: Registered handler for %s\n",
|
||||
time.Now().Format(logDate),
|
||||
|
|
Loading…
Reference in New Issue