Skip to content

Commit

Permalink
add support for neighbor * in the API
Browse files Browse the repository at this point in the history
  • Loading branch information
thomas-mangin committed Sep 18, 2023
1 parent 3f867af commit 66d08fb
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 0 deletions.
20 changes: 20 additions & 0 deletions etc/exabgp/api-announce-star.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
process add-remove {
run ./run/api-announce-star.run;
encoder json;
}

neighbor 127.0.0.1 {
router-id 1.2.3.4;
local-address 127.0.0.1;
local-as 1;
peer-as 1;
group-updates false;

capability {
graceful-restart;
}

api {
processes [ add-remove ];
}
}
26 changes: 26 additions & 0 deletions etc/exabgp/run/api-announce-star.run
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env python3

import os
import sys
import time

messages = [
'neighbor * announce route 1.1.0.0/24 next-hop 101.1.101.1',
'neighbor * announce route 1.2.0.0/25 next-hop 101.1.101.1',
]

while messages:
message = messages.pop(0)
sys.stdout.write(message + '\n')
sys.stdout.flush()
time.sleep(0.1)

try:
now = time.time()
while os.getppid() != 1 and time.time() < now + 5:
line = sys.stdin.readline().strip()
if not line or 'shutdown' in line:
break
time.sleep(1)
except IOError:
pass
2 changes: 2 additions & 0 deletions lib/exabgp/reactor/api/command/limit.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ def extract_neighbors(command):

def match_neighbor(description, name):
for string in description:
if string.strip() == 'neighbor *':
return True
if re.search(r'(^|\s)%s($|\s|,)' % re.escape(string), name) is None:
return False
return True
Expand Down
1 change: 1 addition & 0 deletions qa/ci/api-announce-star.ci
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
api-announce-star.conf
2 changes: 2 additions & 0 deletions qa/ci/api-announce-star.msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
1:announce:1.1.0.0/24
1:announce:1.2.0.0/25

0 comments on commit 66d08fb

Please sign in to comment.