Skip to content

Commit

Permalink
chore(util): use realIp first
Browse files Browse the repository at this point in the history
  • Loading branch information
huangyoukun committed Nov 15, 2018
1 parent daeaa84 commit eee94bf
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions bin/tsw/util/http.js
Expand Up @@ -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)) {
Expand All @@ -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,外网带的不算
Expand Down

0 comments on commit eee94bf

Please sign in to comment.