Skip to content
Snippets Groups Projects
Commit 49053f31 authored by Rob Swindell's avatar Rob Swindell :speech_balloon:
Browse files

Re-write to allow options in any order, more control over all behavior

Previously, in order to just specify the terminal-type string, the sysop
would also have to pass new values for the tg-mode, client-name and
server-name, which was not very friendly. We still support the old syntax
where order of arguments matters, but also a new better syntax for options
(which may now come before or after the required address[:port] argument):

-c <client-name> (default: user alias)
-s <server-name> (default: user real name)
-t <terminal-type> (e.g. "xtrn=doorcode" to auto-exec door on server)
-T <connect-timeout-seconds> (default: 10 seconds)
-m <telnet-gateway-mode> (Number or TG_* vars OR'd together, default: 0)
-p send current user alias and password as server and client-name values
-q don't display banner or pause prompt displayed (quiet)
-P don't pause for user key-press
-C don't clear screen after successful session

For arguments that take a value (e.g. -c, -s, -t, -T, -m), the value may
immediately follow the option letter (e.g. "-cMyName") or be specified
in the following argument (e.g. "-c MyName"). Multiple options cannot be
stuck together in the same option (e.g. use '-C -P' instead of '-CP').

If the RLogin server is a Synchronet BBS, you probably want to specify the
'-p' option which will send the current user's alias and password in the
RLogin connection parameters that Synchronet expects them.

The sysop now has better control over the output (banner, screen-clearing)
and the pause prompt that was previously hard-coded.
parent 21429128
No related branches found
No related tags found
No related merge requests found
// rlogin.js
// Synchronet RLogin Gateway v2.0
// Telnet Gateway using RLogin protocol
// usage: ?rlogin address[:port] [options]
// options:
// -c <client-name> (default: user alias)
// -s <server-name> (default: user real name)
// -t <terminal-type> (e.g. "xtrn=doorcode" to auto-exec door on server)
// -T <connect-timeout-seconds> (default: 10 seconds)
// -m <telnet-gateway-mode> (Number or TG_* vars OR'd together, default: 0)
// -p send current user alias and password as server and client-name values
// -q don't display banner or pause prompt displayed (quiet)
// -P don't pause for user key-press
// -C don't clear screen after successful session
// usage: ?rlogin address[:port] [telnet_gateway_mode] [client-name] [server-name] [terminal-type]
// legacy usage (still supported, but deprecated):
// ?rlogin address[:port] [telnet-gateway-mode] [client-name] [server-name] [terminal-type]
load("sbbsdefs.js");
// See http://wiki.synchro.net/module:rlogin for details
write("\r\n\001h\1hPress \001yCtrl-]\001w for a control menu anytime.\r\n\r\n");
console.pause();
writeln("\001h\001yConnecting to: \001w" + argv[0] + "\001n");
bbs.rlogin_gate(
argv[0] // address[:port]
,argv[2] // client-name
,argv[3] // server-name
,argv[4] // terminal-type
,eval(argv[1]) // mode flags
"use strict";
require("sbbsdefs.js", 'TG_RLOGINSWAP');
var quiet = false;
var pause = true;
var clear = true;
var mode;
var addr;
var client_name;
var server_name;
var term_type;
var timeout = 10;
for(var i = 0; i < argv.length; i++) {
var arg = argv[i];
if(arg[0] != '-') {
if(!addr)
addr = arg;
else if(!mode)
mode = arg;
else if(!client_name)
client_name = arg;
else if(!server_name)
server_name = arg;
else if(!term_type)
term_type = arg;
else {
alert(js.exec_file + ": Unexpected argument: " + arg);
exit(1);
}
continue;
}
switch(arg[1]) { // non-value options
case 'q':
quiet = true;
continue;
case 'P':
pause = false;
break;
case 'C':
clear = false;
break;
case 'p': // send alias and password as expected by Synchronet
client_name = user.security.password;
server_name = user.alias;
continue;
}
var value = arg.length > 2 ? arg.substring(2) : argv[++i];
switch(arg[1]) { // value options
case 'c':
client_name = value;
break;
case 's':
server_name = value;
break;
case 't':
term_type = value;
break;
case 'T':
timeout = Number(value);
break;
case 'm':
mode = value;
break;
default:
alert(js.exec_file + ": Unrecognized option: " + arg);
exit(1);
}
}
if(!addr) {
alert(js.exec_file + ": No destination address specified");
exit(1);
}
if(!quiet) {
write("\r\n\x01h\x01hPress \x01yCtrl-]\x01w for a control menu anytime.\r\n\r\n");
if(pause)
console.pause();
writeln("\x01h\x01yConnecting to: \x01w" + addr + "\x01n");
}
mode = eval(mode);
var result = bbs.rlogin_gate(
addr // address[:port]
,client_name || (mode & TG_RLOGINSWAP ? user.name : user.alias)
,server_name || (mode & TG_RLOGINSWAP ? user.alias : user.name)
,term_type
,mode
,timeout
);
console.clear();
if(result === false)
alert(js.exec_file + ": Failed to connect to: " + addr);
else if(clear)
console.clear();
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