var net = require('net'); var local_port = 8893; //在本地创建一个server监听本地local_port端口 net.createServer(function (client) { //首先监听浏览器的数据发送事件,直到收到的数据包含完整的http请求头 var buffer = new Buffer(0); client.on('data',function(data) { buffer = buffer_add(buffer,data);
/** * Created by chaozhou on 2015/11/24. */ var getIp = function(req){ var ipStr = req.headers['x-forwarded-for']; //F5 if(ipStr){ var ipArray = ipStr.split(","); if(ipArray.length > 1){ //如果获取到的为ip数组(用手机访问时,如果机房双线,可能获取到的为数组 for(var i = 0; i