Skip to content
Permalink
Browse files

chore(util): use realIp first

  • Loading branch information...
huangyoukun committed Nov 15, 2018
1 parent daeaa84 commit eee94bf0ae306db980ebc82b62c18502b69eeb6f
Showing with 7 additions and 7 deletions.
  1. +7 −7 bin/tsw/util/http.js
@@ -416,7 +416,13 @@ this.getUserIp = function(request) {
const qvia = request.headers['qvia'] || '';
const realIp = request.headers['x-real-ip'] || '';

if (xff) {
if (realIp) {

// x-real-ip
if (userIp && this.isInnerIP(userIp)) {
userIp = realIp;
}
} else if (xff) {

// xff判断,注意只认内网ip带的xff,外网带的不算
if (userIp && this.isInnerIP(userIp)) {
@@ -425,12 +431,6 @@ this.getUserIp = function(request) {
userIp = xff.trim() || userIp;
}

} else if (realIp) {

// x-real-ip
if (userIp && this.isInnerIP(userIp)) {
userIp = realIp;
}
} else if (qvia) {

// 注意只认内网ip带的qvia,外网带的不算

0 comments on commit eee94bf

Please sign in to comment.
You can’t perform that action at this time.