1
4
mirror of https://github.com/yunginnanet/HellPot synced 2024-06-24 23:08:03 +00:00

CLI: Use options flag, not positional args

This commit is contained in:
Carl Johnson 2016-12-11 18:24:13 -05:00
parent b5b634b579
commit e1222e014d
2 changed files with 12 additions and 20 deletions

@ -6,10 +6,11 @@ The source of the honeypot data is [Once On a Time](http://www.gutenberg.org/fil
## Usage
Usage of heffalump:
heffalump [<network address> [<path>]]
heffalump [opts]
heffalump serves an endless HTTP honeypot
<network address> defaults to ":8080".
<path> defaults to "/". Paths ending in "/" will match all sub-pathes.
-addr string
Address to serve (default "127.0.0.1:8080")
-path string
Path to serve from. Path ending in / serves sub-paths. (default "/")

@ -12,33 +12,24 @@ import (
const usage = `Usage of heffalump:
heffalump [<network address> [<path>]]
heffalump [opts]
heffalump serves an endless HTTP honeypot
<network address> defaults to ":8080".
<path> defaults to "/". Paths ending in "/" will match all sub-pathes.
`
func main() {
flag.Usage = func() {
fmt.Fprintf(os.Stderr, usage)
flag.PrintDefaults()
}
addr := flag.String("addr", "127.0.0.1:8080", "Network address to listen on")
path := flag.String("path", "/", `Path to serve from. Path ending in / serves sub-paths.`)
flag.Parse()
addr := flag.Arg(0)
if addr == "" {
addr = ":8080"
}
http.HandleFunc(*path, heff.DefaultHoneypot)
path := flag.Arg(1)
if path == "" {
path = "/"
}
http.HandleFunc(path, heff.DefaultHoneypot)
log.Fatal(http.ListenAndServe(addr, nil))
log.Fatal(http.ListenAndServe(*addr, nil))
}