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

IsLocalHost only works with default ports #487

Open
mmatczuk opened this issue Nov 7, 2022 · 1 comment · May be fixed by #488
Open

IsLocalHost only works with default ports #487

mmatczuk opened this issue Nov 7, 2022 · 1 comment · May be fixed by #488

Comments

@mmatczuk
Copy link

mmatczuk commented Nov 7, 2022

It was originally observed in #289.

The IsLocalHost function uses req.URL.Host

return req.URL.Host == "::1" ||

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 added a commit to mmatczuk/goproxy that referenced this issue Nov 7, 2022
Without this patch IsLocalHost does not work for URLs with port specified i.e. it works for `http://localhost` but does not work for `http://localhost:80` or `http://localhost:10000`.

Fixes elazarl#487
@mmatczuk mmatczuk linked a pull request Nov 7, 2022 that will close this issue
mmatczuk added a commit to mmatczuk/goproxy that referenced this issue Nov 7, 2022
Without this patch IsLocalHost does not work for URLs with port specified i.e. it works for `http://localhost` but does not work for `http://localhost:80` or `http://localhost:10000`.

Fixes elazarl#487
@mmatczuk
Copy link
Author

mmatczuk commented Nov 7, 2022

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 added a commit to mmatczuk/goproxy that referenced this issue Nov 7, 2022
Without this patch IsLocalHost does not work for URLs with port specified i.e. it works for `http://localhost` but does not work for `http://localhost:80` or `http://localhost:10000`.

Fixes elazarl#487
mmatczuk added a commit to mmatczuk/goproxy that referenced this issue Nov 8, 2022
Without this patch IsLocalHost does not work for URLs with port specified i.e. it works for `http://localhost` but does not work for `http://localhost:80` or `http://localhost:10000`.

Fixes elazarl#487
mmatczuk added a commit to mmatczuk/goproxy that referenced this issue Nov 9, 2022
Without this patch IsLocalHost does not work for URLs with port specified i.e. it works for `http://localhost` but does not work for `http://localhost:80` or `http://localhost:10000`.

Fixes elazarl#487
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant