Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:66609 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 92585 invoked from network); 14 Mar 2013 09:33:57 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 14 Mar 2013 09:33:57 -0000 Authentication-Results: pb1.pair.com header.from=php@hristov.com; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=php@hristov.com; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain hristov.com from 91.196.124.214 cause and error) X-PHP-List-Original-Sender: php@hristov.com X-Host-Fingerprint: 91.196.124.214 more.superhosting.bg Linux 2.6 Received: from [91.196.124.214] ([91.196.124.214:50773] helo=more.superhosting.bg) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 49/5B-27533-28991415 for ; Thu, 14 Mar 2013 04:33:56 -0500 Received: from androto.ddns.playtime.bg ([87.121.52.78]:38280 helo=[192.168.20.117]) by more.superhosting.bg with esmtpsa (TLSv1:DHE-RSA-AES256-SHA:256) (Exim 4.80) (envelope-from ) id 1UG4Xn-0009BC-Gv for internals@lists.php.net; Thu, 14 Mar 2013 11:33:51 +0200 Message-ID: <5141997B.9070004@hristov.com> Date: Thu, 14 Mar 2013 10:33:47 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130308 Thunderbird/17.0.4 MIME-Version: 1.0 To: internals@lists.php.net References: <5140E399.905@lerdorf.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - more.superhosting.bg X-AntiAbuse: Original Domain - lists.php.net X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - hristov.com X-Get-Message-Sender-Via: more.superhosting.bg: authenticated_id: php@hristov.com X-Source: X-Source-Args: X-Source-Dir: Subject: Re: [PHP-DEV] idea: add wrapper support to mysqli_connect From: php@hristov.com (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:pass@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