Skip to content
This repository has been archived by the owner on Jun 4, 2023. It is now read-only.

Commit

Permalink
socketio: don't crash if we didn't get an IP address for client
Browse files Browse the repository at this point in the history
Related to #40.
  • Loading branch information
vincentbernat committed Feb 9, 2016
1 parent 5063a49 commit ca98006
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/api/socketio/displays.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ function handleNewDisplay(io) {
io.on('connection', function(socket) {
var ip = (socket.handshake.headers || {})['x-forwarded-for'] ||
socket.request.connection.remoteAddress;
ip = ip.replace(/^:ffff:/, '');
if (ip) {
// For some reason, socket.io may not provide an IP in all cases
ip = ip.replace(/^:ffff:/, '');
}
logger.info('new display', ip);
socket.on('register', function(data, fn) {

Expand Down

0 comments on commit ca98006

Please sign in to comment.