Article delegate-en/4922 of [1-5169] on the server localhost:119
  upper oldest olders older1 this newer1 newers latest
search
[Top/Up] [oldest] - [Older+chunk] - [Newer+chunk] - [newest + Check]
[Reference:<_A4921@delegate-en.ML_>]
Newsgroups: mail-lists.delegate-en

[DeleGate-En] Re: DYCONF for dynamic/conditional configuration (Re: conditional mount on arbitrary protocol)
18 Oct 2010 13:22:49 GMT "Jehan-Guillaume (ioguix) de Rorthais" <pg4jqbdyi-uwzfv3oc4ylr.ml@ml.delegate.org>


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Le 09/10/2010 16:09, Yutaka Sato a écrit :
> Hi,

Hello,

> 
> In message <_A4919@delegate-en.ML_> on 09/29/10(01:48:05)
> you "Jehan-Guillaume (ioguix) de Rorthais" <pg4jqbdyi-uwzfv3oc4ylr.ml@ml.delegate.org> wrote:
>  |I played today with delegate trying to figure if I can use it to route some
>  |PostgreSQL clients based on their database connection. meaning:
>  |
>  |  client want to connect to database "db1" -> connect to server1
>  |  client want to connect to database "db2" -> connect to server2
> ...
>  |However, I still cannot route based on the application layer content. I read in
>  |the manual tcprelay cannot use the MOUNT option and it seems to me FCI script
>  |can't helps here.
> 
> Routing based on the content in an application layer could be realized 
> several ways with the existing DeleGate as follows:
> 
>   SERVER=http + FCL(to generate CONNECT method)
>   SERVER=socks + FCL(to generate CONNECT command)
>   SERVER=delegate + FCL(to generate SERVER command)

Well, as I need to proxy pgsql connection only, if I understand it correctly,
the first ones (http and socks) couldn't accomplish this task.

The last one seems appropriate, however, I couldn't make it work despite the
documentation and many tests.

As I understand it, I would have to write a filter that read on stdin and output
on stdout something like:

  SERVER=tcprelay://host:port\n\r
  \n\r
  <the original binary stream readed from stdin here>

Is it correct ?
Moreover, I'm not sure about the difference between -p and -w filter control
options :/

>   ...
> 
>  |./delegated -P9999 SERVER=tcprelay \
>  |  MOUNT="* tcprelay://destination1:port match=*some-regex-or-glob*"
>  |  MOUNT="* tcprelay://destination2:port match=*another-regex-or-glob*"
>  |
>  |Is it possible ? How hard would it be and where should I start ?
>  |If not possible, maybe I could try to add a basic support for pgsql protocol ?
>  |Any pointers/advices as well ?
>  
> There can be so many possible solutions to support your requirement.
> It can be solved in a general mechanism I have in mind for a long time
> that is "changing/generating configuration dynamically and conditionally".
> What I wish to cover and generalize in a new mechanism are the following
> ways for dynamic/conditional configration.
> 
>   1) (Condition)Parameter
>   2) SERVER=Server:-:Condition
>   3) SCREEN=reject
>   4) INETD="Port - - - - - SERVER=Server"
> 
> To do so I added a simple tentative mechanism controled with a parameter
> "DYCONF" in DeleGate/9.9.8-pre17.  Using it, your case will be configured
> as follows:
> 
>   delegated -P9999 SERVER=tcprelay \
>     DYCONF="qrex/rexp1,arg:SERVER=tcprelay://host1:port1" \
>     DYCONF="qrex/rexp2,arg:SERVER=tcprelay://host2:port2" \
>     ...

It actually worked using this conf:

  src/delegated -P9999 DGROOT=home
  SERVER=tcprelay://localhost:5434
  DYCONF="qrex/pagila,arg:SERVER=tcprelay://localhost:5433"

When connecting to database "pagila", delegate routes the tcp stream to
localhost:5433, and fallback on localhost:5434 for others.

> 
> Give it a try.

Thanks !

> 
> Cheers,
> Yutaka
> --
>   9 9   Yutaka Sato, CSDP#005482 <y.sato@delegate.org> http://delegate.org/y.sato/
>  ( ~ )  National Institute of Advanced Industrial Science and Technology
> _<   >_ 1-1-4 Umezono, Tsukuba, Ibaraki, 305-8568 Japan
> Do the more with the less -- B. Fuller
> 
> ---- Manual.htm#DYCONF ----------------------------
> YCONF parameter*   ==  DYCONF=[conditions]parameters
>         parameters  ==  file:path | cgi:path | arg:{listOfParameters}
>                     --  default: none
> DYCONF specifies configuration parameters to be loaded dynamically on the
> beginning of relaying application protocol after the acception of a TCP
> connection from a client before starting a session over it. The loading
> of parameters can be conditional based on the specified conditions, and
> the parameter value can be generated and/or evaluated on each loading.
> 
> A condition for loading can be based on the identity (address or name) of
> the host of a client which is requesting over the new connection. Or it
> can be based on the content (sub-string or pattern) of the initial request
> data which is sent from a client over a connection. The request data is
> polled for a specified period (15sec. by default) and peeked by a
> specified size (4K bytes at max. by default).
> 
> Conditions:
>   qstr/string ... matching by request sub-string
>   qreq/pattern ... matching by request pattern
>   {from/hostList} ... matching by client hosts
>   excl[/number] ... exclusive with other DYCONFs
>   poll/seconds ... timeout of polling request [4k]
>   peek/bytes ... max. bytes of peeking request [15.0s]
>   skip ... purge peeked data before starting relay
>   debug ... enable logging for debugging of DYCONF
> 
> Example:
>   DYCONF="file:path.txt" # load parameters from path.txt
>   DYCONF="cgi:path.cgi" # load parameters generated by path.cgi
>   DYCONF="qstr/string,arg:{SERVER=tcprelay://sv1:1234;TIMEOUT=io:3}"
>   DYCONF="{qrex/[a-z][0-9]*},arg:{SERVER=tcprelay://sv1:1234}"
> ---- DeleGate/9.9.8-pre17 -------------------------

Cheers,
- -- 
Jehan-Guillaume de Rorthais
DBA
http://www.dalibo.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAky8Sg4ACgkQXu9L1HbaT6K9CQCgzgj27iLXAvaE2RPADpqnA17W
QWwAn0+SvDaTCZe0nxwZFYaiXqp32TUY
=Szpl
-----END PGP SIGNATURE-----

  admin search upper oldest olders older1 this newer1 newers latest
[Top/Up] [oldest] - [Older+chunk] - [Newer+chunk] - [newest + Check]
@_@V