Exemple #1
0
    def handle_args(self, args):
        if self.opts.nodelist is None:
            nodelist = self.get_data_path('fidonet', 'nodelist')
            self.opts.nodelist = '%s.idx' % nodelist
            self.log.debug('using nodelist = %s' % self.opts.nodelist)

        if self.opts.routes is None:
            self.opts.routes = self.get_cfg_path('fidonet', 'routes')

        self.log.info('using nodelist %s' % self.opts.nodelist)
        if self.opts.routes:
            self.log.info('using routes from %s' % self.opts.routes)

        nl = Nodelist('sqlite:///%s' % self.opts.nodelist)
        nl.setup()
        session = nl.broker()

        router = Router(nl, self.opts.routes)

        nodes = session.query(Node).join('flags')

        if self.opts.output:
            sys.stdout = open(self.opts.output, 'w')

        for node in nodes:
            addr = fidonet.Address(node.address)
            rspec = router[addr]

            if not self.opts.quiet:
                print '# %s -> %s [%s]' % (addr, rspec[0], ' '.join(
                    [str(x) for x in rspec[1]]))
            print '%s\t%s:%s' % (addr.rfc, self.opts.transport, rspec[0].rfc)
Exemple #2
0
    def handle_args(self, args):
        if self.opts.nodelist is None:
            nodelist = self.get_data_path('fidonet', 'nodelist')
            self.opts.nodelist = '%s.idx' % nodelist
            self.log.debug('using nodelist = %s' % self.opts.nodelist)

        if self.opts.routes is None:
            self.opts.routes = self.get_cfg_path(
                    'fidonet', 'routes')

        self.log.info('using nodelist %s' % self.opts.nodelist)
        if self.opts.routes:
            self.log.info('using routes from %s' % self.opts.routes)

        nl = Nodelist('sqlite:///%s' % self.opts.nodelist)
        nl.setup()
        session = nl.broker()

        router = Router(nl, self.opts.routes)

        nodes = session.query(Node).join('flags')

        if self.opts.output:
            sys.stdout = open(self.opts.output, 'w')

        for node in nodes:
            addr = fidonet.Address(node.address)
            rspec = router[addr]

            if not self.opts.quiet:
                print '# %s -> %s [%s]' % (addr, rspec[0], ' '.join([str(x)
                    for x in rspec[1]]))
            print '%s\t%s:%s' % (addr.rfc, self.opts.transport,
                    rspec[0].rfc)
Exemple #3
0
    def handle_args(self, args):
        if self.opts.nodelist is None:
            nodelist = list(self.get_data_paths(
                    'fidonet', 'nodelist'))[0]
            if not nodelist:
                self.log.error('unable to locate a nodelist index')
                sys.exit(1)

            self.opts.nodelist = '%s.idx' % nodelist
        if self.opts.routes is None:
            self.opts.routes = self.get_cfg_path(
                    'fidonet', 'routes')

        self.log.info('using nodelist %s' % self.opts.nodelist)
        if self.opts.routes:
            self.log.info('using routes from %s' % self.opts.routes)

        nl = Nodelist('sqlite:///%s' % self.opts.nodelist)
        nl.setup()
        router = Router(nl, self.opts.routes)

        for addr in args:
            addr = fidonet.Address(addr)
            rspec = router[addr]
            print addr, 'via', rspec[0], 'using', rspec[1]
Exemple #4
0
    def handle_args (self, args):
        if not self.opts.origin:
            self.opts.origin = self.get('fidonet', 'address')

        if not self.opts.dir:
            self.opts.dir = self.get_data_path('binkd', 'outbound')

        if not self.opts.routes:
            self.opts.routes = self.get_cfg_path('fidonet', 'routes')

        if not self.opts.nodelist:
            nodelist = list(self.get_data_paths(
                    'fidonet', 'nodelist'))[0]
            if not nodelist:
                sys.log.error('unable to locate a nodelist index')
                sys.exit(1)
            self.opts.nodelist = '%s.idx' % nodelist

        if not os.path.isfile(self.opts.nodelist):
            self.log.error('nodelist index "%s" is unavailable.' %
                    self.opts.nodelist)
            sys.exit(1)
        if not os.path.isdir(self.opts.dir):
            self.log.error('binkd outbound directory "%s" is unavailable.'
                    % self.opts.dir)
            sys.exit(1)
        if self.opts.routes is not None and not os.path.isfile(self.opts.routes):
            self.log.error('routing policy file "%s" is unavailable.' %
                    self.opts.routes)
            sys.exit(1)

        self.opts.origin = Address(self.opts.origin)

        self.log.debug('my origin = %s' % self.opts.origin)
        self.log.debug('target directory = %s' % self.opts.dir)
        self.log.debug('routing policy = %s' % self.opts.routes)
        self.log.debug('nodelist = %s' % self.opts.nodelist)

        nodelist = Nodelist('sqlite:///%s' % self.opts.nodelist)
        nodelist.setup()
        self.router = Router(nodelist, self.opts.routes)
        self.packets = {}
        self.origin = fidonet.Address(self.opts.origin)

        self.for_each_arg(self.toss_pkt, args)

        for pkt in self.packets.values():
            out = os.path.join(self.opts.dir, '%s.out' % pkt.destAddr.hex)
            self.log.info('writing packet for %s to %s.' % (pkt.destAddr,
                out))
            pkt.write(open(out, 'w'))
Exemple #5
0
    def handle_args(self, args):
        if self.opts.nodelist is None:
            nodelist = self.get_data_path('fidonet', 'nodelist')
            self.opts.nodelist = '%s.idx' % nodelist

        nl = Nodelist('sqlite:///%s' % self.opts.nodelist)
        nl.setup()
        session = nl.broker()

        nodes = session.query(Node).join('flags').filter(
                Flag.flag_name == 'IBN')

        for n in nodes:
            inet = n.inet('IBN')
            if inet is None:
                continue

            print 'Node %-20s %s' % (
                    ('%s@%s' % (n.address, self.opts.domain)),
                    inet
                    )
Exemple #6
0
    def handle_args(self, args):
        if self.opts.nodelist is None:
            nodelist = list(self.get_data_paths('fidonet', 'nodelist'))[0]
            if not nodelist:
                self.log.error('unable to locate a nodelist index')
                sys.exit(1)

            self.opts.nodelist = '%s.idx' % nodelist
        if self.opts.routes is None:
            self.opts.routes = self.get_cfg_path('fidonet', 'routes')

        self.log.info('using nodelist %s' % self.opts.nodelist)
        if self.opts.routes:
            self.log.info('using routes from %s' % self.opts.routes)

        nl = Nodelist('sqlite:///%s' % self.opts.nodelist)
        nl.setup()
        router = Router(nl, self.opts.routes)

        for addr in args:
            addr = fidonet.Address(addr)
            rspec = router[addr]
            print addr, 'via', rspec[0], 'using', rspec[1]
Exemple #7
0
    def build_index(self, nodelists):
        tmp = tempfile.NamedTemporaryFile(
                dir=os.path.dirname(self.opts.output))

        self.log.debug('output file is %s' % self.opts.output)
        self.log.debug('tmp file is %s' % tmp.name)

        nl = Nodelist('sqlite:///%s' % tmp.name)
        nl.setup(create=True)
        session = nl.broker()

        for nodelist in nodelists:
            self.index_one_nodelist(session, nodelist)

        self.log.info('creating nodelist index %s' % self.opts.output)
        os.rename(tmp.name, self.opts.output)

        try:
            tmp.close()
        except OSError, detail:
            if detail.errno == errno.ENOENT:
                pass
            else:
                raise
Exemple #8
0
    def build_index(self, nodelists):
        tmp = tempfile.NamedTemporaryFile(
            dir=os.path.dirname(self.opts.output))

        self.log.debug('output file is %s' % self.opts.output)
        self.log.debug('tmp file is %s' % tmp.name)

        nl = Nodelist('sqlite:///%s' % tmp.name)
        nl.setup(create=True)
        session = nl.broker()

        for nodelist in nodelists:
            self.index_one_nodelist(session, nodelist)

        self.log.info('creating nodelist index %s' % self.opts.output)
        os.rename(tmp.name, self.opts.output)

        try:
            tmp.close()
        except OSError, detail:
            if detail.errno == errno.ENOENT:
                pass
            else:
                raise
Exemple #9
0
    def handle_args(self, args):
        if self.opts.nodelist is None:
            nodelist = self.get_data_path('fidonet', 'nodelist')
            self.opts.nodelist = '%s.idx' % nodelist

        nl = Nodelist('sqlite:///%s' % self.opts.nodelist)
        nl.setup()
        session = nl.broker()

        nodes = session.query(Node).join('flags')

        if self.opts.address:
            if '%' in self.opts.address or '*' in self.opts.address:
                nodes = nodes.filter(
                    Node.address.like(self.opts.address.replace('*', '%')))
            else:
                nodes = nodes.filter(Node.address == self.opts.address)

        if self.opts.sysop:
            if '%' in self.opts.sysop or '*' in self.opts.sysop:
                nodes = nodes.filter(
                    Node.sysop.like(self.opts.sysop.replace('*', '%')))
            else:
                nodes = nodes.filter(Node.sysop == self.opts.sysop)

        if self.opts.name:
            if '%' in self.opts.name or '*' in self.opts.name:
                nodes = nodes.filter(
                    Node.name.like(self.opts.name.replace('*', '%')))
            else:
                nodes = nodes.filter(Node.name == self.opts.name)

        for flag in self.opts.flag:
            if flag.startswith('!'):
                pass
            else:
                nodes = nodes.filter(Flag.flag_name == flag)

        if self.opts.debug:
            print nodes.as_scalar()

        for n in nodes:
            if self.opts.verbose:
                print '%10s: %s' % ('Address', n.address)
                print '%10s: %s' % ('Name', n.name)
                print '%10s: %s' % ('SysOp', n.sysop)
                print '%10s: %s' % ('Phone', n.phone)

                if [x for x in n.flags if x.flag_name == 'IBN']:
                    print '%10s: %s' % ('BinkD', n.inet('IBN'))
                if [x for x in n.flags if x.flag_name == 'ITN']:
                    print '%10s: %s' % ('Telnet', n.inet('ITN'))
                print '%10s:' % ('Flags', ),
                for flag in n.flags:
                    if flag.flag_val is not None:
                        print '%s:%s' % (flag.flag_name, flag.flag_val),
                    else:
                        print flag.flag_name,
                print
                if self.opts.raw:
                    print '%10s: %s' % ('Raw', n.raw[0].entry)
                print
            else:
                print '%12s : %s' % (n.address, n.name)
Exemple #10
0
    def handle_args(self, args):
        if self.opts.nodelist is None:
            nodelist = self.get_data_path('fidonet', 'nodelist')
            self.opts.nodelist = '%s.idx' % nodelist

        nl = Nodelist('sqlite:///%s' % self.opts.nodelist)
        nl.setup()
        session = nl.broker()

        nodes = session.query(Node).join('flags')

        if self.opts.address:
            if '%' in self.opts.address or '*' in self.opts.address:
                nodes = nodes.filter(
                        Node.address.like(self.opts.address.replace('*', '%')))
            else:
                nodes = nodes.filter(Node.address == self.opts.address)

        if self.opts.sysop:
            if '%' in self.opts.sysop or '*' in self.opts.sysop:
                nodes = nodes.filter(
                        Node.sysop.like(self.opts.sysop.replace('*', '%')))
            else:
                nodes = nodes.filter(Node.sysop == self.opts.sysop)

        if self.opts.name:
            if '%' in self.opts.name or '*' in self.opts.name:
                nodes = nodes.filter(
                        Node.name.like(self.opts.name.replace('*', '%')))
            else:
                nodes = nodes.filter(Node.name == self.opts.name)

        for flag in self.opts.flag:
            if flag.startswith('!'):
                pass
            else:
                nodes = nodes.filter(Flag.flag_name == flag)

        if self.opts.debug:
            print nodes.as_scalar()

        for n in nodes:
            if self.opts.verbose:
                print '%10s: %s' % ('Address', n.address)
                print '%10s: %s' % ('Name', n.name)
                print '%10s: %s' % ('SysOp', n.sysop)
                print '%10s: %s' % ('Phone', n.phone)
                
                if [x for x in n.flags if x.flag_name == 'IBN']:
                    print '%10s: %s' % ('BinkD', n.inet('IBN'))
                if [x for x in n.flags if x.flag_name == 'ITN']:
                    print '%10s: %s' % ('Telnet', n.inet('ITN'))
                print '%10s:' % ('Flags',),
                for flag in n.flags:
                    if flag.flag_val is not None:
                        print '%s:%s' % (flag.flag_name, flag.flag_val),
                    else:
                        print flag.flag_name,
                print
                if self.opts.raw:
                    print '%10s: %s' % ('Raw', n.raw[0].entry)
                print
            else:
                print '%12s : %s' % (n.address, n.name)