tlsd 2.12.0 → 2.12.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/tlsd.js +10 -10
- /package/scaffold/rpc/{index.js → index.cjs} +0 -0
package/package.json
CHANGED
package/tlsd.js
CHANGED
|
@@ -44,10 +44,10 @@ function next_seq() {
|
|
|
44
44
|
|
|
45
45
|
// Handles incoming RPC msgs.
|
|
46
46
|
// Tries to load the rpc handler module from root and if successful, passes the msg to it
|
|
47
|
-
//
|
|
48
|
-
// { type: "WS",
|
|
49
|
-
// { type: "GET",
|
|
50
|
-
// { type: "POST",
|
|
47
|
+
// transport =
|
|
48
|
+
// { type: "WS", connection: { ... } }
|
|
49
|
+
// { type: "GET", connection: { req, res } }
|
|
50
|
+
// { type: "POST", connection: { req, res } }
|
|
51
51
|
function rpc_handler( root, msg, transport, _okay, _fail ) {
|
|
52
52
|
|
|
53
53
|
let ll = toInt( msg.log_level );
|
|
@@ -82,7 +82,7 @@ function rpc_handler( root, msg, transport, _okay, _fail ) {
|
|
|
82
82
|
};
|
|
83
83
|
|
|
84
84
|
try {
|
|
85
|
-
const mod = require( root + "/rpc" );
|
|
85
|
+
const mod = require( root + "/rpc/index.cjs" );
|
|
86
86
|
try {
|
|
87
87
|
mod( msg, okay, ouch, transport );
|
|
88
88
|
} catch( err ) {
|
|
@@ -99,7 +99,7 @@ function rpc_handler( root, msg, transport, _okay, _fail ) {
|
|
|
99
99
|
// Glue function to call rpc handler module and then return response
|
|
100
100
|
// via the websockets msg object
|
|
101
101
|
function ws_msg_handler( root, msg, connection ) {
|
|
102
|
-
rpc_handler( root, msg.msg, { type: "WS",
|
|
102
|
+
rpc_handler( root, msg.msg, { type: "WS", connection }, data => {
|
|
103
103
|
msg.reply( data );
|
|
104
104
|
}, error => {
|
|
105
105
|
msg.error( { error } );
|
|
@@ -165,7 +165,7 @@ function rpc_post( root ) {
|
|
|
165
165
|
const fail = ( error, body ) => { done( error, body ); };
|
|
166
166
|
|
|
167
167
|
// Summon the rpc handler for the domain root.
|
|
168
|
-
rpc_handler( root, input, { type
|
|
168
|
+
rpc_handler( root, input, { type: method, connection: { req, res, } } , okay, fail );
|
|
169
169
|
};
|
|
170
170
|
}
|
|
171
171
|
|
|
@@ -274,7 +274,7 @@ function ws_attach( server, msg_handler ) {
|
|
|
274
274
|
const name = "ws-conn-"+next_seq(); // XXX just use the websocket id
|
|
275
275
|
|
|
276
276
|
// send msg to connected client
|
|
277
|
-
const send = function( msg
|
|
277
|
+
const send = function( msg, cb ) {
|
|
278
278
|
if( msg.msg_id === undefined ) {
|
|
279
279
|
msg.msg_id = "msg-id-" + next_seq(); // every message must have an id
|
|
280
280
|
}
|
|
@@ -396,8 +396,8 @@ if( argv.length == 5 ) {
|
|
|
396
396
|
rest_handler( SITE_ROOT, req, res );
|
|
397
397
|
} );
|
|
398
398
|
|
|
399
|
-
ws_attach( server, ( msg,
|
|
400
|
-
ws_msg_handler( SITE_ROOT, msg );
|
|
399
|
+
ws_attach( server, ( msg, connection, domain ) => {
|
|
400
|
+
ws_msg_handler( SITE_ROOT, msg, connection );
|
|
401
401
|
} );
|
|
402
402
|
|
|
403
403
|
server.listen( toInt( PORT ), () => {
|
|
File without changes
|