Skip to content
Snippets Groups Projects
Commit 32445057 authored by David Hedbor's avatar David Hedbor
Browse files

First version if the Ident protocol.

Rev: lib/modules/Protocols.pmod/Ident.pmod:1.1
parent c7548c5a
No related branches found
No related tags found
No related merge requests found
......@@ -37,6 +37,7 @@ testfont binary
/lib/modules/LR.pmod/rule.pike foreign_ident
/lib/modules/LR.pmod/scanner.pike foreign_ident
/lib/modules/MIME.pmod foreign_ident
/lib/modules/Protocols.pmod/Ident.pmod foreign_ident
/lib/modules/Protocols.pmod/TELNET.pmod foreign_ident
/lib/modules/Protocols.pmod/X.pmod/Atom.pmod foreign_ident
/lib/modules/Protocols.pmod/X.pmod/Auth.pmod foreign_ident
......
// An implementation of the IDENT protocol, specified in RFC 931.
//
// $Id: Ident.pmod,v 1.1 1998/04/08 05:38:52 neotron Exp $
class client {
int|array (string) lookup(object fd)
{
mixed raddr; // Remote Address.
mixed laddr; // Local Address.
array err;
object remote_fd;
if(!fd)
return 0;
err = catch(raddr = fd->query_address());
if(err)
throw(err + ({"Error in Protocols.Ident:"}));
err = catch(laddr = fd->query_address(1));
if(err)
throw(err + ({"Error in Protocols.Ident:" }));
if(!raddr || !laddr)
throw(backtrace() +({ "Protocols.Ident - cannot lookup address"}));
laddr = laddr / " ";
raddr = raddr / " ";
remote_fd = Stdio.File();
if(!remote_fd->open_socket()) {
destruct(remote_fd);
throw(backtrace() +({ "Protocols.Ident: open_socket() failed."}));
}
if(err = catch(remote_fd->connect(raddr[0], 113)))
{
destruct(remote_fd);
throw(err);
}
if(remote_fd->write(laddr[1]+","+raddr[1]+"\r\n") == -1) {
destruct(remote_fd);
throw(backtrace() +({ "Protocols.Ident: write failed."}));
}
mixed response = remote_fd->read();
if(!response || !strlen(response))
{
destruct(remote_fd);
throw(backtrace() +({ "Protocols.Ident: read failed."}));
}
remote_fd->close();
destruct(remote_fd);
response -= " ";
response -= "\r\n";
response /= ":";
if(sizeof(response) < 3)
return ({ "ERROR", "UNKNOWN-ERROR" });
return response[1..];
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment