Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
connection socket wrapper
const net = require('net');
const awaitFirst = require('await-first');
const Connection = require('connection');
const Decoder = require('sofa-bolt-node/lib/decoder');
const Encoder = require('sofa-bolt-node/lib/encoder');
// bolt protocol example
const protocol = {
name: 'Rpc',
encoder: opts => new Encoder(opts),
decoder: opts => new Decoder(opts),
};
async function createConnection(hostname, port) {
const socket = net.connect(port, hostname);
await awaitFirst(socket, [ 'connect', 'error' ]);
return new Connection({
logger: console,
socket,
protocol,
});
}
const conn = await createConnection('127.0.0.1', 12200);
conn.writeRequest({
targetAppName: 'foo',
args: [ 'peter' ],
serverSignature: 'com.alipay.sofa.rpc.quickstart.HelloService:1.0',
methodName: 'sayHello',
methodArgSigs: [ 'java.lang.String' ],
requestProps: null,
});
const Connection = require('connection');
const server = net.createServer();
server.listen(port);
server.on('connection', sock => {
const conn = new Connection({
logger: console,
socket: sock,
protocol,
});
conn.on('request', req => {
conn.writeResponse(req, {
error: null,
appResponse: 'hello, peter',
responseProps: null,
});
});
});
interface Request {
/**
* If request is oneway, shoule set to true
*/
oneway: boolean,
/**
* writeRequest will use the timeout to set the timer
*/
timeout: number,
/**
* request packet type, request|heartbeat|response
*/
packetType: string,
}
interface Response {
packetId: number,
}
interface Encoder extends Transform {
/**
* write request to socket
* Connection#writeRequest and Connection#oneway will call the function.
* @param {number} id - the request id
* @param {Object} req - the request object should be encoded
* @param {Function} cb - the encode callback
*/
writeRequest(id: number, req: object, cb);
/**
* write response to socket
* Connection#writeResponse will call the function.
* @param {Object} req - the request object
* @param {Object} res - the response object should be encoded
* @param {Function} cb - the encode callback
*/
writeResponse(req: object, res: object, cb);
}
interface Decoder extends Writable {
// events
// - request emit when have request packet
// - heartbeat emit when have heartbeat packet
// - response emit when have response packet
}
interface Protocol {
name: string;
encode(options: any): Encoder;
decode(options: any): Decoder;
}
FAQs
wrap for socket
We found that connection demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 15 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
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.