Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
caddy
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
caddy
Commits
da97ac7c
Commit
da97ac7c
authored
May 24, 2016
by
Harrison Heck
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Strip [] from IPv6 addresses for FastCGI.
Fixes #845.
parent
374d0a3f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
2 deletions
+6
-2
middleware/fastcgi/fastcgi.go
middleware/fastcgi/fastcgi.go
+4
-0
middleware/fastcgi/fastcgi_test.go
middleware/fastcgi/fastcgi_test.go
+2
-2
No files found.
middleware/fastcgi/fastcgi.go
View file @
da97ac7c
...
@@ -183,6 +183,10 @@ func (h Handler) buildEnv(r *http.Request, rule Rule, fpath string) (map[string]
...
@@ -183,6 +183,10 @@ func (h Handler) buildEnv(r *http.Request, rule Rule, fpath string) (map[string]
ip
=
r
.
RemoteAddr
ip
=
r
.
RemoteAddr
}
}
// Remove [] from IPv6 addresses
ip
=
strings
.
Replace
(
ip
,
"["
,
""
,
1
)
ip
=
strings
.
Replace
(
ip
,
"]"
,
""
,
1
)
// Split path in preparation for env variables.
// Split path in preparation for env variables.
// Previous rule.canSplit checks ensure this can never be -1.
// Previous rule.canSplit checks ensure this can never be -1.
splitPos
:=
rule
.
splitPos
(
fpath
)
splitPos
:=
rule
.
splitPos
(
fpath
)
...
...
middleware/fastcgi/fastcgi_test.go
View file @
da97ac7c
...
@@ -137,7 +137,7 @@ func TestBuildEnv(t *testing.T) {
...
@@ -137,7 +137,7 @@ func TestBuildEnv(t *testing.T) {
fpath
:=
"/fgci_test.php"
fpath
:=
"/fgci_test.php"
var
envExpected
=
map
[
string
]
string
{
var
envExpected
=
map
[
string
]
string
{
"REMOTE_ADDR"
:
"
[2b02:1810:4f2d:9400:70ab:f822:be8a:9093]
"
,
"REMOTE_ADDR"
:
"
2b02:1810:4f2d:9400:70ab:f822:be8a:9093
"
,
"REMOTE_PORT"
:
"51688"
,
"REMOTE_PORT"
:
"51688"
,
"SERVER_PROTOCOL"
:
"HTTP/1.1"
,
"SERVER_PROTOCOL"
:
"HTTP/1.1"
,
"QUERY_STRING"
:
"test=blabla"
,
"QUERY_STRING"
:
"test=blabla"
,
...
@@ -150,7 +150,7 @@ func TestBuildEnv(t *testing.T) {
...
@@ -150,7 +150,7 @@ func TestBuildEnv(t *testing.T) {
// 2. Test for shorthand notation of IPv6 address
// 2. Test for shorthand notation of IPv6 address
r
.
RemoteAddr
=
"[::1]:51688"
r
.
RemoteAddr
=
"[::1]:51688"
envExpected
[
"REMOTE_ADDR"
]
=
"
[::1]
"
envExpected
[
"REMOTE_ADDR"
]
=
"
::1
"
testBuildEnv
(
&
r
,
rule
,
fpath
,
envExpected
)
testBuildEnv
(
&
r
,
rule
,
fpath
,
envExpected
)
// 3. Test for IPv4 address
// 3. Test for IPv4 address
...
...
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