You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

25 lines
478 B
Go

8 years ago
package obfssh
import (
"net"
"time"
)
var dialer = &net.Dialer{Timeout: 10 * time.Second}
8 years ago
// TimedOutConn is a net.Conn with read/write timeout set
type TimedOutConn struct {
net.Conn
Timeout time.Duration
}
func (tc *TimedOutConn) Read(b []byte) (int, error) {
tc.Conn.SetDeadline(time.Now().Add(tc.Timeout))
return tc.Conn.Read(b)
}
func (tc *TimedOutConn) Write(b []byte) (int, error) {
tc.Conn.SetDeadline(time.Now().Add(tc.Timeout))
return tc.Conn.Write(b)
}