You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am creating a WebSocket proxy. And I need to know which client is receiving the package. Basically I should store data from incoming traffic to use them in outgoing traffic and each client has different data. I searched and tried different ways but none of them worked. Can anyone suggest a working solution?
var proxyWebsocket, serverWebsocket, clientData = {};
const startWSProxy = (data) => {
proxyWebsocket = new httpProxy.createProxyServer({
target: {
protocol: 'ws',
host: 'localhost',
port: localPacketPort
},
ws: true,
xfwd: true,
toProxy: true
});
proxyWebsocket.on('open', function (proxySocket) {
proxySocket.on('data', (res) => {
// access the identifier here
// For example:
// proxySocket._uuid
// console.log(clientData[proxySocket._uuid]);
});
});
serverWebsocket = http.createServer();
serverWebsocket.on('upgrade', function (req, socket, head) {
proxyWebsocket.ws(req, socket, head);
// Set an identifier here
// For example:
// socket._uuid = uuid_generate();
socket.on('data', (res) => {
// clientData[socket._uuid][] = res
});
});
serverWebsocket.listen(remotePacketPort);
};
The text was updated successfully, but these errors were encountered:
Hello,
I am creating a WebSocket proxy. And I need to know which client is receiving the package. Basically I should store data from incoming traffic to use them in outgoing traffic and each client has different data. I searched and tried different ways but none of them worked. Can anyone suggest a working solution?
The text was updated successfully, but these errors were encountered: