Opened 2 years ago
Closed 22 months ago
#22497 closed enhancement (fixed)
[Patch] Add a setting opposite to proxy.exceptions
Reported by: | TrickyFoxy | Owned by: | team |
---|---|---|---|
Priority: | normal | Milestone: | 23.02 |
Component: | Core | Version: | |
Keywords: | proxy | Cc: |
Description
Now, using proxy.exceptions
, you can specify ip addresses that will go past the proxy. But sometimes you need to specify addresses that will definitely go through a proxy. Something like proxy.allow
For example:
osm api is blocked in China https://www.openstreetmap.org/user/booktiger/diary/400233
And Maxar satellite images are not available in Russia https://t.me/ruosm/692015
It was much more convenient to specify addresses in JOSM that are blocked so that only they go to the proxy. It will be enough for the user to enable Tor browser, specify it as a proxy and the ip addresses that need to be proxied.
Attachments (5)
Change History (16)
comment:1 by , 2 years ago
Keywords: | proxy added |
---|
by , 2 years ago
Attachment: | Снимок экрана 2022-12-02 в 00.14.06.png added |
---|
comment:2 by , 2 years ago
I decided to try my hand and implement it. I'm not very good with English, so the naming most likely contains grammatical errors.
What is done in the patch:
- Added
proxy.includes
- If any type of proxy is selected, and there is at least one element in
proxy.includes
, then it is checked whether the host is inproxy.includes
. If not, then the request to the host goes past the proxy. - In the settings in the Proxy section, you can now edit
proxy.exceptions
andproxy.includes
Also, I'm not very familiar with the JOSM code yet, so check if I forgot to do something (translations, style)
comment:3 by , 2 years ago
Summary: | Add a setting opposite to proxy.exceptions → [Patch] Add a setting opposite to proxy.exceptions |
---|
comment:4 by , 23 months ago
I know that JOSM is developed by volunteers and in their spare time, but just in case, I will make a ping comment.
comment:5 by , 23 months ago
Milestone: | → 23.02 |
---|
comment:7 by , 23 months ago
The name proxy.includes
doesn't really say anything about what it's for. Maybe it should be called something like proxy.only-for-hosts
.
I think the if (!proxyIncludes.isEmpty() && !proxyIncludes.contains(uri.getHost()))
check could be moved out of the switch and done once beforehand similar to the exclude check instead of being repeated in every switch case? (It might also need a null check for the uri similar to the exclude check)
comment:9 by , 23 months ago
I've got a few comments on the patch.
- There are several locations where an NPE could be thrown. From the specification for the method, the argument should be expected to be
null
at some point/** [...snip...] * @throws IllegalArgumentException if the argument is null or if * the protocol or host cannot be determined from the provided * {@code uri} */
- It would have helped if the switch statement indentation hadn't changed. This is probably your IDE at work, and I was able to work around it. If you decide to compare my patch with your patch, please keep that in mind.
Arrays.asList()
->Collections.emptyList()
- Multiple branches have the same implementation (
if (httpProxySocketAddress == null) { return NO_PROXY_LIST; } if (!proxyIncludes.isEmpty() && !proxyIncludes.contains(uri.getHost())) { return NO_PROXY_LIST; }
)- This isn't caught by SonarLint yet, but it probably should be. (java:S1871)
I'll upload my suggested changes so you can play around with it a bit -- I don't have a proxy set up, and while the specification for that method says that we should be throwing an IAE, it doesn't mean that other code expects that.
by , 23 months ago
Attachment: | 22497.patch added |
---|
comment:10 by , 23 months ago
Thank you for your comments. Corrected code duplication in switch branches, and indentation when initializing proxyExceptions
:
by , 23 months ago
Attachment: | Include_proxy_hosts__Correcting_code_duplication.patch added |
---|
Proxy on