mirror of https://github.com/fluffle/goirc
Gofix run.
This commit is contained in:
parent
be271308c9
commit
b23215d09b
|
@ -6,8 +6,8 @@ import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/fluffle/goevent/event"
|
"github.com/fluffle/goevent/event"
|
||||||
"github.com/fluffle/golog/logging"
|
|
||||||
"github.com/fluffle/goirc/state"
|
"github.com/fluffle/goirc/state"
|
||||||
|
"github.com/fluffle/golog/logging"
|
||||||
"net"
|
"net"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
@ -228,7 +228,7 @@ func (conn *Conn) recv() {
|
||||||
conn.l.Debug("<- %s", s)
|
conn.l.Debug("<- %s", s)
|
||||||
|
|
||||||
if line := parseLine(s); line != nil {
|
if line := parseLine(s); line != nil {
|
||||||
line.Time = time.LocalTime()
|
line.Time = time.Now()
|
||||||
conn.in <- line
|
conn.in <- line
|
||||||
} else {
|
} else {
|
||||||
conn.l.Warn("irc.recv(): problems parsing line:\n %s", s)
|
conn.l.Warn("irc.recv(): problems parsing line:\n %s", s)
|
||||||
|
@ -279,12 +279,12 @@ func (conn *Conn) rateLimit(chars int64) int64 {
|
||||||
// Hybrid's algorithm allows for 2 seconds per line and an additional
|
// Hybrid's algorithm allows for 2 seconds per line and an additional
|
||||||
// 1/120 of a second per character on that line.
|
// 1/120 of a second per character on that line.
|
||||||
linetime := 2*second + chars*second/120
|
linetime := 2*second + chars*second/120
|
||||||
elapsed := time.Nanoseconds() - conn.lastsent
|
elapsed := time.Now().Sub(conn.lastsent)
|
||||||
if conn.badness += linetime - elapsed; conn.badness < 0 {
|
if conn.badness += linetime - elapsed; conn.badness < 0 {
|
||||||
// negative badness times are badness...
|
// negative badness times are badness...
|
||||||
conn.badness = int64(0)
|
conn.badness = int64(0)
|
||||||
}
|
}
|
||||||
conn.lastsent = time.Nanoseconds()
|
conn.lastsent = time.Now()
|
||||||
// If we've sent more than 10 second's worth of lines according to the
|
// If we've sent more than 10 second's worth of lines according to the
|
||||||
// calculation above, then we're at risk of "Excess Flood".
|
// calculation above, then we're at risk of "Excess Flood".
|
||||||
if conn.badness > 10*second {
|
if conn.badness > 10*second {
|
||||||
|
|
|
@ -14,7 +14,7 @@ type Line struct {
|
||||||
Nick, Ident, Host, Src string
|
Nick, Ident, Host, Src string
|
||||||
Cmd, Raw string
|
Cmd, Raw string
|
||||||
Args []string
|
Args []string
|
||||||
Time *time.Time
|
Time time.Time
|
||||||
}
|
}
|
||||||
|
|
||||||
// NOTE: this doesn't copy l.Time (this should be read-only anyway)
|
// NOTE: this doesn't copy l.Time (this should be read-only anyway)
|
||||||
|
|
Loading…
Reference in New Issue