Skip to content

Commit

Permalink
feat(http): support ipv6
Browse files Browse the repository at this point in the history
  • Loading branch information
huangyoukun committed Aug 15, 2018
1 parent 2a426a6 commit c5d2ff7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions bin/tsw/util/http.isInnerIP.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ this.isInnerIP = (function() {
return false;
}

// ipv4 in ipv6
if (ipAddress.startsWith('::ffff:')) {
ipAddress = ipAddress.substr(7);
}

if (!net.isIPv4(ipAddress)) {
return false;
}
Expand Down
5 changes: 5 additions & 0 deletions bin/tsw/util/http.js
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,11 @@ this.getUserIp = function(request) {

}

// ipv4 in ipv6
if (userIp.startsWith('::ffff:')) {
userIp = userIp.substr(7);
}

request.userIp = userIp;

return userIp;
Expand Down

0 comments on commit c5d2ff7

Please sign in to comment.