22 lines
514 B
Python
22 lines
514 B
Python
from app.core.config import settings
|
|
|
|
|
|
class ReservedProxyPortError(ValueError):
|
|
pass
|
|
|
|
|
|
def backend_port() -> int:
|
|
return settings.API_PORT
|
|
|
|
|
|
def reserved_proxy_port_message(proxy_port: int) -> str:
|
|
return (
|
|
f"Proxy port {proxy_port} is reserved for the backend API "
|
|
"and cannot be used by mitmdump."
|
|
)
|
|
|
|
|
|
def ensure_proxy_port_not_reserved(proxy_port: int) -> None:
|
|
if proxy_port == backend_port():
|
|
raise ReservedProxyPortError(reserved_proxy_port_message(proxy_port))
|