diff options
22 files changed, 18 insertions, 277 deletions
diff --git a/configs/kvmd/main/v0-hdmi-rpi.yaml b/configs/kvmd/main/v0-hdmi-rpi.yaml index 267e40c8..2cba036f 100644 --- a/configs/kvmd/main/v0-hdmi-rpi.yaml +++ b/configs/kvmd/main/v0-hdmi-rpi.yaml @@ -7,9 +7,6 @@ override: !include [override.d, override.yaml] logging: !include logging.yaml kvmd: - server: - unix: /run/kvmd/kvmd.sock - auth: !include auth.yaml hid: @@ -28,7 +25,6 @@ kvmd: type: disabled streamer: - unix: /run/kvmd/ustreamer.sock cmd: - "/usr/bin/ustreamer" - "--device=/dev/kvmd-video" @@ -49,17 +45,8 @@ kvmd: - "--notify-parent" - "--no-log-colors" -ipmi: - kvmd: - unix: /run/kvmd/kvmd.sock vnc: - kvmd: - unix: /run/kvmd/kvmd.sock - - streamer: - unix: /run/kvmd/ustreamer.sock - server: tls: x509: diff --git a/configs/kvmd/main/v0-hdmi-rpi2.yaml b/configs/kvmd/main/v0-hdmi-rpi2.yaml index 71a51e53..2cba036f 100644 --- a/configs/kvmd/main/v0-hdmi-rpi2.yaml +++ b/configs/kvmd/main/v0-hdmi-rpi2.yaml @@ -7,9 +7,6 @@ override: !include [override.d, override.yaml] logging: !include logging.yaml kvmd: - server: - unix: /run/kvmd/kvmd.sock - auth: !include auth.yaml hid: @@ -28,7 +25,6 @@ kvmd: type: disabled streamer: - unix: /run/kvmd/ustreamer.sock cmd: - "/usr/bin/ustreamer" - "--device=/dev/kvmd-video" @@ -49,18 +45,8 @@ kvmd: - "--notify-parent" - "--no-log-colors" -ipmi: - kvmd: - unix: /run/kvmd/kvmd.sock - vnc: - kvmd: - unix: /run/kvmd/kvmd.sock - - streamer: - unix: /run/kvmd/ustreamer.sock - server: tls: x509: diff --git a/configs/kvmd/main/v0-hdmi-rpi3.yaml b/configs/kvmd/main/v0-hdmi-rpi3.yaml index 3018ad3d..1d09fbc9 100644 --- a/configs/kvmd/main/v0-hdmi-rpi3.yaml +++ b/configs/kvmd/main/v0-hdmi-rpi3.yaml @@ -7,9 +7,6 @@ override: !include [override.d, override.yaml] logging: !include logging.yaml kvmd: - server: - unix: /run/kvmd/kvmd.sock - auth: !include auth.yaml hid: @@ -28,7 +25,6 @@ kvmd: type: disabled streamer: - unix: /run/kvmd/ustreamer.sock cmd: - "/usr/bin/ustreamer" - "--device=/dev/kvmd-video" @@ -51,17 +47,8 @@ kvmd: - "--sink=kvmd::ustreamer::jpeg" - "--sink-mode=0660" -ipmi: - kvmd: - unix: /run/kvmd/kvmd.sock vnc: - kvmd: - unix: /run/kvmd/kvmd.sock - - streamer: - unix: /run/kvmd/ustreamer.sock - memsink: jpeg: sink: "kvmd::ustreamer::jpeg" diff --git a/configs/kvmd/main/v0-hdmi-zero2w.yaml b/configs/kvmd/main/v0-hdmi-zero2w.yaml index ddca06c3..1a455a21 100644 --- a/configs/kvmd/main/v0-hdmi-zero2w.yaml +++ b/configs/kvmd/main/v0-hdmi-zero2w.yaml @@ -7,9 +7,6 @@ override: !include [override.d, override.yaml] logging: !include logging.yaml kvmd: - server: - unix: /run/kvmd/kvmd.sock - auth: !include auth.yaml hid: @@ -28,7 +25,6 @@ kvmd: type: disabled streamer: - unix: /run/kvmd/ustreamer.sock h264_bitrate: default: 5000 cmd: @@ -57,17 +53,8 @@ kvmd: - "--h264-bitrate={h264_bitrate}" - "--h264-gop={h264_gop}" -ipmi: - kvmd: - unix: /run/kvmd/kvmd.sock vnc: - kvmd: - unix: /run/kvmd/kvmd.sock - - streamer: - unix: /run/kvmd/ustreamer.sock - memsink: jpeg: sink: "kvmd::ustreamer::jpeg" diff --git a/configs/kvmd/main/v0-hdmi-zerow.yaml b/configs/kvmd/main/v0-hdmi-zerow.yaml index 43e565b8..f3ab670c 100644 --- a/configs/kvmd/main/v0-hdmi-zerow.yaml +++ b/configs/kvmd/main/v0-hdmi-zerow.yaml @@ -7,9 +7,6 @@ override: !include [override.d, override.yaml] logging: !include logging.yaml kvmd: - server: - unix: /run/kvmd/kvmd.sock - auth: !include auth.yaml hid: @@ -29,7 +26,6 @@ kvmd: streamer: quality: 50 - unix: /run/kvmd/ustreamer.sock cmd: - "/usr/bin/ustreamer" - "--device=/dev/kvmd-video" @@ -50,17 +46,8 @@ kvmd: - "--notify-parent" - "--no-log-colors" -ipmi: - kvmd: - unix: /run/kvmd/kvmd.sock vnc: - kvmd: - unix: /run/kvmd/kvmd.sock - - streamer: - unix: /run/kvmd/ustreamer.sock - server: tls: x509: diff --git a/configs/kvmd/main/v0-hdmiusb-rpi.yaml b/configs/kvmd/main/v0-hdmiusb-rpi.yaml index 0f037cb7..aee96996 100644 --- a/configs/kvmd/main/v0-hdmiusb-rpi.yaml +++ b/configs/kvmd/main/v0-hdmiusb-rpi.yaml @@ -7,9 +7,6 @@ override: !include [override.d, override.yaml] logging: !include logging.yaml kvmd: - server: - unix: /run/kvmd/kvmd.sock - auth: !include auth.yaml hid: @@ -43,7 +40,6 @@ kvmd: - 720x576 - 720x480 - 640x480 - unix: /run/kvmd/ustreamer.sock cmd: - "/usr/bin/ustreamer" - "--device=/dev/kvmd-video" @@ -61,17 +57,8 @@ kvmd: - "--notify-parent" - "--no-log-colors" -ipmi: - kvmd: - unix: /run/kvmd/kvmd.sock vnc: - kvmd: - unix: /run/kvmd/kvmd.sock - - streamer: - unix: /run/kvmd/ustreamer.sock - server: tls: x509: diff --git a/configs/kvmd/main/v0-hdmiusb-rpi2.yaml b/configs/kvmd/main/v0-hdmiusb-rpi2.yaml index 0f037cb7..aee96996 100644 --- a/configs/kvmd/main/v0-hdmiusb-rpi2.yaml +++ b/configs/kvmd/main/v0-hdmiusb-rpi2.yaml @@ -7,9 +7,6 @@ override: !include [override.d, override.yaml] logging: !include logging.yaml kvmd: - server: - unix: /run/kvmd/kvmd.sock - auth: !include auth.yaml hid: @@ -43,7 +40,6 @@ kvmd: - 720x576 - 720x480 - 640x480 - unix: /run/kvmd/ustreamer.sock cmd: - "/usr/bin/ustreamer" - "--device=/dev/kvmd-video" @@ -61,17 +57,8 @@ kvmd: - "--notify-parent" - "--no-log-colors" -ipmi: - kvmd: - unix: /run/kvmd/kvmd.sock vnc: - kvmd: - unix: /run/kvmd/kvmd.sock - - streamer: - unix: /run/kvmd/ustreamer.sock - server: tls: x509: diff --git a/configs/kvmd/main/v0-hdmiusb-rpi3.yaml b/configs/kvmd/main/v0-hdmiusb-rpi3.yaml index 3182efb7..7e18a22c 100644 --- a/configs/kvmd/main/v0-hdmiusb-rpi3.yaml +++ b/configs/kvmd/main/v0-hdmiusb-rpi3.yaml @@ -7,9 +7,6 @@ override: !include [override.d, override.yaml] logging: !include logging.yaml kvmd: - server: - unix: /run/kvmd/kvmd.sock - auth: !include auth.yaml hid: @@ -43,7 +40,6 @@ kvmd: - 720x576 - 720x480 - 640x480 - unix: /run/kvmd/ustreamer.sock cmd: - "/usr/bin/ustreamer" - "--device=/dev/kvmd-video" @@ -63,17 +59,8 @@ kvmd: - "--sink=kvmd::ustreamer::jpeg" - "--sink-mode=0660" -ipmi: - kvmd: - unix: /run/kvmd/kvmd.sock vnc: - kvmd: - unix: /run/kvmd/kvmd.sock - - streamer: - unix: /run/kvmd/ustreamer.sock - memsink: jpeg: sink: "kvmd::ustreamer::jpeg" diff --git a/configs/kvmd/main/v0-hdmiusb-zero2w.yaml b/configs/kvmd/main/v0-hdmiusb-zero2w.yaml index 3182efb7..7e18a22c 100644 --- a/configs/kvmd/main/v0-hdmiusb-zero2w.yaml +++ b/configs/kvmd/main/v0-hdmiusb-zero2w.yaml @@ -7,9 +7,6 @@ override: !include [override.d, override.yaml] logging: !include logging.yaml kvmd: - server: - unix: /run/kvmd/kvmd.sock - auth: !include auth.yaml hid: @@ -43,7 +40,6 @@ kvmd: - 720x576 - 720x480 - 640x480 - unix: /run/kvmd/ustreamer.sock cmd: - "/usr/bin/ustreamer" - "--device=/dev/kvmd-video" @@ -63,17 +59,8 @@ kvmd: - "--sink=kvmd::ustreamer::jpeg" - "--sink-mode=0660" -ipmi: - kvmd: - unix: /run/kvmd/kvmd.sock vnc: - kvmd: - unix: /run/kvmd/kvmd.sock - - streamer: - unix: /run/kvmd/ustreamer.sock - memsink: jpeg: sink: "kvmd::ustreamer::jpeg" diff --git a/configs/kvmd/main/v0-hdmiusb-zerow.yaml b/configs/kvmd/main/v0-hdmiusb-zerow.yaml index 0f037cb7..aee96996 100644 --- a/configs/kvmd/main/v0-hdmiusb-zerow.yaml +++ b/configs/kvmd/main/v0-hdmiusb-zerow.yaml @@ -7,9 +7,6 @@ override: !include [override.d, override.yaml] logging: !include logging.yaml kvmd: - server: - unix: /run/kvmd/kvmd.sock - auth: !include auth.yaml hid: @@ -43,7 +40,6 @@ kvmd: - 720x576 - 720x480 - 640x480 - unix: /run/kvmd/ustreamer.sock cmd: - "/usr/bin/ustreamer" - "--device=/dev/kvmd-video" @@ -61,17 +57,8 @@ kvmd: - "--notify-parent" - "--no-log-colors" -ipmi: - kvmd: - unix: /run/kvmd/kvmd.sock vnc: - kvmd: - unix: /run/kvmd/kvmd.sock - - streamer: - unix: /run/kvmd/ustreamer.sock - server: tls: x509: diff --git a/configs/kvmd/main/v2-hdmi-rpi3.yaml b/configs/kvmd/main/v2-hdmi-rpi3.yaml index 2b3e4f29..88d0f350 100644 --- a/configs/kvmd/main/v2-hdmi-rpi3.yaml +++ b/configs/kvmd/main/v2-hdmi-rpi3.yaml @@ -7,9 +7,6 @@ override: !include [override.d, override.yaml] logging: !include logging.yaml kvmd: - server: - unix: /run/kvmd/kvmd.sock - auth: !include auth.yaml hid: @@ -30,7 +27,6 @@ kvmd: type: otg streamer: - unix: /run/kvmd/ustreamer.sock cmd: - "/usr/bin/ustreamer" - "--device=/dev/kvmd-video" @@ -53,17 +49,8 @@ kvmd: - "--sink=kvmd::ustreamer::jpeg" - "--sink-mode=0660" -ipmi: - kvmd: - unix: /run/kvmd/kvmd.sock vnc: - kvmd: - unix: /run/kvmd/kvmd.sock - - streamer: - unix: /run/kvmd/ustreamer.sock - memsink: jpeg: sink: "kvmd::ustreamer::jpeg" diff --git a/configs/kvmd/main/v2-hdmi-rpi4.yaml b/configs/kvmd/main/v2-hdmi-rpi4.yaml index 1ab8dda9..52bedc0d 100644 --- a/configs/kvmd/main/v2-hdmi-rpi4.yaml +++ b/configs/kvmd/main/v2-hdmi-rpi4.yaml @@ -7,9 +7,6 @@ override: !include [override.d, override.yaml] logging: !include logging.yaml kvmd: - server: - unix: /run/kvmd/kvmd.sock - auth: !include auth.yaml hid: @@ -30,7 +27,6 @@ kvmd: type: otg streamer: - unix: /run/kvmd/ustreamer.sock h264_bitrate: default: 5000 cmd: @@ -59,17 +55,8 @@ kvmd: - "--h264-bitrate={h264_bitrate}" - "--h264-gop={h264_gop}" -ipmi: - kvmd: - unix: /run/kvmd/kvmd.sock vnc: - kvmd: - unix: /run/kvmd/kvmd.sock - - streamer: - unix: /run/kvmd/ustreamer.sock - memsink: jpeg: sink: "kvmd::ustreamer::jpeg" diff --git a/configs/kvmd/main/v2-hdmi-zero2w.yaml b/configs/kvmd/main/v2-hdmi-zero2w.yaml index 1ab8dda9..52bedc0d 100644 --- a/configs/kvmd/main/v2-hdmi-zero2w.yaml +++ b/configs/kvmd/main/v2-hdmi-zero2w.yaml @@ -7,9 +7,6 @@ override: !include [override.d, override.yaml] logging: !include logging.yaml kvmd: - server: - unix: /run/kvmd/kvmd.sock - auth: !include auth.yaml hid: @@ -30,7 +27,6 @@ kvmd: type: otg streamer: - unix: /run/kvmd/ustreamer.sock h264_bitrate: default: 5000 cmd: @@ -59,17 +55,8 @@ kvmd: - "--h264-bitrate={h264_bitrate}" - "--h264-gop={h264_gop}" -ipmi: - kvmd: - unix: /run/kvmd/kvmd.sock vnc: - kvmd: - unix: /run/kvmd/kvmd.sock - - streamer: - unix: /run/kvmd/ustreamer.sock - memsink: jpeg: sink: "kvmd::ustreamer::jpeg" diff --git a/configs/kvmd/main/v2-hdmi-zerow.yaml b/configs/kvmd/main/v2-hdmi-zerow.yaml index 7fab7c74..b5eb5231 100644 --- a/configs/kvmd/main/v2-hdmi-zerow.yaml +++ b/configs/kvmd/main/v2-hdmi-zerow.yaml @@ -7,9 +7,6 @@ override: !include [override.d, override.yaml] logging: !include logging.yaml kvmd: - server: - unix: /run/kvmd/kvmd.sock - auth: !include auth.yaml hid: @@ -31,7 +28,6 @@ kvmd: streamer: quality: 50 - unix: /run/kvmd/ustreamer.sock cmd: - "/usr/bin/ustreamer" - "--device=/dev/kvmd-video" @@ -52,17 +48,8 @@ kvmd: - "--notify-parent" - "--no-log-colors" -ipmi: - kvmd: - unix: /run/kvmd/kvmd.sock vnc: - kvmd: - unix: /run/kvmd/kvmd.sock - - streamer: - unix: /run/kvmd/ustreamer.sock - server: tls: x509: diff --git a/configs/kvmd/main/v2-hdmiusb-generic.yaml b/configs/kvmd/main/v2-hdmiusb-generic.yaml index 8a397aee..0e7159d2 100644 --- a/configs/kvmd/main/v2-hdmiusb-generic.yaml +++ b/configs/kvmd/main/v2-hdmiusb-generic.yaml @@ -7,9 +7,6 @@ override: !include [override.d, override.yaml] logging: !include logging.yaml kvmd: - server: - unix: /run/kvmd/kvmd.sock - auth: !include auth.yaml hid: @@ -41,7 +38,6 @@ kvmd: - 720x576 - 720x480 - 640x480 - unix: /run/kvmd/ustreamer.sock cmd: - "/usr/bin/ustreamer" - "--device=/dev/kvmd-video" @@ -61,17 +57,8 @@ kvmd: - "--sink=kvmd::ustreamer::jpeg" - "--sink-mode=0660" -ipmi: - kvmd: - unix: /run/kvmd/kvmd.sock vnc: - kvmd: - unix: /run/kvmd/kvmd.sock - - streamer: - unix: /run/kvmd/ustreamer.sock - memsink: jpeg: sink: "kvmd::ustreamer::jpeg" diff --git a/configs/kvmd/main/v2-hdmiusb-rpi4.yaml b/configs/kvmd/main/v2-hdmiusb-rpi4.yaml index cb0bbe0a..a90d0be3 100644 --- a/configs/kvmd/main/v2-hdmiusb-rpi4.yaml +++ b/configs/kvmd/main/v2-hdmiusb-rpi4.yaml @@ -7,9 +7,6 @@ override: !include [override.d, override.yaml] logging: !include logging.yaml kvmd: - server: - unix: /run/kvmd/kvmd.sock - auth: !include auth.yaml hid: @@ -45,7 +42,6 @@ kvmd: - 720x576 - 720x480 - 640x480 - unix: /run/kvmd/ustreamer.sock cmd: - "/usr/bin/ustreamer" - "--device=/dev/kvmd-video" @@ -65,17 +61,8 @@ kvmd: - "--sink=kvmd::ustreamer::jpeg" - "--sink-mode=0660" -ipmi: - kvmd: - unix: /run/kvmd/kvmd.sock vnc: - kvmd: - unix: /run/kvmd/kvmd.sock - - streamer: - unix: /run/kvmd/ustreamer.sock - memsink: jpeg: sink: "kvmd::ustreamer::jpeg" diff --git a/configs/kvmd/main/v3-hdmi-rpi4.yaml b/configs/kvmd/main/v3-hdmi-rpi4.yaml index 7de62ccd..ba26d12a 100644 --- a/configs/kvmd/main/v3-hdmi-rpi4.yaml +++ b/configs/kvmd/main/v3-hdmi-rpi4.yaml @@ -7,9 +7,6 @@ override: !include [override.d, override.yaml] logging: !include logging.yaml kvmd: - server: - unix: /run/kvmd/kvmd.sock - auth: !include auth.yaml info: @@ -34,7 +31,6 @@ kvmd: type: otg streamer: - unix: /run/kvmd/ustreamer.sock h264_bitrate: default: 5000 cmd: @@ -72,17 +68,8 @@ kvmd: pulse: delay: 0 -ipmi: - kvmd: - unix: /run/kvmd/kvmd.sock vnc: - kvmd: - unix: /run/kvmd/kvmd.sock - - streamer: - unix: /run/kvmd/ustreamer.sock - memsink: jpeg: sink: "kvmd::ustreamer::jpeg" diff --git a/kvmd/apps/__init__.py b/kvmd/apps/__init__.py index 59490fc5..521c73db 100644 --- a/kvmd/apps/__init__.py +++ b/kvmd/apps/__init__.py @@ -343,9 +343,7 @@ def _get_config_scheme() -> Dict: "kvmd": { "server": { - "host": Option("localhost", type=valid_ip_or_host), - "port": Option(0, type=valid_port), - "unix": Option("", type=valid_abs_path, only_if="!port", unpack_as="unix_path"), + "unix": Option("/run/kvmd/kvmd.sock", type=valid_abs_path, unpack_as="unix_path"), "unix_rm": Option(True, type=valid_bool), "unix_mode": Option(0o660, type=valid_unix_mode), "heartbeat": Option(15.0, type=valid_float_f01), @@ -447,9 +445,7 @@ def _get_config_scheme() -> Dict: "max": Option(60, type=valid_stream_h264_gop, unpack_as="h264_gop_max"), }, - "host": Option("localhost", type=valid_ip_or_host), - "port": Option(0, type=valid_port), - "unix": Option("", type=valid_abs_path, only_if="!port", unpack_as="unix_path"), + "unix": Option("/run/kvmd/ustreamer.sock", type=valid_abs_path, unpack_as="unix_path"), "timeout": Option(2.0, type=valid_float_f01), "process_name_prefix": Option("kvmd/streamer"), @@ -600,9 +596,7 @@ def _get_config_scheme() -> Dict: }, "kvmd": { - "host": Option("localhost", type=valid_ip_or_host), - "port": Option(0, type=valid_port), - "unix": Option("", type=valid_abs_path, only_if="!port", unpack_as="unix_path"), + "unix": Option("/run/kvmd/kvmd.sock", type=valid_abs_path, unpack_as="unix_path"), "timeout": Option(5.0, type=valid_float_f01), }, @@ -646,16 +640,12 @@ def _get_config_scheme() -> Dict: }, "kvmd": { - "host": Option("localhost", type=valid_ip_or_host), - "port": Option(0, type=valid_port), - "unix": Option("", type=valid_abs_path, only_if="!port", unpack_as="unix_path"), + "unix": Option("/run/kvmd/kvmd.sock", type=valid_abs_path, unpack_as="unix_path"), "timeout": Option(5.0, type=valid_float_f01), }, "streamer": { - "host": Option("localhost", type=valid_ip_or_host), - "port": Option(0, type=valid_port), - "unix": Option("", type=valid_abs_path, only_if="!port", unpack_as="unix_path"), + "unix": Option("/run/kvmd/ustreamer.sock", type=valid_abs_path, unpack_as="unix_path"), "timeout": Option(5.0, type=valid_float_f01), }, diff --git a/kvmd/apps/kvmd/http.py b/kvmd/apps/kvmd/http.py index f2d73ad9..797d32dc 100644 --- a/kvmd/apps/kvmd/http.py +++ b/kvmd/apps/kvmd/http.py @@ -215,34 +215,26 @@ def set_request_auth_info(request: BaseRequest, info: str) -> None: class HttpServer: def run( self, - host: str, - port: int, unix_path: str, unix_rm: bool, unix_mode: int, access_log_format: str, ) -> None: - assert port or unix_path - if unix_path: - socket_kwargs: Dict = {} - if unix_rm and os.path.exists(unix_path): - os.remove(unix_path) - server_socket = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) - server_socket.bind(unix_path) - if unix_mode: - os.chmod(unix_path, unix_mode) - socket_kwargs = {"sock": server_socket} - else: - socket_kwargs = {"host": host, "port": port} + if unix_rm and os.path.exists(unix_path): + os.remove(unix_path) + server_socket = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) + server_socket.bind(unix_path) + if unix_mode: + os.chmod(unix_path, unix_mode) run_app( + sock=server_socket, app=self._make_app(), shutdown_timeout=1, access_log_format=access_log_format, print=self.__run_app_print, loop=asyncio.get_event_loop(), - **socket_kwargs, ) async def _make_app(self) -> Application: diff --git a/kvmd/apps/kvmd/streamer.py b/kvmd/apps/kvmd/streamer.py index 68195fa4..357403ec 100644 --- a/kvmd/apps/kvmd/streamer.py +++ b/kvmd/apps/kvmd/streamer.py @@ -182,8 +182,6 @@ class Streamer: # pylint: disable=too-many-instance-attributes shutdown_delay: float, state_poll: float, - host: str, - port: int, unix_path: str, timeout: float, @@ -200,9 +198,6 @@ class Streamer: # pylint: disable=too-many-instance-attributes self.__shutdown_delay = shutdown_delay self.__state_poll = state_poll - assert port or unix_path - self.__host = host - self.__port = port self.__unix_path = unix_path self.__timeout = timeout @@ -402,16 +397,15 @@ class Streamer: # pylint: disable=too-many-instance-attributes if not self.__http_session: kwargs: Dict = { "headers": {"User-Agent": htclient.make_user_agent("KVMD")}, + "connector": aiohttp.UnixConnector(path=self.__unix_path), "timeout": aiohttp.ClientTimeout(total=self.__timeout), } - if self.__unix_path: - kwargs["connector"] = aiohttp.UnixConnector(path=self.__unix_path) self.__http_session = aiohttp.ClientSession(**kwargs) return self.__http_session def __make_url(self, handle: str) -> str: assert not handle.startswith("/"), handle - return f"http://{self.__host}:{self.__port}/{handle}" + return f"http://localhost:0/{handle}" # ===== @@ -452,8 +446,6 @@ class Streamer: # pylint: disable=too-many-instance-attributes assert self.__streamer_proc is None cmd = [ part.format( - host=self.__host, - port=self.__port, unix=self.__unix_path, process_name_prefix=self.__process_name_prefix, **self.__params.get_params(), diff --git a/kvmd/clients/kvmd.py b/kvmd/clients/kvmd.py index d3d91094..84576fb2 100644 --- a/kvmd/clients/kvmd.py +++ b/kvmd/clients/kvmd.py @@ -245,15 +245,11 @@ class KvmdClientSession: class KvmdClient: def __init__( self, - host: str, - port: int, unix_path: str, timeout: float, user_agent: str, ) -> None: - self.__host = host - self.__port = port self.__unix_path = unix_path self.__timeout = timeout self.__user_agent = user_agent @@ -271,12 +267,11 @@ class KvmdClient: "X-KVMD-Passwd": passwd, "User-Agent": self.__user_agent, }, + "connector": aiohttp.UnixConnector(path=self.__unix_path), "timeout": aiohttp.ClientTimeout(total=self.__timeout), } - if self.__unix_path: - kwargs["connector"] = aiohttp.UnixConnector(path=self.__unix_path) return aiohttp.ClientSession(**kwargs) def __make_url(self, handle: str) -> str: assert not handle.startswith("/"), handle - return f"http://{self.__host}:{self.__port}/{handle}" + return f"http://localhost:0/{handle}" diff --git a/kvmd/clients/streamer.py b/kvmd/clients/streamer.py index 35006ede..dd4167f9 100644 --- a/kvmd/clients/streamer.py +++ b/kvmd/clients/streamer.py @@ -71,17 +71,12 @@ class HttpStreamerClient(BaseStreamerClient): def __init__( self, name: str, - host: str, - port: int, unix_path: str, timeout: float, user_agent: str, ) -> None: - assert port or unix_path self.__name = name - self.__host = host - self.__port = port self.__unix_path = unix_path self.__timeout = timeout self.__user_agent = user_agent @@ -125,18 +120,17 @@ class HttpStreamerClient(BaseStreamerClient): def __make_http_session(self) -> aiohttp.ClientSession: kwargs: Dict = { "headers": {"User-Agent": self.__user_agent}, + "connector": aiohttp.UnixConnector(path=self.__unix_path), "timeout": aiohttp.ClientTimeout( connect=self.__timeout, sock_read=self.__timeout, ), } - if self.__unix_path: - kwargs["connector"] = aiohttp.UnixConnector(path=self.__unix_path) return aiohttp.ClientSession(**kwargs) def __make_url(self, handle: str) -> str: assert not handle.startswith("/"), handle - return f"http://{self.__host}:{self.__port}/{handle}" + return f"http://localhost:0/{handle}" def __patch_stream_reader(self, reader: aiohttp.StreamReader) -> None: # https://github.com/pikvm/pikvm/issues/92 |