Security News
PyPI’s New Archival Feature Closes a Major Security Gap
PyPI now allows maintainers to archive projects, improving security and helping users make informed decisions about their dependencies.
@gobark/udprpc
Advanced tools
A UDP-based JSON-RPC 2.0 library for peer-to-peer communications with support for ES6 promises
This is a UDP-based JSON-RPC 2.0 library with support for ES6 promises. One common use-case would be for for peer-to-peer communications.
This library is (nearly) compliant with the JSON-RPC 2.0 Specification at http://www.jsonrpc.org/specification.
Missing: Support JSON-RPC batch requests and reponses (see Contribution section below).
npm install @gobark/udprpc
UdpRpc leverages UDP to enable each peer listen to and send requests on the same port.
Even through all peers can send and receive requests -- for the sake of simplicity -- in the example below the "cient" sends requests and the "server" receives them.
Also note that different peers can reside on different hosts. In the example below, we assume that both peers are on localhost.
// import UdpRpc
const UdpRpc = require("@gobark/udprpc").UdpRpc;
// create a new instance of UdpRpc
let udpRpcServer = new UdpRpc(3000); // can be any port
// start listening
udpRpcServer.start();
// handle incoming requests
udpRpcServer.register((method, params, address, port, resolve, reject) => {
switch (method) {
case "sum": {
if (isNaN(params[0]) || isNaN(params[1])) {
reject("Parameters must be numbers");
} else {
resolve(Number(params[0]) + Number(params[1]));
}
break;
}
case "concat": {
resolve(`${params[0]}${params[1]}`);
break;
}
}
// stop server when needed
// udpRpcServer.stop();
});
// import UdpRpc
const UdpRpc = require("@gobark/udprpc").UdpRpc;
// create a new instance of UdpRpc
let udpRpcClient = new UdpRpc(3001);
// start listening
udpRpcClient.start();
return udpRpcClient.send("sum", [ 1, 2 ], "127.0.0.1", 3000).then((response) => {
// the server can be any address and port as long as their accessible to the client
console.log(response); // response === 3
}).catch((err) => {
console.error(err);
}).then(() => {
// stop client
udpRpcClient.stop();
});
FAQs
A UDP-based JSON-RPC 2.0 library for peer-to-peer communications with support for ES6 promises
We found that @gobark/udprpc demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
PyPI now allows maintainers to archive projects, improving security and helping users make informed decisions about their dependencies.
Research
Security News
Malicious npm package postcss-optimizer delivers BeaverTail malware, targeting developer systems; similarities to past campaigns suggest a North Korean connection.
Security News
CISA's KEV data is now on GitHub, offering easier access, API integration, commit history tracking, and automated updates for security teams and researchers.