Skip to content
This repository has been archived by the owner on Dec 4, 2018. It is now read-only.

CURLOPT_INTERFACE setup breaks on proxy setup #109

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

CURLOPT_INTERFACE setup breaks on proxy setup #109

wants to merge 2 commits into from

Conversation

dotroll
Copy link

@dotroll dotroll commented May 13, 2011

Dear authors!

We recently changed our network layout and had a complaint from one of our users, thet EpiTwitter wasn't working any more. As we found out, EpiOAuth tries to determine the interface address from the SERVER_ADDR as requested in your Issue #26. Unfortunately this breaks, if the hosting provider has a proxy setup and uses a different network interface for user communication as for proxy-webhost communication.

We have added a small patch to exclude the private address ranges as per RFC 1918. This is fixed in our issue #1. This is not a fool-proof fix, so you should add a switch to turn this funcionality on if somebody absolutely needs it. Otherwise the sysop should configure routing, so you don't need to touch interface binding.

Yours sincerely

Janos Pasztor
DotRoll Ltd.

@jmathai
Copy link
Owner

jmathai commented May 13, 2011

Thanks for this. I'll have a look and merge the request appropriately.

@@ -168,7 +168,8 @@ class EpiOAuth
curl_setopt($ch, CURLOPT_ENCODING, '');
if($this->followLocation)
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
if(isset($_SERVER ['SERVER_ADDR']) && !empty($_SERVER['SERVER_ADDR']) && $_SERVER['SERVER_ADDR'] != '127.0.0.1')
if(isset($_SERVER ['SERVER_ADDR']) && !empty($_SERVER['SERVER_ADDR']) &&
!preg_match('/^(|10\.127\.|192\.168\.|172\.(16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31)\.)/', $_SERVER['SERVER_ADDR']))
Copy link

Choose a reason for hiding this comment

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

This line has the regexp messed up, needs a fix.

@@ -168,7 +168,8 @@ class EpiOAuth
curl_setopt($ch, CURLOPT_ENCODING, '');
if($this->followLocation)
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
if(isset($_SERVER ['SERVER_ADDR']) && !empty($_SERVER['SERVER_ADDR']) && $_SERVER['SERVER_ADDR'] != '127.0.0.1')
if(isset($_SERVER ['SERVER_ADDR']) && !empty($_SERVER['SERVER_ADDR']) &&
!preg_match('/^(10\.|127\.|192\.168\.|172\.(16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31)\.)/', $_SERVER['SERVER_ADDR']))
Copy link
Author

Choose a reason for hiding this comment

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

The regexp is now fixed.

@zemaj
Copy link

zemaj commented Feb 22, 2013

We spent several days trying to find out what the problem was when this lib didn't work in our production environment, but worked everything else. This turned out to be the issue - it was forcing curl to use the wrong network interface when receiving traffic from our load balancer.

@jmathai
Copy link
Owner

jmathai commented Feb 22, 2013

@zemaj Thanks for posting a follow up. We should merge this in. I've been terribly busy with other things and there's another PR which adds support for the 1.1 version of the API. Once the unit tests for that are done I'll merge this in.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants