-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into issue-453
- Loading branch information
Showing
70 changed files
with
1,161 additions
and
652 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package goproxy | ||
|
||
import ( | ||
"net" | ||
"net/http" | ||
"strings" | ||
"testing" | ||
) | ||
|
||
func TestIsLocalHost(t *testing.T) { | ||
hosts := []string{ | ||
"localhost", | ||
"127.0.0.1", | ||
"127.0.0.7", | ||
"::ffff:127.0.0.1", | ||
"::ffff:127.0.0.7", | ||
"::1", | ||
"0:0:0:0:0:0:0:1", | ||
} | ||
ports := []string{ | ||
"", | ||
"80", | ||
"443", | ||
} | ||
|
||
for _, host := range hosts { | ||
for _, port := range ports { | ||
if port == "" && strings.HasPrefix(host, "::ffff:") { | ||
continue | ||
} | ||
|
||
addr := host | ||
if port != "" { | ||
addr = net.JoinHostPort(host, port) | ||
} | ||
t.Run(addr, func(t *testing.T) { | ||
req, err := http.NewRequest(http.MethodGet, "http://"+addr, http.NoBody) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
if !IsLocalHost(req, nil) { | ||
t.Fatal("expected true") | ||
} | ||
}) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# CascadeProxy | ||
|
||
`CascadeProxy` is an example that shows an aggregator server that forwards | ||
the requests to another proxy server (end proxy). | ||
|
||
Diagram: | ||
``` | ||
client --> middle proxy --> end proxy --> internet | ||
``` | ||
|
||
This example starts both proxy servers using goproxy, the middle one | ||
listens on port `8081`, and the end one on port `8082`. | ||
|
||
The middle proxy must be an HTTP server, since we use goproxy that | ||
expose only it. | ||
The end proxy can be any type of proxy supported by Go, including SOCKS5, | ||
there is a comment in the part where you can put its address. |
Oops, something went wrong.