#!/usr/pkg/bin/python3.13

import sys
import time

try:
    while True:
        line = sys.stdin.readline().strip()
        if 'start' in line:
            continue
        if 'end' in line:
            continue
        if 'eor' in line:
            continue
        if (
            'neighbor 127.0.0.1 receive update announced 0.0.0.0/32 next-hop 127.0.0.1 origin igp local-preference 100'
            not in line
        ):
            sys.stdout.write('neighbor 127.0.0.1 announce route 0.0.0.0/0 next-hop 255.255.255.255\n')
            sys.stdout.flush()
            time.sleep(5)
            sys.exit(1)
        break

    sys.stdout.write('neighbor 127.0.0.1 announce route 1.2.3.4 next-hop 5.6.7.8\n')
    sys.stdout.flush()

    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
