记得上下班打卡 | git大法好,push需谨慎
Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
liquidnet-bus-v1
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
董敬伟
liquidnet-bus-v1
Commits
84b6a21d
Commit
84b6a21d
authored
Jun 03, 2021
by
张国柄
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix
parent
77af0675
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
0 deletions
+23
-0
CurrentUtil.java
...ain/java/com/liquidnet/commons/lang/util/CurrentUtil.java
+23
-0
No files found.
liquidnet-bus-common/liquidnet-common-base/src/main/java/com/liquidnet/commons/lang/util/CurrentUtil.java
View file @
84b6a21d
...
...
@@ -2,6 +2,7 @@ package com.liquidnet.commons.lang.util;
import
org.apache.commons.lang3.StringUtils
;
import
javax.servlet.http.HttpServletRequest
;
import
java.util.HashMap
;
import
java.util.Map
;
...
...
@@ -11,6 +12,7 @@ public class CurrentUtil {
public
static
final
String
uToken
=
"u-token"
;
public
static
final
String
CLI_SOURCE
=
"source"
;
public
static
final
String
CLI_VERSION
=
"version"
;
public
static
final
String
CLI_UNKNOWN
=
"unknown"
;
public
static
String
getToken
()
{
String
authToken
=
ServletUtils
.
getRequest
().
getHeader
(
uToken
);
...
...
@@ -45,4 +47,25 @@ public class CurrentUtil {
public
static
String
getCliVersion
()
{
return
ServletUtils
.
getRequest
().
getHeader
(
CLI_VERSION
);
}
public
static
String
getCliIpAddr
()
{
HttpServletRequest
request
=
ServletUtils
.
getRequest
();
String
ip
=
request
.
getHeader
(
"x-forwarded-for"
);
if
(
ip
==
null
||
ip
.
length
()
==
0
||
CLI_UNKNOWN
.
equalsIgnoreCase
(
ip
))
{
ip
=
request
.
getHeader
(
"Proxy-Client-IP"
);
}
if
(
ip
==
null
||
ip
.
length
()
==
0
||
CLI_UNKNOWN
.
equalsIgnoreCase
(
ip
))
{
ip
=
request
.
getHeader
(
"X-Forwarded-For"
);
}
if
(
ip
==
null
||
ip
.
length
()
==
0
||
CLI_UNKNOWN
.
equalsIgnoreCase
(
ip
))
{
ip
=
request
.
getHeader
(
"WL-Proxy-Client-IP"
);
}
if
(
ip
==
null
||
ip
.
length
()
==
0
||
CLI_UNKNOWN
.
equalsIgnoreCase
(
ip
))
{
ip
=
request
.
getHeader
(
"X-Real-IP"
);
}
if
(
ip
==
null
||
ip
.
length
()
==
0
||
CLI_UNKNOWN
.
equalsIgnoreCase
(
ip
))
{
ip
=
request
.
getRemoteAddr
();
}
return
"0:0:0:0:0:0:0:1"
.
equals
(
ip
)
?
"127.0.0.1"
:
ip
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment