Ticket #4011 (new enhancement)

Opened 1 year ago

Last modified 3 months ago

add global proxy support in options

Reported by: tmountjr Assigned to: anonymous
Priority: normal Milestone: 2.9
Component: General Version: 2.2
Severity: normal Keywords: proxy snoopy needs-patch needs-testing
Cc:

Description

I use the 2.2-bleeding SVN build of WP on a local install to test upcoming changes to the system before putting them on my live blog. In order to test accurately, I installed FeedWordPress? to pull my live RSS feed. I couldn't figure out why it wouldn't pull my feeds (even after adding all the appropriate snoopy proxy variables in the plugin) unless I set the proxy in wp-includes/class-snoopy.php. Ticket 3082 details the same problem. Perhaps a set of define statements could be added to wp-config.php:

define('WP_PROXYHOST', 'proxy.server.com'); define('WP_PROXYPORT', '8080'); define('WP_USEPROXY', 'TRUE');

In wp-includes/class-snoopy.php, for instance, the current code could be changed to respect the proxy settings if entered:

var $proxy_host = WP_PROXYHOST; var $proxy_port = WP_PROXYPORT; var $_isproxy = (WP_USEPROXY == 'TRUE') : true ? false;

These settings could also be carried over to Akismet and any other class that uses snoopy or fsockopen; I successfully tested this in class-snoopy.php. Besides not remembering my ternary operators for the _isproxy variable, the change works and applies to all instances where WP is using snoopy to get something from the web.

I'd be happy to work up something official if anyone thinks it's worth it...

Attachments

wp-config-sample.php.diff (0.7 kB) - added by tmountjr on 03/23/07 16:13:28.
sample wp-config file with added support for proxy variables
class-snoppy.php.diff (1.2 kB) - added by tmountjr on 03/23/07 16:15:04.
updated Snoopy class with support for proxy variables
class-IXR.php.diff (1.0 kB) - added by tmountjr on 03/23/07 16:15:53.
updated IXR-RPC class file with proxy support for fsockopen
functions.php.diff (2.5 kB) - added by tmountjr on 04/03/07 13:03:02.
updated to include support in get_headers and curl libraries

Change History

03/21/07 21:08:23 changed by foolswisdom

  • milestone set to 2.3.

03/23/07 16:13:28 changed by tmountjr

  • attachment wp-config-sample.php.diff added.

sample wp-config file with added support for proxy variables

03/23/07 16:15:04 changed by tmountjr

  • attachment class-snoppy.php.diff added.

updated Snoopy class with support for proxy variables

03/23/07 16:15:53 changed by tmountjr

  • attachment class-IXR.php.diff added.

updated IXR-RPC class file with proxy support for fsockopen

03/23/07 16:24:23 changed by tmountjr

  • keywords changed from proxy snoopy to proxy snoopy has-patch needs-testing.

I've created and attached a few patches:

/wp-config-sample.php - adds support for proxy variables in the sample config file.

/wp-includes/functions.php - adds proxy support for fsockopen

/wp-includes/class-snoopy.php - adds proxy support for snoopy

/wp-includes/class-IXR.php - adds proxy support for fsockopen in the IXR-RPC class

These have been tested on mirror installations - one live (no proxy, so no options in wp-config.php set) and one local (with proxy, options set in wp-config.php). Both appear to work well. I think if no proxy is set the change would be transparent. What needs further testing is how the changes respond in a proxy environment. At the moment Snoopy works well in my environment, but I'm a little less clear on fsockopen and how that will respond, particularly in an environment where HTTP authentication is used.

04/03/07 13:03:02 changed by tmountjr

  • attachment functions.php.diff added.

updated to include support in get_headers and curl libraries

04/03/07 13:05:09 changed by tmountjr

I just modified functions.php.diff so that both instances of fsockopen were proxied. I also added the support for curl in the same file.

09/12/07 02:54:07 changed by ryan

  • milestone changed from 2.3 to 2.4 (next).

09/27/07 22:34:45 changed by Johnny_one_eye

I think this patch is great, as I could really use it. I've been trying it out, and I only have 1 problem with it. My proxy doesn't require authentication (user/pass). I think you should probably edit it so that it would check if I need a user/pass and adjust accordingly...

(follow-up: ↓ 7 ) 10/24/07 12:27:51 changed by dubelclique

the patch worked for me on my pre-2.3 installs, but i can't get it to work on my 2.3 install; i'm positive i'm patching the right code, but i think there's something else in need of revision in 2.3.

any ideas? is the 2.4 milestone definite? i'm pretty surprised this isn't more of an issue for folks.

(in reply to: ↑ 6 ) 10/24/07 12:57:28 changed by westi

  • keywords changed from proxy snoopy has-patch needs-testing to proxy snoopy needs-patch needs-testing.

Replying to dubelclique:

the patch worked for me on my pre-2.3 installs, but i can't get it to work on my 2.3 install; i'm positive i'm patching the right code, but i think there's something else in need of revision in 2.3. any ideas? is the 2.4 milestone definite? i'm pretty surprised this isn't more of an issue for folks.

The 2.4 milestone is suggested not definite - if this issue is not resolved when it comes to releasing 2.4 then it will be bumped to 2.5

I think a better fix to this issue is to move all direct uses of fsockopen to a wrapped version which provides the proxy support (and possibly uses curl is fsockopen is disabled)

Then all places where we have duplicated fsockopen code can use this one route.

03/19/08 11:09:53 changed by thee17

  • milestone changed from 2.5 to 2.6.

06/06/08 10:46:23 changed by futtta

just bumping up, support for proxies is very important if we want to enable intranet-deployments of wordpress. servers on an intranet rarely have a direct connection to the internet (proxy or even no connection at all). currently this means wordpress will stop working after some time, with timeouts caused by attempts to connect to the internet to check for updates for core/ plugins.

not only should one be able to configure a proxy (+ proxy authentication info), you should also be able to specify there is no connection to the internet at all?

i tried to add 'return false' to a number of update functions, but ended up disabling fsockopen in php.ini all together. a pain, really.

06/06/08 10:52:51 changed by DD32

In the event of #4779 being implemented, It should allow a global proxy setting to be added with ease without too much trouble.