Connect from controlplane node to mesh ingress

This commit is contained in:
Hao Liu 2023-10-03 15:47:07 -04:00 committed by Seth Foster
parent d54c5934ff
commit 387e877485
2 changed files with 22 additions and 2 deletions

View File

@ -27,3 +27,11 @@ class ReceptorAddress(models.Model):
port = f":{self.port}"
return f"{scheme}{self.address}{port}{path}"
def get_peer_type(self):
if self.protocol == 'tcp':
return 'tcp-peer'
elif self.protocol in ['ws', 'wss']:
return 'ws-peer'
else:
return None

View File

@ -703,8 +703,20 @@ def generate_config_data():
receptor_config = list(RECEPTOR_CONFIG_STARTER)
for instance in instances:
peer = {'tcp-peer': {'address': f'{instance.hostname}:{instance.listener_port}', 'tls': 'tlsclient'}}
receptor_config.append(peer)
if instance.listener_port:
peer = {'tcp-peer': {'address': f'{instance.hostname}:{instance.listener_port}', 'tls': 'tlsclient'}}
receptor_config.append(peer)
for address in instance.receptor_addresses.all():
if address.get_peer_type() and address.is_internal:
peer = {
f'{address.get_peer_type()}': {
'address': f'{address.get_full_address()}',
'tls': 'tlsclient',
}
}
receptor_config.append(peer)
else:
logger.warning(f"Receptor address {address} has unsupported peer type, skipping.")
should_update = should_update_config(instances)
return receptor_config, should_update