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

[DeleGate-En] Re: Can I use one port for multiple protocols
11 May 2004 14:44:25 GMT (Yutaka Sato)
The DeleGate Project

On 04/20/04(09:58) "Dan Higgins" <dan@danamis..> wrote
in <_A2597@delegate-en.ML_>
 |If I have one port open, can I use Delegate to accept connections on that
 |port, then look at the incoming stream, and forward on to different ports
 |based on the stream data?
 |More specifically, I need to listen on port 8888. Then IF a http request is
 |made on that port, relay it to port 80. If the incoming stream is NOT http,
 |then relay to some other default port.

On 04/21/04(03:15) "Dan Higgins" <dan@danamis..> wrote
in <_A2599@delegate-en.ML_>
 |# Default server type if coming into :8888
 |# :8900 will be relay for HTTP
 |# :8901 will be relay for whatever is not HTTP
 |At first I was putting everything into one file, but it seems you can't mix
 |"delegate" and other types of servers.

It could be reasonable that, reading the Manual.htm, you thought that
FORWARD can be used for such routing based on protocol.  But actually
the protocol on the client-side is fixed with SERVER parameter,
and the protocol to be used for routing is the server-side protocol.

For example, when the client-side protocol is HTTP by SERVER=http, then
the routing can be switched with "GET protocol://server" or so.  When
the client-side protocol is "delegate", the special protocol used only
inter-DeleGate communication, the server-side protocol is specified as
"SERVER protocol://server" command.

Thus there is no way to do routing based on client-side protocol using
built-in features of DeleGate, but you can do it by an "external filter".

The enclosed program "pswitch" reads incoming stream and if it is not
in HTTP, then output "CONNECT host:port<CR><LF>" before the real input.
Attaching this program as a external filter to HTTP-DeleGate like follows,
non-HTTP request is forwarded to "localhost 8889" where  it should be

% delegated -P8888 -v 
    SERVER=http REMITTABLE=ssltunnel
    FFROMCL="-p,pswitch localhost 8889"

  D G   Yutaka 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

/*------ pswitch.c ---------------------------------------------------*/
#include <stdio.h>
	char *av[];
{	char com[64],con[64];
	int rcc;

	if( ac < 3 ){
		fprintf(stderr,"Usage: %s host port\n",av[0]);
	if( (rcc = read(0,com,4)) < 0 )

	com[rcc] = 0;
	if( strcasecmp(com,"GET ") == 0
	 || strcasecmp(com,"HEAD") == 0
	 || strcasecmp(com,"POST") == 0
		sprintf(con,"CONNECT %s:%s\r\n",av[1],av[2]);

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