mirror of
https://github.com/ncoevoet/ChanTracker.git
synced 2025-04-26 13:01:06 -05:00
added an experimental feature, when attackPermit is raised, skynet, which try to find the best pattern bad users, prevent check evade onjoin while netsplit
This commit is contained in:
parent
acd292fdda
commit
b9a835a0c7
@ -185,7 +185,7 @@ conf.registerChannelValue(ChanTracker, 'useChanServForQuiets',
|
|||||||
registry.Boolean(False,"""if bot is not opped, use services for quiet / unquiets"""))
|
registry.Boolean(False,"""if bot is not opped, use services for quiet / unquiets"""))
|
||||||
|
|
||||||
conf.registerChannelValue(ChanTracker, 'skynet',
|
conf.registerChannelValue(ChanTracker, 'skynet',
|
||||||
registry.Boolean(False,"""when True, bot could use some experimental features against spam / channel's attacks, ie : trying to find better patterns to use against"""))
|
registry.Integer(-1,"""when positive, bot could use some experimental features against user's marked as bad, the value represents number of bad users to trigger it"""))
|
||||||
|
|
||||||
# related to channel's protection
|
# related to channel's protection
|
||||||
|
|
||||||
|
15
plugin.py
15
plugin.py
@ -2273,7 +2273,7 @@ class ChanTracker(callbacks.Plugin,plugins.ChannelDBHandler):
|
|||||||
n.addLog(channel,'has joined')
|
n.addLog(channel,'has joined')
|
||||||
c = ircdb.channels.getChannel(channel)
|
c = ircdb.channels.getChannel(channel)
|
||||||
banned = False
|
banned = False
|
||||||
if not self._isVip(irc,channel,n):
|
if not self._isVip(irc,channel,n) and not chan.netsplit:
|
||||||
if self.registryValue('checkEvade',channel=channel) and msg.prefix.find('/ip.') != -1 and self.registryValue('resolveIp'):
|
if self.registryValue('checkEvade',channel=channel) and msg.prefix.find('/ip.') != -1 and self.registryValue('resolveIp'):
|
||||||
items = chan.getItemsFor('b')
|
items = chan.getItemsFor('b')
|
||||||
for k in items:
|
for k in items:
|
||||||
@ -3226,9 +3226,11 @@ class ChanTracker(callbacks.Plugin,plugins.ChannelDBHandler):
|
|||||||
f = self._logChan
|
f = self._logChan
|
||||||
i.edit(irc,item.channel,item.mode,item.value,0,irc.prefix,self.getDb(irc.network),self._schedule,f,self)
|
i.edit(irc,item.channel,item.mode,item.value,0,irc.prefix,self.getDb(irc.network),self._schedule,f,self)
|
||||||
self.forceTickle = True
|
self.forceTickle = True
|
||||||
self.forceTickle = True
|
|
||||||
c.close()
|
c.close()
|
||||||
|
# as _tickle now may be a bit too earlier, delay it a bit
|
||||||
|
def ttickle():
|
||||||
self._tickle(irc)
|
self._tickle(irc)
|
||||||
|
schedule.addEvent(ttickle,time.time()+1)
|
||||||
|
|
||||||
def do474(self,irc,msg):
|
def do474(self,irc,msg):
|
||||||
# bot banned from a channel it's trying to join
|
# bot banned from a channel it's trying to join
|
||||||
@ -3333,14 +3335,15 @@ class ChanTracker(callbacks.Plugin,plugins.ChannelDBHandler):
|
|||||||
if self._isSomething(irc,channel,channel,'attack') and not chan.attacked:
|
if self._isSomething(irc,channel,channel,'attack') and not chan.attacked:
|
||||||
# if number of bad users raise the allowed limit, bot has to set channel attackmode
|
# if number of bad users raise the allowed limit, bot has to set channel attackmode
|
||||||
# todo retreive all wrong users and find the best pattern to use against them
|
# todo retreive all wrong users and find the best pattern to use against them
|
||||||
if self.registryValue('skynet',channel=channel):
|
if self.registryValue('skynet',channel=channel) > 0:
|
||||||
L = []
|
L = []
|
||||||
for n in chan.nicks:
|
for n in chan.nicks:
|
||||||
n = self.getNick(irc,n)
|
n = self.getNick(irc,n)
|
||||||
pattern = getBestPattern(n,irc,self.registryValue('useIpForGateway'),channel=channel)[0]
|
pattern = getBestPattern(n,irc,self.registryValue('useIpForGateway',channel=channel),self.registryValue('resolveIp'))[0]
|
||||||
if chan.isWrong(pattern):
|
if chan.isWrong(pattern):
|
||||||
L.append(n)
|
L.append(n)
|
||||||
self.log.debug('founds bads %s' % ' '.join(L))
|
self.log.debug('founds bads %s' % ' '.join(L))
|
||||||
|
if self.registryValue('skynet',channel=channel) > len(L):
|
||||||
idents = {}
|
idents = {}
|
||||||
users = {}
|
users = {}
|
||||||
for n in L:
|
for n in L:
|
||||||
@ -3365,8 +3368,10 @@ class ChanTracker(callbacks.Plugin,plugins.ChannelDBHandler):
|
|||||||
if len(users[user]) < len(users[u]):
|
if len(users[user]) < len(users[u]):
|
||||||
user = u
|
user = u
|
||||||
self.log.debug('computed $r:%s and *!%s@*' % (user,fident))
|
self.log.debug('computed $r:%s and *!%s@*' % (user,fident))
|
||||||
|
r = []
|
||||||
if fident and user:
|
if fident and user:
|
||||||
self._act (irc,channel,'b','$x:*!%s@*#%s' % (fident,user.replace(' ','?')),self.registryValue('attackDuration',channel=channel),'skynet powered')
|
self._act (irc,channel,'b','*!%s@*' % fident,self.registryValue('attackDuration',channel=channel),'skynet powered')
|
||||||
|
self._act (irc,channel,'b','$r:%s' % user.replace(' ','?').replace('$','?'),self.registryValue('attackDuration',channel=channel),'skynet powered')
|
||||||
chan.attacked = True
|
chan.attacked = True
|
||||||
chan.action.enqueue(ircmsgs.IrcMsg('MODE %s %s' % (channel,self.registryValue('attackMode',channel=channel))))
|
chan.action.enqueue(ircmsgs.IrcMsg('MODE %s %s' % (channel,self.registryValue('attackMode',channel=channel))))
|
||||||
def unAttack():
|
def unAttack():
|
||||||
|
Loading…
x
Reference in New Issue
Block a user