Re: libwww, a different approach

Graham Barr (bodg@tiuk.ti.com)
Wed, 15 Mar 95 17:54:30 GMT


In <199503151544.JAA12696@gate.ti.com> 
On Wed, 15 Mar 1995 15:39:55 +0000 
Martijn Koster <m.koster@nexor.co.uk> writes:
> > What my scheme allows is
> > 
> > ftp_proxy=ftp://ftp.proxy
> > telnet_proxy=telnet://telnet.proxy
> > 
> > IE not all proxies have to be proxied to http
> 
> Interesing. In my scheme this should be possible too, but I hadn't
> thought it'd be used :)
> 
> > This is required for people like me who sit behind firewalls and to
> > telnet out I have to do a proxy telnet to a get machine. 
> 
> Can you give an example of what happens when you telnet through
> your library?

The library calls a callback routine with either 4 or 8 arguments

 URL   host/port/login/passwd
 PROXY host/port/login/passwd

all the proxy could be undf if not being proxied.

The proxy I need to use for telnet

telnet_proxy=telnet://gate.ti.com

The callback which I use invokes a xterm echos some info then telnets to
gate

the info echo'd is enough to ask the user to login to thier proxy account
and it also echos the host/port/login/passwd for the remote site

Here is the code

sub do_telnet {
 my $host = shift;
 my $port = shift;
 my $user = shift;
 my $pass = shift;

 my $phost = shift;
 my $pport = shift;
 my $puser = shift;
 my $ppass = shift;

 my $pid = fork();

 if(defined $pid && $pid == 0) {
  my $cmd = "";
  my $sinfo = $server->atom;
 
  if(defined $phost) {
   $cmd  = "echo;";
   $cmd .= "echo '******' You are using a proxy telnet server '******';";
   $cmd .= "echo '******' login to your proxy account then :- '******';";
   $cmd .= "echo ;";
   $cmd .= "echo username: " . $puser if(defined $puser);
   $cmd .= "echo password: " . $ppass if(defined $ppass);
   $cmd .= "echo ;";
   $cmd .= "echo ' open' " . $host;
   $cmd .= " " . $port if(defined $port);
   $cmd .= ";";
  }
 
  if(defined $user || defined $pass) {
   $cmd .= "echo ;";
   $cmd .= "echo username: " . $user if(defined $user);
   $cmd .= "echo password: " . $pass if(defined $pass);
   $cmd .= "echo ;";
  }
 
  if(defined $phost) {
   $cmd .= " telnet " . $phost;
   $cmd .= " " . $ppass if(defined $ppass);
  }
  else {
   $cmd .= " telnet " . $host;
   $cmd .= " " . $pass if(defined $pass);
  }
 
  exec(qw(xterm -e sh -c), $cmd);
 }
 elsif($pid) {
  return $WWW::RC_OK;
 }
 return $WWW::RC_UNAVAILABLE;
}

__END__

Regards,
Graham.

--
        .-----------------------------------------------------------.  
  ////  | Graham Barr                Email: bodg@tiuk.ti.com        |  \\\\ 
 |  00  | VLSI Cell Designer            or: bodg@ti.com             |  00  |
 O   ^  | MOS Design                TI MSG: BODG                    |  ^   O
  \ ~/  | Texas Instruments Ltd      Phone: +44 (0)1234 22 3419     |  \~ / 
        | ENGLAND                      Fax: +44 (0)1234 22 3331     |
        `-----------------------------------------------------------'