Skip to content

Instantly share code, notes, and snippets.

@skroll
Created May 8, 2016 18:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save skroll/f4f46831daffb689de57b309ce36bf5d to your computer and use it in GitHub Desktop.
Save skroll/f4f46831daffb689de57b309ce36bf5d to your computer and use it in GitHub Desktop.
package main
import (
"github.com/elazarl/goproxy"
"log"
"net/http"
"strings"
)
func onSWCall(req *http.Request, resp *http.Response) {
log.Print("SW Call")
}
func main() {
proxy := goproxy.NewProxyHttpServer()
proxy.OnResponse().DoFunc(
func(r *http.Response, ctx *goproxy.ProxyCtx) *http.Response {
if strings.HasPrefix(ctx.Req.Host, "summonerswar") && strings.HasSuffix(ctx.Req.Host, "com2us.net") && strings.HasPrefix(ctx.Req.URL.Path, "/api/") {
onSWCall(ctx.Req, r)
}
return r
})
http.ListenAndServe(":8080", proxy)
}
@Nacheen81
Copy link

@skroll I was able to successfully run the proxy.go and SW was able to log in without issue.

The feedback from the system while connected showed as follows:
2016/05/08 13:25:54 [214] WARN: Error copying to client: use of closed network connection
2016/05/08 13:26:00 SW Call
2016/05/08 13:26:01 SW Call
2016/05/08 13:26:01 SW Call
2016/05/08 13:26:24 SW Call
2016/05/08 13:26:24 SW Call
2016/05/08 13:26:25 [191] WARN: Error copying to client: use of closed network connection
2016/05/08 13:26:26 SW Call
2016/05/08 13:26:27 SW Call
2016/05/08 13:26:28 [196] WARN: Error copying to client: use of closed network connection
2016/05/08 13:26:36 SW Call
2016/05/08 13:26:36 SW Call
2016/05/08 13:26:36 SW Call
2016/05/08 13:26:36 SW Call
2016/05/08 13:26:36 SW Call
2016/05/08 13:26:36 SW Call
2016/05/08 13:26:36 SW Call
2016/05/08 13:26:36 SW Call
2016/05/08 13:26:36 [197] WARN: Error copying to client: use of closed network connection
2016/05/08 13:26:39 SW Call
2016/05/08 13:26:40 SW Call
2016/05/08 13:26:40 SW Call
2016/05/08 13:26:51 [011] WARN: Error copying to client: use of closed network connection

I'm not a coder by trade and everything I know is self taught. So forgive any ignorance. I didn't get any file output while connected, however I don't believe that there is a file output expected by the current revision of your code.

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