Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
H
hphy
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
向怀芳
hphy
Commits
43eb8f06
Commit
43eb8f06
authored
Oct 20, 2022
by
向怀芳
🎱
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1. IP白名单04
parent
5db3bca0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
2 additions
and
1 deletion
+2
-1
WhitIPConfig.java
...sh/stc/sict/cloud/common/gateway/config/WhitIPConfig.java
+1
-0
RequestGlobalFilter.java
...sict/cloud/common/gateway/filter/RequestGlobalFilter.java
+1
-1
No files found.
cloud-common/cloud-common-gateway/src/main/java/cn/sh/stc/sict/cloud/common/gateway/config/WhitIPConfig.java
View file @
43eb8f06
...
@@ -20,5 +20,6 @@ import java.util.List;
...
@@ -20,5 +20,6 @@ import java.util.List;
@ConditionalOnExpression
(
"!'${whiteip}'.isEmpty()"
)
@ConditionalOnExpression
(
"!'${whiteip}'.isEmpty()"
)
@ConfigurationProperties
(
prefix
=
"whiteip"
)
@ConfigurationProperties
(
prefix
=
"whiteip"
)
public
class
WhitIPConfig
{
public
class
WhitIPConfig
{
private
Boolean
limitFlag
;
private
List
<
String
>
whites
=
new
ArrayList
<>();
private
List
<
String
>
whites
=
new
ArrayList
<>();
}
}
cloud-common/cloud-common-gateway/src/main/java/cn/sh/stc/sict/cloud/common/gateway/filter/RequestGlobalFilter.java
View file @
43eb8f06
...
@@ -67,7 +67,7 @@ public class RequestGlobalFilter implements GlobalFilter, Ordered {
...
@@ -67,7 +67,7 @@ public class RequestGlobalFilter implements GlobalFilter, Ordered {
String
ip
=
WebUtils
.
getIP
(
request
);
String
ip
=
WebUtils
.
getIP
(
request
);
log
.
error
(
"RemoteAddress ===================> {}"
,
request
.
getRemoteAddress
());
log
.
error
(
"RemoteAddress ===================> {}"
,
request
.
getRemoteAddress
());
try
{
try
{
if
(!
IPStrUtil
.
matches
(
ip
,
whitIPConfig
.
getWhites
()))
{
if
(
whitIPConfig
.
getLimitFlag
()
&&
!
IPStrUtil
.
matches
(
ip
,
whitIPConfig
.
getWhites
()))
{
ServerHttpResponse
response
=
exchange
.
getResponse
();
ServerHttpResponse
response
=
exchange
.
getResponse
();
response
.
setStatusCode
(
HttpStatus
.
PRECONDITION_REQUIRED
);
response
.
setStatusCode
(
HttpStatus
.
PRECONDITION_REQUIRED
);
response
.
getHeaders
().
set
(
"Content-type"
,
"application/json; charset=utf-8"
);
response
.
getHeaders
().
set
(
"Content-type"
,
"application/json; charset=utf-8"
);
...
...
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