如何在Tower.js中获取远程ip地址



我正在使用Tower.js创建web服务。我能够获得HTTP头和用户代理,但无法获得远程ip地址。如何获取请求者的远程ip地址?

我试过

  1. 查找Tower.Controller类成员变量和方法(this.request和this.request.app以及this.request.headers等)
  2. 检查HTTP标头
  3. 阅读塔台文件(https://github.com/viatropos/tower-docs)
  4. 阅读超级代理文件(https://github.com/visionmedia/superagent)

如果缺少信息,请添加。谢谢

感谢您的回复!

我已检查请求对象。但无法获取IP地址。

已安装Tower 0.4.2-3和Express 3.0.0rc5但是发生运行时错误。Tower.js支持Express3.0吗?或者Express 2.x可以获得远程ip地址?

你能告诉我吗?

错误消息:/var/www/html/melissa/server2/node_modules/tower/bin/test/node_modules/mongodb/lib/mongodb/connection/server.js:432投掷失误;^TypeError:无法调用未定义的方法"apply"位于Tower.Application.Application.reopen.use(/var/www/html/mellissa/server2/node_modules/Tower/bin/test/node_modules/stower/lib/Tower-Application/server/Application.js:115:52)为null。(/var/www/html/mellissa/server2/node_modules/tower/bin/test/app/config/server/bootstrap.coffee:9:12)位于Tower.Application.Application.reopen.stack(/var/www/html/mellissa/server2/node_modules/Tower/bin/test/node_modules/stower/lib/Tower-Application/server/Application.js:177:16)位于Tower.Application.Application.reopen.initialize.initializer(/var/www/html/melisa/server2/node_modules/Tower/bin/test/node_modules/stower/lib/Tower-Application/server/Application.js:90:19)位于Tower.Application.Application.reopen.configurateStores(/var/www/html/melisa/server2/node_modules/Tower/bin/test/node_modules/stower/lib/Tower-Application/server/Application.js:164:27)在_.exextend.parallel(/var/www/html/melisa/server2/node_modules/tower/bin/test/node_modules/stower/lib/tower-support/shared/shared.js:344:20)网址:/var/www/html/mellissa/server2/node_modules/tower/bin/test/node_modules/stower/lib/tower-store/server/mongodb/database.js:52:24在applyIndex(/var/www/html/mellissa/server2/node_modules/tower/bin/test/node_modules/stower/lib/tower-store/server/mongodb/database.js:26:20)网址:/var/www/html/mellissa/server2/node_modules/tower/bin/test/node_modules/stower/lib/tower-store/server/mongodb/database.js:50:20在Db.open(/var/www/html/melisa/server2/node_modules/tower/bin/test/node_modules/mongodb/lib/mongodb/Db.js:258:14)

最新更新