Exemple #1
0
// Triggered when an gnet.Connection terminates. Disconnect events are not
// pushed to a separate channel, because disconnects are already processed
// by a queue in the daemon.Run() select{}.
func (self *Daemon) onGnetDisconnect(c *gnet.Connection,
	reason gnet.DisconnectReason) {
	a := c.Addr()
	logger.Info("%s disconnected because: %v", a, reason)
	duration, exists := BlacklistOffenses[reason]
	if exists {
		self.Peers.Peers.AddBlacklistEntry(a, duration)
	}
	delete(self.OutgoingConnections, a)
	delete(self.ExpectingIntroductions, a)
	self.Visor.RemoveConnection(a)
	self.removeIPCount(a)
	self.removeConnectionMirror(a)
}
Exemple #2
0
// Triggered when an gnet.Connection is connected
func (self *Daemon) onGnetConnect(c *gnet.Connection, solicited bool) {
	self.onConnectEvent <- ConnectEvent{Addr: c.Addr(), Solicited: solicited}
}