Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
self.peer = peer
self.neighbor = peer.neighbor
self.negotiated = Negotiated(self.neighbor)
self.connection = None
if self.neighbor.connect:
self.port = self.neighbor.connect
elif os.environ.get('exabgp.tcp.port','').isdigit():
self.port = int(os.environ.get('exabgp.tcp.port'))
elif os.environ.get('exabgp_tcp_port','').isdigit():
self.port = int(os.environ.get('exabgp_tcp_port'))
else:
self.port = 179
from exabgp.configuration.environment import environment
self.log_routes = peer.neighbor.adj_rib_in or environment.settings().log.routes
def __init__ (self, reactor):
self.pid = environment.settings().daemon.pid
self.user = environment.settings().daemon.user
self.daemonize = environment.settings().daemon.daemonize
self.logger = Logger()
self.reactor = reactor
os.chdir('/')
# os.umask(0)
os.umask(0137)
def __init__ (self):
# cached representation of the object
self._str = ''
self._idx = ''
self._json = ''
# The parsed attributes have no mp routes and/or those are last
self.cacheable = True
# XXX: FIXME: surely not the best place for this
Attribute.caching = environment.settings().cache.attributes
def __init__ (self, afi, peer, local):
self.msg_size = ExtendedMessage.INITIAL_SIZE
# peer and local are strings of the IP
try:
self.defensive = environment.settings().debug.defensive
self.logger = Logger()
except RuntimeError:
self.defensive = True
self.logger = FakeLogger()
self.afi = afi
self.peer = peer
self.local = local
self.io = None
self.established = False
self._rpoller = {}
self._wpoller = {}
self.id = self.identifier.get(self.direction,1)
def __init__ (self, version):
self.version = version
self.time = nop
self.compact = environment.settings().api.compact
def reload (self):
try:
return self._reload()
except KeyboardInterrupt:
return self.error.set('configuration reload aborted by ^C or SIGINT')
except Error as exc:
if environment.settings().debug.configuration:
raise
return self.error.set(
'problem parsing configuration file line %d\n'
'error message: %s' % (self.tokeniser.index_line, exc)
)
except StandardError as exc:
if environment.settings().debug.configuration:
raise
return self.error.set(
'problem parsing configuration file line %d\n'
'error message: %s' % (self.tokeniser.index_line, exc)
)
def _read_open (self):
wait = environment.settings().bgp.openwait
opentimer = ReceiveTimer(self.proto.connection.session,wait,1,1,'waited for open too long, we do not like stuck in active')
# Only yield if we have not the open, otherwise the reactor can run the other connection
# which would be bad as we need to do the collission check without going to the other peer
for message in self.proto.read_open(self.neighbor.peer_address.top()):
opentimer.check_ka(message)
# XXX: FIXME: change the whole code to use the ord and not the chr version
# Only yield if we have not the open, otherwise the reactor can run the other connection
# which would be bad as we need to do the collission check
if ordinal(message.TYPE) == Message.CODE.NOP:
# If a peer does not reply to OPEN message, or not enough bytes
# yielding ACTION.NOW can cause ExaBGP to busy spin trying to
# read from peer. See GH #723 .
yield ACTION.LATER
yield message
def callback ():
families = None
lines_per_yield = environment.settings().api.chunk
if last in ('routes', 'extensive', 'static', 'flow', 'l2vpn'):
peers = list(reactor.peers)
else:
peers = [n for n in reactor.peers.keys() if 'neighbor %s' % last in n]
for key in peers:
peer = reactor.peers.get(key, None)
if not peer:
continue
if advertised:
families = peer.proto.negotiated.families if peer.proto else []
rib = peer.neighbor.rib.outgoing if rib_name == 'out' else peer.neighbor.rib.incoming
routes = list(rib.cached_changes(families))
while routes:
changes, routes = routes[:lines_per_yield], routes[lines_per_yield:]
for change in changes:
if isinstance(change.nlri, route_type):