|
|
|
@ -1,4 +1,3 @@
|
|
|
|
|
|
|
|
|
|
package sgfw
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
@ -335,12 +334,15 @@ func connectionReader(conn net.Conn, is_client bool, c chan connReader, done cha
|
|
|
|
|
ntimeouts = 0
|
|
|
|
|
} else if stage == 2 {
|
|
|
|
|
remainder := make([]byte, mlen)
|
|
|
|
|
conn.SetReadDeadline(time.Now().Add(1 * time.Second))
|
|
|
|
|
_, err := io.ReadFull(conn, remainder)
|
|
|
|
|
conn.SetReadDeadline(time.Now().Add(2 * time.Second))
|
|
|
|
|
numRead, err := io.ReadFull(conn, remainder)
|
|
|
|
|
conn.SetReadDeadline(time.Time{})
|
|
|
|
|
if err != nil {
|
|
|
|
|
if err, ok := err.(net.Error); ok && err.Timeout() {
|
|
|
|
|
ret_error = err
|
|
|
|
|
if numRead > 0 {
|
|
|
|
|
buffered = append(buffered, remainder[:numRead]...)
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
ntimeouts++
|
|
|
|
|
if ntimeouts == TLSGUARD_READ_TIMEOUT {
|
|
|
|
@ -348,9 +350,9 @@ func connectionReader(conn net.Conn, is_client bool, c chan connReader, done cha
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
buffered = append(buffered, remainder...)
|
|
|
|
|
}
|
|
|
|
|
//fmt.Printf("------- CHUNK READ: client: %v, err = %v, bytes = %v\n", is_client, err, len(buffered))
|
|
|
|
|
cr := connReader{client: is_client, data: buffered, rtype: rtype, err: err}
|
|
|
|
|
c <- cr
|
|
|
|
@ -456,7 +458,7 @@ select_loop:
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
alert_desc := int(int(cr.data[5])<<8 | int(cr.data[6]))
|
|
|
|
|
//fmt.Println("ALERT DESCRIPTION: ", alert_desc)
|
|
|
|
|
fmt.Println("ALERT DESCRIPTION: ", alert_desc)
|
|
|
|
|
|
|
|
|
|
if cr.data[TLS_RECORD_HDR_LEN] == SSL3_AL_FATAL {
|
|
|
|
|
return errors.New(fmt.Sprintf("TLSGuard dropped connection after fatal error alert detected"))
|
|
|
|
@ -479,14 +481,14 @@ select_loop:
|
|
|
|
|
|
|
|
|
|
if (client_sess || server_sess) && (client_change_cipher || server_change_cipher) {
|
|
|
|
|
|
|
|
|
|
if handshakeMessageLenInt > len(cr.data)+9 {
|
|
|
|
|
// log.Notice("TLSGuard saw what looks like a resumed encrypted session... passing connection through")
|
|
|
|
|
//if handshakeMessageLenInt > len(cr.data)+9 {
|
|
|
|
|
log.Notice("TLSGuard saw what looks like a resumed encrypted session... passing connection through")
|
|
|
|
|
other.Write(cr.data)
|
|
|
|
|
dChan <- true
|
|
|
|
|
dChan2 <- true
|
|
|
|
|
x509Valid = true
|
|
|
|
|
break select_loop
|
|
|
|
|
}
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -503,6 +505,9 @@ select_loop:
|
|
|
|
|
|
|
|
|
|
if s != SSL3_MT_CLIENT_HELLO {
|
|
|
|
|
server_expected = []uint{SSL3_MT_CERTIFICATE, SSL3_MT_HELLO_REQUEST}
|
|
|
|
|
//SRC = "CLIENT"
|
|
|
|
|
} else {
|
|
|
|
|
//SRC = "SERVER"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
hello_offset := 4
|
|
|
|
@ -685,13 +690,11 @@ select_loop:
|
|
|
|
|
// fmt.Printf("Sending chunk of type %d to client.\n", s)
|
|
|
|
|
} else if cr.err != nil {
|
|
|
|
|
ndone++
|
|
|
|
|
|
|
|
|
|
if cr.client {
|
|
|
|
|
fmt.Println("Client read error: ", cr.err)
|
|
|
|
|
} else {
|
|
|
|
|
fmt.Println("Server read error: ", cr.err)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return cr.err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|