From 908ad52ee25d794c9445e0d4ad17ab196d6bbf2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gregor=20Poga=C4=8Dnik?= <1640719+fiksn@users.noreply.github.com> Date: Tue, 28 Sep 2021 12:20:05 +0000 Subject: [PATCH] Possibility to specify listening IP --- lnme.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lnme.go b/lnme.go index 2910a0f..42c7e98 100644 --- a/lnme.go +++ b/lnme.go @@ -188,7 +188,15 @@ func main() { if os.Getenv("PORT") != "" { port = os.Getenv("PORT") } - e.Logger.Fatal(e.Start(":" + port)) + listen := cfg.String("listen") + if os.Getenv("LISTEN") != "" { + listen = os.Getenv("LISTEN") + } + if strings.Contains(listen, ":") { + listen = fmt.Sprintf("[%s]", listen) + } + + e.Logger.Fatal(e.Start(fmt.Sprintf("%s:%s", listen, port))) } func LoadConfig() *koanf.Koanf { @@ -204,6 +212,7 @@ func LoadConfig() *koanf.Koanf { f.Float64("request-limit", 5, "Request limit per second.") f.String("static-path", "", "Path to a static assets directory.") f.String("port", "1323", "Port to bind on.") + f.String("listen", "", "Address to bind on.") var configPath string f.StringVar(&configPath, "config", "config.toml", "Path to a .toml config file.") f.Parse(os.Args[1:])