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

Add support to exclude hosts from proxy #19139

Merged
merged 1 commit into from May 6, 2022

Conversation

juergenthomann
Copy link
Contributor

Description:

This add supports for curls noproxy option.

The support is not added for the other transports as that would involve manually splitting (if multiple should be supported) and matching of hosts. Curl also supports whole domains instead of just hosts so the logic would be a bit more complicated.

For the naming: normally I would have used the name no_proxy, but that causes names in the code like proxyNoproxy which I personally did not like, but I'll change it, if that is preferred (or even something else)

I'm not sure where I can update https://matomo.org/faq/troubleshooting/faq_121/ but that page could be updated to include the new option

Review

@sgiehl sgiehl added the Needs Review PRs that need a code review label Apr 25, 2022
@github-actions
Copy link
Contributor

github-actions bot commented May 3, 2022

This issue is in "needs review" but there has been no activity for 7 days. ping @matomo-org/core-reviewers

@github-actions github-actions bot added the Stale The label used by the Close Stale Issues action label May 3, 2022
Copy link
Member

@sgiehl sgiehl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a tiny comment, otherwise this looks good in general.
Regarding support for other transport methods. I see that it would be a bit more complicated to rebuilt the behavior, the no_proxy option of curl has. But we could define that for other requests methods we only do an exact host compare for now. So it would be a simple in_array check (after applying explode on the config)

config/global.ini.php Outdated Show resolved Hide resolved
@juergenthomann
Copy link
Contributor Author

Thank you for the review.

I checked how I could integrate the changes in the other transports and that would result in having the explode + in_array logic for both transports and different logic for curl. I now changed the behavior to check this once in the getProxyConfiguration method and have it the same way for all transports. In my use case this would be enough and there was already logic to exclude localhost.

I also tried to write a small unit test for it. I never had to write them before so it is mostly inspired by what I found in other tests. If something is not how it should be, let me know and I will change it.

@juergenthomann juergenthomann changed the title Add support to exclude hosts from proxy with libcurl Add support to exclude hosts from proxy May 4, 2022
@github-actions github-actions bot removed the Stale The label used by the Close Stale Issues action label May 5, 2022
Copy link
Member

@sgiehl sgiehl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left some comments for minor improvements. Otherwise this already looks good. Awesome that you even added some tests 💯

config/global.ini.php Outdated Show resolved Hide resolved
core/Http.php Outdated Show resolved Hide resolved
@sgiehl sgiehl removed the Needs Review PRs that need a code review label May 6, 2022
Copy link
Member

@sgiehl sgiehl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good now. I've already updated the FAQ, so the new setting is mentioned there.
This will be included in Matomo 4.11.0.
Thanks for your contribution @juergenthomann

@sgiehl sgiehl added the Enhancement For new feature suggestions that enhance Matomo's capabilities or add a new report, new API etc. label May 6, 2022
@sgiehl sgiehl merged commit f4f46a2 into matomo-org:4.x-dev May 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement For new feature suggestions that enhance Matomo's capabilities or add a new report, new API etc.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants