Article delegate-en/460 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:<_A430@delegate-en.ML_>]
Newsgroups: mail-lists.delegate-en

[DeleGate-En] Re: How to filter based on separate server names?
19 May 1999 08:40:16 GMT ysato@etl.go.jp (Yutaka Sato)


On 04/16/99(14:49) you "Simon Bennett" <pvyaqbdyi-gdzs2fkqc6nr.ml@ml.delegate.org> wrote
in <_A430@delegate-en.ML_>
 |How do I set up a number of filters to perform different actions based on
 |the server names.
 |I can set up CMAP entries on the command line like:
 |
 |CMAP=/opt/dgate/oze.cfi:FTOCL:http:*.ozemail.com.au:* \
 |CMAP=/opt/dgate/sun.cfi:FTOCL:http:*.sun.com:*
 |
 |Which will apply separate filters to URL's matching those two patterns.
 |Also applying a blanket filter to all URL's works e.g:
 |CMP=/opt/dgate/all.cfi:FTOCL:http:*:*
 |
 |However if you combine these options it doesn't work - neither does it work
 |if I have any other form of overlapping pattern matches - say I have a  dst
 |server of "*.com" as well as "*.sun.com".
 |How can I do this?  Is CMAP the wrong approach?

I could not find a problem caused by multiple CMAPs for FTOCL in
an experiment like this:

#!/bin/sh
../src/delegated \
 -P9999 -v \
 CMAP="sun.cfi:FTOCL:http:*.sun.com:*" \
 CMAP="oze.cfi:FTOCL:http:*.ozemail.com.au:*"

[sun.cfi]
#!cfi
Filter: echo "SUN"

[oze.cfi]
#!cfi
Filter: echo "OZE"

% telnet localhost 9999
 GET http://www.sun.com/ HTTP/1.0

 HTTP/1.0 200 OK
 DeleGate-Ver: 5.9.2 (delay=2)
 Server: Netscape-Enterprise/2.01
 Date: Wed, 19 May 1999 08:31:01 GMT
 Set-cookie: sessionid=2DR4D0IAADRO3AMUVFZE5YQ;domain=.sun.com;path=/
 Content-type: text/html
 Via: 1.0 - (DeleGate/5.9.2)
 Content-Length: 4

 SUN
 Connection closed by foreign host.

% telnet localhost 9999
 GET http://www.ozemail.com.au/ HTTP/1.0

 HTTP/1.1 200 OK
 DeleGate-Ver: 5.9.2 (delay=9)
 Date: Wed, 19 May 1999 08:34:08 GMT
 Server: Apache/1.3.1 (Unix)
 Last-Modified: Tue, 18 May 1999 23:55:48 GMT
 ETag: "1770c-99d0-3741fe04"
 Accept-Ranges: bytes
 Content-Type: text/html
 Via: 1.0 - (DeleGate/5.9.2)
 Content-Length: 4

 OZE
 Connection closed by foreign host.

I did this on FreeBSD-2.2.5 using DeleGate5.9.1 modified with a enclosed
patch.

Cheers,
Yutaka
--
Yutaka Sato <ysato@etl.go.jp> http://www.etl.go.jp/~ysato/   @ @ 
Computer Science Division, Electrotechnical Laboratory      ( - )
1-1-4 Umezono, Tsukuba, Ibaraki, 305-8568 Japan            _<   >_


On 03/24/99(03:57) I wrote in <_A371@delegate-en.ML_>
 |On 03/18/99(16:30) you Phill Edwards <pnyaqbdyi-gdzs2fkqc6nr.ml@ml.delegate.org> wrote
 |in <_A366@delegate-en.ML_>
 | |I've got as far as applying filters to html which is being passed from 
 | |Delegate where the Content-Type is html. This works great. I'm now trying 
 | |to understand how to apply different filters to different web sites. I've 
 | |tried using Server and Server-Host, eg
 | |#!cfi
 | |Server-Host: www.ozemail.com.au
 | |Filter: /usr/home/phill/working/delegate.sh
 |
 |Sorry but matching by "Server-Host" is not implemented yet, and it
 |will be far less efficient than matching with CMAP with "dstHostList"
 |restriction, like one in your example.
 |
 | |I've also tried
 | |CMAP="/usr/home/phill/working/delegate.cfi:FTOCL:http:www.ozemail.com.au:*"
 |
 |This must work.
 |
 | |but that didn't work because it tried to execute cfi as a unix shell script 
 | |which wasn't valid.
 |
 |I fixed the problem with the enclosed patch.  It also fixes problems
 |which occurs when "CGI:" is used instead of "Filter:", and when a
 |complex shell commands is specified for Filter or CGI.
 |
 |Cheers,
 |Yutaka
 |--
 |Yutaka Sato <ysato@etl.go.jp> http://www.etl.go.jp/~ysato/   @ @ 
 |Computer Science Division, Electrotechnical Laboratory      ( - )
 |1-1-4 Umezono, Tsukuba, Ibaraki, 305-8568 Japan            _<   >_

diff -c -r ../delegate5.9.1/src/filter.c ./src/filter.c
*** ../delegate5.9.1/src/filter.c	Mon Mar 15 19:48:03 1999
--- ./src/filter.c	Wed Mar 24 02:52:52 1999
***************
*** 166,171 ****
--- 166,172 ----
  	Connection *Conn;
  {	char *fname,*filter;
  	static char filterb[2048];
+ 	char *cfi;
  
  	filter = NULL;
  
***************
*** 175,180 ****
--- 176,185 ----
  		if( filterb[0] ){
  			filter = filterb;
  			Verbose("## gotFilter[%s][%s]\n",fname,filter);
+ 			if( cfi = open_cfi(filterb) ){
+ 				strcpy(filterb,cfi);
+ 				free(cfi);
+ 			}
  		}
  	}
  	if( filter == NULL )
***************
*** 532,537 ****
--- 537,546 ----
  	char *what,*command;
  {	char execpath[1024],*av[128],argb[1024];
  
+ 	/* if with some command syntax ... */
+ 	if( strpbrk(command,"\r\n|()[]<>{}:;") )
+ 		Finish(system(command));
+ 	else
  	if( 0 <= scanComArg(command,execpath,av,128,argb) )
  		Execvp(what,execpath,av);
  	else	Finish(system(command));
diff -c -r ../delegate5.9.1/filters/cfi.c ./filters/cfi.c
*** ../delegate5.9.1/filters/cfi.c	Fri Aug 21 22:23:42 1998
--- ./filters/cfi.c	Wed Mar 24 03:38:21 1999
***************
*** 457,471 ****
--- 457,474 ----
  	FILE *tmp;
  	char *xhead,*dp;
  	char url[4096],ourl[4096];
+ 	char **oenv;
  
  	xhead = strdup(head);
  	scan_http_request(oreq,NULL,ourl,NULL);
  	scan_http_request(req,NULL,url,NULL);
  	cgi_makeenv(conninfo,req,xhead,ourl,url,"","",NULL,ev,eb);
+ 	oenv = environ;
  	environ = ev;
  
  	tmp = TMPFILE("CFI-system_CGI");
  	System(cgi,in,tmp);
+ 	environ = oenv;
  	fseek(tmp,0,0);
  	if( dp = strstr(head,"\r\n\r\n") )
  		dp[2] = 0;

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