diff --git a/src/autossh_mgr/process.py b/src/autossh_mgr/process.py index 6b351d1..3f7bd00 100644 --- a/src/autossh_mgr/process.py +++ b/src/autossh_mgr/process.py @@ -2,7 +2,6 @@ import os import shlex import shutil import signal -import socket import subprocess import time from dataclasses import dataclass @@ -115,20 +114,9 @@ def build_autossh_cmd(tunnel: TunnelConfig) -> list[str]: return cmd -def _is_port_in_use(port: int) -> bool: - with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: - try: - s.bind(("127.0.0.1", port)) - return False - except OSError: - return True - - def start_tunnel(config_dir: Path, tunnel: TunnelConfig) -> int: if not shutil.which("autossh"): raise click.ClickException("autossh not found. Install it first.") - if _is_port_in_use(tunnel.local_port): - raise click.ClickException(f"Port {tunnel.local_port} is already in use") log_path = config_dir / "logs" / f"{tunnel.name}.log" log_path.parent.mkdir(parents=True, exist_ok=True)