Re: How to limit source IP in PHP

From: Date: Thu, 13 Sep 2012 19:55:37 +0000
Subject: Re: How to limit source IP in PHP
References: 1 2 3 4 5 6 7 8 9  Groups: php.general 
Request: Send a blank email to php-general+get-319066@lists.php.net to get a copy of this message
Il 13/09/2012 21:41, Jim Lucas ha scritto:
On 09/13/2012 12:28 PM, Tonix (Antonio Nati) wrote:
You are speaking about incoming connections, I suppose. I'm speaking about connections started from within PHP.
Which is a response to the incoming connection.
And so? There is no relation between the call received from Apache (which is not passed to PHP), and any connection PHP may open later.
Unless you are talking about PHP being ran from cron or the CLI. if you are talking about YOU running a PHP script as a daemon, then yes, you have the ability to BIND to an IP address. I do this in a few scripts/daemons of mine. I use the stream_* functions for this. But, if you are talking about calling fopen() from the CLI and have it "bind" to a specific IP when connecting out, that is more of a OS specific option. You will need to find out how to run a php script and have it "bind" to a given IP (or interface) when it connects to the WWW.
When apache starts a php script, the script can open a socket towards another end-point, asking to bind to any local address as source address. Period. Regards, Tonino
Hope this helps. Jim
Regards, Tonino
-- ------------------------------------------------------------ Inter@zioni Interazioni di Antonio Nati http://www.interazioni.it tonix@interazioni.it ------------------------------------------------------------

« previous php.general (#319066) next »