#!/usr/bin/env python3
import sys
import time
# we do not announce withdraw on the first run of the reactor
messages1 = [
'announce route 1.1.0.0/24 next-hop 101.1.101.1',
'announce route 1.1.0.0/25 next-hop 101.1.101.1',
'withdraw route 1.1.0.0/24 next-hop 101.1.101.1',
'announce route 1.1.0.0/25 next-hop 101.1.101.1',
]
messages2 = [
'announce route 2.2.0.0/25 next-hop 101.1.101.1',
'announce route 2.2.0.0/24 next-hop 101.1.101.1',
'withdraw route 2.2.0.0/25 next-hop 101.1.101.1',
]
messages3 = [
'announce route 0.0.0.0/0 next-hop 1.101.1.101',
]
time.sleep(2)
sys.stdout.write('\n'.join(messages1) + '\n')
sys.stdout.flush()
time.sleep(1)
sys.stdout.write('\n'.join(messages2) + '\n')
sys.stdout.flush()
time.sleep(1)
while messages3:
message = messages3.pop(0)
sys.stdout.write(message + '\n')
sys.stdout.flush()
try:
now = time.time()
while True and time.time() < now + 5:
line = sys.stdin.readline().strip()
if not line or 'shutdown' in line:
break
time.sleep(1)
except IOError:
pass