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

[DeleGate-En] Re: Few questions about transparent proxy & srcif
23 Jan 2009 09:36:03 GMT feedback@delegate.org (Yutaka Sato)
The DeleGate Project


Hi,

In message <_A4350@delegate-en.ML_> on 01/23/09(17:16:08) I wrote:
 |In DeleGate/9.9.1-pre8, I added "-dontroute." to be prefixed to a hostname
 |in SRCIF.  If unconditionally seting SO_DONTROUTE fits your requirment,
 |this is it.
 |
 |  SRCIF="-dontroute.if1"
 |  HOSTS="-dontroute.if1/10.1.1.1"
 |
 |This "-dontroute." prefix can be used just to set SO_DONTROUTE leaving the
 |socket unbound (or bound to 0.0.0.0).
 |
 |  SRCIF="-dontroute.if1"
 |  HOSTS="-dontroute.if1/0.0.0.0"

In DeleGate/9.9.2-pre1, I'll change the code as the enclosed patch.
It introduces a generic prefix in form "_-xxxx.host" for name or address.
For example, you can use it as follows:

 SRCIF=_-DontRoute.0.0.0.0    ... don't bind SRCIF but set SO_DONTROUTE
 SRCIF=_-DontRoute.10.1.1.1    ... bind SRCIF (by add) and set SO_DONTROUTE
 SRCIF=_-DontRoute.host.domain  ... bind SRCIF (by name) and set SO_DONTROUTE
 SRCIF=_-DontRouteIfBound.10.1.1.1  ... set SO_DONTROUTE if bound successfully
 SRCIF=_-DontRouteIfNotBound.10.1.1.1  ... set SO_DONTROUTE if not bound

Cheers,
Yutaka
--
  9 9   Yutaka Sato <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


*** dist/src/delegate9.9.1/src/inets.c	Tue Jan 13 13:44:08 2009
--- ./src/inets.c	Fri Jan 23 18:24:48 2009
***************
*** 436,437 ****
--- 436,445 ----
  }
+ const char *stripHostPrefix(PCStr(host)){
+ 	const char *dp;
+ 	while( strncmp(host,"_-",2) == 0 ){
+ 		if( dp = strchr(host+2,'.') )
+ 			host = dp+1;
+ 	}
+ 	return host;
+ }
  
***************
*** 449,450 ****
--- 457,459 ----
  		return NULL;
+ 	name = stripHostPrefix(name);
  
***************
*** 493,494 ****
--- 502,504 ----
  		return NULL;
+ 	addr = stripHostPrefix(addr);
  
***************
*** 2168,2169 ****
--- 2178,2180 ----
  	VSAddr Vaddr;
+ 	int rcode;
  
***************
*** 2199,2200 ****
--- 2210,2212 ----
  	else	VSA_atosa(&Vaddr,0,"0.0.0.0");
+ 	rcode =
  	bind_inets(sock,&Vaddr,0,SRCPORT);
***************
*** 2204,2206 ****
--- 2216,2224 ----
  
+ 	/*
  	if( strheadstrX(SRCHOST,"-dontroute.",0) ){
+ 	*/
+ 	if( strheadstrX(SRCHOST,"_-DontRoute.",1)
+ 	 || strheadstrX(SRCHOST,"_-DontRouteIfBound.",1) && rcode == 0
+ 	 || strheadstrX(SRCHOST,"_-DontRouteIfNotBound.",1) && rcode != 0
+ 	){
  	int on = 1;

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