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

Replace the activeuserservice.js with a command-line option to fingerservice.js

since activeuserservice.js was just a copy/paste of fingerservice.js to begin
with. Replace the "command" value for the ActiveUser and ActiveUser-UDP
services in ctrl/services.ini with "fingerservice.js -u".
The "?services" request now uses the portdefs.js to go through a list of known
standard TCP service ports.
parent 25ddb352
No related branches found
No related tags found
No related merge requests found
// activeuserservice.js
// Synchronet Service for the Active User protocol (RFC 866)
// $Id$
// Example configurations (in ctrl/services.ini):
// [ActiveUser]
// Port=11
// MaxClients=10
// Options=NO_HOST_LOOKUP
// Command=activeuserservice.js
// [ActiveUser-UDP]
// Port=11
// MaxClients=10
// Options=UDP | NO_HOST_LOOKUP
// Command=activeuserservice.js
// Command-line options:
// -n to the configuration line to eliminate user age and gender
// information from the query results.
// -a report aliases only (no real names)
// !WARNING!
// Active User is an open protocol utilizing no forms of authorization
// or authentication. ACTIVE USER IS A KNOWN AND ACCEPTED SECURITY RISK.
// Detailed information about your system and its users is made
// available to ANYONE using this service. If there is anything in
// this script that you do not want to be made available to anyone
// and everyone, please comment-out (using /* and */) that portion
// of the script.
const REVISION = "$Revision$".split(' ')[1];
var include_age_gender=true;
var include_real_name=true;
load("nodedefs.js");
load("sockdefs.js");
load("sbbsdefs.js");
for(i=0;i<argc;i++) {
switch(argv[i].toLowerCase()) {
case "-n": // no age or gender
include_age_gender = false;
break;
case "-a": // aliases only
include_real_name = false;
break;
}
}
var output_buf = "";
// Write a string to the client socket
function write(str)
{
output_buf += str;
}
// Write all the output at once
function flush()
{
client.socket.send(output_buf);
}
// Write a crlf terminated string to the client socket
function writeln(str)
{
write(str + "\r\n");
}
function xtrn_name(code)
{
if(this.xtrn_area==undefined)
return(code);
if(xtrn_area.prog!=undefined)
if(xtrn_area.prog[code]!=undefined)
return(xtrn_area.prog[code].name);
else { /* old way */
for(s in xtrn_area.sec_list)
for(p in xtrn_area.sec_list[s].prog_list)
if(xtrn_area.sec_list[s].prog_list[p].code.toLowerCase()==code.toLowerCase())
return(xtrn_area.sec_list[s].prog_list[p].name);
}
return(code);
}
function done()
{
flush();
exit();
}
log("client requested Active User list");
write(format("%-25.25s %-31.31s Time %7s Node\r\n"
,"User","Action",include_age_gender ? "Age Sex":""));
var dashes="----------------------------------------";
write(format("%-25.25s %-31.31s %8.8s %3.3s %3.3s %4.4s\r\n"
,dashes,dashes,dashes
,include_age_gender ? dashes : ""
,include_age_gender ? dashes : ""
,dashes));
var u = new User(1);
for(n=0;n<system.node_list.length;n++) {
if(system.node_list[n].status!=NODE_INUSE)
continue;
u.number=system.node_list[n].useron;
if(system.node_list[n].action==NODE_XTRN && system.node_list[n].aux)
action=format("running %s",xtrn_name(u.curxtrn));
else
action=format(NodeAction[system.node_list[n].action]
,system.node_list[n].aux);
t=time()-u.logontime;
if(t&0x80000000) t=0;
write(format("%-25.25s %-31.31s%3u:%02u:%02u %3s %3s %4d\r\n"
,u.alias
,action
,Math.floor(t/(60*60))
,Math.floor(t/60)%60
,t%60
,include_age_gender ? u.age.toString() : ""
,include_age_gender ? u.gender : ""
,n+1
));
}
done();
// fingerservice.js
// Synchronet Service for the Finger protocol (RFC 1288)
// and/or the Active Users protocol (RFC 866)
// $Id$
// Example configuration (in ctrl/services.ini)
// Example configurations (in ctrl/services.ini)
// [Finger]
// Port=79
// MaxClients=10
// Options=NO_HOST_LOOKUP
// Command=fingerservice.js
// [Finger-UDP]
// Port=79
// Options=UDP | NO_HOST_LOOKUP
// Command=fingerservice.js
// [ActiveUser]
// Port=11
// Options=NO_HOST_LOOKUP
// Command=fingerservice.js -u
// [ActiveUser-UDP]
// Port=11
// Options=UDP | NO_HOST_LOOKUP
// Command=fingerservice.js -u
// Command-line options:
// -n add to the Command line to eliminate user age and gender
// information from the query results.
// -a report aliases only (no real names)
// -ff enable the findfile feature (requires a "guest" account)
// -u report users only (ignore any request), a.k.a. Active Users protocol
// !WARNING!
// Finger is an open protocol utilizing no forms of authorization
......@@ -32,10 +48,12 @@ const REVISION = "$Revision$".split(' ')[1];
var include_age_gender=true;
var include_real_name=true;
var findfile=true;
var active_users=false;
load("nodedefs.js");
load("sockdefs.js");
load("sbbsdefs.js");
load("portdefs.js");
for(i=0;i<argc;i++) {
switch(argv[i].toLowerCase()) {
......@@ -48,6 +66,9 @@ for(i=0;i<argc;i++) {
case "-ff": // enable findfile (requires "guest" account)
findfile=true;
break;
case "-u": // Active Users only
active_users=true;
break;
}
}
......@@ -117,26 +138,31 @@ function done()
exit();
}
// Get Finger Request (the main entry point)
if(datagram == undefined) // TCP
request = client.socket.recvline(128 /*maxlen*/, 10 /*timeout*/);
else // UDP
request = datagram;
var request="";
if(request==null) {
log(LOG_WARNING,"!TIMEOUT waiting for request");
exit();
}
if(!active_users) {
request = truncsp(request);
// Get Finger Request (the main entry point)
if(datagram == undefined) // TCP
request = client.socket.recvline(128 /*maxlen*/, 10 /*timeout*/);
else // UDP
request = datagram;
log(LOG_DEBUG,"client request: " + request);
if(request==null) {
log(LOG_WARNING,"!TIMEOUT waiting for request");
exit();
}
if(request.substr(0,2).toUpperCase()=="/W") // "higher level of verbosity"
request=request.slice(2); // ignored...
request = truncsp(request);
while(request.charAt(0)==' ') // skip prepended spaces
request=request.slice(1);
log(LOG_DEBUG,"client request: " + request);
if(request.substr(0,2).toUpperCase()=="/W") // "higher level of verbosity"
request=request.slice(2); // ignored...
while(request.charAt(0)==' ') // skip prepended spaces
request=request.slice(1);
}
if(request=="") { // no specific user requested, give list of active users
log("client requested active user list");
......@@ -267,28 +293,16 @@ if(request.charAt(0)=='?' || request.charAt(0)=='.') { // Handle "special" reque
break;
case "services": /* Services running on this host */
if(test_port(23))
writeln("Telnet");
if(test_port(513))
writeln("RLogin");
if(test_port(21))
writeln("FTP");
if(test_port(25))
writeln("SMTP");
if(test_port(110))
writeln("POP3");
if(test_port(119))
writeln("NNTP");
if(test_port(70))
writeln("Gopher");
if(test_port(80))
writeln("HTTP");
if(test_port(113))
writeln("IDENT");
if(test_port(6667))
writeln("IRC");
if(test_port(8080))
writeln("HTTP Proxy");
var ports = [];
for(i in standard_service_port) {
if(i == "finger")
continue;
if(ports.indexOf(standard_service_port[i]) >= 0) // Already tested this port
continue;
ports.push(standard_service_port[i]);
if(test_port(standard_service_port[i]))
writeln(i);
}
break;
default:
......
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