diff --git a/net/conn.go b/net/conn.go index 1058bd2..ad23326 100644 --- a/net/conn.go +++ b/net/conn.go @@ -91,15 +91,16 @@ func (lConn *Conn) HandleHttp(p packet.HttpPacket) { log.Debug("[HTTP] Connected to the server.") - go rConn.Serve(lConn, "[HTTP]") - go lConn.Serve(rConn, "[HTTP]") - _, err = rConn.Write(p.Raw()) if err != nil { log.Debug("[HTTP] Error sending request to the server: ", err) return } log.Debug("[HTTP] Sent a request to the server") + + go rConn.Serve(lConn, "[HTTP]") + lConn.Serve(rConn, "[HTTP]") + } func (lConn *Conn) HandleHttps(p packet.HttpPacket) { @@ -135,10 +136,6 @@ func (lConn *Conn) HandleHttps(p packet.HttpPacket) { log.Debug("[HTTPS] Client "+lConn.RemoteAddr().String()+" sent hello: ", len(clientHello), "bytes") - // Generate a go routine that reads from the server - go rConn.Serve(lConn, "[HTTPS]") - go lConn.Serve(rConn, "[HTTPS]") - pkt := packet.NewHttpsPacket(clientHello) chunks := pkt.SplitInChunks() @@ -147,6 +144,10 @@ func (lConn *Conn) HandleHttps(p packet.HttpPacket) { log.Debug("[HTTPS] Error writing client hello: ", err) return } + + // Generate a go routine that reads from the server + go rConn.Serve(lConn, "[HTTPS]") + lConn.Serve(rConn, "[HTTPS]") } func (from *Conn) Serve(to *Conn, proto string) { diff --git a/proxy/proxy.go b/proxy/proxy.go index 9274dbe..5fe3ff6 100644 --- a/proxy/proxy.go +++ b/proxy/proxy.go @@ -56,10 +56,10 @@ func (p *Proxy) Start() { if pkt.IsConnectMethod() { log.Debug("[HTTPS] Start") - go conn.HandleHttps(pkt) + conn.HandleHttps(pkt) } else { log.Debug("[HTTP] Start") - go conn.HandleHttp(pkt) + conn.HandleHttp(pkt) } }() }