code: def __init__(
      self,
      app_specs: List[AppSpec],
      ports: Dict[int, int],
      hostname: str,
      secure: bool,
      ip_address: Optional[str] = None,
  ):
      self.app_specs = {
          app_spec.port: app_spec for app_spec in app_specs
      }
      self.ports = ports
      self.hostname = hostname
      self.secure = secure
  
      hosts = ["localhost", "0.0.0.0", "127.0.0.1"]
      if ip_address and ip_address not in hosts:
          hosts.append(ip_address)
      hosts_re = "|".join(hosts)
      self._url_re = re.compile(
          rf"http://(?:{hosts_re}):(\d+)\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)".encode()
      )
  
file_path: dstack/src/dstack/_internal/core/services/logs.py
imports: import re
  import urllib.parse
  from typing import Dict, List, Optional
  from dstack._internal.core.models.runs import AppSpec
label_desc: Use image node_id 1 to create a new URLReplacer object  with example: obj = URLReplacer(app_specs, ports, hostname, secure, ip_address)