Skip to content

Instantly share code, notes, and snippets.

@zengxs
Last active March 19, 2020 06:42
Show Gist options
  • Save zengxs/ea71205d4343759b66db33947de3cd19 to your computer and use it in GitHub Desktop.
Save zengxs/ea71205d4343759b66db33947de3cd19 to your computer and use it in GitHub Desktop.
a simple http-proxy program use goproxy, with basic auth
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))
}
@mfdeux
Copy link

mfdeux commented Sep 28, 2017

You should be using the ProxyBasic function instead of BasicConnect.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment