This is the ws module, what I want to ask is how to get the client's MAC, ip and other information when connecting
const WebSocket = require('ws');
const WebSocketServer = WebSocket.Server;
const wss = new WebSocketServer({
//...
}, () => {
});
wss.on('connection', function (ws, req) {}); //How to get client MAC, ip and other information?
I don't know what you mean by "other information", but req
is an http.IncomingMessage
, so the documentation would be a good starting point.
For example, the IP address is accessible as req.socket.localAddress
.
You won't be able to get the MAC address.