BIRD-LG currently keeps log files indefinitely. This patch allows
setting the number of days logs should be kept for by adding
a `LOG_NUM_DAYS` parameter in the configuration files.
This change is backwards compatible: Running the updated code with
old configuration files will keep logs indefinitely as before; new
deployments based on the example configuration will keep logs
indefinitely.
Commit eaf531eee2 ("Correctly parse aspath for both bird 1.x and 2.0.")
inadvertently made a regexp more strict, and it no longer matches some
interface names. Example include `eth1.945` (tagged VLAN, which is a
common use-case for routers) or `br-foo`.
As a result, the regexp would not parse the "peer protocol name" that is
normally displayed on the bgpmap.
Fixes: #64
Without this patch, `show route where net ~ [ prefix+ ] (bgpmap)` erroneously returns only one prefix with a box shape, and all the other prefixes with a oval shape as if they were multipath intermediate ASes.
Bird displays neighbor's 4-byte AS capability as `AS4`.
This patch prevents it from being treated as an clickable ASN in the output of `show protocols <protocol_name> all` response.
Due to the change in the output of `show route for <prefix> all` since bird-2.0, this patch is necessary to correctly parse aspaths.
Without this patch, `build_as_tree_from_raw_bird_ouput()` fails with the following exception if the backend is bird-2.0.
```
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/flask/app.py", line 1836, in __call__
return self.wsgi_app(environ, start_response)
File "/usr/lib/python2.7/dist-packages/flask/app.py", line 1820, in wsgi_app
response = self.make_response(self.handle_exception(e))
File "/usr/lib/python2.7/dist-packages/flask/app.py", line 1403, in handle_exception
reraise(exc_type, exc_value, tb)
File "/usr/lib/python2.7/dist-packages/flask/app.py", line 1817, in wsgi_app
response = self.full_dispatch_request()
File "/usr/lib/python2.7/dist-packages/flask/app.py", line 1477, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/usr/lib/python2.7/dist-packages/flask/app.py", line 1381, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/usr/lib/python2.7/dist-packages/flask/app.py", line 1475, in full_dispatch_request
rv = self.dispatch_request()
File "/usr/lib/python2.7/dist-packages/flask/app.py", line 1461, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "./lg.py", line 522, in show_bgpmap
response = Response(graph.create_png(), mimetype='image/png')
File "/usr/lib/python2.7/dist-packages/pydot.py", line 1735, in <lambda>
lambda f=frmt, prog=self.prog: self.create(format=f, prog=prog)
File "/usr/lib/python2.7/dist-packages/pydot.py", line 1905, in create
self.write(tmp_name)
File "/usr/lib/python2.7/dist-packages/pydot.py", line 1830, in write
data = self.to_string()
File "/usr/lib/python2.7/dist-packages/pydot.py", line 1600, in to_string
graph.append(node.to_string() + '\n')
File "/usr/lib/python2.7/dist-packages/pydot.py", line 865, in to_string
node += ' [' + node_attr + ']'
TypeError: unsupported operand type(s) for +=: 'NoneType' and 'str'
```
Consequently, `show route for <prefix> (bgpmap)` shows an error icon.
The current parsing method (ugly regexp) is hard to understand and prone
to breakage:
- Bird 1.4 changed the date format, which broke the parser ()
- Bird 2.0 changed the format of the "Table" field, which again broke the parser (#36)
The new method is much simpler, does not involve any regexp, and should
thus resist small syntax changes in Bird's output.
Important limitation: parsing will be messed up if the date contains a
space character. There is no space in the default date format of Bird
(checked with Bird 1.3 to Bird 2.0), but since the date format is
configurable in Bird, it may happen anyway. In particular, setting
"timeformat protocol iso long" in Bird will break bird-lg's parser.
Fixes#36
Add the options
```BIND_IP = "0.0.0.0"
BIND_PORT = 5000```
which allows to bind lgproxy.py to an IP/interface.
As ports on routers shouldn't be exposed too much, it probably also makes sense to others to have this function. Tested.