Skip to content
Merged
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
17 changes: 12 additions & 5 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,13 +180,20 @@ func InitConfig() (*Config, error) {
}

// check listenIP and proxyPort
if net.ParseIP(listenIP) == nil {
return nil, fmt.Errorf("invalid IP \"%s\" for listenip", listenIP)
}
if proxyPort < 1 || proxyPort > 65535 {
return nil, errors.New("port number has to be between 1 and 65535")
return nil, errors.New("port number has to be between 1 and 65535")
}
ip := net.ParseIP(listenIP)
if ip == nil {
return nil, fmt.Errorf("invalid IP \"%s\" for listenip", listenIP)
}

// Properly format address for both IPv4 and IPv6
if ip.To4() == nil {
cfg.ListenAddress = fmt.Sprintf("[%s]:%d", listenIP, proxyPort)
} else {
cfg.ListenAddress = fmt.Sprintf("%s:%d", listenIP, proxyPort)
}
cfg.ListenAddress = fmt.Sprintf("%s:%d", listenIP, proxyPort)

// parse defaultLogLevel and setup logging handler depending on defaultLogJSON
switch strings.ToUpper(logLevel) {
Expand Down