这似乎是一个非常基本的问题,没有一个优雅的解决方案/答案。
如何从 (1) 服务器或 (2) 客户端访问客户端(远程)IP 地址?
获取客户端IP:
如果没有 http 请求,在函数中您应该能够通过以下方式获取 clientIP:
clientIP = this.connection.clientAddress;
//EX: you declare a submitForm function with Meteor.methods and
//you call it from the client with Meteor.call().
//In submitForm function you will have access to the client address as above
通过 http 请求并使用iron-router 及其 Router.map 函数:
在目标路由的操作函数中使用:
clientIp = this.request.connection.remoteAddress;
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)