Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ale
autoradio
Commits
064a7387
Commit
064a7387
authored
Jul 24, 2015
by
ale
Browse files
fix withLocalhost: RemoteAddr is a host:port
parent
e01cbaab
Changes
1
Hide whitespace changes
Inline
Side-by-side
fe/http.go
View file @
064a7387
...
...
@@ -371,7 +371,12 @@ func (h *HttpRedirector) serveStatusPage(w http.ResponseWriter, r *http.Request)
func
withLocalhost
(
h
http
.
Handler
)
http
.
Handler
{
return
http
.
HandlerFunc
(
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
if
ip
:=
net
.
ParseIP
(
r
.
RemoteAddr
);
!
ip
.
IsLoopback
()
{
host
,
_
,
err
:=
net
.
SplitHostPort
(
r
.
RemoteAddr
)
if
err
!=
nil
{
http
.
Error
(
w
,
"Unauthorized"
,
http
.
StatusUnauthorized
)
return
}
if
ip
:=
net
.
ParseIP
(
host
);
!
ip
.
IsLoopback
()
{
http
.
Error
(
w
,
"Unauthorized"
,
http
.
StatusUnauthorized
)
return
}
...
...
Write
Preview
Supports
Markdown
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