Skip to content

Commit 3f1a281

Browse files
implemented demo
1 parent 43f6b3c commit 3f1a281

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

demo/main.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,13 @@ func OnAccept(ctx *httpproxy.Context, req *http.Request) *http.Response {
1616
}
1717

1818
func OnAuth(ctx *httpproxy.Context, user string, pass string) bool {
19-
return true
19+
if user == "test" && pass == "1234" {
20+
return true
21+
}
22+
return false
2023
}
2124

2225
func OnConnect(ctx *httpproxy.Context, host string) (httpproxy.ConnectAction, string) {
23-
//return httpproxy.ConnectOk, host
2426
return httpproxy.ConnectMitm, host
2527
}
2628

@@ -35,7 +37,11 @@ func OnResponse(ctx *httpproxy.Context, req *http.Request, resp *http.Response)
3537
func main() {
3638
prx, _ := httpproxy.NewProxy()
3739
prx.OnError = OnError
38-
prx.OnResponse = OnResponse
40+
prx.OnAccept = OnAccept
41+
prx.OnAuth = OnAuth
3942
prx.OnConnect = OnConnect
43+
prx.OnRequest = OnRequest
44+
prx.OnResponse = OnResponse
45+
4046
http.ListenAndServe(":8080", prx)
4147
}

0 commit comments

Comments
 (0)