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

feat: add HOST config to control which network interface ld-relay binds to #354

Draft
wants to merge 1 commit into
base: v8
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ type MainConfig struct {
StreamURI ct.OptURLAbsolute `conf:"STREAM_URI"`
BaseURI ct.OptURLAbsolute `conf:"BASE_URI"`
ClientSideBaseURI ct.OptURLAbsolute `conf:"CLIENT_SIDE_BASE_URI"`
Host string `conf:"HOST"`
Port ct.OptIntGreaterThanZero `conf:"PORT"`
InitTimeout ct.OptDuration `conf:"INIT_TIMEOUT"`
HeartbeatInterval ct.OptDuration `conf:"HEARTBEAT_INTERVAL"`
Expand Down
3 changes: 2 additions & 1 deletion internal/application/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
// StartHTTPServer starts the server, with or without TLS. It returns immediately, starting the server
// on a separate goroutine; if the server fails to start up, it sends an error to the error channel.
func StartHTTPServer(
host string,
port int,
handler http.Handler,
tlsEnabled bool,
Expand All @@ -22,7 +23,7 @@ func StartHTTPServer(
loggers ldlog.Loggers,
) (*http.Server, <-chan error) {
srv := &http.Server{
Addr: fmt.Sprintf(":%d", port),
Addr: fmt.Sprintf("%s:%d", host, port),
Handler: handler,
ReadHeaderTimeout: 10 * time.Second,
}
Expand Down
2 changes: 2 additions & 0 deletions ld-relay.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,10 @@ func main() {
}

port := c.Main.Port.GetOrElse(config.DefaultPort)
host := c.Main.Host

_, errs := application.StartHTTPServer(
host,
port,
r,
c.Main.TLSEnabled,
Expand Down
Loading