goproxy icon indicating copy to clipboard operation
goproxy copied to clipboard

IsLocalHost only works with default ports

Open mmatczuk opened this issue 2 years ago • 1 comments

It was originally observed in https://github.com/elazarl/goproxy/issues/289.

The IsLocalHost function uses req.URL.Host https://github.com/elazarl/goproxy/blob/a0805db90819b464f8fadc660e23a6a6b9d4942f/dispatcher.go#L105

It can be host or host:port. In the latter case the check simply does not work. It's not documented and it simply looks like a bug. It should be using the Hostname function instead.

mmatczuk avatar Nov 07 '22 12:11 mmatczuk

It seems this is not the only problem the var localHostIpv4 = regexp.MustCompile(127.0.0.\d+) matches everything that contains the 127.0.0. string say my127.0.0.foo.

mmatczuk avatar Nov 07 '22 13:11 mmatczuk