Modify

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)

Снимок экрана 2022-12-02 в 00.14.06.png (659.1 KB ) - added by TrickyFoxy 2 years ago.
Proxy on
Снимок экрана 2022-12-02 в 00.16.05.png (656.2 KB ) - added by TrickyFoxy 2 years ago.
Proxy off
Include_proxy_hosts.patch (9.8 KB ) - added by TrickyFoxy 2 years ago.
Patch
22497.patch (9.4 KB ) - added by taylor.smock 23 months ago.
Include_proxy_hosts__Correcting_code_duplication.patch (8.4 KB ) - added by TrickyFoxy 23 months ago.

Download all attachments as: .zip

Change History (16)

comment:1 by skyper, 2 years ago

Keywords: proxy added

by TrickyFoxy, 2 years ago

Proxy on

by TrickyFoxy, 2 years ago

Proxy off

by TrickyFoxy, 2 years ago

Attachment: Include_proxy_hosts.patch added

Patch

comment:2 by TrickyFoxy, 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 in proxy.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 and proxy.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 skyper, 2 years ago

Summary: Add a setting opposite to proxy.exceptions[Patch] Add a setting opposite to proxy.exceptions

comment:4 by TrickyFoxy, 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 stoecker, 23 months ago

Milestone: 23.02

comment:6 by stoecker, 23 months ago

Looks ok to me.

comment:7 by Woazboat, 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:8 by TrickyFoxy, 23 months ago

How about proxy.proxied-hosts or proxy.only-these-hosts?

comment:9 by taylor.smock, 23 months ago

I've got a few comments on the patch.

  1. 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}
         */
    
  2. 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.
  3. Arrays.asList() -> Collections.emptyList()
  4. 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 taylor.smock, 23 months ago

Attachment: 22497.patch added

comment:10 by TrickyFoxy, 23 months ago

Thank you for your comments. Corrected code duplication in switch branches, and indentation when initializing proxyExceptions:

comment:11 by taylor.smock, 22 months ago

Resolution: fixed
Status: newclosed

In 18663/josm:

Fix #22497: Add setting to only proxy specific hosts (patch by TrickyFoxy)

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain team.
as The resolution will be set.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.