]> jfr.im git - irc/freenode/Sigyn.git/commitdiff
fix conflicts
authorNicolas Coevoet <redacted>
Sat, 30 Jan 2016 13:41:34 +0000 (14:41 +0100)
committerNicolas Coevoet <redacted>
Sat, 30 Jan 2016 13:41:34 +0000 (14:41 +0100)
1  2 
plugin.py

diff --cc plugin.py
index e9426775e4eee973a26cf8a5815a36f6bef0468f,df9e80cc1a280a932d5cc8de2634fa6b1cd53ccb..7c54fc1869cad94a6a26b11994cac46a0ab37348
+++ b/plugin.py
@@@ -596,110 -684,14 +596,109 @@@ class Sigyn(callbacks.Plugin,plugins.Ch
          else:
              irc.replyError('operatorNick or operatorPassword is empty')
      oper = wrap(oper,['owner'])
 -    
 +
      # internal stuff
  
-         self.log.debug('%s is known as %s' % (prefix,cache[prefix]))
 +    def resolve (self,irc,prefix):
 +        (nick,ident,host) = ircutils.splitHostmask(prefix)
 +        if ident.startswith('~'):
 +            ident = '*'
 +        try:
 +            resolver = dns.resolver.Resolver()
 +            resolver.timeout = self.registryValue('resolverTimeout')
 +            resolver.lifetime = self.registryValue('resolverTimeout')
 +            ips = resolver.query(host,'A')
 +            L = []
 +            for ip in ips:
 +                L.append(str(ip))
 +            if len(L) == 1:
 +                h = L[0]
 +                if ':' in h:
 +                    if h.startswith('2400:6180:') or h.startswith('2604:a880:'):
 +                        h = '%s/116' % h
 +                    elif h.startswith('2600:3c01'):
 +                        h = '%s/124' % h
 +                    if not '/' in h:
 +                        a = h.split(':')
 +                        if len(a) > 4:
 +                            h = '%s:*' % ':'.join(a[:4])
 +                cache[prefix] = '%s@%s' % (ident,h)
 +            else:
 +                cache[prefix] = '%s@%s' % (ident,host)
 +        except:
 +            cache[prefix] = '%s@%s' % (ident,host)
-             self.log.debug('prefixToMask %s --> %s' % (prefix,cache[prefix]))
++        self.log.debug('%s is resolved as %s' % (prefix,cache[prefix]))
 +
 +    def prefixToMask (self,irc,prefix):
 +        if prefix in cache:
 +            return cache[prefix]
 +        (nick,ident,host) = ircutils.splitHostmask(prefix)
 +        if '/' in host:
 +            if host.startswith('gateway/web/freenode'):
 +                if 'ip.' in host:
 +                    cache[prefix] = '*@%s' % host.split('ip.')[1]
 +                else:
 +                    # syn offline / busy
 +                    cache[prefix] = '%s@gateway/web/freenode/*' % ident
 +            elif host.startswith('gateway/tor-sasl'):
 +                cache[prefix] = '*@%s' % host
 +            elif host.startswith('gateway'):
 +                h = host.split('/')
 +                if 'ip.' in host:
 +                    ident = '*'
 +                    h = host.split('ip.')[1]
 +                elif '/vpn/' in host:
 +                    if 'x-' in host:
 +                        h = h[:3]
 +                        h = '%s/*' % '/'.join(h)
 +                    else:
 +                        h = host
 +                    if ident.startswith('~'):
 +                        ident = '*'
 +                elif len(h) > 3:
 +                    h = h[:3]
 +                    h = '%s/*' % '/'.join(h)
 +                else:
 +                    h = host
 +                cache[prefix] = '%s@%s' % (ident,h)
 +            elif host.startswith('nat'):
 +                h = host.split('/')
 +                h = h[:2]
 +                h = '%s/*' % '/'.join(h)
 +                cache[prefix] = '%s@%s' % (ident,host)
 +            else:
 +                if ident.startswith('~'):
 +                    ident = '*'
 +                cache[prefix] = '%s@%s' % (ident,host)
 +        else:
 +            if ident.startswith('~'):
 +                ident = '*'
 +            if utils.net.isIPV4(host):
 +                cache[prefix] = '%s@%s' % (ident,host)
 +            elif utils.net.bruteIsIPV6(host):
 +                h = host
 +                if h.startswith('2400:6180:') or h.startswith('2604:a880:'):
 +                    h = '%s/116' % h
 +                elif h.startswith('2600:3c01'):
 +                    h = '%s/124' % h
 +                if not '/' in h:
 +                    a = h.split(':')
 +                    if len(a) > 4:
 +                        h = '%s:*' % ':'.join(a[:4])
 +                cache[prefix] = '%s@%s' % (ident,h)
 +            else:
 +                t = world.SupyThread(target=self.resolve,name=format('resolve %s', prefix),args=(irc,prefix))
 +                t.setDaemon(True)
 +                t.start()
 +                return '%s@%s' % (ident,host)
 +        return cache[prefix]
 +
 +
      def do001 (self,irc,msg):
 -        i = self.getIrc(irc)    
 +        i = self.getIrc(irc)
          if not i.opered:
              if len(self.registryValue('operatorNick')) and len(self.registryValue('operatorPassword')):
 -                irc.queueMsg(ircmsgs.IrcMsg('OPER %s %s' % (self.registryValue('operatorNick'),self.registryValue('operatorPassword'))))       
 +                irc.queueMsg(ircmsgs.IrcMsg('OPER %s %s' % (self.registryValue('operatorNick'),self.registryValue('operatorPassword'))))
  
      def do381 (self,irc,msg):
          i = self.getIrc(irc)