File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -180,13 +180,20 @@ func InitConfig() (*Config, error) {
180180 }
181181
182182 // check listenIP and proxyPort
183- if net .ParseIP (listenIP ) == nil {
184- return nil , fmt .Errorf ("invalid IP \" %s\" for listenip" , listenIP )
185- }
186183 if proxyPort < 1 || proxyPort > 65535 {
187- return nil , errors .New ("port number has to be between 1 and 65535" )
184+ return nil , errors .New ("port number has to be between 1 and 65535" )
185+ }
186+ ip := net .ParseIP (listenIP )
187+ if ip == nil {
188+ return nil , fmt .Errorf ("invalid IP \" %s\" for listenip" , listenIP )
189+ }
190+
191+ // Properly format address for both IPv4 and IPv6
192+ if ip .To4 () == nil {
193+ cfg .ListenAddress = fmt .Sprintf ("[%s]:%d" , listenIP , proxyPort )
194+ } else {
195+ cfg .ListenAddress = fmt .Sprintf ("%s:%d" , listenIP , proxyPort )
188196 }
189- cfg .ListenAddress = fmt .Sprintf ("%s:%d" , listenIP , proxyPort )
190197
191198 // parse defaultLogLevel and setup logging handler depending on defaultLogJSON
192199 switch strings .ToUpper (logLevel ) {
You can’t perform that action at this time.
0 commit comments