1
0
Fork 0
forked from External/ergo

implement fakelag (#189)

This commit is contained in:
Shivaram Lingamneni 2018-03-22 11:04:21 -04:00
parent e3e714059c
commit 1bf5e2a7c8
9 changed files with 293 additions and 19 deletions

View file

@ -49,6 +49,7 @@ type Client struct {
class *OperClass
ctime time.Time
exitedSnomaskSent bool
fakelag *Fakelag
flags map[modes.Mode]bool
hasQuit bool
hops int
@ -145,6 +146,26 @@ func NewClient(server *Server, conn net.Conn, isTLS bool) *Client {
return client
}
func (client *Client) resetFakelag() {
fakelag := func() *Fakelag {
if client.HasRoleCapabs("nofakelag") {
return nil
}
flc := client.server.FakelagConfig()
if !flc.Enabled {
return nil
}
return NewFakelag(flc.Window, flc.BurstLimit, flc.MessagesPerWindow)
}()
client.stateMutex.Lock()
defer client.stateMutex.Unlock()
client.fakelag = fakelag
}
// IP returns the IP address of this client.
func (client *Client) IP() net.IP {
if client.proxiedIP != nil {
@ -221,6 +242,8 @@ func (client *Client) run() {
client.nickTimer = NewNickTimer(client)
client.resetFakelag()
// Set the hostname for this client
// (may be overridden by a later PROXY command from stunnel)
client.rawHostname = utils.AddrLookupHostname(client.socket.conn.RemoteAddr())