Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possibility to specify listening IP #17

Merged
merged 2 commits into from
Sep 30, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion lnme.go
Original file line number Diff line number Diff line change
Expand Up @@ -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") != "" {
fiksn marked this conversation as resolved.
Show resolved Hide resolved
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 {
Expand All @@ -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:])
Expand Down