@@ -0,0 +1,1674 @@
+from twisted.plugin import IPlugin%0Afrom txircd.module_interface import IModuleData, ModuleData%0Afrom zope.interface import implements%0A%0Aclass ConnectionLimit(ModuleData):%0A    implements(IPlugin, IModuleData)%0A%0A    name = %22ConnectionLimit%22%0A    peerConnections = %7B%7D%0A%0A    def hookIRCd(self, ircd):%0A        self.ircd = ircd%0A%0A    def actions(self):%0A        return %5B (%22userconnect%22, 100, self.handleLocalConnect),%0A                 (%22remoteregister%22, 100, self.handleRemoteConnect),%0A                 (%22quit%22, 100, self.handleDisconnect),%0A                 (%22remotequit%22, 100, self.handleDisconnect) %5D%0A%0A    def handleLocalConnect(self, user, *params):%0A        ip = user.ip%0A        if self.addToConnections(ip) and self.peerConnections%5Bip%5D %3E self.ircd.config.getWithDefault(%22connlimit_globmax%22, 3):%0A            user.disconnect(%22No more connections allowed from your IP (%7B%7D)%22.format(ip))%0A            return None%0A        return True%0A%0A    def handleRemoteConnect(self, user, *params):%0A        self.addToConnections(user.ip)%0A%0A    def handleDisconnect(self, user, *params):%0A        ip = user.ip%0A        if ip in self.peerConnections:%0A            self.peerConnections%5Bip%5D -= 1%0A            if self.peerConnections%5Bip%5D %3C 1:%0A                del self.peerConnections%5Bip%5D%0A%0A    def addToConnections(self, ip):%0A        if ip in self.ircd.config.getWithDefault(%22connlimit_whitelist%22, %5B%5D):%0A            return False%0A        if ip in self.peerConnections:%0A            self.peerConnections%5Bip%5D += 1%0A        else:%0A            self.peerConnections%5Bip%5D = 1%0A        return True%0A%0A    def load(self):%0A        for user in self.ircd.users:%0A            self.addToConnections(user.ip)%0A%0AconnLimit = ConnectionLimit()

Implement the connection limit module