See if I can keep this from racing.
This commit is contained in:
@ -179,12 +179,12 @@ TLS configuration is experimental. It might not be possible(To multiplex http
|
||||
and https on the same SAM tunnel).
|
||||
-----BEGIN PGP SIGNATURE-----
|
||||
|
||||
iQEzBAEBCAAdFiEEcNIGBzi++AUjrK/311wDs5teFOEFAluXGEYACgkQ11wDs5te
|
||||
FOFlzAf/eBTmCZjkPhBI0jLYB8ENvZbFDCqM+ymigLz4jl85o0RSywfsebDQd0p/
|
||||
VrDFLPnPfZCaPa14wpBPhj2KCCVSsQC7eqPm+S//A6B28I7t7Gp91qy1SP9X3F6W
|
||||
aXJImEjbCzVyLa1izzCSxEDVUIJaDfAl630+aznESM0tYbHqvutDOgtevc2nv/FS
|
||||
KeqIf8PW9Q/ulsZaxo9JKYj6vo+zuEFMLWqvQFLkjilweOO7E1yPLKpQEMZZECjS
|
||||
pBDGeWogxZYIzUO6bRsXP/bgGxLphB7XagsOIJjpI7uCOf+cSVCdYCY1kafPQ78C
|
||||
U0ugpS1ZKyI5ZXFRr/OZViWAo+9dRQ==
|
||||
=mB7m
|
||||
iQEzBAEBCAAdFiEEcNIGBzi++AUjrK/311wDs5teFOEFAluXGrQACgkQ11wDs5te
|
||||
FOGdOAf/ST0cl04NV+Drm36dYnlOQO9eFssQ9xSB74jKpemUoFtjt+pCzLDQnyRT
|
||||
G3pt5e/OONqAGlgCOPiv3psUXU4QCw5w0ZNGCfVCZ7VAoFeI6+7mswyUKAt8Bd2n
|
||||
KIWmI48fyrL2aOmaE9l9Odf9gRgMWWBKuATcU+aP7itGDnOkpXI4o+Ifq6js4oro
|
||||
7XXRBua8P+kNDEHsVsovw8DCQWbIQHkCsK81KXlgvpkLozANwUE8Zt/oZKoZrzMT
|
||||
1v2Wxiull9OGk6NI7WkVUPM7TtVg+kjnw90PwetfAw5rssfk1y62wtvWGGL6r+zd
|
||||
eqTb15NsmR2hgpDfRBFOoak3vH93PA==
|
||||
=bXFb
|
||||
-----END PGP SIGNATURE-----
|
||||
|
22
forwarder.go
22
forwarder.go
@ -151,6 +151,18 @@ func (f *SAMForwarder) clientUnlockAndClose(cli, conn bool, client net.Conn) {
|
||||
}
|
||||
}
|
||||
|
||||
func (f *SAMForwarder) connUnlockAndClose(cli, conn bool, client *sam3.SAMConn) {
|
||||
if cli == true {
|
||||
f.clientLock = cli
|
||||
}
|
||||
if conn == true {
|
||||
f.connLock = conn
|
||||
}
|
||||
if f.clientLock && f.connLock {
|
||||
client.Close()
|
||||
}
|
||||
}
|
||||
|
||||
func (f *SAMForwarder) forward(conn *sam3.SAMConn) { //(conn net.Conn) {
|
||||
var request *http.Request
|
||||
var requestbytes []byte
|
||||
@ -161,9 +173,8 @@ func (f *SAMForwarder) forward(conn *sam3.SAMConn) { //(conn net.Conn) {
|
||||
log.Fatalf("Dial failed: %v", err)
|
||||
}
|
||||
go func() {
|
||||
//defer f.clientUnlockAndClose(true, false, client)
|
||||
defer client.Close()
|
||||
defer conn.Close()
|
||||
defer f.clientUnlockAndClose(true, false, client) //defer client.Close()
|
||||
defer f.connUnlockAndClose(false, true, conn) //defer conn.Close()
|
||||
if f.Type == "http" {
|
||||
if requestbytes, request, err = f.HTTPRequestBytes(conn); err == nil {
|
||||
log.Printf("Forwarding modified request: \n\t %s", string(requestbytes))
|
||||
@ -176,9 +187,8 @@ func (f *SAMForwarder) forward(conn *sam3.SAMConn) { //(conn net.Conn) {
|
||||
}
|
||||
}()
|
||||
go func() {
|
||||
//defer f.clientUnlockAndClose(false, true, client)
|
||||
defer client.Close()
|
||||
defer conn.Close()
|
||||
defer f.clientUnlockAndClose(false, true, client) //defer client.Close()
|
||||
defer f.connUnlockAndClose(true, false, conn) //defer conn.Close()
|
||||
if f.Type == "http" {
|
||||
if responsebytes, err = f.HTTPResponseBytes(client, request); err == nil {
|
||||
log.Printf("Forwarding modified response: \n\t%s", string(responsebytes))
|
||||
|
Reference in New Issue
Block a user