예제 #1
0
    def connect(self):
        # allows to test the protocol code using modified StringIO with a extra 'pending' function
        if not self.connection:
            local = self.neighbor.md5_ip.top(
            ) if not self.neighbor.auto_discovery else None
            peer = self.neighbor.peer_address.top()
            afi = self.neighbor.peer_address.afi
            md5 = self.neighbor.md5_password
            md5_base64 = self.neighbor.md5_base64
            ttl_out = self.neighbor.ttl_out
            self.connection = Outgoing(afi, peer, local, self.port, md5,
                                       md5_base64, ttl_out)
            if not self.connection.init:
                yield False
                return
            if not local:
                self.neighbor.local_address = IP.create(self.connection.local)
                if self.neighbor.router_id is None and self.neighbor.local_address.afi == AFI.ipv4:
                    self.neighbor.router_id = self.neighbor.local_address

            for connected in self.connection.establish():
                if not connected:
                    yield False
                    continue
                if self.peer.neighbor.api['neighbor-changes']:
                    self.peer.reactor.processes.connected(self.peer.neighbor)
                yield True
                return
예제 #2
0
    def connect(self):
        # allows to test the protocol code using modified StringIO with a extra 'pending' function
        if not self.connection:
            local = self.neighbor.md5_ip.top(
            ) if not self.neighbor.auto_discovery else None
            peer = self.neighbor.peer_address.top()
            afi = self.neighbor.peer_address.afi
            md5 = self.neighbor.md5_password
            md5_base64 = self.neighbor.md5_base64
            ttl_out = self.neighbor.ttl_out
            self.connection = Outgoing(afi, peer, local, self.port, md5,
                                       md5_base64, ttl_out)
            if not local and self.connection.init:
                self.neighbor.local_address = IP.create(self.connection.local)
                if self.neighbor.router_id is None and self.neighbor.local_address.afi == AFI.ipv4:
                    self.neighbor.router_id = self.neighbor.local_address

            try:
                generator = self.connection.establish()
                while True:
                    connected = six.next(generator)
                    if not connected:
                        yield False
                        continue
                    if self.peer.neighbor.api['neighbor-changes']:
                        self.peer.reactor.processes.connected(
                            self.peer.neighbor)
                    yield True
                    return
            except StopIteration:
                # close called by the caller
                # self.close('could not connect to remote end')
                yield False
                return
예제 #3
0
    def connect(self):
        # allows to test the protocol code using modified StringIO with a extra 'pending' function
        if not self.connection:
            peer = self.neighbor.peer_address
            local = self.neighbor.local_address
            md5 = self.neighbor.md5
            ttl = self.neighbor.ttl
            self.connection = Outgoing(peer.afi, peer.ip, local.ip, self.port,
                                       md5, ttl)

            try:
                generator = self.connection.establish()
                while True:
                    connected = generator.next()
                    if not connected:
                        yield False
                        continue
                    if self.peer.neighbor.api['neighbor-changes']:
                        self.peer.reactor.processes.connected(self.peer)
                    yield True
                    return
            except StopIteration:
                # close called by the caller
                # self.close('could not connect to remote end')
                yield False
                return
예제 #4
0
def test():
    OPEN = ''.join([
        chr(int(_, 16)) for _ in
        "FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 00 1D 01 04 78 14 00 5A 52 DB 00 45 00"
        .split()
    ])
    KEEP = ''.join([
        chr(int(_, 16)) for _ in
        "FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 00 00 04".split()
    ])

    from exabgp.reactor.network.outgoing import Outgoing
    connection = Outgoing(1, '82.219.0.5', '82.219.212.34')
    writer = connection._writer(OPEN)
    while writer() == False:
        pass
    writer = connection._writer(KEEP)
    while writer() == False:
        pass

    reader = connection.reader()

    for size, kind, header, body in reader:
        if size: print od(header + body)
        else: sys.stdout.write('-')
예제 #5
0
def test():
    OPEN = ''.join([
        chr(int(_, 16)) for _ in
        "FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 00 1D 01 04 78 14 00 5A 52 DB 00 45 00"
        .split()
    ])
    KEEP = ''.join([
        chr(int(_, 16)) for _ in
        "FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 00 00 04".split()
    ])

    from exabgp.reactor.network.outgoing import Outgoing

    connection = Outgoing(1, '82.219.0.69', '82.219.212.34')
    writer = connection.writer(OPEN)
    while next(writer) is False:
        pass
    writer = connection.writer(KEEP)
    while next(writer) is False:
        pass

    reader = connection.reader()

    for size, msg, header, body, notification in reader:
        if size:
            print(od(header + body))
        else:
            sys.stdout.write('-')

    reader = connection.reader()

    for size, msg, header, body, notification in reader:
        if size:
            print(od(header + body))
        else:
            sys.stdout.write('+')

    connection.close()