diff --git a/README.md b/README.md index 2548c38..eedc701 100644 --- a/README.md +++ b/README.md @@ -33,25 +33,29 @@ For more features, see the [Configuration](#Configuration) file ``` $ webproc --help - Usage: webproc [options] args... - - args can be either a command with arguments or a webproc file - - Options: - --host, -h listening interface - --port, -p listening port (env PORT) - --user, -u basic auth username (env USER) - --pass basic auth password (env PASS) - --on-exit, -o process exit action (default ignore) - --config, -c comma-separated list of configuration files - --help - --version, -v - - Version: - 0.0.0-src - - Read more: - https://github.com/jpillora/webproc + Usage: webproc [options] [arg] ... + + args can be either a command with arguments or a webproc file + + Options: + --host, -h listening interface (default 0.0.0.0) + --port, -p listening port (default 8080, env PORT) + --user, -u basic auth username (env HTTP_USER) + --pass basic auth password (env HTTP_PASS) + --allowed-ip, -a allowed ip or cidr block (allows multiple) + --log, -l log mode (must be 'webui' or 'proxy' or 'both' defaults to 'both') + --on-exit, -o process exit action (default ignore) + --configuration-file, -c configuration file (allows multiple) + --restart-timeout, -r restart timeout controls when to perform a force kill (default 30s) + --max-lines, -m maximum number of log lines to show in webui (default 5000) + --version, -v display version + --help display help + + Version: + 0.0.0-src + + Read more: + https://github.com/jpillora/webproc ``` diff --git a/agent/config.go b/agent/config.go index 007e65b..a24cb9c 100644 --- a/agent/config.go +++ b/agent/config.go @@ -25,19 +25,20 @@ const ( OnExitProxy OnExit = "proxy" ) -//Config is shared for both toml unmarshalling and opts CLI generation +//Config is shared for both toml unmarshalling and opts CLI generation. +//Defaults are applied on ValidateConfig. type Config struct { - Host string `help:"listening interface"` - Port int `help:"listening port" env:"PORT"` - User string `help:"basic auth username" env:"HTTP_USER"` - Pass string `help:"basic auth password" env:"HTTP_PASS"` - AllowedIPs []string `opts:"-"` - ProgramArgs []string `type:"arglist" min:"1" name:"args" help:"args can be either a command with arguments or a webproc file"` - Log Log `opts:"-"` - OnExit OnExit `help:"process exit action" default:"ignore"` - ConfigurationFiles []string `name:"config" type:"commalist" help:"comma-separated list of configuration files"` - RestartTimeout Duration `opts:"-"` - MaxLines int `help:"maximum number of log lines to show in webui" default:"5000"` + Host string `opts:"help=listening interface, default=0.0.0.0"` + Port int `opts:"help=listening port, default=8080, env=PORT"` + User string `opts:"help=basic auth username, env=HTTP_USER"` + Pass string `opts:"help=basic auth password, env=HTTP_PASS"` + AllowedIPs []string `opts:"name=allowed-ip, help=allowed ip or cidr block"` + ProgramArgs []string `opts:"mode=arg, name=arg, help=args can be either a command with arguments or a webproc file, min=1"` + Log Log `opts:"help=log mode (must be 'webui' or 'proxy' or 'both' defaults to 'both')"` + OnExit OnExit `opts:"help=process exit action, default=ignore"` + ConfigurationFiles []string `opts:"mode=flag, help=writable configuration file"` + RestartTimeout Duration `opts:"help=restart timeout controls when to perform a force kill, default=30s"` + MaxLines int `opts:"help=maximum number of log lines to show in webui, default=5000"` } func LoadConfig(path string, c *Config) error { diff --git a/go.mod b/go.mod index 621338c..e3d1504 100644 --- a/go.mod +++ b/go.mod @@ -12,7 +12,7 @@ require ( github.com/jpillora/cookieauth v0.0.0-20181130112401-3b2db39b9d2c github.com/jpillora/eventsource v0.0.0-20170920003432-7ed8c999e167 // indirect github.com/jpillora/ipfilter v0.0.0-20180911073613-0cbe4c7e01b1 - github.com/jpillora/opts v0.0.0-20160806153215-3f7962811f23 + github.com/jpillora/opts v1.1.0 github.com/jpillora/requestlog v0.0.0-20181015073026-df8817be5f82 github.com/jpillora/sizestr v0.0.0-20160130011556-e2ea2fa42fb9 // indirect github.com/jpillora/velox v0.0.0-20180825063758-42845d323220 diff --git a/go.sum b/go.sum index 6894cbf..94dab5b 100644 --- a/go.sum +++ b/go.sum @@ -8,6 +8,10 @@ github.com/elithrar/simple-scrypt v1.3.0 h1:KIlOlxdoQf9JWKl5lMAJ28SY2URB0XTRDn2T github.com/elithrar/simple-scrypt v1.3.0/go.mod h1:U2XQRI95XHY0St410VE3UjT7vuKb1qPwrl/EJwEqnZo= github.com/gorilla/websocket v1.4.0 h1:WDFjx/TMzVgy9VdMMQi2K2Emtwi2QcUQsztZ/zLaH/Q= github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= +github.com/hashicorp/errwrap v1.0.0 h1:hLrqtEDnRye3+sgx6z4qVLNuviH3MR5aQ0ykNJa/UYA= +github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= +github.com/hashicorp/go-multierror v1.0.0 h1:iVjPR7a6H0tWELX5NxNe7bYopibicUzc7uPribsnS6o= +github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk= github.com/hashicorp/golang-lru v0.5.0 h1:CL2msUPvZTLb5O648aiLNJw3hnBxN2+1Jq8rCOH9wdo= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/jpillora/ansi v0.0.0-20170202005112-f496b27cd669 h1:l5rH/CnVVu+HPxjtxjM90nHrm4nov3j3RF9/62UjgLs= @@ -22,6 +26,8 @@ github.com/jpillora/ipfilter v0.0.0-20180911073613-0cbe4c7e01b1 h1:uVa/fnx/kuryY github.com/jpillora/ipfilter v0.0.0-20180911073613-0cbe4c7e01b1/go.mod h1:cVpzWD9ypibSo5IdbBqJf9dVKW/pPeLGx0q+4X7k5rk= github.com/jpillora/opts v0.0.0-20160806153215-3f7962811f23 h1:Oba9AG0bpHgp5FZFG+XfiNDlFX6tLO0AWCMe/YJR0GM= github.com/jpillora/opts v0.0.0-20160806153215-3f7962811f23/go.mod h1:8/sC6XyMKHq/ybiU9Oqc1i0tDjFA/6otW7+Ha/qtnfo= +github.com/jpillora/opts v1.1.0 h1:eP4c8yn68iN4OgQ/6nTAWd+obufJOwUvAqW7dYzvCwA= +github.com/jpillora/opts v1.1.0/go.mod h1:7p7X/vlpKZmtaDFYKs956EujFqA6aCrOkcCaS6UBcR4= github.com/jpillora/requestlog v0.0.0-20181015073026-df8817be5f82 h1:7ufdyC3aMxFcCv+ABZy/dmIVGKFoGNBCqOgLYPIckD8= github.com/jpillora/requestlog v0.0.0-20181015073026-df8817be5f82/go.mod h1:w8buj+yNfmLEP0ENlbG/FRnK6bVmuhqXnukYCs9sDvY= github.com/jpillora/sizestr v0.0.0-20160130011556-e2ea2fa42fb9 h1:0c9jcgBtHRtDU//jTrcCgWG6UHjMZytiq/3WhraNgUM= @@ -38,6 +44,8 @@ github.com/naoina/toml v0.1.1 h1:PT/lllxVVN0gzzSqSlHEmP8MJB4MY2U7STGxiouV4X8= github.com/naoina/toml v0.1.1/go.mod h1:NBIhNtsFMo3G2szEBne+bO4gS192HuIYRqfvOWb4i1E= github.com/oschwald/maxminddb-golang v1.3.0 h1:oTh8IBSj10S5JNlUDg5WjJ1QdBMdeaZIkPEVfESSWgE= github.com/oschwald/maxminddb-golang v1.3.0/go.mod h1:3jhIUymTJ5VREKyIhWm66LJiQt04F0UCDdodShpjWsY= +github.com/posener/complete v1.2.2-0.20190308074557-af07aa5181b3 h1:GqpA1/5oN1NgsxoSA4RH0YWTaqvUlQNeOpHXD/JRbOQ= +github.com/posener/complete v1.2.2-0.20190308074557-af07aa5181b3/go.mod h1:6gapUrK/U1TAN7ciCoNRIdVC5sbdBTUh1DKN0g6uH7E= github.com/rakyll/statik v0.1.5 h1:Ly2UjURzxnsSYS0zI50fZ+srA+Fu7EbpV5hglvJvJG0= github.com/rakyll/statik v0.1.5/go.mod h1:OEi9wJV/fMUAGx1eNjq75DKDsJVuEv1U0oYdX6GX8Zs= github.com/tomasen/realip v0.0.0-20180522021738-f0c99a92ddce h1:fb190+cK2Xz/dvi9Hv8eCYJYvIGUTN2/KLq1pT6CjEc=