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

Added terminating '.' line (required by WSGopher).

Using system.host_name instead of system.inetaddr for links.
Added support back in for debug output (with -d option).
Added ver, time, and stats documents (same as special finger requests).
parent 171c422e
No related branches found
No related tags found
No related merge requests found
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
load("sbbsdefs.js"); load("sbbsdefs.js");
load("nodedefs.js"); load("nodedefs.js");
const VERSION = "1.00 Alpha"; const REVISION = "$Revision$".split(' ')[1];
const GOPHER_PORT = client.socket.local_port; const GOPHER_PORT = client.socket.local_port;
var debug = false; var debug = false;
...@@ -23,7 +23,7 @@ for(i=0;i<argc;i++) ...@@ -23,7 +23,7 @@ for(i=0;i<argc;i++)
// Write a string to the client socket // Write a string to the client socket
function write(str) function write(str)
{ {
if(0 && debug) if(debug)
log("rsp: " + str); log("rsp: " + str);
client.socket.send(str); client.socket.send(str);
} }
...@@ -47,12 +47,8 @@ function send_file(fname) ...@@ -47,12 +47,8 @@ function send_file(fname)
var msgbase=null; var msgbase=null;
if(!login("guest")) { if(!login("guest"))
writeln("Sorry, no Gopher access here."); log("!WARNING: NO GUEST ACCOUNT CONFIGURED");
log("!NO GUEST ACCOUNT CONFIGURED");
exit();
}
// Get Request // Get Request
request = client.socket.recvline(512 /*maxlen*/, 10 /*timeout*/); request = client.socket.recvline(512 /*maxlen*/, 10 /*timeout*/);
...@@ -75,27 +71,37 @@ if(request=="" || request=='/') { /* "root" */ ...@@ -75,27 +71,37 @@ if(request=="" || request=='/') { /* "root" */
for(g in msg_area.grp_list) for(g in msg_area.grp_list)
writeln("1" + msg_area.grp_list[g].description writeln("1" + msg_area.grp_list[g].description
+ "\tgrp:" + msg_area.grp_list[g].name.toLowerCase() + "\tgrp:" + msg_area.grp_list[g].name.toLowerCase()
+ "\t" + system.inetaddr + "\t" + system.host_name
+ "\t" + GOPHER_PORT); + "\t" + GOPHER_PORT);
/** to-do /** to-do
for(l in file_area.lib_list) for(l in file_area.lib_list)
writeln(format("1%s\tlib:%s\t%s\t%u" writeln(format("1%s\tlib:%s\t%s\t%u"
,file_area.lib_list[l].description ,file_area.lib_list[l].description
,file_area.lib_list[l].name.toLowerCase() ,file_area.lib_list[l].name.toLowerCase()
,system.inetaddr ,system.host_name
,GOPHER_PORT ,GOPHER_PORT
)); ));
**/ **/
writeln("0Node List\tnodelist" writeln("0Node List\tnodelist"
+"\t" + system.inetaddr +"\t" + system.host_name
+"\t" + GOPHER_PORT); +"\t" + GOPHER_PORT);
writeln("0Logon List\tlogonlist" writeln("0Logon List\tlogonlist"
+"\t" + system.inetaddr +"\t" + system.host_name
+"\t" + GOPHER_PORT); +"\t" + GOPHER_PORT);
writeln("0Auto-Message\tautomsg" writeln("0Auto-Message\tautomsg"
+"\t" + system.inetaddr +"\t" + system.host_name
+"\t" + GOPHER_PORT);
writeln("0System Statistics\tstats"
+"\t" + system.host_name
+"\t" + GOPHER_PORT);
writeln("0System Time\ttime"
+"\t" + system.host_name
+"\t" + GOPHER_PORT);
writeln("0Version Information\tver"
+"\t" + system.host_name
+"\t" + GOPHER_PORT); +"\t" + GOPHER_PORT);
writeln(".");
exit(); exit();
} }
...@@ -125,6 +131,36 @@ switch(request) { ...@@ -125,6 +131,36 @@ switch(request) {
case "automsg": case "automsg":
send_file(system.data_dir + "msgs/auto.msg"); send_file(system.data_dir + "msgs/auto.msg");
break; break;
case "ver":
writeln("Synchronet Gopher Service " + REVISION);
writeln(server.version);
writeln(system.version_notice + system.revision);
writeln("Compiled " + system.compiled_when + " with " + system.compiled_with);
writeln(system.js_version);
writeln(system.os_version);
break;
case "time":
t=time();
writeln(system.timestr(t) + " " + system.zonestr() + " 0x" + t.toString(16));
break;
case "stats": /* Statistics */
for(i in system.stats)
writeln(format("%-25s = ", i) + system.stats[i]);
total = time()-system.uptime;
days = Math.floor(total/(24*60*60));
if(days)
total%=(24*60*60);
hours = Math.floor(total/(60*60));
min = (Math.floor(total/60))%60;
sec = total%60;
writeln(format("uptime = %u days, %u hours, %u minutes and %u seconds"
,days,hours,min,sec));
break;
} }
field = request.split(':'); field = request.split(':');
...@@ -138,7 +174,7 @@ switch(field[0]) { ...@@ -138,7 +174,7 @@ switch(field[0]) {
+ "\tsub:" + "\tsub:"
+ msg_area.grp_list[g].sub_list[s].code.toLowerCase() + msg_area.grp_list[g].sub_list[s].code.toLowerCase()
+ "\t" + "\t"
+ system.inetaddr + system.host_name
+ "\t" + "\t"
+ GOPHER_PORT + GOPHER_PORT
); );
...@@ -153,7 +189,7 @@ switch(field[0]) { ...@@ -153,7 +189,7 @@ switch(field[0]) {
,file_area.lib_list[l].name ,file_area.lib_list[l].name
,file_area.lib_list[l].dir_list[d].description ,file_area.lib_list[l].dir_list[d].description
,file_area.lib_list[l].dir_list[d].code.toLowerCase() ,file_area.lib_list[l].dir_list[d].code.toLowerCase()
,system.inetaddr ,system.host_name
,GOPHER_PORT ,GOPHER_PORT
)); ));
break; break;
...@@ -205,7 +241,7 @@ switch(field[0]) { ...@@ -205,7 +241,7 @@ switch(field[0]) {
); );
writeln("0" + msginfo + "\tsub:" writeln("0" + msginfo + "\tsub:"
+ field[1] + ":" + i + "\t" + field[1] + ":" + i + "\t"
+ system.inetaddr + "\t" + system.host_name + "\t"
+ GOPHER_PORT + GOPHER_PORT
); );
} }
...@@ -216,4 +252,6 @@ switch(field[0]) { ...@@ -216,4 +252,6 @@ switch(field[0]) {
break; break;
} }
writeln(".");
/* End of gopherservice.js */ /* End of gopherservice.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