removed unused network code and simplified configs

This commit is contained in:
Maxim Devaev
2022-03-27 22:50:35 +03:00
parent 8775cd2286
commit 056f069346
22 changed files with 18 additions and 277 deletions

View File

@@ -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:

View File

@@ -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:

View File

@@ -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"

View File

@@ -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"

View File

@@ -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:

View File

@@ -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:

View File

@@ -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:

View File

@@ -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"

View File

@@ -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"

View File

@@ -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:

View File

@@ -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"

View File

@@ -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"

View File

@@ -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"

View File

@@ -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:

View File

@@ -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"

View File

@@ -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"

View File

@@ -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"

View File

@@ -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),
},

View File

@@ -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:

View File

@@ -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(),

View File

@@ -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}"

View File

@@ -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