Hi everyone, May I ask you for a little help?
I have a problem proxying requests. I want to use chrome with --proxy-server flag with username and password, but it only accepts host:port, I would like to recreate something like this https://github.com/sjitech/proxy-login-automator/blob/master/proxy-login-automator.js#L91 which is created to solve this exact problem but for node. In the code I use golang http.ReadRequest with req.WriteProxy and it works but only with http and not with https. This is a code snippet: func tcpProxy() { var localAddr = "localhost:8080" var remoteAddr = "localhost:8888" l, err := net.Listen("tcp", localAddr) if err != nil { log.Fatalln("listen err:", err) } for { lconn, err := l.Accept() if err != nil { log.Println("accept err:", err) } go handleConnection(lconn, remoteAddr) } } func handleConnection(lconn net.Conn, remoteAddr string) { req, err := http.ReadRequest(bufio.NewReader(lconn)) if err != nil { fmt.Println("req read err:", err) return } rconn, err := net.Dial("tcp", remoteAddr) if err != nil { log.Println("dial err:", err) return } go func() { if err := req.WriteProxy(rconn); err != nil { log.Println("req write err:", err) return } }() resp, err := http.ReadResponse(bufio.NewReader(rconn), req) if err != nil { log.Println("response read err:", err) return } go func() { if err := resp.Write(lconn); err != nil { log.Println("esp write err: ", err) return } }() } Thank you very much for your help! -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.