diff --git a/display.go b/display.go index ab9e601..4220c76 100644 --- a/display.go +++ b/display.go @@ -22,7 +22,7 @@ const maxDisplayFileSizeBytes = 1024 * 512 var cliUserAgentRe = regexp.MustCompile("(?i)(lib)?curl|wget") func fileDisplayHandler(c web.C, w http.ResponseWriter, r *http.Request) { - if cliUserAgentRe.MatchString(r.Header.Get("User-Agent")) { + if !Config.noDirectAgents && cliUserAgentRe.MatchString(r.Header.Get("User-Agent")) { fileServeHandler(c, w, r) return } diff --git a/server.go b/server.go index daaf89e..ba0efb8 100644 --- a/server.go +++ b/server.go @@ -58,6 +58,7 @@ var Config struct { remoteAuthFile string addHeaders headerList googleShorterAPIKey string + noDirectAgents bool } var Templates = make(map[string]*pongo2.Template) @@ -243,6 +244,8 @@ func main() { "Add an arbitrary header to the response. This option can be used multiple times.") flag.StringVar(&Config.googleShorterAPIKey, "googleapikey", "", "API Key for Google's URL Shortener.") + flag.BoolVar(&Config.noDirectAgents, "nodirectagents", false, + "disable serving files directly for wget/curl user agents") iniflags.Parse()