Add method to handle formatting of IPv6 in URLs

This commit is contained in:
Simon Li
2025-01-30 18:44:50 +00:00
parent 948e112bde
commit 5b02d9c222
4 changed files with 19 additions and 13 deletions

View File

@@ -46,7 +46,7 @@ from sqlalchemy.pool import StaticPool
from sqlalchemy.types import LargeBinary, Text, TypeDecorator
from tornado.log import app_log
from .utils import compare_token, hash_token, new_token, random_port, utcnow
from .utils import compare_token, fmt_ip_url, hash_token, new_token, random_port, utcnow
# top-level variable for easier mocking in tests
utcnow = partial(utcnow, with_tz=False)
@@ -157,8 +157,7 @@ class Server(Base):
spawner = relationship("Spawner", back_populates="server", uselist=False)
def __repr__(self):
ip = f"[{self.ip}]" if ":" in self.ip else self.ip
return f"<Server({ip}:{self.port})>"
return f"<Server({fmt_ip_url(self.ip)}:{self.port})>"
# lots of things have roles