Add support for inbound hop nodes

This commit is contained in:
Seth Foster
2023-10-03 14:32:39 -04:00
committed by Seth Foster
parent 2fa5116197
commit d54c5934ff
8 changed files with 123 additions and 0 deletions

View File

@@ -0,0 +1,29 @@
from django.db import models
class ReceptorAddress(models.Model):
address = models.CharField(max_length=255)
port = models.IntegerField(null=True)
protocol = models.CharField(max_length=10)
websocket_path = models.CharField(max_length=255, default="", blank=True)
is_internal = models.BooleanField(default=False)
instance = models.ForeignKey(
'Instance',
related_name='receptor_addresses',
on_delete=models.CASCADE,
)
def get_full_address(self):
scheme = ""
path = ""
port = ""
if self.protocol == "ws":
scheme = "wss://"
if self.protocol == "ws" and self.websocket_path:
path = f"/{self.websocket_path}"
if self.port:
port = f":{self.port}"
return f"{scheme}{self.address}{port}{path}"