mirror of https://github.com/fluffle/goirc
Make socket timeouts a configurable thingy.
This commit is contained in:
parent
a19bce5998
commit
83b482f8ce
|
@ -40,6 +40,9 @@ type Conn struct {
|
||||||
SSL bool
|
SSL bool
|
||||||
SSLConfig *tls.Config
|
SSLConfig *tls.Config
|
||||||
|
|
||||||
|
// Socket timeout, in seconds. Defaulted to 5m in New().
|
||||||
|
Timeout int
|
||||||
|
|
||||||
// Set this to true to disable flood protection and false to re-enable
|
// Set this to true to disable flood protection and false to re-enable
|
||||||
Flood bool
|
Flood bool
|
||||||
|
|
||||||
|
@ -70,6 +73,7 @@ func New(nick, user, name string) *Conn {
|
||||||
conn.initialise()
|
conn.initialise()
|
||||||
conn.SSL = false
|
conn.SSL = false
|
||||||
conn.SSLConfig = nil
|
conn.SSLConfig = nil
|
||||||
|
conn.Timeout = 300
|
||||||
conn.Me = conn.NewNick(nick, user, name, "")
|
conn.Me = conn.NewNick(nick, user, name, "")
|
||||||
conn.Timestamp = time.LocalTime
|
conn.Timestamp = time.LocalTime
|
||||||
conn.TSFormat = "15:04:05"
|
conn.TSFormat = "15:04:05"
|
||||||
|
@ -140,7 +144,7 @@ func (conn *Conn) Connect(host string, pass ...string) os.Error {
|
||||||
conn.io = bufio.NewReadWriter(
|
conn.io = bufio.NewReadWriter(
|
||||||
bufio.NewReader(conn.sock),
|
bufio.NewReader(conn.sock),
|
||||||
bufio.NewWriter(conn.sock))
|
bufio.NewWriter(conn.sock))
|
||||||
conn.sock.SetTimeout(300000000000) // 5 minutes
|
conn.sock.SetTimeout(conn.Timeout * 1e9)
|
||||||
go conn.send()
|
go conn.send()
|
||||||
go conn.recv()
|
go conn.recv()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue