few fix related to computed hostmask

This commit is contained in:
Nicolas Coevoet 2015-01-06 22:11:42 +01:00
parent c30bb66ddf
commit c408579355

View File

@ -207,11 +207,8 @@ def getBestPattern (n,irc,useIp=False):
if not n.prefix or not ircutils.isUserHostmask(n.prefix): if not n.prefix or not ircutils.isUserHostmask(n.prefix):
return [] return []
(nick,ident,host) = ircutils.splitHostmask(n.prefix) (nick,ident,host) = ircutils.splitHostmask(n.prefix)
if ident.startswith('~'): if host.startswith('gateway/web/freenode/ip.') or host.startswith('gateway/tor-sasl/') or host.startswith('unaffiliated/') or ident.startswith('~'):
ident = '*' ident = '*'
else:
if host.startswith('gateway/web/freenode/ip.') or host.startswith('gateway/tor-sasl/') or host.startswith('unaffiliated/'):
ident = '*'
if n.ip != None: if n.ip != None:
if len(n.ip.split(':')) > 4: if len(n.ip.split(':')) > 4:
# large ipv6 # large ipv6
@ -231,18 +228,21 @@ def getBestPattern (n,irc,useIp=False):
host = '*%s' % host.split('ip.')[1] host = '*%s' % host.split('ip.')[1]
else: else:
h = host.split('/') h = host.split('/')
# gateway/type/(domain|account) [?/random] if host.find('x-') != -1:
p = '' # gateway/type/(domain|account) [?/random]
if len(h) > 3: p = ''
p = '/*' if len(h) > 3:
h = h[:3] p = '/*'
host = '%s%s' % ('/'.join(h),p) h = h[:3]
host = '%s%s' % ('/'.join(h),p)
(nick,i,h) = ircutils.splitHostmask(n.prefix)
if i.startswith('~'):
i = '*'
ident = i
elif host.startswith('nat/'): elif host.startswith('nat/'):
h = host.replace('nat/','') h = host.replace('nat/','')
if h.find('/') != -1: if h.find('/') != -1:
host = 'nat/%s/*' % h.split('/')[0] host = 'nat/%s/*' % h.split('/')[0]
if not ircutils.userFromHostmask(n.prefix).startswith('~') and not host.startswith('unaffiliated/'):
ident = ircutils.userFromHostmask(n.prefix)
if host.find('gateway/') != -1 and host.find('/x-') != -1: if host.find('gateway/') != -1 and host.find('/x-') != -1:
host = '%s/*' % host.split('/x-')[0] host = '%s/*' % host.split('/x-')[0]
k = '*!%s@%s' % (ident,host) k = '*!%s@%s' % (ident,host)