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

Moved list of common_bbs_services from exec/sbbslist.js to load/sbbslist_lib.js

Removed TCP/IP services not supported by BBS clients (e.g. SyncTERM) from the
list (e.g. ftp, nntp, smtp, binkp, irc) and added "modem".
This list is now used by the syncterm_list() function to filter which entries
will be written to the exported syncterm.lst file.
Also added duplicate section name detection and better names for multiple
services per BBS (using service description and port as well as protocol)
to syncterm_list().
Added support to imsg_capable_system() for an over-ride (imsg_capable).
Changed several info-level log messages to debug-level (e.g. for every list
open/read/write).
parent aae9370e
Branches
Tags
No related merge requests found
...@@ -45,6 +45,14 @@ const max_len = { ...@@ -45,6 +45,14 @@ const max_len = {
description: 250, description: 250,
}; };
// Services supported by BBS clients (e.g. SyncTERM)
const common_bbs_services = [
"telnet",
"rlogin",
"ssh",
"modem"
];
function compare(a, b) function compare(a, b)
{ {
var val1=""; var val1="";
...@@ -342,7 +350,7 @@ function parse(f) ...@@ -342,7 +350,7 @@ function parse(f)
function read_list() function read_list()
{ {
var f = new File(list_fname); var f = new File(list_fname);
log(LOG_INFO, "Opening list file: " + f.name); log(LOG_DEBUG, "Opening list file: " + f.name);
if(!f.open("r")) { if(!f.open("r")) {
log(LOG_ERR, "SBBSLIST: Error " + f.error + " opening " + f.name); log(LOG_ERR, "SBBSLIST: Error " + f.error + " opening " + f.name);
return []; return [];
...@@ -355,12 +363,12 @@ function read_list() ...@@ -355,12 +363,12 @@ function read_list()
function write_list(list) function write_list(list)
{ {
var out = new File(list_fname); var out = new File(list_fname);
log(LOG_INFO, "SBBSLIST: Opening / creating list file: " + list_fname); log(LOG_DEBUG, "SBBSLIST: Opening / creating list file: " + list_fname);
if(!out.open("w+")) { if(!out.open("w+")) {
log(LOG_ERR, "SBBSLIST: Error " + out.error + " creating " + out.name); log(LOG_ERR, "SBBSLIST: Error " + out.error + " creating " + out.name);
return false; return false;
} }
log(LOG_INFO, "SBBSLIST: Writing list file: " + out.name + " (" + list.length + " BBS entries)"); log(LOG_DEBUG, "SBBSLIST: Writing list file: " + out.name + " (" + list.length + " BBS entries)");
out.write(JSON.stringify(list, null, 4)); out.write(JSON.stringify(list, null, 4));
out.close(); out.close();
return true; return true;
...@@ -369,14 +377,14 @@ function write_list(list) ...@@ -369,14 +377,14 @@ function write_list(list)
function append(bbs) function append(bbs)
{ {
var f = new File(list_fname); var f = new File(list_fname);
log(LOG_INFO, "SBBSLIST: Opening / creating list file: " + list_fname); log(LOG_DEBUG, "SBBSLIST: Opening / creating list file: " + list_fname);
if(!f.open(f.exists ? 'r+':'w+')) { if(!f.open(f.exists ? 'r+':'w+')) {
log(LOG_ERR, "SBBSLIST: Error " + f.error + " creating " + f.name); log(LOG_ERR, "SBBSLIST: Error " + f.error + " creating " + f.name);
return false; return false;
} }
var list = parse(f); var list = parse(f);
list.push(bbs); list.push(bbs);
log(LOG_INFO, "SBBSLIST: Writing list file: " + f.name + " (" + list.length + " BBS entries)"); log(LOG_DEBUG, "SBBSLIST: Writing list file: " + f.name + " (" + list.length + " BBS entries)");
f.truncate(); f.truncate();
f.write(JSON.stringify(list, null, 4)); f.write(JSON.stringify(list, null, 4));
f.close(); f.close();
...@@ -454,6 +462,8 @@ function remove_dupes(list) ...@@ -454,6 +462,8 @@ function remove_dupes(list)
function imsg_capable_system(bbs) function imsg_capable_system(bbs)
{ {
if(bbs.imsg_capable == true)
return true;
if(!bbs.entry.autoverify || !bbs.entry.autoverify.last_success) if(!bbs.entry.autoverify || !bbs.entry.autoverify.last_success)
return false; return false;
var services = bbs.entry.autoverify.last_success.other_services; var services = bbs.entry.autoverify.last_success.other_services;
...@@ -564,16 +574,33 @@ function syncterm_list(list, dir) ...@@ -564,16 +574,33 @@ function syncterm_list(list, dir)
} }
f.writeln(format("; Exported from %s on %s", system.name, new Date().toString())); f.writeln(format("; Exported from %s on %s", system.name, new Date().toString()));
f.writeln(); f.writeln();
var sections = [];
for(i in list) { for(i in list) {
for(j in list[i].service) { for(j in list[i].service) {
if(!list[i].service[j].protocol) if(!list[i].service[j].protocol)
continue; continue;
if(common_bbs_services.indexOf(list[i].service[j].protocol.toLowerCase()) < 0)
continue;
var section;
if(j > 0) if(j > 0)
f.writeln(format("[%-23.23s %6.6s]", list[i].name, list[i].service[j].protocol)); section = format("%-23.23s %6.6s", list[i].name, list[i].service[j].protocol);
else else
f.writeln(format("[%s]", list[i].name)); section = list[i].name;
f.writeln(format("ConnectionType=%s", list[i].service[j].protocol)); if(sections.indexOf(section) >= 0) { // duplicate
f.writeln(format("Address=%s", list[i].service[j].address)); if(list[i].service[j].description)
section = format("%-20.20s%10.10s", list[i].name, list[i].service[j].description);
else if(list[i].service[j].port)
section = format("%-24.24s %5u", list[i].name, list[i].service[j].port);
if(sections.indexOf(section) >= 0) // duplicate
continue;
}
sections.push(section);
sections.push(format("%-23.23s %6.6s", list[i].name, list[i].service[j].protocol));
f.writeln(format("[%s]", section));
f.writeln(format("\tConnectionType=%s", list[i].service[j].protocol));
f.writeln(format("\tAddress=%s", list[i].service[j].address));
if(list[i].service[j].port)
f.writeln(format("\tPort=%s", list[i].service[j].port));
f.writeln(); f.writeln();
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment