feat(tcp): add listener + export socket schema

This commit adds a TCP listener that can be optionally exposed on a port
provided by the user using the --tcp-port flag. If the flag is not
provided, the TCP listener will not be started.

Client state is tracked using the connecting address, and clients are
purged if they send unrecognised messages.

A JSON Schema of the SocketMessage enum can be exported via komorebic
and be used to generate type definitions in various programming
languages.

This commit also makes some improvements to the handling of 'komorebic
start'.

The previous backoff approach was not working as once the Windows API
denies access to the process for any call, no amount of retries with the
same process id will result in approval.

Therefore, 'komorebic start' now checks if the process has been started,
and if it hasn't (ie. it has errored out because of an access denied
error), it will continue to restart the process until all the komorebi
startup calls to the Windows API succeed.

resolve #176
This commit is contained in:
LGUG2Z
2022-08-11 10:40:33 -07:00
parent 441bfce053
commit d3dc193d29
9 changed files with 312 additions and 94 deletions

23
Cargo.lock generated
View File

@@ -202,9 +202,9 @@ dependencies = [
[[package]]
name = "ctrlc"
version = "3.2.2"
version = "3.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b37feaa84e6861e00a1f5e5aa8da3ee56d605c9992d33e082786754828e20865"
checksum = "1d91974fbbe88ec1df0c24a4f00f99583667a7e2e6272b2b92d294d81e462173"
dependencies = [
"nix",
"winapi 0.3.9",
@@ -479,6 +479,7 @@ dependencies = [
"lazy_static",
"miow 0.4.0",
"nanoid",
"net2",
"os_info",
"parking_lot",
"paste",
@@ -528,6 +529,7 @@ dependencies = [
"serde",
"serde_json",
"serde_yaml",
"sysinfo",
"uds_windows",
"windows",
]
@@ -546,9 +548,9 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55"
[[package]]
name = "libc"
version = "0.2.129"
version = "0.2.131"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "64de3cc433455c14174d42e554d4027ee631c4d046d43e3ecc6efc4636cdc7a7"
checksum = "04c3b4822ccebfa39c02fc03d1534441b22ead323fa0f48bb7ddd8e6ba076a40"
[[package]]
name = "lock_api"
@@ -676,10 +678,11 @@ dependencies = [
[[package]]
name = "nix"
version = "0.24.2"
version = "0.25.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "195cdbc1741b8134346d515b3a56a1c94b0912758009cfd53f99ea0f57b065fc"
checksum = "e322c04a9e3440c327fca7b6c8a63e6890a32fa2ad689db972425f07e0d22abb"
dependencies = [
"autocfg",
"bitflags",
"cfg-if 1.0.0",
"libc",
@@ -759,9 +762,9 @@ dependencies = [
[[package]]
name = "os_str_bytes"
version = "6.2.0"
version = "6.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "648001efe5d5c0102d8cea768e348da85d90af8ba91f0bea908f157951493cd4"
checksum = "9ff7415e9ae3fff1225851df9e0d9e4e5479f947619774677a63572e55e80eff"
[[package]]
name = "owo-colors"
@@ -1079,9 +1082,9 @@ dependencies = [
[[package]]
name = "serde_yaml"
version = "0.9.4"
version = "0.9.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "79b7c9017c64a49806c6e8df8ef99b92446d09c92457f85f91835b01a8064ae0"
checksum = "f50845f68d5c693aac7d72a25415ddd21cb8182c04eafe447b73af55a05f9e1b"
dependencies = [
"indexmap",
"itoa",