mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2025-12-12 09:10:30 +08:00
refactoring
This commit is contained in:
parent
63aa4a07a7
commit
3de55653fa
@ -298,6 +298,10 @@ def _dump_config(config: Section) -> None:
|
||||
print(dump)
|
||||
|
||||
|
||||
def _make_ifarg(validator, unless): # type: ignore
|
||||
return (lambda arg: (validator(arg) if arg else unless))
|
||||
|
||||
|
||||
def _get_config_scheme() -> Dict:
|
||||
return {
|
||||
"logging": Option({}),
|
||||
@ -342,7 +346,7 @@ def _get_config_scheme() -> Dict:
|
||||
"wol": {
|
||||
"ip": Option("255.255.255.255", type=functools.partial(valid_ip, v6=False)),
|
||||
"port": Option(9, type=valid_port),
|
||||
"mac": Option("", type=(lambda arg: (valid_mac(arg) if arg else ""))),
|
||||
"mac": Option("", type=_make_ifarg(valid_mac, "")),
|
||||
},
|
||||
|
||||
"hid": {
|
||||
@ -368,8 +372,8 @@ def _get_config_scheme() -> Dict:
|
||||
"shutdown_delay": Option(10.0, type=valid_float_f01),
|
||||
"state_poll": Option(1.0, type=valid_float_f01),
|
||||
|
||||
"quality": Option(80, type=(lambda arg: (valid_stream_quality(arg) if arg else 0))), # 0 for disabled feature
|
||||
"resolution": Option("", type=(lambda arg: (valid_stream_resolution(arg) if arg else ""))),
|
||||
"quality": Option(80, type=_make_ifarg(valid_stream_quality, 0)),
|
||||
"resolution": Option("", type=_make_ifarg(valid_stream_resolution, "")),
|
||||
"available_resolutions": Option([], type=functools.partial(valid_string_list, subval=valid_stream_resolution)),
|
||||
|
||||
"desired_fps": {
|
||||
@ -379,7 +383,7 @@ def _get_config_scheme() -> Dict:
|
||||
},
|
||||
|
||||
"h264_bitrate": {
|
||||
"default": Option(0, type=(lambda arg: (valid_stream_h264_bitrate(arg) if arg else 0)), unpack_as="h264_bitrate"),
|
||||
"default": Option(0, type=_make_ifarg(valid_stream_h264_bitrate, 0), unpack_as="h264_bitrate"),
|
||||
"min": Option(100, type=valid_stream_h264_bitrate, unpack_as="h264_bitrate_min"),
|
||||
"max": Option(16000, type=valid_stream_h264_bitrate, unpack_as="h264_bitrate_max"),
|
||||
},
|
||||
@ -406,7 +410,7 @@ def _get_config_scheme() -> Dict:
|
||||
"idle_interval": Option(0.0, type=valid_float_f0),
|
||||
"live_interval": Option(0.0, type=valid_float_f0),
|
||||
|
||||
"wakeup_key": Option("", type=(lambda arg: (valid_hid_key(arg) if arg else ""))),
|
||||
"wakeup_key": Option("", type=_make_ifarg(valid_hid_key, "")),
|
||||
"wakeup_move": Option(0, type=valid_hid_mouse_move),
|
||||
|
||||
"online_delay": Option(5.0, type=valid_float_f0),
|
||||
@ -460,8 +464,8 @@ def _get_config_scheme() -> Dict:
|
||||
"ethernet": {
|
||||
"enabled": Option(False, type=valid_bool),
|
||||
"driver": Option("ecm", type=valid_otg_ethernet),
|
||||
"host_mac": Option("", type=(lambda arg: (valid_mac(arg) if arg else ""))),
|
||||
"kvm_mac": Option("", type=(lambda arg: (valid_mac(arg) if arg else ""))),
|
||||
"host_mac": Option("", type=_make_ifarg(valid_mac, "")),
|
||||
"kvm_mac": Option("", type=_make_ifarg(valid_mac, "")),
|
||||
},
|
||||
|
||||
"drives": {
|
||||
@ -536,7 +540,7 @@ def _get_config_scheme() -> Dict:
|
||||
},
|
||||
|
||||
"sol": {
|
||||
"device": Option("", type=(lambda arg: (valid_abs_path(arg) if arg else "")), unpack_as="sol_device_path"),
|
||||
"device": Option("", type=_make_ifarg(valid_abs_path, ""), unpack_as="sol_device_path"),
|
||||
"speed": Option(115200, type=valid_tty_speed, unpack_as="sol_speed"),
|
||||
"select_timeout": Option(0.1, type=valid_float_f01, unpack_as="sol_select_timeout"),
|
||||
"proxy_port": Option(0, type=valid_port, unpack_as="sol_proxy_port"),
|
||||
@ -561,7 +565,7 @@ def _get_config_scheme() -> Dict:
|
||||
},
|
||||
|
||||
"tls": {
|
||||
"ciphers": Option("ALL:@SECLEVEL=0", type=(lambda arg: valid_ssl_ciphers(arg) if arg else "")),
|
||||
"ciphers": Option("ALL:@SECLEVEL=0", type=_make_ifarg(valid_ssl_ciphers, "")),
|
||||
"timeout": Option(5.0, type=valid_float_f01),
|
||||
},
|
||||
},
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user