From 606beda91c70cafbde5bd93783cb03949ebe0ee3 Mon Sep 17 00:00:00 2001 From: ache Date: Sun, 16 May 2021 04:22:01 +0200 Subject: Force host with cli arg --- server.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'server.go') diff --git a/server.go b/server.go index 820a21a..eab1e75 100644 --- a/server.go +++ b/server.go @@ -414,6 +414,7 @@ func main() { var dirRoot string var help, version bool var port = -1 + var host string helpString := `This is the help` versionString := "0.0.0" @@ -425,9 +426,12 @@ func main() { usageDir = "the directory to serve" usageHelp = "show some help" usageVersion = "show the version" + usageHost = "select the host adress" ) flag.StringVar(&dirRoot, "directory", "", usageDir) - flag.StringVar(&dirRoot, "d", "", usageDir + " (shorthand)") + flag.StringVar(&dirRoot, "d", "localhost", usageHost + " (shorthand)") + flag.StringVar(&host, "hostname", "", usageHost) + flag.StringVar(&host, "H", "", usageHost + " (shorthand)") flag.IntVar(&port, "port", 0, portUsage) flag.IntVar(&port, "p", 0, portUsage + " (shorthand)") flag.BoolVar(&help, "help", false, usageHelp) @@ -467,6 +471,9 @@ func main() { dirRoot = defaultRoot } } + if host != "" { + config.Config.Hostnames = []string{host} + } fmap := template.FuncMap{ "formatURL": encodeURL, -- cgit v1.2.3