moscajs / mosca

MQTT broker as a module
mosca.io
3.2k stars 513 forks source link

Strange ip address #801

Closed chishi2612 closed 4 years ago

chishi2612 commented 4 years ago

I create mqtt server with mosca. I implement authenticate in my server:

server.authenticate = function(client, username, password, callback) { //check client id const id = client.id; var ip = ''; if (client && client.connection && client.connection.stream) { ip = client.connection.stream.remoteAddress; }

  console.log("mqtt server authenticate " + id + " " + ip );
  let authorized = (username === 'username' && password.toString() === 'password');

  console.log("authenticate " + authorized);
  callback(null, authorized);
};

I check ip of clients with:

netstat -nat | sort

I see some strange ip address that i can't log in my authenticate function. is there another way to connect to mosca server?

Thanks