Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
CAP
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
tsai
CAP
Commits
3b73274e
Commit
3b73274e
authored
Jun 07, 2018
by
Savorboard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed Incorrect local IP address judgment of IPv6. (#140)
parent
32d71144
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
12 deletions
+8
-12
DashboardRequest.cs
src/DotNetCore.CAP/Dashboard/DashboardRequest.cs
+3
-8
LocalRequestsOnlyAuthorizationFilter.cs
...ore.CAP/Dashboard/LocalRequestsOnlyAuthorizationFilter.cs
+5
-4
No files found.
src/DotNetCore.CAP/Dashboard/DashboardRequest.cs
View file @
3b73274e
...
...
@@ -28,19 +28,14 @@ namespace DotNetCore.CAP.Dashboard
public
CapDashboardRequest
(
HttpContext
context
)
{
if
(
context
==
null
)
{
throw
new
ArgumentNullException
(
nameof
(
context
));
}
_context
=
context
;
_context
=
context
??
throw
new
ArgumentNullException
(
nameof
(
context
));
}
public
override
string
Method
=>
_context
.
Request
.
Method
;
public
override
string
Path
=>
_context
.
Request
.
Path
.
Value
;
public
override
string
PathBase
=>
_context
.
Request
.
PathBase
.
Value
;
public
override
string
LocalIpAddress
=>
_context
.
Connection
.
LocalIpAddress
.
ToString
();
public
override
string
RemoteIpAddress
=>
_context
.
Connection
.
RemoteIpAddress
.
ToString
();
public
override
string
LocalIpAddress
=>
_context
.
Connection
.
LocalIpAddress
.
MapToIPv4
().
ToString
();
public
override
string
RemoteIpAddress
=>
_context
.
Connection
.
RemoteIpAddress
.
MapToIPv4
().
ToString
();
public
override
string
GetQuery
(
string
key
)
{
...
...
src/DotNetCore.CAP/Dashboard/LocalRequestsOnlyAuthorizationFilter.cs
View file @
3b73274e
...
...
@@ -9,26 +9,27 @@ namespace DotNetCore.CAP.Dashboard
{
public
bool
Authorize
(
DashboardContext
context
)
{
var
ipAddress
=
context
.
Request
.
RemoteIpAddress
;
// if unknown, assume not local
if
(
string
.
IsNullOrEmpty
(
context
.
Request
.
RemoteI
pAddress
))
if
(
string
.
IsNullOrEmpty
(
i
pAddress
))
{
return
false
;
}
// check if localhost
if
(
context
.
Request
.
RemoteIpAddress
==
"127.0.0.1"
||
context
.
Request
.
RemoteIpAddress
==
"::
1"
)
if
(
ipAddress
==
"127.0.0.1"
||
ipAddress
==
"0.0.0.
1"
)
{
return
true
;
}
// compare with local address
if
(
context
.
Request
.
RemoteI
pAddress
==
context
.
Request
.
LocalIpAddress
)
if
(
i
pAddress
==
context
.
Request
.
LocalIpAddress
)
{
return
true
;
}
// check if private ip
if
(
Helper
.
IsInnerIP
(
context
.
Request
.
RemoteI
pAddress
))
if
(
Helper
.
IsInnerIP
(
i
pAddress
))
{
return
true
;
}
...
...
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