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

[DeleGate-En] Telent proxy for clients on WinXP (Re: Telnet Proxy Problem)
08 Mar 2004 08:48:22 GMT feedback@delegate.org (Yutaka Sato)
The DeleGate Project


On 02/18/04(00:56) you "Mike Runge" <mjrunge@hotmail..> wrote
in <_A2549@delegate-en.ML_>
 |I am running  DeleGate/8.7.8 in a Solaris 8 environment.  I am using 
 |Delegate as a telnet and ftp proxy server.  It works great except for one 
 |minor problem I am having with the telnet proxy.  When I connect to the 
 |Delegate from a Windows XP command line, every character that I type for the 
 |host name is displayed twice.  For example if I want to connect to host 
 |"memphis", I see ">>Hostname: mmeemmpphhiiss" on my screen once I have typed 
 |it.  When I am connected to the remote host, and I am prompted for the user 
 |name and password, the characters I type are no longer echoed.  This problem 
 |that I have only occurs from the Windows command line.  When I use a program 
 |like Tera Term or if I use a unix command line, the Delegate proxy works 
 |great!  Any help and/or suggestions would be greatly appreciated.

I think that the problem depends on the initial default status of
ECHO (by server or client) and SUPPRESS-GO-AHEAD (full-duplex mode)
in each Telnet protocol interpreter.  Telnet clients in Win95 series
seems to have a bit strange initial status with "full-duplex mode
without server side ECHO, doing local (client side) echo".  To fit
with such client status, I can modify src/telnet.c like follows:

*** ../dist/delegate8.9.2/src/telnet.c	Mon Jan 20 12:35:19 2003
--- src/telnet.c	Mon Mar  8 15:27:01 2004
***************
*** 274,277 ****
--- 274,278 ----
  
  	/* it should be 0 baesd on RFC857... */
+ 	return 0;
  	return 1;
  }
***************
*** 639,642 ****
--- 640,649 ----
  			case 0x7F:
  			case 'H'-0x40:
+ 				if( !willEcho() ){
+ 					if( 0 < lx ){
+ 						lx--;
+ 						fwrite(" \b",1,3,tc);
+ 					}else	fwrite(" ",1,1,tc);
+ 				}else
  				if( 0 < lx ){
  					fwrite("\b \b",1,3,tc);

But this modification causes a problem with Telnet clients on WinNT
series which seems to have initial status including "DONT ECHO".
Another way to solve the problem is initializing client by explicit
negotiation at the start of session by, for example, sending
"DONT ECHO" from DeleGate to client.

*** ../../dist/delegate8.9.2/src/telnet.c	Mon Jan 20 12:35:19 2003
--- telnet.c	Sun Mar  7 15:09:59 2004
***************
*** 740,747 ****
--- 740,749 ----
  /*
  	putIAC(tc,WILL,O_ECHO);
  	putIAC(tc,WILL,O_SUPAHEAD);
  */
+ 	/* 9.8.3: disable local echo of telnet clients on Win95 series */
+ 	putIAC(tc,DONT,O_ECHO);
  
  	if( ncom == 0 )
  		sayWelcome(Conn,tc);
  
But this negotiation was found to be harmful for a Telnet server on a
certain main-frame, so it was disabled in DeleGate/6.1.3 (Mar.2000).
#Yet another problem is sending something (IAC Telnet commands) that
#shows this is a Telnet server makes a Telnet client act as telnet
#client which send Telnet command too.  It is not good for relaying
#to non-Telnet server... but such relay might not be necessary nowadays.

As a consequence, I modified Telnet proxy to issue NOP message at the
beginning of session, since NOP let Telnet clients on Windows be suppose
ECHO on server side, while it is expected to have no effect to cause
the problem like fixed in 6.1.3.
Finally, the Telnet proxy is modified is like enclosed patch.

Cheers,
Yutaka
--
  D G   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/delegate8.9.2/src/telnet.c	Mon Jan 20 12:35:19 2003
--- src/telnet.c	Mon Mar  8 17:33:27 2004
***************
*** 119,124 ****
--- 119,126 ----
  #define O_XDISPLOC	35	/* X Display Location */
  #define O_ENVIRON	36	/* Environment Variables */
  
+ static char NOPstr[2] = { IAC, NOP };
+ 
  static void sigurg(sig)
  {	char *ssig;
  
***************
*** 238,243 ****
--- 240,246 ----
   * in RFC857.  But some clients programs (like MS's one) seem to
   * expect the server to be WILL ECHO by default, making full-duplex
   * (character by character) communication without doing local-echo...
+  * (it's the case of WinNT/2K but not the case in Win95/98/Me/XP...)
   * Doing ECHO negotiation between DeleGate and client is a possible
   * solution, like in older version of DeleGate, but it spoiles
   * the transparent relaying between a server and a client.
***************
*** 273,278 ****
--- 276,282 ----
  		return 0;
  
  	/* it should be 0 baesd on RFC857... */
+ 	/* 0 for Win95 series but 1 for WinNT series */
  	return 1;
  }
  static logEcho()
***************
*** 299,304 ****
--- 303,317 ----
  	for( si = 0; si < 128; si++)
  		ServersWill[si] = 0;
  }
+ static numServersWill()
+ {	int si,num;
+ 
+ 	num = 0;
+ 	for( si = 0; si < 128; si++ )
+ 		if( ServersWill[si] )
+ 			num++;
+ 	return num;
+ }
  
  static char *code(ch)
  {	char *mn;
***************
*** 407,412 ****
--- 420,428 ----
  				ServersWill[ch] = cch;
  			}
  		}else
+ 		if( ch == NOP ){
+ 			sprintf(vch,"NOP");
+ 		}else
  		if( ch == SB ){
  			strcpy(vch,"SB,");
  			ch = buf[++i];
***************
*** 639,644 ****
--- 655,661 ----
  			case 0x7F:
  			case 'H'-0x40:
  				if( 0 < lx ){
+ 					if( willEcho() )
  					fwrite("\b \b",1,3,tc);
  					lx--;
  				}
***************
*** 1341,1347 ****
--- 1358,1376 ----
  			/* Some telnet client (at least SunOS's one)
  			 * does not repeat WILL/WONT twice.
  			 */
+ 			if( numServersWill() != 0 ){ /* is Telnet server */
  			relayClientsWills(ts);
+ 			}else{
+ 			/* how the client can be reset to initial state ? */
+ 				/*
+ 				sv1log("#### force kludge line mode ...\n");
+ 				putIAC(tc,WONT,O_ECHO);
+ 				putIAC(tc,WILL,O_SUPAHEAD);
+ 				putIAC(tc,DO,O_TIMING);
+ 				... skip until TIMING-MARK ...
+ 				*/
+ 			}
+ 
  			fclose(ts);
  			bidirectional_relay(Conn,1024,1024);
  			fprintf(tc,"\r\n");
***************
*** 1460,1465 ****
--- 1489,1510 ----
  	fclose(fc);
  }
  
+ /*
+  * relaying to non-Telnet arbitrary port is enabled with REMITTABLE="telnet"
+  */
+ static telnetonly(Conn)
+ 	Connection *Conn;
+ {	int relayany;
+ 	Port sv;
+ 
+ 	sv = Conn->sv;
+ 	strcpy(REAL_HOST,"-");
+ 	strcpy(REAL_PROTO,"telnet");
+ 	REAL_PORT = 99999;
+ 	relayany = service_permitted2(Conn,"telnet",1);
+ 	Conn->sv = sv;
+ 	return !relayany;
+ }
  service_telnet(Conn)
  	Connection *Conn;
  {
***************
*** 1478,1483 ****
--- 1523,1538 ----
  	}
  	if( isMYSELF(DFLT_HOST) ){
  		ImProxy = 1;
+ 		if( PollIn(FromC,10) == 0 ){
+ 			/* disable local echo in telnet client on Win95 series,
+ 			 * but don't disable local echo necessary for
+ 			 * non-Telnet protocols.
+ 			 */
+ 			if( telnetonly(Conn) ){
+ 				write(ToC,NOPstr,2);
+ 				scanCommands(DtoC,NOPstr,2);
+ 			}
+ 		}
  		return proxy_telnet(Conn);
  	}
  
***************
*** 1491,1501 ****
--- 1546,1562 ----
  	 * negotiation in the relay will be helpful for clients to notice
  	 * that he is connected with telnet server.
  	 */
+ 	if( PollIn(FromS,10) == 0 ){
+ 		write(ToC,NOPstr,2);
+ 		scanCommands(DtoC,NOPstr,2);
+ 	}
+ 	/*
  	{	char buf[3];
  		buf[0] = IAC; buf[1] = WILL; buf[2] = O_SUPAHEAD;
  		write(ToC,buf,3);
  		scanCommands(DtoC,buf,3);
  	}
+ 	*/
  	return bidirectional_relay(Conn,0x2000,0x2000);
  }
  

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