diff --git a/README.md b/README.md index b2d07b1..d0b01e4 100644 --- a/README.md +++ b/README.md @@ -34,19 +34,26 @@ location '/wp-login.php' { If the configuration file is missing, the default settings will automatically drop itself in the current working directory as `config.toml`. ``` -title = "HellPot" - -[logger] -debug = false -log_directory = "./logs/" +[diception] + server_name = "nginx" [http] -bind_addr = "127.0.0.1" -bind_port = "8080" -# paths to be added to robots.txt that we will respond to -paths = [ - "wp-login.php", - "wp-login", -] + bind_addr = "127.0.0.1" + bind_port = "8080" + paths = ["wp-login.php","wp-login"] + unix_socket = "/var/run/hellpot" + use_unix_socket = false + +[logger] + debug = true + directory = "/home/kayos/.config/HellPot/logs/" + nocolor = false + use_date_filename = true + +[performance] + # max_workers is only valid if restrict_concurrency is true + restrict_concurrency = false + max_workers = 256 + ``` diff --git a/config/config.go b/config/config.go index 104f9e1..b654c96 100644 --- a/config/config.go +++ b/config/config.go @@ -53,6 +53,7 @@ var ( f *os.File err error + NoColorForce = false NoColor bool customconfig = false home string @@ -159,10 +160,10 @@ func setDefaults() { "use_date_filename": true, } Opt["http"] = map[string]interface{}{ - "use_unix_socket": false, - "unix_socket": "/var/run/hellpot", - "bind_addr": "127.0.0.1", - "bind_port": "8080", + "use_unix_socket": false, + "unix_socket_path": "/var/run/hellpot", + "bind_addr": "127.0.0.1", + "bind_port": "8080", "paths": []string{ "wp-login.php", "wp-login", @@ -215,12 +216,17 @@ func argParse() { for i, arg := range os.Args { switch arg { case "-h": - println("HellPot: use -c to specify config file.") + println("HellPot Usage") + println("-c - Specify config file") + println("--nocolor - disable color and banner ") + println("--banner - show banner + version and exit") os.Exit(0) - case "--config": - fallthrough + case "--nocolor": + NoColorForce = true case "--banner": BannerOnly = true + case "--config": + fallthrough case "-c": if len(os.Args) <= i-1 { panic("syntax error! expected file after -c") @@ -246,7 +252,6 @@ func associate() { Opt = newOpt Debug = snek.GetBool("logger.debug") logDir = snek.GetString("logger.directory") - NoColor = snek.GetBool("logger.nocolor") BindAddr = snek.GetString("http.bind_addr") BindPort = snek.GetString("http.bind_port") Paths = snek.GetStringSlice("http.paths") @@ -254,7 +259,10 @@ func associate() { FakeServerName = snek.GetString("diception.server_name") RestrictConcurrency = snek.GetBool("performance.restrict_concurrency") MaxWorkers = snek.GetInt("performance.max_workers") - + NoColor = snek.GetBool("logger.nocolor") + if NoColorForce { + NoColor = true + } if UseUnixSocket { UnixSocketPath = snek.GetString("http.unix_socket_path") } diff --git a/http/router.go b/http/router.go index 40bdc09..7cf17c6 100644 --- a/http/router.go +++ b/http/router.go @@ -65,9 +65,7 @@ func listenOnUnixSocket(addr string, r *router.Router) error { unixAddr, err = net.ResolveUnixAddr("unix", addr) if err == nil { // Always unlink sockets before listening on them - if err2 := syscall.Unlink(addr); err2 != nil { - panic(err2) - } + syscall.Unlink(addr) unixListener, err = net.ListenUnix("unix", unixAddr) if err == nil { err = fasthttp.Serve(unixListener, r.Handler)