iport
honeycomb的runner
Last updated 5 years ago by jifeng.zjd .
Original npm · Tarball · package.json
$ cnpm install iport 
SYNC missed versions from official npm registry.

iport

logo

web服务中ip和port的统一公里工具类

取名

iport = ip + port

安装

npm install iport

用法


var http = require('http');
var iport = require('iport');
var connect = require('connect');

var app = connect()
app.use(function (req, res, next) {
  res.statusCode = 200;
  //获取ip地址
  var ip = iport.getIP(req);
  //获取port地址
  var port = iport.getPort(req);
  res.end(ip + ':' + port);
});

//按规则通知ip和port的获取
app.use('/normal', iport.middleware());

var server = http.createServer(app);

server.listen(1723);

讲解

  • ip和port的获取规则: http headers -> http -> tcp
  • headers的默认头信息 x-forwarded-forx-forwarded-for-port

Current Tags

  • 0.0.1                                ...           latest (5 years ago)

1 Versions

  • 0.0.1                                ...           5 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 1
Dependencies (1)
Dev Dependencies (6)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |