Re: [PHP-DEV] idea: add wrapper support to mysqli_connect

2013-03-14 Thread Andrey Hristov

 Hi,
On 03/13/2013 10:09 PM, Thomas Anderson wrote:

On Wed, Mar 13, 2013 at 3:37 PM, Rasmus Lerdorf  wrote:

On 03/13/2013 12:08 PM, Thomas Anderson wrote:

Instead of passing localhost to mysqli_connect as the $host parameter
I think it'd be useful if you could pass something like
ssh2.tunnel://user:p...@example.com:22/192.168.0.1:14 to it as well.

The main advantage I see of doing that is that you could tunnel
through SSH2, through SOCKS, through HTTP CONNECT, etc, a lot more
easily than you currently can. Like you could have an SSH connection
re-created every time a PHP script is called and a tunnel dynamically
made instead of having a persistent tunnel created with autossh or
whatever.

And even if SSH2 / SOCKS / CONNECT don't exist as built-in wrappers
custom stream wrappers could be made. This would additionally make it
easy for people to examine the underpinnings of MySQL. Instead of
intercepting the packets the MySQL client sends out and placing them
into an SSH tunnel or whatever one could just dump them to a log file
to better understand how MySQL clients work internally.


Instead of adding all that gear to PHP itself, wouldn't it make more
sense to just use something like autossh to maintain your ssh tunnel and
have PHP connect to your tunnel endpoint? mysqli_connect() in PHP is
just a thin wrapper on top of the underlying library.


Oh - I didn't know that. I thought (hoped) it might have been like a
two second code change lol.



a very easy way is to write a mysqlnd plugin that overwrites 
mysqlnd_connect, maybe some small changes to mysqlnd_net. You can pass 
whatever you want and it will connect the way you want. At the end there 
should be opened PHP stream. Upload it to pecl.php.net and let the 
people use it. If many people decide to use it it might get its way into 
the core of mysqlnd.


Best,
Andrey

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] idea: add wrapper support to mysqli_connect

2013-03-13 Thread Thomas Anderson
On Wed, Mar 13, 2013 at 3:37 PM, Rasmus Lerdorf  wrote:
> On 03/13/2013 12:08 PM, Thomas Anderson wrote:
>> Instead of passing localhost to mysqli_connect as the $host parameter
>> I think it'd be useful if you could pass something like
>> ssh2.tunnel://user:p...@example.com:22/192.168.0.1:14 to it as well.
>>
>> The main advantage I see of doing that is that you could tunnel
>> through SSH2, through SOCKS, through HTTP CONNECT, etc, a lot more
>> easily than you currently can. Like you could have an SSH connection
>> re-created every time a PHP script is called and a tunnel dynamically
>> made instead of having a persistent tunnel created with autossh or
>> whatever.
>>
>> And even if SSH2 / SOCKS / CONNECT don't exist as built-in wrappers
>> custom stream wrappers could be made. This would additionally make it
>> easy for people to examine the underpinnings of MySQL. Instead of
>> intercepting the packets the MySQL client sends out and placing them
>> into an SSH tunnel or whatever one could just dump them to a log file
>> to better understand how MySQL clients work internally.
>
> Instead of adding all that gear to PHP itself, wouldn't it make more
> sense to just use something like autossh to maintain your ssh tunnel and
> have PHP connect to your tunnel endpoint? mysqli_connect() in PHP is
> just a thin wrapper on top of the underlying library.

Oh - I didn't know that. I thought (hoped) it might have been like a
two second code change lol.

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] idea: add wrapper support to mysqli_connect

2013-03-13 Thread Rasmus Lerdorf
On 03/13/2013 12:08 PM, Thomas Anderson wrote:
> Instead of passing localhost to mysqli_connect as the $host parameter
> I think it'd be useful if you could pass something like
> ssh2.tunnel://user:p...@example.com:22/192.168.0.1:14 to it as well.
> 
> The main advantage I see of doing that is that you could tunnel
> through SSH2, through SOCKS, through HTTP CONNECT, etc, a lot more
> easily than you currently can. Like you could have an SSH connection
> re-created every time a PHP script is called and a tunnel dynamically
> made instead of having a persistent tunnel created with autossh or
> whatever.
> 
> And even if SSH2 / SOCKS / CONNECT don't exist as built-in wrappers
> custom stream wrappers could be made. This would additionally make it
> easy for people to examine the underpinnings of MySQL. Instead of
> intercepting the packets the MySQL client sends out and placing them
> into an SSH tunnel or whatever one could just dump them to a log file
> to better understand how MySQL clients work internally.

Instead of adding all that gear to PHP itself, wouldn't it make more
sense to just use something like autossh to maintain your ssh tunnel and
have PHP connect to your tunnel endpoint? mysqli_connect() in PHP is
just a thin wrapper on top of the underlying library.

And your debugging use-case is also handled nicely by external tools
that listen on a unix-domain socket, for example.

-Rasmus


-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DEV] idea: add wrapper support to mysqli_connect

2013-03-13 Thread Thomas Anderson
Instead of passing localhost to mysqli_connect as the $host parameter
I think it'd be useful if you could pass something like
ssh2.tunnel://user:p...@example.com:22/192.168.0.1:14 to it as well.

The main advantage I see of doing that is that you could tunnel
through SSH2, through SOCKS, through HTTP CONNECT, etc, a lot more
easily than you currently can. Like you could have an SSH connection
re-created every time a PHP script is called and a tunnel dynamically
made instead of having a persistent tunnel created with autossh or
whatever.

And even if SSH2 / SOCKS / CONNECT don't exist as built-in wrappers
custom stream wrappers could be made. This would additionally make it
easy for people to examine the underpinnings of MySQL. Instead of
intercepting the packets the MySQL client sends out and placing them
into an SSH tunnel or whatever one could just dump them to a log file
to better understand how MySQL clients work internally.

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php