Skip to content
Snippets Groups Projects
Commit 379b5d27 authored by rswindell's avatar rswindell
Browse files

This update actually works like a real finger service.

parent 77baef84
No related branches found
No related tags found
No related merge requests found
// fingerservice.js
// Synchronet Service for the Finger protocol (RFC 1288)
load("nodedefs.js");
// This is just an example of how you access command-line args
for(i=0;i<argc;i++)
log(format("argv[%d]=%s",i,argv[i]));
// End of example :-)
// Write a string to the client socket
function write(str)
{
client.socket.send(str);
}
var user = new User(1);
for(n=0;n<system.node_list.length;n++) {
write(format("Node %2d ",n+1));
if(system.node_list[n].status==NODE_INUSE) {
// Get Finger Request
request = client.socket.recvline(128 /*maxlen*/, 3 /*timeout*/);
if(request==null) {
log("!TIMEOUT waiting for request");
exit();
}
if(request=="") { /* no specific user requested, give list of active users */
log("client requested active user list");
write(format("%-25.25s %-40.40s Node Age Sex\r\n","Name","Action"));
write("-------------------------------------------------------------------------------\r\n");
var user = new User(1);
for(n=0;n<system.node_list.length;n++) {
if(system.node_list[n].status!=NODE_INUSE)
continue;
user.number=system.node_list[n].useron;
write(format("%s (%u %s) ", user.alias, user.age, user.gender));
write(format(NodeAction[system.node_list[n].action],system.node_list[n].aux));
} else
write(format(NodeStatus[system.node_list[n].status],system.node_list[n].aux));
var action=format(NodeAction[system.node_list[n].action],system.node_list[n].aux);
write(format("%-25.25s %-40.40s %4d %3d %3s\r\n"
,user.alias
,action
,n+1
,user.age
,user.gender));
}
exit();
}
log(format("client request: '%s'",request));
var usernum=Number(request);
if(!usernum) {
var at = request.indexOf('@');
if(at>0)
request = request.substr(0,at-1);
usernum = system.matchuser(request);
if(!usernum) {
log("!UNKNOWN USER: " + request);
exit();
}
}
var user = new User(usernum);
if(user == null) {
log(format("!INVALID USER NUMBER: %d",usernum));
exit();
}
write(format("Site: %s\r\n"
,system.inetaddr));
write(format("Login name: %-30s In real life: %s\r\n"
,user.alias,user.name));
write(format("Shell: %s\r\n",user.command_shell));
write(format("Last login %s via %s from %s [%s]\r\n"
,system.timestr()
,user.connection
,user.host_name
,user.ip_address));
write("\r\n");
}
\ No newline at end of file
/* End of fingerservice.js */
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