Last active
March 19, 2020 06:42
-
-
Save zengxs/ea71205d4343759b66db33947de3cd19 to your computer and use it in GitHub Desktop.
a simple http-proxy program use goproxy, with basic auth
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
package main | |
import ( | |
"log" | |
"net/http" | |
"github.com/elazarl/goproxy" | |
"github.com/elazarl/goproxy/ext/auth" | |
) | |
func main() { | |
proxy := goproxy.NewProxyHttpServer() | |
proxy.Verbose = true | |
proxy.OnRequest().HandleConnect(auth.BasicConnect("rainy-proxy v0.0.1", func(user, passwd string) bool { | |
return user == "rainy" && passwd == "proxy" | |
})) | |
log.Fatal(http.ListenAndServe(":8000", proxy)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You should be using the ProxyBasic function instead of BasicConnect.