Skip to content

Commit

Permalink
Merge pull request #1221 from ton31337/feature/do_not_send_fqdn_capab…
Browse files Browse the repository at this point in the history
…ility_by_default

Do not send hostname/domainname (fqdn capability) by default
  • Loading branch information
thomas-mangin authored Jul 9, 2024
2 parents 0746cbf + fcf6bb0 commit 86b2a89
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 11 deletions.
2 changes: 2 additions & 0 deletions src/exabgp/bgp/message/open/capability/capabilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,8 @@ def pack(self):
parameters = b''
for k, capabilities in self.items():
for capability in capabilities.extract():
if len(capability) == 0:
continue
encoded = bytes([k, len(capability)]) + capability
parameters += bytes([2, len(encoded)]) + encoded

Expand Down
26 changes: 17 additions & 9 deletions src/exabgp/bgp/message/open/capability/hostname.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,23 @@ def json(self):
return '{ "host-name": "%s", "domain-name": "%s" }' % (self.host_name, self.domain_name)

def extract(self):
hostname = self.host_name.encode('utf-8')
if len(hostname) > self.HOSTNAME_MAX_LEN:
hostname = hostname[:self.HOSTNAME_MAX_LEN]

domainname = self.domain_name.encode('utf-8')
if len(domainname) > self.HOSTNAME_MAX_LEN:
domainname = domainname[:self.HOSTNAME_MAX_LEN]

return [bytes([len(hostname)]) + hostname + bytes([len(domainname)]) + domainname]
ret = b''

if self.host_name:
hostname = self.host_name.encode('utf-8')
if len(hostname) > self.HOSTNAME_MAX_LEN:
hostname = hostname[: self.HOSTNAME_MAX_LEN]
ret += bytes([len(hostname)]) + hostname

if self.domain_name:
domainname = self.domain_name.encode('utf-8')
if len(domainname) > self.HOSTNAME_MAX_LEN:
domainname = domainname[: self.HOSTNAME_MAX_LEN]
ret += bytes([len(domainname)]) + domainname
else:
ret += bytes([0]) + b''

return [ret]

@staticmethod
def unpack_capability(instance, data, capability=None): # pylint: disable=W0613
Expand Down
4 changes: 2 additions & 2 deletions src/exabgp/bgp/neighbor.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ class Capability(dict):
'connect': 0,
'hold-time': HoldTime(180),
'rate-limit': 0,
'host-name': host(),
'domain-name': domain(),
'host-name': None,
'domain-name': None,
'group-updates': True,
'auto-flush': True,
'adj-rib-in': True,
Expand Down

0 comments on commit 86b2a89

Please sign in to comment.