How do you restrict access to a Meteor site based on IP


#1

I would like to restrict access to my site based on the IP address of the client. For example, if an user’s IP address has had past transgressions on my site, I want to effectively block it.

I know how to access the IP address in Meteor Methods (ip = this.connection.clientAddress;), but now I want to know how I can block it from access.


#2

Something like this?

// Server.js
Meteor.onConnection(function (connection) {
  // Check if connected client has their IP banned
  if (BannedIPs.findOne({IP: connection.clientAddress})) {
    // Close/deny connection
    connection.close();
  }
})

More info: http://docs.meteor.com/#/full/meteor_onconnection
Relevant package: https://github.com/mizzao/meteor-user-status