Merge pull request #83 from QuantumEntangledAndy/protocol_updates
Protocol Updates
This commit is contained in:
20 files changed
+915
-453
No files matched your search
Generated
+223
-146
@@ -1,5 +1,36 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
[[package]]
|
||||
name = "aes"
|
||||
version = "0.6.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "884391ef1066acaa41e766ba8f596341b96e93ce34f9a43e7d24bf0a0eaf0561"
|
||||
dependencies = [
|
||||
"aes-soft",
|
||||
"aesni",
|
||||
"cipher",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "aes-soft"
|
||||
version = "0.6.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "be14c7498ea50828a38d0e24a765ed2effe92a705885b57d029cd67d45744072"
|
||||
dependencies = [
|
||||
"cipher",
|
||||
"opaque-debug",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "aesni"
|
||||
version = "0.10.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ea2e11f5e94c2f7d386164cc2aa1f97823fed6f259e486940a71c174dd01b0ce"
|
||||
dependencies = [
|
||||
"cipher",
|
||||
"opaque-debug",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "aho-corasick"
|
||||
version = "0.7.15"
|
||||
@@ -20,9 +51,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "anyhow"
|
||||
version = "1.0.35"
|
||||
version = "1.0.40"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2c0df63cb2955042487fad3aefd2c6e3ae7389ac5dc1beb28921de0b69f779d4"
|
||||
checksum = "28b2cd92db5cbd74e8e5028f7e27dd7aa3090e89e4f2a197cc7c8dfb69c7063b"
|
||||
|
||||
[[package]]
|
||||
name = "arrayvec"
|
||||
@@ -60,10 +91,31 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693"
|
||||
|
||||
[[package]]
|
||||
name = "bumpalo"
|
||||
version = "3.4.0"
|
||||
name = "bitvec"
|
||||
version = "0.19.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2e8c087f005730276d1096a652e92a8bacee2e2472bcc9715a74d2bec38b5820"
|
||||
checksum = "8942c8d352ae1838c9dda0b0ca2ab657696ef2232a20147cf1b30ae1a9cb4321"
|
||||
dependencies = [
|
||||
"funty",
|
||||
"radium",
|
||||
"tap",
|
||||
"wyz",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bumpalo"
|
||||
version = "3.6.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "63396b8a4b9de3f4fdfb320ab6080762242f66a8ef174c49d8e19b674db4cdbe"
|
||||
|
||||
[[package]]
|
||||
name = "cfb-mode"
|
||||
version = "0.6.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1d6975e91054798d325f85f50115056d7deccf6817fe7f947c438ee45b119632"
|
||||
dependencies = [
|
||||
"cipher",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cfg-if"
|
||||
@@ -77,6 +129,15 @@ version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
||||
|
||||
[[package]]
|
||||
name = "cipher"
|
||||
version = "0.2.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "12f8e7987cbd042a63249497f41aed09f8e65add917ea6566effbc56578d6801"
|
||||
dependencies = [
|
||||
"generic-array",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clap"
|
||||
version = "2.33.3"
|
||||
@@ -94,15 +155,15 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "const_fn"
|
||||
version = "0.4.3"
|
||||
version = "0.4.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c478836e029dcef17fb47c89023448c64f781a046e0300e257ad8225ae59afab"
|
||||
checksum = "402da840495de3f976eaefc3485b7f5eb5b0bf9761f9a47be27fe975b3b8c2ec"
|
||||
|
||||
[[package]]
|
||||
name = "cookie-factory"
|
||||
version = "0.3.1"
|
||||
version = "0.3.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "41f21b581d2f0cb891554812435667bb9610d74feb1a4c6415bf09c28ff0381d"
|
||||
checksum = "396de984970346b0d9e93d1415082923c679e5ae5c3ee3dcbd104f5610af126b"
|
||||
|
||||
[[package]]
|
||||
name = "crossbeam"
|
||||
@@ -190,9 +251,9 @@ checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457"
|
||||
|
||||
[[package]]
|
||||
name = "env_logger"
|
||||
version = "0.8.2"
|
||||
version = "0.8.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f26ecb66b4bdca6c1409b40fb255eefc2bd4f6d135dab3c3124f80ffa2a9661e"
|
||||
checksum = "17392a012ea30ef05a610aa97dfb49496e71c9f676b27879922ea5bdf60d9d3f"
|
||||
dependencies = [
|
||||
"atty",
|
||||
"humantime",
|
||||
@@ -217,19 +278,25 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "form_urlencoded"
|
||||
version = "1.0.0"
|
||||
version = "1.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ece68d15c92e84fa4f19d3780f1294e5ca82a78a6d515f1efaabcc144688be00"
|
||||
checksum = "5fc25a87fa4fd2094bffb06925852034d90a17f0d1e05197d4956d3555752191"
|
||||
dependencies = [
|
||||
"matches",
|
||||
"percent-encoding",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "futures"
|
||||
version = "0.3.8"
|
||||
name = "funty"
|
||||
version = "1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9b3b0c040a1fe6529d30b3c5944b280c7f0dcb2930d2c3062bca967b602583d0"
|
||||
checksum = "fed34cd105917e91daa4da6b3728c47b068749d6a62c59811f06ed2ac71d9da7"
|
||||
|
||||
[[package]]
|
||||
name = "futures"
|
||||
version = "0.3.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a9d5813545e459ad3ca1bff9915e9ad7f1a47dc6a91b627ce321d5863b7dd253"
|
||||
dependencies = [
|
||||
"futures-channel",
|
||||
"futures-core",
|
||||
@@ -242,9 +309,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "futures-channel"
|
||||
version = "0.3.8"
|
||||
version = "0.3.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4b7109687aa4e177ef6fe84553af6280ef2778bdb7783ba44c9dc3399110fe64"
|
||||
checksum = "ce79c6a52a299137a6013061e0cf0e688fce5d7f1bc60125f520912fdb29ec25"
|
||||
dependencies = [
|
||||
"futures-core",
|
||||
"futures-sink",
|
||||
@@ -252,15 +319,15 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "futures-core"
|
||||
version = "0.3.8"
|
||||
version = "0.3.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "847ce131b72ffb13b6109a221da9ad97a64cbe48feb1028356b836b47b8f1748"
|
||||
checksum = "098cd1c6dda6ca01650f1a37a794245eb73181d0d4d4e955e2f3c37db7af1815"
|
||||
|
||||
[[package]]
|
||||
name = "futures-executor"
|
||||
version = "0.3.8"
|
||||
version = "0.3.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4caa2b2b68b880003057c1dd49f1ed937e38f22fcf6c212188a121f08cf40a65"
|
||||
checksum = "10f6cb7042eda00f0049b1d2080aa4b93442997ee507eb3828e8bd7577f94c9d"
|
||||
dependencies = [
|
||||
"futures-core",
|
||||
"futures-task",
|
||||
@@ -269,15 +336,15 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "futures-io"
|
||||
version = "0.3.8"
|
||||
version = "0.3.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "611834ce18aaa1bd13c4b374f5d653e1027cf99b6b502584ff8c9a64413b30bb"
|
||||
checksum = "365a1a1fb30ea1c03a830fdb2158f5236833ac81fa0ad12fe35b29cddc35cb04"
|
||||
|
||||
[[package]]
|
||||
name = "futures-macro"
|
||||
version = "0.3.8"
|
||||
version = "0.3.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "77408a692f1f97bcc61dc001d752e00643408fbc922e4d634c655df50d595556"
|
||||
checksum = "668c6733a182cd7deb4f1de7ba3bf2120823835b3bcfbeacf7d2c4a773c1bb8b"
|
||||
dependencies = [
|
||||
"proc-macro-hack",
|
||||
"proc-macro2",
|
||||
@@ -287,24 +354,21 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "futures-sink"
|
||||
version = "0.3.8"
|
||||
version = "0.3.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f878195a49cee50e006b02b93cf7e0a95a38ac7b776b4c4d9cc1207cd20fcb3d"
|
||||
checksum = "5c5629433c555de3d82861a7a4e3794a4c40040390907cfbfd7143a92a426c23"
|
||||
|
||||
[[package]]
|
||||
name = "futures-task"
|
||||
version = "0.3.8"
|
||||
version = "0.3.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7c554eb5bf48b2426c4771ab68c6b14468b6e76cc90996f528c3338d761a4d0d"
|
||||
dependencies = [
|
||||
"once_cell",
|
||||
]
|
||||
checksum = "ba7aa51095076f3ba6d9a1f702f74bd05ec65f555d70d2033d55ba8d69f581bc"
|
||||
|
||||
[[package]]
|
||||
name = "futures-util"
|
||||
version = "0.3.8"
|
||||
version = "0.3.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d304cff4a7b99cfb7986f7d43fbe93d175e72e704a8860787cc95e9ffd85cbd2"
|
||||
checksum = "3c144ad54d60f23927f0a6b6d816e4271278b64f005ad65e4e35291d2de9c025"
|
||||
dependencies = [
|
||||
"futures-channel",
|
||||
"futures-core",
|
||||
@@ -313,13 +377,23 @@ dependencies = [
|
||||
"futures-sink",
|
||||
"futures-task",
|
||||
"memchr",
|
||||
"pin-project",
|
||||
"pin-project-lite",
|
||||
"pin-utils",
|
||||
"proc-macro-hack",
|
||||
"proc-macro-nested",
|
||||
"slab",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "generic-array"
|
||||
version = "0.14.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "501466ecc8a30d1d3b7fc9229b122b2ce8ed6e9d9223f1138d4babb253e51817"
|
||||
dependencies = [
|
||||
"typenum",
|
||||
"version_check",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "gio"
|
||||
version = "0.9.1"
|
||||
@@ -412,9 +486,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "gstreamer"
|
||||
version = "0.16.5"
|
||||
version = "0.16.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5d50f822055923f1cbede233aa5dfd4ee957cf328fb3076e330886094e11d6cf"
|
||||
checksum = "9ff5d0f7ff308ae37e6eb47b6ded17785bdea06e438a708cd09e0288c1862f33"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"cfg-if 1.0.0",
|
||||
@@ -602,9 +676,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "gstreamer-sdp"
|
||||
version = "0.16.5"
|
||||
version = "0.16.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "36832b09858102a4def30d2eb0d599043914ef83674609d578feb80a0e6bd3f2"
|
||||
checksum = "db2583808102240bf3e94b4dc5d099ee0ad36557211279c8b90b82c45c2b76e8"
|
||||
dependencies = [
|
||||
"glib",
|
||||
"glib-sys",
|
||||
@@ -641,33 +715,33 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "heck"
|
||||
version = "0.3.1"
|
||||
version = "0.3.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "20564e78d53d2bb135c343b3f47714a56af2061f1c928fdb541dc7b9fdd94205"
|
||||
checksum = "87cbf45460356b7deeb5e3415b5563308c0a9b057c85e12b06ad551f98d0a6ac"
|
||||
dependencies = [
|
||||
"unicode-segmentation",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hermit-abi"
|
||||
version = "0.1.17"
|
||||
version = "0.1.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5aca5565f760fb5b220e499d72710ed156fdb74e631659e99377d9ebfbd13ae8"
|
||||
checksum = "322f4de77956e22ed0e5032c359a0f1273f1f7f0d79bfa3b8ffbc730d7fbcc5c"
|
||||
dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "humantime"
|
||||
version = "2.0.1"
|
||||
version = "2.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3c1ad908cc71012b7bea4d0c53ba96a8cba9962f048fa68d143376143d863b7a"
|
||||
checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4"
|
||||
|
||||
[[package]]
|
||||
name = "idna"
|
||||
version = "0.2.0"
|
||||
version = "0.2.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "02e2673c30ee86b5b96a9cb52ad15718aa1f966f5ab9ad54a8b95d5ca33120a9"
|
||||
checksum = "418a0a6fab821475f634efe3ccc45c013f742efe03d853e8d3355d5cb850ecf8"
|
||||
dependencies = [
|
||||
"matches",
|
||||
"unicode-bidi",
|
||||
@@ -714,9 +788,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "itoa"
|
||||
version = "0.4.6"
|
||||
version = "0.4.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dc6f3ad7b9d11a0c00842ff8de1b60ee58661048eb8049ed33c73594f359d7e6"
|
||||
checksum = "dd25036021b0de88a0aff6b850051563c6516d0bf53f8638938edbb9de732736"
|
||||
|
||||
[[package]]
|
||||
name = "lazy_static"
|
||||
@@ -726,30 +800,30 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
|
||||
|
||||
[[package]]
|
||||
name = "lexical-core"
|
||||
version = "0.7.4"
|
||||
version = "0.7.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "db65c6da02e61f55dae90a0ae427b2a5f6b3e8db09f58d10efab23af92592616"
|
||||
checksum = "21f866863575d0e1d654fbeeabdc927292fdf862873dc3c96c6f753357e13374"
|
||||
dependencies = [
|
||||
"arrayvec",
|
||||
"bitflags",
|
||||
"cfg-if 0.1.10",
|
||||
"cfg-if 1.0.0",
|
||||
"ryu",
|
||||
"static_assertions",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.81"
|
||||
version = "0.2.93"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1482821306169ec4d07f6aca392a4681f66c75c9918aa49641a2595db64053cb"
|
||||
checksum = "9385f66bf6105b241aa65a61cb923ef20efc665cb9f9bb50ac2f0c4b7f378d41"
|
||||
|
||||
[[package]]
|
||||
name = "log"
|
||||
version = "0.4.11"
|
||||
version = "0.4.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4fabed175da42fed1fa0746b0ea71f412aa9d35e76e95e59b192c64b9dc2bf8b"
|
||||
checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710"
|
||||
dependencies = [
|
||||
"cfg-if 0.1.10",
|
||||
"cfg-if 1.0.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -795,6 +869,8 @@ checksum = "0419348c027fa7be448d2ae7ea0e4e04c2334c31dc4e74ab29f00a2a7ca69204"
|
||||
name = "neolink"
|
||||
version = "0.3.0"
|
||||
dependencies = [
|
||||
"aes",
|
||||
"cfb-mode",
|
||||
"cookie-factory",
|
||||
"crossbeam",
|
||||
"env_logger",
|
||||
@@ -826,10 +902,12 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "nom"
|
||||
version = "5.1.2"
|
||||
version = "6.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ffb4262d26ed83a1c0a33a38fe2bb15797329c85770da05e6b828ddb782627af"
|
||||
checksum = "e7413f999671bd4745a7b624bd370a569fb6bc574b23c83a3c5ed2e453f3d5e2"
|
||||
dependencies = [
|
||||
"bitvec",
|
||||
"funty",
|
||||
"lexical-core",
|
||||
"memchr",
|
||||
"version_check",
|
||||
@@ -867,15 +945,21 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "once_cell"
|
||||
version = "1.5.2"
|
||||
version = "1.7.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "13bd41f508810a131401606d54ac32a467c97172d74ba7662562ebba5ad07fa0"
|
||||
checksum = "af8b08b04175473088b46763e51ee54da5f9a164bc162f615b91bc179dbf15a3"
|
||||
|
||||
[[package]]
|
||||
name = "opaque-debug"
|
||||
version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5"
|
||||
|
||||
[[package]]
|
||||
name = "paste"
|
||||
version = "1.0.3"
|
||||
version = "1.0.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7151b083b0664ed58ed669fcdd92f01c3d2fdbf10af4931a301474950b52bfa9"
|
||||
checksum = "acbf547ad0c65e31259204bd90935776d1c693cec2f4ff7abb7a1bbbd40dfe58"
|
||||
|
||||
[[package]]
|
||||
name = "percent-encoding"
|
||||
@@ -884,24 +968,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e"
|
||||
|
||||
[[package]]
|
||||
name = "pin-project"
|
||||
version = "1.0.2"
|
||||
name = "pin-project-lite"
|
||||
version = "0.2.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9ccc2237c2c489783abd8c4c80e5450fc0e98644555b1364da68cc29aa151ca7"
|
||||
dependencies = [
|
||||
"pin-project-internal",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pin-project-internal"
|
||||
version = "1.0.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f8e8d2bf0b23038a4424865103a4df472855692821aab4e4f5c3312d461d9e5f"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
checksum = "dc0e1f259c92177c30a4c9d177246edd0a3568b25756a977d0632cf8fa37e905"
|
||||
|
||||
[[package]]
|
||||
name = "pin-utils"
|
||||
@@ -962,51 +1032,50 @@ checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5"
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro-nested"
|
||||
version = "0.1.6"
|
||||
version = "0.1.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "eba180dafb9038b050a4c280019bbedf9f2467b61e5d892dcad585bb57aadc5a"
|
||||
checksum = "bc881b2c22681370c6a780e47af9840ef841837bc98118431d4e1868bd0c1086"
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.24"
|
||||
version = "1.0.26"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1e0704ee1a7e00d7bb417d0770ea303c1bccbabf0ef1667dae92b5967f5f8a71"
|
||||
checksum = "a152013215dca273577e18d2bf00fa862b89b24169fb78c4c95aeb07992c9cec"
|
||||
dependencies = [
|
||||
"unicode-xid",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "1.0.7"
|
||||
version = "1.0.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "aa563d17ecb180e500da1cfd2b028310ac758de548efdd203e18f283af693f37"
|
||||
checksum = "c3d0b9745dc2debf507c8422de05d7226cc1f0644216dfdfead988f9b1ab32a7"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "redox_syscall"
|
||||
version = "0.1.57"
|
||||
name = "radium"
|
||||
version = "0.5.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce"
|
||||
checksum = "941ba9d78d8e2f7ce474c015eea4d9c6d25b6a3327f9832ee29a4de27f91bbb8"
|
||||
|
||||
[[package]]
|
||||
name = "regex"
|
||||
version = "1.4.2"
|
||||
version = "1.4.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "38cf2c13ed4745de91a5eb834e11c00bcc3709e773173b2ce4c56c9fbde04b9c"
|
||||
checksum = "957056ecddbeba1b26965114e191d2e8589ce74db242b6ea25fc4062427a5c19"
|
||||
dependencies = [
|
||||
"aho-corasick",
|
||||
"memchr",
|
||||
"regex-syntax",
|
||||
"thread_local",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex-syntax"
|
||||
version = "0.6.21"
|
||||
version = "0.6.23"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3b181ba2dcf07aaccad5448e8ead58db5b742cf85dfe035e2227f137a539a189"
|
||||
checksum = "24d5f089152e60f62d28b835fbff2cd2e8dc0baf1ac13343bef92ab7eed84548"
|
||||
|
||||
[[package]]
|
||||
name = "rustc_version"
|
||||
@@ -1052,18 +1121,18 @@ checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3"
|
||||
|
||||
[[package]]
|
||||
name = "serde"
|
||||
version = "1.0.118"
|
||||
version = "1.0.125"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "06c64263859d87aa2eb554587e2d23183398d617427327cf2b3d0ed8c69e4800"
|
||||
checksum = "558dc50e1a5a5fa7112ca2ce4effcb321b0300c0d4ccf0776a9f60cd89031171"
|
||||
dependencies = [
|
||||
"serde_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_derive"
|
||||
version = "1.0.118"
|
||||
version = "1.0.125"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c84d3526699cd55261af4b941e4e725444df67aa4f9e6a3564f18030d12672df"
|
||||
checksum = "b093b7a2bb58203b5da3056c05b4ec1fed827dcfdb37347a8841695263b3d06d"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
@@ -1072,9 +1141,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "serde_json"
|
||||
version = "1.0.60"
|
||||
version = "1.0.64"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1500e84d27fe482ed1dc791a56eddc2f230046a040fa908c08bda1d9fb615779"
|
||||
checksum = "799e97dc9fdae36a5c8b8f2cae9ce2ee9fdce2058c57a93e6099d919fd982f79"
|
||||
dependencies = [
|
||||
"itoa",
|
||||
"ryu",
|
||||
@@ -1095,21 +1164,20 @@ checksum = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8"
|
||||
|
||||
[[package]]
|
||||
name = "socket2"
|
||||
version = "0.3.17"
|
||||
version = "0.3.19"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2c29947abdee2a218277abeca306f25789c938e500ea5a9d4b12a5a504466902"
|
||||
checksum = "122e570113d28d773067fab24266b66753f6ea915758651696b6e35e49f88d6e"
|
||||
dependencies = [
|
||||
"cfg-if 1.0.0",
|
||||
"libc",
|
||||
"redox_syscall",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "standback"
|
||||
version = "0.2.13"
|
||||
version = "0.2.17"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cf906c8b8fc3f6ecd1046e01da1d8ddec83e48c8b08b84dcc02b585a6bedf5a8"
|
||||
checksum = "e113fb6f3de07a243d434a56ec6f186dfd51cb08448239fe7bcae73f87ff28ff"
|
||||
dependencies = [
|
||||
"version_check",
|
||||
]
|
||||
@@ -1219,9 +1287,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "1.0.54"
|
||||
version = "1.0.69"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9a2af957a63d6bd42255c359c93d9bfdb97076bd3b820897ce55ffbfbf107f44"
|
||||
checksum = "48fe99c6bd8b1cc636890bcc071842de909d902c81ac7dab53ba33c421ab8ffb"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
@@ -1255,6 +1323,12 @@ dependencies = [
|
||||
"version-compare",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tap"
|
||||
version = "1.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369"
|
||||
|
||||
[[package]]
|
||||
name = "termcolor"
|
||||
version = "1.1.2"
|
||||
@@ -1275,38 +1349,29 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "thiserror"
|
||||
version = "1.0.22"
|
||||
version = "1.0.24"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0e9ae34b84616eedaaf1e9dd6026dbe00dcafa92aa0c8077cb69df1fcfe5e53e"
|
||||
checksum = "e0f4a65597094d4483ddaed134f409b2cb7c1beccf25201a9f73c719254fa98e"
|
||||
dependencies = [
|
||||
"thiserror-impl",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "thiserror-impl"
|
||||
version = "1.0.22"
|
||||
version = "1.0.24"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9ba20f23e85b10754cd195504aebf6a27e2e6cbe28c17778a0c930724628dd56"
|
||||
checksum = "7765189610d8241a44529806d6fd1f2e0a08734313a35d5b3a556f92b381f3c0"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "thread_local"
|
||||
version = "1.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d40c6d1b69745a6ec6fb1ca717914848da4b44ae29d9b3080cbee91d72a69b14"
|
||||
dependencies = [
|
||||
"lazy_static",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "time"
|
||||
version = "0.2.23"
|
||||
version = "0.2.26"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bcdaeea317915d59b2b4cd3b5efcd156c309108664277793f5351700c02ce98b"
|
||||
checksum = "08a8cbfbf47955132d0202d1662f49b2423ae35862aee471f3ba4b133358f372"
|
||||
dependencies = [
|
||||
"const_fn",
|
||||
"libc",
|
||||
@@ -1342,9 +1407,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "tinyvec"
|
||||
version = "1.1.0"
|
||||
version = "1.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ccf8dbc19eb42fba10e8feaaec282fb50e2c14b2726d6301dbfeed0f73306a6f"
|
||||
checksum = "5b5220f05bb7de7f3f53c7c065e1199b3172696fe2db9f9c4d8ad9b4ee74c342"
|
||||
dependencies = [
|
||||
"tinyvec_macros",
|
||||
]
|
||||
@@ -1357,27 +1422,33 @@ checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c"
|
||||
|
||||
[[package]]
|
||||
name = "toml"
|
||||
version = "0.5.7"
|
||||
version = "0.5.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "75cf45bb0bef80604d001caaec0d09da99611b3c0fd39d3080468875cdb65645"
|
||||
checksum = "a31142970826733df8241ef35dc040ef98c679ab14d7c3e54d827099b3acecaa"
|
||||
dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "unicode-bidi"
|
||||
version = "0.3.4"
|
||||
name = "typenum"
|
||||
version = "1.13.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "49f2bd0c6468a8230e1db229cff8029217cf623c767ea5d60bfbd42729ea54d5"
|
||||
checksum = "879f6906492a7cd215bfa4cf595b600146ccfac0c79bcbd1f3000162af5e8b06"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-bidi"
|
||||
version = "0.3.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "eeb8be209bb1c96b7c177c7420d26e04eccacb0eeae6b980e35fcb74678107e0"
|
||||
dependencies = [
|
||||
"matches",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "unicode-normalization"
|
||||
version = "0.1.16"
|
||||
version = "0.1.17"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a13e63ab62dbe32aeee58d1c5408d35c36c392bba5d9d3142287219721afe606"
|
||||
checksum = "07fbfce1c8a97d547e8b5334978438d9d6ec8c20e38f56d4a4374d181493eaef"
|
||||
dependencies = [
|
||||
"tinyvec",
|
||||
]
|
||||
@@ -1408,9 +1479,9 @@ checksum = "f14ee04d9415b52b3aeab06258a3f07093182b88ba0f9b8d203f211a7a7d41c7"
|
||||
|
||||
[[package]]
|
||||
name = "url"
|
||||
version = "2.2.0"
|
||||
version = "2.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5909f2b0817350449ed73e8bcd81c8c3c8d9a7a5d8acba4b27db277f1868976e"
|
||||
checksum = "9ccd964113622c8e9322cfac19eb1004a07e636c545f325da085d5cdde6f1f8b"
|
||||
dependencies = [
|
||||
"form_urlencoded",
|
||||
"idna",
|
||||
@@ -1462,15 +1533,15 @@ checksum = "d63556a25bae6ea31b52e640d7c41d1ab27faba4ccb600013837a3d0b3994ca1"
|
||||
|
||||
[[package]]
|
||||
name = "version_check"
|
||||
version = "0.9.2"
|
||||
version = "0.9.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b5a972e5669d67ba988ce3dc826706fb0a8b01471c088cb0b6110b805cc36aed"
|
||||
checksum = "5fecdca9a5291cc2b8dcf7dc02453fee791a280f3743cb0905f8822ae463b3fe"
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen"
|
||||
version = "0.2.69"
|
||||
version = "0.2.73"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3cd364751395ca0f68cafb17666eee36b63077fb5ecd972bbcd74c90c4bf736e"
|
||||
checksum = "83240549659d187488f91f33c0f8547cbfef0b2088bc470c116d1d260ef623d9"
|
||||
dependencies = [
|
||||
"cfg-if 1.0.0",
|
||||
"wasm-bindgen-macro",
|
||||
@@ -1478,9 +1549,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-backend"
|
||||
version = "0.2.69"
|
||||
version = "0.2.73"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1114f89ab1f4106e5b55e688b828c0ab0ea593a1ea7c094b141b14cbaaec2d62"
|
||||
checksum = "ae70622411ca953215ca6d06d3ebeb1e915f0f6613e3b495122878d7ebec7dae"
|
||||
dependencies = [
|
||||
"bumpalo",
|
||||
"lazy_static",
|
||||
@@ -1493,9 +1564,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-macro"
|
||||
version = "0.2.69"
|
||||
version = "0.2.73"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7a6ac8995ead1f084a8dea1e65f194d0973800c7f571f6edd70adf06ecf77084"
|
||||
checksum = "3e734d91443f177bfdb41969de821e15c516931c3c3db3d318fa1b68975d0f6f"
|
||||
dependencies = [
|
||||
"quote",
|
||||
"wasm-bindgen-macro-support",
|
||||
@@ -1503,9 +1574,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-macro-support"
|
||||
version = "0.2.69"
|
||||
version = "0.2.73"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b5a48c72f299d80557c7c62e37e7225369ecc0c963964059509fbafe917c7549"
|
||||
checksum = "d53739ff08c8a68b0fdbcd54c372b8ab800b1449ab3c9d706503bc7dd1621b2c"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
@@ -1516,9 +1587,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-shared"
|
||||
version = "0.2.69"
|
||||
version = "0.2.73"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7e7811dd7f9398f14cc76efd356f98f03aa30419dea46aa810d71e819fc97158"
|
||||
checksum = "d9a543ae66aa233d14bb765ed9af4a33e81b8b58d1584cf1b47ff8cd0b9e4489"
|
||||
|
||||
[[package]]
|
||||
name = "winapi"
|
||||
@@ -1551,6 +1622,12 @@ version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
||||
|
||||
[[package]]
|
||||
name = "wyz"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "85e60b0d1b5f99db2556934e21937020776a5d31520bf169e851ac44e6420214"
|
||||
|
||||
[[package]]
|
||||
name = "xml-rs"
|
||||
version = "0.8.3"
|
||||
|
||||
+3
-1
@@ -8,6 +8,8 @@ edition = "2018"
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
aes = "0.6"
|
||||
cfb-mode = "0.6"
|
||||
cookie-factory = "0.3"
|
||||
crossbeam = "0.7"
|
||||
env_logger = "*"
|
||||
@@ -23,7 +25,7 @@ log = { version = "0.4" }
|
||||
indoc = "0.3"
|
||||
itertools = "0.9"
|
||||
md5 = "0.7"
|
||||
nom = "5.1"
|
||||
nom = "6.1.2"
|
||||
regex = "1"
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
socket2 = "0.3"
|
||||
|
||||
@@ -2,14 +2,19 @@
|
||||
|
||||

|
||||
|
||||
Neolink is a small program that acts as a proxy between Reolink IP cameras and normal RTSP clients.
|
||||
Certain cameras, such as the Reolink B800, do not implement ONVIF or RTSP, but instead use a proprietary "Baichuan" protocol only compatible with their apps and NVRs (any camera that uses "port 9000" will likely be using this protocol).
|
||||
|
||||
Neolink allows you to use NVR software such as Shinobi or Blue Iris to receive video from these cameras instead.
|
||||
Neolink is a small program that acts as a proxy between Reolink IP cameras and
|
||||
normal RTSP clients.
|
||||
Certain cameras, such as the Reolink B800, do not implement ONVIF or RTSP, but
|
||||
instead use a proprietary "Baichuan" protocol only compatible with their apps
|
||||
and NVRs (any camera that uses "port 9000" will likely be using this protocol).
|
||||
Neolink allows you to use NVR software such as Shinobi or Blue Iris to receive
|
||||
video from these cameras instead.
|
||||
The Reolink NVR is not required, and the cameras are unmodified.
|
||||
Your NVR software connects to Neolink, which forwards the video stream from the camera.
|
||||
Your NVR software connects to Neolink, which forwards the video stream from the
|
||||
camera.
|
||||
|
||||
The Neolink project is not affiliated with Reolink in any way; everything it does has been reverse engineered.
|
||||
The Neolink project is not affiliated with Reolink in any way; everything it
|
||||
does has been reverse engineered.
|
||||
|
||||
## Supported cameras
|
||||
|
||||
@@ -21,7 +26,8 @@ Currently it has been tested on the following cameras:
|
||||
- E1
|
||||
- Lumus
|
||||
|
||||
Neolink does not support other cameras such as the RLC-420, since they already [provide native RTSP](https://support.reolink.com/hc/en-us/articles/360007010473-How-to-Live-View-Reolink-Cameras-via-VLC-Media-Player).
|
||||
Neolink does not support other cameras such as the RLC-420, since they already
|
||||
[provide native RTSP](https://support.reolink.com/hc/en-us/articles/360007010473-How-to-Live-View-Reolink-Cameras-via-VLC-Media-Player).
|
||||
|
||||
## Installation
|
||||
|
||||
@@ -39,27 +45,36 @@ Builds are provided for the following platforms:
|
||||
|
||||
### Windows/Linux
|
||||
|
||||
1. [Install Gstreamer][gstreamer] from the most recent MSI installer on Windows, or your package manager on Linux.
|
||||
1. [Install Gstreamer][gstreamer] from the most recent MSI installer on Windows,
|
||||
or your package manager on Linux.
|
||||
|
||||
2. If you are using Windows, add the following to your `PATH` environment variable:
|
||||
|
||||
```
|
||||
%GSTREAMER_1_0_ROOT_X86_64%\bin
|
||||
```
|
||||
```
|
||||
%GSTREAMER_1_0_ROOT_X86_64%\bin
|
||||
```
|
||||
|
||||
Note that if you use Chocolatey to install Gstreamer, it does this automatically.
|
||||
**Note:** If you use Chocolatey to install Gstreamer, it does this
|
||||
automatically.
|
||||
|
||||
3. Download and extract a [prebuilt binary from continuous integration][ci-download]
|
||||
(click on the topmost commit for the most recent build).
|
||||
|
||||
3. Download and unpack Neolink from the links above.
|
||||
1. Note: you can also click on [this link][ci-download] to see all historical builds.
|
||||
You will need to be logged in to GitHub to download directly from the builds page.
|
||||
4. Write a configuration file for your cameras. See the section below.
|
||||
|
||||
5. Launch Neolink from a shell, passing your configuration file:
|
||||
|
||||
```
|
||||
neolink --config my_config.toml
|
||||
```
|
||||
```bash
|
||||
neolink --config my_config.toml
|
||||
```
|
||||
|
||||
6. Connect your NVR software to Neolink's RTSP server.
|
||||
The default URL is `rtsp://127.0.0.1:8554/your_camera_name` if you're running it on the same computer.
|
||||
|
||||
The default URL is `rtsp://127.0.0.1:8554/your_camera_name` if you're running
|
||||
it on the same computer.
|
||||
If you run it on a different server, you may need to open firewall ports.
|
||||
See the "Viewing" section below for more troubleshooting.
|
||||
|
||||
@@ -78,11 +93,12 @@ neolink --config my_config.toml
|
||||
A Docker image is also available containing Neolink and all its dependencies.
|
||||
The image is `thirtythreeforty/neolink`.
|
||||
Port 8554 is exposed, which is the default listen port.
|
||||
You must mount a configuration file (see below) into the container at `/etc/neolink.toml`.
|
||||
You must mount a configuration file (see below) into the container at
|
||||
`/etc/neolink.toml`.
|
||||
|
||||
Here is a sample launch commmand:
|
||||
|
||||
```
|
||||
```bash
|
||||
docker run \
|
||||
-p 8554:8554 \
|
||||
--restart=on-failure \
|
||||
@@ -90,87 +106,128 @@ docker run \
|
||||
thirtythreeforty/neolink
|
||||
```
|
||||
|
||||
The Docker image is "best effort" and intended for advanced users; questions about running Docker are outside the scope of Neolink.
|
||||
The Docker image is "best effort" and intended for advanced users; questions
|
||||
about running Docker are outside the scope of Neolink.
|
||||
|
||||
## Configuration
|
||||
|
||||
**Note**: for a more comprehensive setup tutorial, refer to the [Blue Iris setup walkthrough in `docs/`][blue-iris-setup] (which is probably also helpful even with other NVR software).
|
||||
**Note**: for a more comprehensive setup tutorial, refer to the
|
||||
[Blue Iris setup walkthrough in `docs/`][blue-iris-setup] (which is probably
|
||||
also helpful even with other NVR software).
|
||||
|
||||
[blue-iris-setup]: docs/Setting%20Up%20Neolink%20For%20Use%20With%20Blue%20Iris.md
|
||||
|
||||
Copy and modify the `sample_config.toml` to specify the address, username, and password for each camera (if there is no password, you can omit that line).
|
||||
Each `[[cameras]]` block creates a new camera; the `name` determines the RTSP path you should connect your client to.
|
||||
Currently Neolink cannot auto-detect cameras like the official clients do; you must specify their IP addresses directly.
|
||||
Copy and modify the `sample_config.toml` to specify the address, username, and
|
||||
password for each camera (if there is no password, you can omit that line).
|
||||
|
||||
By default the H265 video format is used. Some cameras, for example E1, provide H264 streams. To use these you must specify `format = "h264"` in the `[[cameras]]` config.
|
||||
Soon this will be auto-detected, and you will not have to know or care about the format.
|
||||
Each `[[cameras]]` block creates a new camera; the `name` determines the RTSP
|
||||
path you should connect your client to.
|
||||
Currently Neolink cannot auto-detect cameras like the official clients do; you
|
||||
must specify their IP addresses directly.
|
||||
|
||||
By default, the HD stream is available at the RTSP path `/name` or `/name/mainStream`, and the SD stream is available at `/name/subStream`.
|
||||
You can use only the HD stream by adding `stream = "mainStream"` to the `[[cameras]]` config, or only the SD stream with `stream = "subStream"`.
|
||||
By default the H265 video format is used. Some cameras, for example E1, provide
|
||||
H264 streams. To use these you must specify `format = "h264"` in the
|
||||
`[[cameras]]` config. Soon this will be auto-detected, and you will not have to know or care about
|
||||
the format.
|
||||
|
||||
**Note**: The B400/D400 models only support a single stream at a time, so you must add this line to sections for those cameras.
|
||||
By default, the HD stream is available at the RTSP path `/name` or
|
||||
`/name/mainStream`, and the SD stream is available at `/name/subStream`.
|
||||
You can use only the HD stream by adding `stream = "mainStream"` to the
|
||||
`[[cameras]]` config, or only the SD stream with `stream = "subStream"`.
|
||||
|
||||
**Note**: The B400/D400 models only support a single stream at a time, so you
|
||||
must add this line to sections for those cameras.
|
||||
|
||||
By default Neolink serves on all IP addresses on port 8554.
|
||||
You can modify this by changing the `bind` and the `bind_port` parameter.
|
||||
You only need one `bind`/`bind_port` setting at the top of the config file.
|
||||
|
||||
You can enable `rtsps` (TLS) by adding a `certificate = "/path/to/pem"` to the top section of the config file. This PEM should contain by the certificate and the key used for the server. If TLS is enabled all connections must use `rtsps`. You can also control client side TLS with the config option `tls_client_auth = "none|request|require"`; in this case the client should present a certificate signed by the server's CA.
|
||||
You can enable `rtsps` (TLS) by adding a `certificate = "/path/to/pem"` to the
|
||||
top section of the config file. This PEM should contain by the certificate
|
||||
and the key used for the server. If TLS is enabled all connections must use
|
||||
`rtsps`. You can also control client side TLS with the config option
|
||||
`tls_client_auth = "none|request|require"`; in this case the client should
|
||||
present a certificate signed by the server's CA.
|
||||
|
||||
TLS is disabled by default.
|
||||
|
||||
You can password-protect the Neolink server by adding `[[users]]`` sections to the configuration file:
|
||||
You can password-protect the Neolink server by adding `[[users]]` sections to
|
||||
the configuration file:
|
||||
|
||||
```
|
||||
[[users]]
|
||||
name: someone
|
||||
pass: somepass
|
||||
```
|
||||
you also need to add the allowed users into each camera by adding the following to `[[cameras]]`.
|
||||
|
||||
you also need to add the allowed users into each camera by adding the following
|
||||
to `[[cameras]]`.
|
||||
|
||||
```
|
||||
permitted_users = ["someone", "someoneelse"]
|
||||
```
|
||||
|
||||
Anywhere a username is accepted it can take any username or one of the following special values.
|
||||
Anywhere a username is accepted it can take any username or one of the
|
||||
following special values.
|
||||
|
||||
- `anyone` means any user with a valid user/pass
|
||||
- `anonymous` means no user/pass required
|
||||
|
||||
The default `permitted_users` list is:
|
||||
- `[ "anonymous"]` if no `[[users]]` were given in the config meaning no authentication required to connect.
|
||||
- `[ "anyone" ]` if `[[users]]` were provided meaning any authourised users can connect.
|
||||
|
||||
You can change the Neolink log level by setting the `RUST_LOG` environment variable (not in the configuration file) to one of `error`, `warn`, `info`, `debug`, or `trace`:
|
||||
- `[ "anonymous"]` if no `[[users]]` were given in the config meaning no
|
||||
authentication required to connect.
|
||||
|
||||
```
|
||||
- `[ "anyone" ]` if `[[users]]` were provided meaning any authourised users can
|
||||
connect.
|
||||
|
||||
You can change the Neolink log level by setting the `RUST_LOG` environment
|
||||
variable (not in the configuration file) to one of `error`, `warn`, `info`,
|
||||
`debug`, or `trace`:
|
||||
|
||||
```sh
|
||||
set RUST_LOG=debug
|
||||
```
|
||||
|
||||
On Linux:
|
||||
|
||||
```
|
||||
```bash
|
||||
export RUST_LOG=debug
|
||||
```
|
||||
|
||||
## Viewing
|
||||
|
||||
Connect your RTSP client to the stream with the name you provided in the configuration file.
|
||||
Again, the default URL is `rtsp://127.0.0.1:8554/your_camera_name` if you're running it on the same computer as the client.
|
||||
Connect your RTSP client to the stream with the name you provided in the
|
||||
configuration file.
|
||||
|
||||
Again, the default URL is `rtsp://127.0.0.1:8554/your_camera_name` if you're
|
||||
running it on the same computer as the client.
|
||||
The smaller SD video is `rtsp://127.0.0.1:8554/your_camera_name/subStream`.
|
||||
|
||||
4K cameras send large video "key frames" once every few seconds and the client must have a receive buffer large enough to store the entire frame.
|
||||
If your client's buffer size is configurable (like Blue Iris), ensure it's set to 20MB, which should ensure plenty of headroom.
|
||||
4K cameras send large video "key frames" once every few seconds and the client
|
||||
must have a receive buffer large enough to store the entire frame.
|
||||
If your client's buffer size is configurable (like Blue Iris), ensure it's set
|
||||
to 20MB, which should ensure plenty of headroom.
|
||||
|
||||
## Stability
|
||||
|
||||
Neolink has had minimal testing, but it seems to be very reliable in multiple users' testing.
|
||||
Neolink has had minimal testing, but it seems to be very reliable in multiple
|
||||
users' testing.
|
||||
|
||||
The formats of all configuration files and APIs is subject to change as required while it is pre-1.0.
|
||||
The formats of all configuration files and APIs is subject to change as required
|
||||
while it is pre-1.0.
|
||||
|
||||
## Development
|
||||
|
||||
Neolink is written in Rust, and binds to Gstreamer to provide RTSP server functionality.
|
||||
To compile, ensure you have the Rust compiler, Gstreamer, and gst-rtsp-server installed.
|
||||
Neolink is written in Rust, and binds to Gstreamer to provide RTSP server
|
||||
functionality.
|
||||
|
||||
To compile, ensure you have the Rust compiler, Gstreamer, and gst-rtsp-server
|
||||
installed.
|
||||
|
||||
Then simply run:
|
||||
|
||||
```
|
||||
```bash
|
||||
cargo build
|
||||
```
|
||||
|
||||
@@ -178,22 +235,36 @@ from this top directory.
|
||||
|
||||
### Baichuan Protocol
|
||||
|
||||
The "port 9000" protocol used by Reolink and some Swann cameras is internally referred to as the Baichuan protocol; this is the company based in China that is known internationally as Reolink.
|
||||
The "port 9000" protocol used by Reolink and some Swann cameras is internally
|
||||
referred to as the Baichuan protocol; this is the company based in China that
|
||||
is known internationally as Reolink.
|
||||
|
||||
This protocol is a slightly convoluted header-data format, and appears to have
|
||||
been upgraded several times.
|
||||
|
||||
The modern variant uses obfuscated XML commands and sends ordinary H.265 or
|
||||
H.264 video streams encapsulated in a custom header.
|
||||
|
||||
This protocol is a slightly convoluted header-data format, and appears to have been upgraded several times.
|
||||
The modern variant uses obfuscated XML commands and sends ordinary H.265 or H.264 video streams encapsulated in a custom header.
|
||||
More details about the on-the-wire protocol will come later.
|
||||
|
||||
### Baichuan dissector
|
||||
|
||||
A Wireshark dissector is available for the BC wire protocol in the `dissector` directory.
|
||||
It dissects the BC header and also allows viewing the deobfuscated XML in command messages.
|
||||
To use it, copy or symlink it into your Wireshark plugin directory; typically this is `~/.local/lib/wireshark/plugins/` under Linux.
|
||||
A Wireshark dissector is available for the BC wire protocol in the `dissector`
|
||||
directory.
|
||||
|
||||
Currently the dissector does not attempt to decode the Baichuan "extension" messages except `binaryData`.
|
||||
It dissects the BC header and also allows viewing the deobfuscated XML in
|
||||
command messages.
|
||||
To use it, copy or symlink it into your Wireshark plugin directory; typically
|
||||
this is `~/.local/lib/wireshark/plugins/` under Linux.
|
||||
|
||||
Currently the dissector does not attempt to decode the Baichuan "extension"
|
||||
messages except `binaryData`.
|
||||
This will change in the future as reverse engineering needs require.
|
||||
|
||||
## License
|
||||
|
||||
Neolink is free software, released under the GNU Affero General Public License v3.
|
||||
This means that if you incorporate it into a piece of software available over the network, you must offer that software's source code to your users.
|
||||
Neolink is free software, released under the GNU Affero General Public License
|
||||
v3.
|
||||
|
||||
This means that if you incorporate it into a piece of software available over
|
||||
the network, you must offer that software's source code to your users.
|
||||
@@ -1 +0,0 @@
|
||||
enum-variant-size-threshold = 700
|
||||
@@ -15,7 +15,7 @@ unknown = ProtoField.int8("baichuan.unknown", "unknown", base.DEC)
|
||||
msg_handle = ProtoField.int8("baichuan.message_handle", "messageHandle", base.DEC)
|
||||
status_code = ProtoField.int16("baichuan.status_code", "status_code", base.DEC)
|
||||
message_class = ProtoField.int32("baichuan.msg_class", "messageClass", base.DEC)
|
||||
f_bin_offset = ProtoField.int32("baichuan.bin_offset", "binOffset", base.DEC)
|
||||
f_payload_offset = ProtoField.int32("baichuan.payload_offset", "binOffset", base.DEC)
|
||||
username = ProtoField.string("baichuan.username", "username", base.ASCII)
|
||||
password = ProtoField.string("baichuan.password", "password", base.ASCII)
|
||||
|
||||
@@ -31,7 +31,7 @@ bc_protocol.fields = {
|
||||
encrypt_xml,
|
||||
status_code,
|
||||
message_class,
|
||||
f_bin_offset,
|
||||
f_payload_offset,
|
||||
username,
|
||||
password,
|
||||
}
|
||||
@@ -187,7 +187,7 @@ function get_header(buffer)
|
||||
local msg_type = buffer(4, 4):le_uint()
|
||||
if header_len == 24 then
|
||||
bin_offset = buffer(20, 4):le_uint() -- if NHD-805/806 legacy protocol 30 30 30 30 aka "0000"
|
||||
status_code = buffer(16, 2):le_uint()
|
||||
status_code = buffer(16, 2):le_uint()
|
||||
else
|
||||
encrypt_xml = buffer(16, 1):le_uint()
|
||||
end
|
||||
@@ -234,13 +234,13 @@ function process_header(buffer, headers_tree)
|
||||
header:add_le(channel_id, buffer(12, 1))
|
||||
header:add_le(stream_id, buffer(13, 1))
|
||||
:append_text(stream_text)
|
||||
header:add_le(unknown, buffer(14, 1))
|
||||
header:add_le(unknown, buffer(14, 1))
|
||||
header:add_le(msg_handle, buffer(15, 1))
|
||||
|
||||
header:add_le(message_class, buffer(18, 2)):append_text(" (" .. header_data.class .. ")")
|
||||
|
||||
|
||||
if header_data.header_len == 24 then
|
||||
header:add_le(status_code, buffer(16, 2))
|
||||
header:add_le(status_code, buffer(16, 2))
|
||||
header:add_le(f_bin_offset, buffer(20, 4))
|
||||
else
|
||||
header:add_le(encrypt_xml, buffer(16, 1))
|
||||
|
||||
@@ -1111,6 +1111,72 @@ a PR to improve it.
|
||||
cameras only have weak encryption that is easily broken since the
|
||||
decryption key is fixed and well-known.
|
||||
|
||||
- 67: `<ConfigFileInfo> (FW Upgrade)`
|
||||
|
||||
- Client
|
||||
|
||||
- Header
|
||||
|
||||
| Magic | Message ID | Message Length | Encryption Offset | Status Code | Message Class | Binary Offset |
|
||||
|--------------|--------------|----------------|-------------------|-------------------|---------------|---------------|
|
||||
| 0a bc de f0 | 00 00 00 43 | 00 00 01 00 | 00 00 00 00 | 00 00 | 64 14 | 00 00 00 00 |
|
||||
|
||||
- Body
|
||||
|
||||
```xml
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<body>
|
||||
<ConfigFileInfo version="1.1">
|
||||
<fileName>FIRMWAREFILE.pak</fileName>
|
||||
<fileSize>SIZE_IN_BYTES</fileSize>
|
||||
<updateParameter>0</updateParameter>
|
||||
</ConfigFileInfo>
|
||||
</body>
|
||||
```
|
||||
|
||||
- **Notes:** updateParameter refers to updating the settings. If 1 it will restore factory settings. If 0 it will keep current.
|
||||
|
||||
- Camera
|
||||
|
||||
- Header
|
||||
|
||||
| Magic | Message ID | Message Length | Encryption Offset | Status Code | Message Class | Binary Offset |
|
||||
|--------------|--------------|----------------|-------------------|-------------------|---------------|---------------|
|
||||
| 0a bc de f0 | 00 00 00 43 | 00 00 00 00 | 00 00 00 00 | c8 00 | 00 00 | 00 00 00 00 |
|
||||
|
||||
- Client
|
||||
|
||||
- Header
|
||||
|
||||
| Magic | Message ID | Message Length | Encryption Offset | Status Code | Message Class | Binary Offset |
|
||||
|--------------|--------------|----------------|-------------------|-------------------|---------------|---------------|
|
||||
| 0a bc de f0 | 00 00 00 43 | 00 00 94 58 | 00 00 00 00 | 00 00 | 64 14 | 00 00 00 6a |
|
||||
|
||||
- Body
|
||||
|
||||
```xml
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<Extension version="1.1">
|
||||
<binaryData>1</binaryData>
|
||||
</Extension>
|
||||
```
|
||||
|
||||
- Binary
|
||||
|
||||
This contains binary data of the file but stops once the message size reaches
|
||||
38000 bytes and continues in another packet. There does not appear to
|
||||
be a checksum or hash and this part contains only the raw bytes of the file.
|
||||
|
||||
- Camera
|
||||
|
||||
- Header
|
||||
|
||||
| Magic | Message ID | Message Length | Encryption Offset | Status Code | Message Class | Binary Offset |
|
||||
|--------------|--------------|----------------|-------------------|-------------------|---------------|---------------|
|
||||
| 0a bc de f0 | 00 00 00 43 | 00 00 00 00 | 00 00 00 00 | c8 00 | 00 00 | 00 00 00 00 |
|
||||
|
||||
- **Notes:** Last two messages repeat until all data is sent
|
||||
|
||||
- 76: `<Ip>`
|
||||
|
||||
- Client
|
||||
|
||||
+131
-97
@@ -1,5 +1,5 @@
|
||||
use super::model::*;
|
||||
use super::xml::{AllTopXmls, Extension};
|
||||
use super::xml::{BcPayloads, BcXml};
|
||||
use super::xml_crypto;
|
||||
use err_derive::Error;
|
||||
use log::*;
|
||||
@@ -15,10 +15,10 @@ pub enum Error {
|
||||
IoError(#[error(source)] std::io::Error),
|
||||
}
|
||||
|
||||
type NomErrorTuple<'a> = (&'a [u8], nom::error::ErrorKind);
|
||||
type NomErrorType<'a> = nom::error::Error<&'a [u8]>;
|
||||
|
||||
impl<'a> From<nom::Err<NomErrorTuple<'a>>> for Error {
|
||||
fn from(k: nom::Err<NomErrorTuple<'a>>) -> Self {
|
||||
impl<'a> From<nom::Err<NomErrorType<'a>>> for Error {
|
||||
fn from(k: nom::Err<NomErrorType<'a>>) -> Self {
|
||||
let reason = match k {
|
||||
nom::Err::Error(_) => "Nom Error",
|
||||
nom::Err::Failure(_) => "Nom Failure",
|
||||
@@ -38,7 +38,7 @@ impl Bc {
|
||||
fn read_from_reader<P, O, E, R>(mut parser: P, mut rdr: R) -> Result<O, E>
|
||||
where
|
||||
R: Read,
|
||||
E: for<'a> From<nom::Err<NomErrorTuple<'a>>> + From<std::io::Error>,
|
||||
E: for<'a> From<nom::Err<NomErrorType<'a>>> + From<std::io::Error>,
|
||||
P: FnMut(&[u8]) -> nom::IResult<&[u8], O>,
|
||||
{
|
||||
let mut input: Vec<u8> = Vec::new();
|
||||
@@ -47,14 +47,17 @@ where
|
||||
Ok((_, parsed)) => return Ok(parsed),
|
||||
Err(nom::Err::Incomplete(needed)) => {
|
||||
match needed {
|
||||
nom::Needed::Unknown => 1, // read one byte
|
||||
nom::Needed::Unknown => std::num::NonZeroUsize::new(1).unwrap(), // read one byte
|
||||
nom::Needed::Size(len) => len,
|
||||
}
|
||||
}
|
||||
Err(e) => return Err(e.into()),
|
||||
};
|
||||
|
||||
if 0 == (&mut rdr).take(to_read as u64).read_to_end(&mut input)? {
|
||||
if 0 == (&mut rdr)
|
||||
.take(to_read.get() as u64)
|
||||
.read_to_end(&mut input)?
|
||||
{
|
||||
return Err(std::io::Error::new(
|
||||
std::io::ErrorKind::UnexpectedEof,
|
||||
"Read returned 0 bytes",
|
||||
@@ -93,13 +96,13 @@ fn bc_body<'a, 'b, 'c>(
|
||||
}
|
||||
}
|
||||
|
||||
fn hex32<'a>() -> impl Fn(&'a [u8]) -> IResult<&'a [u8], String> {
|
||||
fn hex32<'a>() -> impl FnMut(&'a [u8]) -> IResult<&'a [u8], String> {
|
||||
map_res(take(32usize), |slice: &'a [u8]| {
|
||||
String::from_utf8(slice.to_vec())
|
||||
})
|
||||
}
|
||||
|
||||
fn bc_legacy_login_msg<'a>(buf: &'a [u8]) -> IResult<&'a [u8], LegacyMsg> {
|
||||
fn bc_legacy_login_msg(buf: &'_ [u8]) -> IResult<&'_ [u8], LegacyMsg> {
|
||||
let (buf, username) = hex32()(buf)?;
|
||||
let (buf, password) = hex32()(buf)?;
|
||||
|
||||
@@ -116,99 +119,102 @@ fn bc_modern_msg<'a, 'b>(
|
||||
Err,
|
||||
};
|
||||
|
||||
let mut in_bin_mode = context.in_bin_mode.contains(&header.msg_id);
|
||||
|
||||
// We'd like to know where the XML stops, but we haven't parsed the XML yet to see if the
|
||||
// binaryData offset in the header is valid
|
||||
let end_of_xml = if in_bin_mode {
|
||||
0
|
||||
} else {
|
||||
match header.bin_offset {
|
||||
Some(off) if off > 0 => off,
|
||||
_ => header.body_len,
|
||||
}
|
||||
let ext_len = match header.payload_offset {
|
||||
Some(off) => off,
|
||||
_ => 0, // If missing payload_offset treat all as payload
|
||||
};
|
||||
|
||||
let (mut buf, body_buf) = take(end_of_xml)(buf)?;
|
||||
if header.msg_id == 1 && (header.response_code >> 8) == 0xdd {
|
||||
// Login reply has the encryption info
|
||||
// Set that the encryption type now
|
||||
let encryption_protocol_byte = (header.response_code & 0xff) as usize;
|
||||
match encryption_protocol_byte {
|
||||
0x00 => context.set_encrypted(EncryptionProtocol::Unencrypted),
|
||||
0x01 => context.set_encrypted(EncryptionProtocol::BCEncrypt),
|
||||
0x02 => context.set_encrypted(EncryptionProtocol::Aes(None)),
|
||||
_ => return Err(Err::Error(make_error(buf, ErrorKind::MapRes))),
|
||||
}
|
||||
}
|
||||
|
||||
let (buf, ext_buf) = take(ext_len)(buf)?;
|
||||
let payload_len = header.body_len - ext_len;
|
||||
let (buf, payload_buf) = take(payload_len)(buf)?;
|
||||
|
||||
let decrypted;
|
||||
let processed_body_buf = if !header.is_encrypted() {
|
||||
buf
|
||||
} else {
|
||||
decrypted = xml_crypto::crypt(header.enc_offset, body_buf);
|
||||
&decrypted
|
||||
let processed_ext_buf = match context.get_encrypted() {
|
||||
EncryptionProtocol::Unencrypted => ext_buf,
|
||||
encryption_protocol => {
|
||||
decrypted =
|
||||
xml_crypto::decrypt(header.channel_id as u32, ext_buf, &encryption_protocol);
|
||||
&decrypted
|
||||
}
|
||||
};
|
||||
|
||||
// Now we'll take the buffer that Nom gave a ref to and parse it.
|
||||
let mut xml = None;
|
||||
let mut binary = None;
|
||||
if end_of_xml > 0 {
|
||||
let extension;
|
||||
if ext_len > 0 {
|
||||
// Apply the XML parse function, but throw away the reference to decrypted in the Ok and
|
||||
// Err case. This error-error-error thing is the same idiom Nom uses internally.
|
||||
let parsed = AllTopXmls::try_parse(processed_body_buf)
|
||||
let parsed = Extension::try_parse(processed_ext_buf)
|
||||
.map_err(|_| Err::Error(make_error(buf, ErrorKind::MapRes)))?;
|
||||
|
||||
// If this is the first message containing binary, the Extension message puts the message
|
||||
// ID into binary mode, then the first binary is sent after the XML. All remaining
|
||||
// messages for that ID are pure binary.
|
||||
match parsed {
|
||||
AllTopXmls::BcXml(x) => {
|
||||
xml = Some(x);
|
||||
}
|
||||
AllTopXmls::Extension(Extension { binary_data: _ }) => {
|
||||
in_bin_mode = true;
|
||||
}
|
||||
if let Extension {
|
||||
binary_data: Some(1),
|
||||
..
|
||||
} = &parsed
|
||||
{
|
||||
context.in_bin_mode.insert(header.msg_num);
|
||||
}
|
||||
extension = Some(parsed);
|
||||
} else {
|
||||
extension = None;
|
||||
}
|
||||
|
||||
// If we are in binary mode, extract it
|
||||
if in_bin_mode {
|
||||
if let Some(bin_offset) = header.bin_offset {
|
||||
// Extract remainder of message as binary, if it exists
|
||||
let (buf_after, payload) =
|
||||
map(take(header.body_len - bin_offset), |x: &[u8]| x.to_vec())(buf)?;
|
||||
|
||||
// Since the parser operates in streaming mode, must wait until after we successfully
|
||||
// receive enough bytes before modifying the context (otherwise we'll alter the
|
||||
// behavior of future passes of this function even if we didn't yet consume the
|
||||
// message).
|
||||
context.in_bin_mode.insert(header.msg_id);
|
||||
|
||||
binary = Some(payload);
|
||||
buf = buf_after;
|
||||
// Now to handle the payload block
|
||||
// This block can either be xml or binary depending on what the message expects.
|
||||
// For our purposes we use try_parse and if all xml based parsers fail we treat
|
||||
// As binary
|
||||
let payload;
|
||||
if payload_len > 0 {
|
||||
// Extract remainder of message as binary, if it exists
|
||||
let encryption_protocol = context.get_encrypted();
|
||||
let processed_payload_buf =
|
||||
xml_crypto::decrypt(header.channel_id as u32, payload_buf, &encryption_protocol);
|
||||
if context.in_bin_mode.contains(&(header.msg_num)) {
|
||||
payload = Some(BcPayloads::Binary(payload_buf.to_vec()));
|
||||
} else {
|
||||
// Seriously, Nom, what even is this
|
||||
error!("Expected header to contain a binary offset, but there was none");
|
||||
return Err(Err::Error(make_error(buf, ErrorKind::Verify)));
|
||||
let xml = BcXml::try_parse(processed_payload_buf.as_slice())
|
||||
.map_err(|_| Err::Error(make_error(buf, ErrorKind::MapRes)))?;
|
||||
payload = Some(BcPayloads::BcXml(xml));
|
||||
}
|
||||
} else {
|
||||
payload = None;
|
||||
}
|
||||
|
||||
Ok((buf, ModernMsg { xml, binary }))
|
||||
Ok((buf, ModernMsg { extension, payload }))
|
||||
}
|
||||
|
||||
fn bc_header(buf: &[u8]) -> IResult<&[u8], BcHeader> {
|
||||
let (buf, _magic) = verify(le_u32, |x| *x == MAGIC_HEADER)(buf)?;
|
||||
let (buf, msg_id) = le_u32(buf)?;
|
||||
let (buf, body_len) = le_u32(buf)?;
|
||||
let (buf, enc_offset) = le_u32(buf)?;
|
||||
let (buf, (response_code, _ignored, class)) = tuple((le_u8, le_u8, le_u16))(buf)?;
|
||||
let (buf, channel_id) = le_u8(buf)?;
|
||||
let (buf, stream_type) = le_u8(buf)?;
|
||||
let (buf, msg_num) = le_u16(buf)?;
|
||||
let (buf, (response_code, class)) = tuple((le_u16, le_u16))(buf)?;
|
||||
|
||||
// All modern messages are encrypted. In addition, it seems that the camera firmware checks
|
||||
// this field to see if some other messages should be encrypted. This is still somewhat fuzzy.
|
||||
// A copy of the source code for the camera would be very useful.
|
||||
let encrypted = response_code != 0;
|
||||
|
||||
let (buf, bin_offset) = cond(has_bin_offset(class), le_u32)(buf)?;
|
||||
let (buf, payload_offset) = cond(has_payload_offset(class), le_u32)(buf)?;
|
||||
|
||||
Ok((
|
||||
buf,
|
||||
BcHeader {
|
||||
msg_id,
|
||||
body_len,
|
||||
enc_offset,
|
||||
encrypted,
|
||||
channel_id,
|
||||
stream_type,
|
||||
msg_num,
|
||||
response_code,
|
||||
class,
|
||||
bin_offset,
|
||||
payload_offset,
|
||||
},
|
||||
))
|
||||
}
|
||||
@@ -217,20 +223,28 @@ fn bc_header(buf: &[u8]) -> IResult<&[u8], BcHeader> {
|
||||
fn test_bc_modern_login() {
|
||||
let sample = include_bytes!("samples/model_sample_modern_login.bin");
|
||||
|
||||
let mut context = BcContext::new();
|
||||
let encryption_protocol =
|
||||
std::sync::Arc::new(std::sync::Mutex::new(EncryptionProtocol::BCEncrypt));
|
||||
let mut context = BcContext::new(encryption_protocol);
|
||||
|
||||
let (buf, header) = bc_header(&sample[..]).unwrap();
|
||||
let (_, body) = bc_body(&mut context, &header, buf).unwrap();
|
||||
assert_eq!(header.msg_id, 1);
|
||||
assert_eq!(header.body_len, 145);
|
||||
assert_eq!(header.enc_offset, 0x1000000);
|
||||
assert_eq!(header.encrypted, true);
|
||||
assert_eq!(header.channel_id, 0);
|
||||
assert_eq!(header.stream_type, 0);
|
||||
assert_eq!(header.payload_offset, None);
|
||||
assert_eq!(header.response_code, 0xdd01);
|
||||
assert_eq!(header.class, 0x6614);
|
||||
match body {
|
||||
BcBody::ModernMsg(ModernMsg {
|
||||
xml: Some(ref xml),
|
||||
binary: None,
|
||||
}) => assert_eq!(xml.encryption.as_ref().unwrap().nonce, "9E6D1FCB9E69846D"),
|
||||
payload:
|
||||
Some(BcPayloads::BcXml(BcXml {
|
||||
encryption: Some(encryption),
|
||||
..
|
||||
})),
|
||||
..
|
||||
}) => assert_eq!(encryption.nonce, "9E6D1FCB9E69846D"),
|
||||
_ => assert!(false),
|
||||
}
|
||||
}
|
||||
@@ -239,14 +253,18 @@ fn test_bc_modern_login() {
|
||||
fn test_bc_legacy_login() {
|
||||
let sample = include_bytes!("samples/model_sample_legacy_login.bin");
|
||||
|
||||
let mut context = BcContext::new();
|
||||
let encryption_protocol =
|
||||
std::sync::Arc::new(std::sync::Mutex::new(EncryptionProtocol::BCEncrypt));
|
||||
let mut context = BcContext::new(encryption_protocol);
|
||||
|
||||
let (buf, header) = bc_header(&sample[..]).unwrap();
|
||||
let (_, body) = bc_body(&mut context, &header, buf).unwrap();
|
||||
assert_eq!(header.msg_id, 1);
|
||||
assert_eq!(header.body_len, 1836);
|
||||
assert_eq!(header.enc_offset, 0x1000000);
|
||||
assert_eq!(header.encrypted, true);
|
||||
assert_eq!(header.channel_id, 0);
|
||||
assert_eq!(header.stream_type, 0);
|
||||
assert_eq!(header.payload_offset, None);
|
||||
assert_eq!(header.response_code, 0xdc01);
|
||||
assert_eq!(header.class, 0x6514);
|
||||
match body {
|
||||
BcBody::LegacyMsg(LegacyMsg::LoginMsg { username, password }) => {
|
||||
@@ -261,19 +279,23 @@ fn test_bc_legacy_login() {
|
||||
fn test_bc_modern_login_failed() {
|
||||
let sample = include_bytes!("samples/modern_login_failed.bin");
|
||||
|
||||
let mut context = BcContext::new();
|
||||
let encryption_protocol =
|
||||
std::sync::Arc::new(std::sync::Mutex::new(EncryptionProtocol::BCEncrypt));
|
||||
let mut context = BcContext::new(encryption_protocol);
|
||||
|
||||
let (buf, header) = bc_header(&sample[..]).unwrap();
|
||||
let (_, body) = bc_body(&mut context, &header, buf).unwrap();
|
||||
assert_eq!(header.msg_id, 1);
|
||||
assert_eq!(header.body_len, 0);
|
||||
assert_eq!(header.enc_offset, 0x0);
|
||||
assert_eq!(header.encrypted, true);
|
||||
assert_eq!(header.channel_id, 0);
|
||||
assert_eq!(header.stream_type, 0);
|
||||
assert_eq!(header.payload_offset, Some(0x0));
|
||||
assert_eq!(header.response_code, 0x190); // 400
|
||||
assert_eq!(header.class, 0x0000);
|
||||
match body {
|
||||
BcBody::ModernMsg(ModernMsg {
|
||||
xml: None,
|
||||
binary: None,
|
||||
extension: None,
|
||||
payload: None,
|
||||
}) => {
|
||||
assert!(true);
|
||||
}
|
||||
@@ -285,22 +307,26 @@ fn test_bc_modern_login_failed() {
|
||||
fn test_bc_modern_login_success() {
|
||||
let sample = include_bytes!("samples/modern_login_success.bin");
|
||||
|
||||
let mut context = BcContext::new();
|
||||
let encryption_protocol =
|
||||
std::sync::Arc::new(std::sync::Mutex::new(EncryptionProtocol::BCEncrypt));
|
||||
let mut context = BcContext::new(encryption_protocol);
|
||||
|
||||
let (buf, header) = bc_header(&sample[..]).unwrap();
|
||||
let (_, body) = bc_body(&mut context, &header, buf).unwrap();
|
||||
assert_eq!(header.msg_id, 1);
|
||||
assert_eq!(header.body_len, 2949);
|
||||
assert_eq!(header.enc_offset, 0x0);
|
||||
assert_eq!(header.encrypted, true);
|
||||
assert_eq!(header.channel_id, 0);
|
||||
assert_eq!(header.stream_type, 0);
|
||||
assert_eq!(header.payload_offset, Some(0x0));
|
||||
assert_eq!(header.response_code, 0xc8); // 200
|
||||
assert_eq!(header.class, 0x0000);
|
||||
|
||||
// Previously, we were not handling bin_offset == 0 (no bin offset) correctly.
|
||||
// Previously, we were not handling payload_offset == 0 (no bin offset) correctly.
|
||||
// Test that we decoded XML and no binary.
|
||||
match body {
|
||||
BcBody::ModernMsg(ModernMsg {
|
||||
xml: Some(_),
|
||||
binary: None,
|
||||
extension: None,
|
||||
payload: Some(_),
|
||||
}) => assert!(true),
|
||||
_ => assert!(false),
|
||||
}
|
||||
@@ -311,23 +337,31 @@ fn test_bc_binary_mode() {
|
||||
let sample1 = include_bytes!("samples/modern_video_start1.bin");
|
||||
let sample2 = include_bytes!("samples/modern_video_start2.bin");
|
||||
|
||||
let mut context = BcContext::new();
|
||||
let encryption_protocol =
|
||||
std::sync::Arc::new(std::sync::Mutex::new(EncryptionProtocol::BCEncrypt));
|
||||
let mut context = BcContext::new(encryption_protocol);
|
||||
|
||||
let msg1 = Bc::deserialize(&mut context, &sample1[..]).unwrap();
|
||||
let msg2 = Bc::deserialize(&mut context, &sample2[..]).unwrap();
|
||||
match msg1.body {
|
||||
BcBody::ModernMsg(ModernMsg {
|
||||
xml: None,
|
||||
binary: Some(bin),
|
||||
extension:
|
||||
Some(Extension {
|
||||
binary_data: Some(1),
|
||||
..
|
||||
}),
|
||||
payload: Some(BcPayloads::Binary(bin)),
|
||||
}) => {
|
||||
assert_eq!(bin.len(), 32);
|
||||
}
|
||||
_ => assert!(false),
|
||||
}
|
||||
|
||||
context.in_bin_mode.insert(msg1.meta.msg_num);
|
||||
let msg2 = Bc::deserialize(&mut context, &sample2[..]).unwrap();
|
||||
match msg2.body {
|
||||
BcBody::ModernMsg(ModernMsg {
|
||||
xml: None,
|
||||
binary: Some(bin),
|
||||
extension: None,
|
||||
payload: Some(BcPayloads::Binary(bin)),
|
||||
}) => {
|
||||
assert_eq!(bin.len(), 30344);
|
||||
}
|
||||
|
||||
+81
-32
@@ -1,5 +1,6 @@
|
||||
use super::xml::BcXml;
|
||||
pub use super::xml::{BcPayloads, BcXml, Extension};
|
||||
use std::collections::HashSet;
|
||||
use std::sync::{Arc, Mutex};
|
||||
|
||||
pub(super) const MAGIC_HEADER: u32 = 0xabcdef0;
|
||||
|
||||
@@ -20,6 +21,7 @@ pub struct Bc {
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
pub enum BcBody {
|
||||
LegacyMsg(LegacyMsg),
|
||||
ModernMsg(ModernMsg),
|
||||
@@ -27,8 +29,8 @@ pub enum BcBody {
|
||||
|
||||
#[derive(Debug, Default, PartialEq, Eq)]
|
||||
pub struct ModernMsg {
|
||||
pub xml: Option<BcXml>,
|
||||
pub binary: Option<Vec<u8>>,
|
||||
pub extension: Option<Extension>,
|
||||
pub payload: Option<BcPayloads>,
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
@@ -41,10 +43,12 @@ pub enum LegacyMsg {
|
||||
pub(super) struct BcHeader {
|
||||
pub body_len: u32,
|
||||
pub msg_id: u32,
|
||||
pub enc_offset: u32,
|
||||
pub encrypted: bool,
|
||||
pub channel_id: u8,
|
||||
pub stream_type: u8,
|
||||
pub msg_num: u16,
|
||||
pub response_code: u16,
|
||||
pub class: u16,
|
||||
pub bin_offset: Option<u32>,
|
||||
pub payload_offset: Option<u32>,
|
||||
}
|
||||
|
||||
/// The components of the Baichuan TLV header that are not
|
||||
@@ -52,9 +56,11 @@ pub(super) struct BcHeader {
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
pub struct BcMeta {
|
||||
pub msg_id: u32,
|
||||
pub client_idx: u32,
|
||||
pub channel_id: u8,
|
||||
pub stream_type: u8,
|
||||
pub response_code: u16,
|
||||
pub msg_num: u16,
|
||||
pub class: u16,
|
||||
pub encrypted: bool,
|
||||
}
|
||||
|
||||
/// The components of the Baichuan header that must be filled out after the body is serialized, or
|
||||
@@ -62,12 +68,22 @@ pub struct BcMeta {
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
pub(super) struct BcSendInfo {
|
||||
pub body_len: u32,
|
||||
pub bin_offset: Option<u32>,
|
||||
pub payload_offset: Option<u32>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum EncryptionProtocol {
|
||||
Unencrypted,
|
||||
BCEncrypt,
|
||||
Aes(Option<[u8; 16]>),
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct BcContext {
|
||||
pub(super) in_bin_mode: HashSet<u32>,
|
||||
pub(super) in_bin_mode: HashSet<u16>,
|
||||
// Arc<Mutex<EncryptionProtocol>> because it is shared between context
|
||||
// and connection for deserialisation and serialistion respectivly
|
||||
pub(super) encryption_protocol: Arc<Mutex<EncryptionProtocol>>,
|
||||
}
|
||||
|
||||
impl Bc {
|
||||
@@ -77,68 +93,101 @@ impl Bc {
|
||||
Bc {
|
||||
meta,
|
||||
body: BcBody::ModernMsg(ModernMsg {
|
||||
xml: Some(xml),
|
||||
binary: None,
|
||||
extension: None,
|
||||
payload: Some(BcPayloads::BcXml(xml)),
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn new_from_ext(meta: BcMeta, xml: Extension) -> Bc {
|
||||
Bc {
|
||||
meta,
|
||||
body: BcBody::ModernMsg(ModernMsg {
|
||||
extension: Some(xml),
|
||||
payload: None,
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn new_from_meta(meta: BcMeta) -> Bc {
|
||||
Bc {
|
||||
meta,
|
||||
body: BcBody::ModernMsg(ModernMsg {
|
||||
extension: None,
|
||||
payload: None,
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn new_from_ext_xml(meta: BcMeta, ext: Extension, xml: BcXml) -> Bc {
|
||||
Bc {
|
||||
meta,
|
||||
body: BcBody::ModernMsg(ModernMsg {
|
||||
extension: Some(ext),
|
||||
payload: Some(BcPayloads::BcXml(xml)),
|
||||
}),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for BcContext {
|
||||
fn default() -> BcContext {
|
||||
Self::new()
|
||||
}
|
||||
}
|
||||
|
||||
impl BcContext {
|
||||
pub fn new() -> BcContext {
|
||||
pub fn new(encryption_protocol: Arc<Mutex<EncryptionProtocol>>) -> BcContext {
|
||||
BcContext {
|
||||
in_bin_mode: HashSet::new(),
|
||||
encryption_protocol,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_encrypted(&mut self, encryption_protocol: EncryptionProtocol) {
|
||||
*(self.encryption_protocol.lock().unwrap()) = encryption_protocol;
|
||||
}
|
||||
|
||||
pub fn get_encrypted(&self) -> EncryptionProtocol {
|
||||
(*(self.encryption_protocol.lock().unwrap())).clone()
|
||||
}
|
||||
}
|
||||
|
||||
impl BcHeader {
|
||||
pub fn is_modern(&self) -> bool {
|
||||
// Most modern messages have an extra word at the end of the header; this
|
||||
// serves as the start offset of the appended binary data, if any.
|
||||
// serves as the start offset of the appended payload data, if any.
|
||||
// A notable exception is the encrypted reply to the login message;
|
||||
// in this case the message is modern (with XML encryption etc), but there is
|
||||
// no extra word.
|
||||
// Here are the message classes:
|
||||
// 0x6514: legacy, no bin offset (initial login message, encrypted or not)
|
||||
// 0x6614: modern, no bin offset (reply to encrypted 0x6514 login)
|
||||
// 0x6414: modern, has bin offset, always encrypted (re-sent login message)
|
||||
// 0x6414: modern, has bin offset, encrypted if supported (re-sent login message)
|
||||
// 0x0000, modern, has bin offset (most modern messages)
|
||||
self.class != 0x6514
|
||||
}
|
||||
|
||||
pub fn is_encrypted(&self) -> bool {
|
||||
self.encrypted || self.class == 0x6414
|
||||
}
|
||||
|
||||
pub fn to_meta(&self) -> BcMeta {
|
||||
BcMeta {
|
||||
msg_id: self.msg_id,
|
||||
client_idx: self.enc_offset,
|
||||
msg_num: self.msg_num,
|
||||
channel_id: self.channel_id,
|
||||
response_code: self.response_code,
|
||||
stream_type: self.stream_type,
|
||||
class: self.class,
|
||||
encrypted: self.encrypted,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn from_meta(meta: &BcMeta, body_len: u32, bin_offset: Option<u32>) -> BcHeader {
|
||||
pub fn from_meta(meta: &BcMeta, body_len: u32, payload_offset: Option<u32>) -> BcHeader {
|
||||
BcHeader {
|
||||
bin_offset,
|
||||
payload_offset,
|
||||
body_len,
|
||||
msg_id: meta.msg_id,
|
||||
enc_offset: meta.client_idx,
|
||||
channel_id: meta.channel_id,
|
||||
stream_type: meta.stream_type,
|
||||
response_code: meta.response_code,
|
||||
msg_num: meta.msg_num,
|
||||
class: meta.class,
|
||||
encrypted: meta.encrypted,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) fn has_bin_offset(class: u16) -> bool {
|
||||
pub(super) fn has_payload_offset(class: u16) -> bool {
|
||||
// See BcHeader::is_modern() for a description of which packets have the bin offset
|
||||
class == 0x6414 || class == 0x0000
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
+80
-41
@@ -1,90 +1,121 @@
|
||||
use super::model::*;
|
||||
use super::xml::BcXml;
|
||||
use super::xml::BcPayloads;
|
||||
use super::xml_crypto;
|
||||
use cookie_factory::bytes::*;
|
||||
use cookie_factory::sequence::tuple;
|
||||
use cookie_factory::{combinator::*, gen};
|
||||
use cookie_factory::{GenError, SerializeFn, WriteContext};
|
||||
use log::error;
|
||||
use std::io::Write;
|
||||
|
||||
pub type Error = GenError;
|
||||
|
||||
impl Bc {
|
||||
pub fn serialize<W: Write>(&self, buf: W) -> Result<W, GenError> {
|
||||
pub fn serialize<W: Write>(
|
||||
&self,
|
||||
buf: W,
|
||||
encryption_protocol: &EncryptionProtocol,
|
||||
) -> Result<W, GenError> {
|
||||
// Ideally this would be a combinator, but that would be hairy because we have to
|
||||
// serialize the XML to have the metadata to build the header
|
||||
let body_buf;
|
||||
let bin_offset;
|
||||
let payload_offset;
|
||||
|
||||
match &self.body {
|
||||
BcBody::ModernMsg(ref modern) => {
|
||||
let (buf, xml_len) = gen(
|
||||
opt_ref(&modern.xml, |xml| bc_xml(self.meta.client_idx, xml)),
|
||||
// First serialize ext
|
||||
let (temp_buf, ext_len) = gen(
|
||||
opt_ref(&modern.extension, |ext| {
|
||||
bc_ext(self.meta.channel_id as u32, ext, encryption_protocol)
|
||||
}),
|
||||
vec![],
|
||||
)?;
|
||||
body_buf = buf;
|
||||
bin_offset = if has_bin_offset(self.meta.class) {
|
||||
|
||||
// Now get the offset of the payload
|
||||
payload_offset = if has_payload_offset(self.meta.class) {
|
||||
// If we're required to put binary length, put 0 if we have no binary
|
||||
Some(if modern.binary.is_some() {
|
||||
xml_len as u32
|
||||
Some(if modern.payload.is_some() {
|
||||
ext_len as u32
|
||||
} else {
|
||||
0
|
||||
})
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
// Now get the payload part of the body and add to ext_buf
|
||||
let (temp_buf, _) = gen(
|
||||
opt_ref(&modern.payload, |payload_offset| {
|
||||
bc_payload(
|
||||
self.meta.channel_id as u32,
|
||||
payload_offset,
|
||||
encryption_protocol,
|
||||
)
|
||||
}),
|
||||
temp_buf,
|
||||
)?;
|
||||
body_buf = temp_buf;
|
||||
}
|
||||
|
||||
BcBody::LegacyMsg(ref legacy) => {
|
||||
let (buf, _) = gen(bc_legacy(legacy), vec![])?;
|
||||
let (buf, _) = gen(bc_legacy(legacy), vec![]).map_err(|e| {
|
||||
error!("Send error: {}", e);
|
||||
e
|
||||
})?;
|
||||
body_buf = buf;
|
||||
bin_offset = None;
|
||||
payload_offset = None;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Now have enough info to create the header
|
||||
let header = BcHeader::from_meta(&self.meta, body_buf.len() as u32, bin_offset);
|
||||
let header = BcHeader::from_meta(&self.meta, body_buf.len() as u32, payload_offset);
|
||||
|
||||
let (mut buf, _n) = gen(tuple((bc_header(&header), slice(body_buf))), buf)?;
|
||||
|
||||
// Put the binary part of the body, TODO this is poorly written
|
||||
if let BcBody::ModernMsg(ModernMsg {
|
||||
binary: Some(ref binary),
|
||||
..
|
||||
}) = self.body
|
||||
{
|
||||
let (buf2, _) = gen(slice(binary), buf)?;
|
||||
buf = buf2
|
||||
}
|
||||
let (buf, _n) = gen(tuple((bc_header(&header), slice(body_buf))), buf)?;
|
||||
|
||||
Ok(buf)
|
||||
}
|
||||
}
|
||||
|
||||
fn bc_xml<W: Write>(enc_offset: u32, xml: &BcXml) -> impl SerializeFn<W> {
|
||||
fn bc_ext<W: Write>(
|
||||
enc_offset: u32,
|
||||
xml: &Extension,
|
||||
encryption_protocol: &EncryptionProtocol,
|
||||
) -> impl SerializeFn<W> {
|
||||
let xml_bytes = xml.serialize(vec![]).unwrap();
|
||||
let enc_bytes = xml_crypto::crypt(enc_offset, &xml_bytes);
|
||||
let enc_bytes = xml_crypto::encrypt(enc_offset, &xml_bytes, encryption_protocol);
|
||||
slice(enc_bytes)
|
||||
}
|
||||
|
||||
fn bc_header<W: Write>(header: &BcHeader) -> impl SerializeFn<W> {
|
||||
// TODO this is actually a u16 "response code" in modern messages
|
||||
let (signaled_encryption, spare) = if header.class == 0x0000 {
|
||||
(0x00, 0x00)
|
||||
} else {
|
||||
(header.encrypted as u8, 0xdc)
|
||||
fn bc_payload<W: Write>(
|
||||
enc_offset: u32,
|
||||
payload: &BcPayloads,
|
||||
encryption_protocol: &EncryptionProtocol,
|
||||
) -> impl SerializeFn<W> {
|
||||
let payload_bytes = match payload {
|
||||
BcPayloads::BcXml(x) => {
|
||||
let xml_bytes = x.serialize(vec![]).unwrap();
|
||||
xml_crypto::encrypt(enc_offset, &xml_bytes, encryption_protocol)
|
||||
}
|
||||
BcPayloads::Binary(x) => x.to_owned(),
|
||||
};
|
||||
slice(payload_bytes)
|
||||
}
|
||||
|
||||
fn bc_header<W: Write>(header: &BcHeader) -> impl SerializeFn<W> {
|
||||
tuple((
|
||||
le_u32(MAGIC_HEADER),
|
||||
le_u32(header.msg_id),
|
||||
le_u32(header.body_len),
|
||||
le_u32(header.enc_offset),
|
||||
le_u8(signaled_encryption),
|
||||
le_u8(spare), // skipped byte
|
||||
le_u8(header.channel_id),
|
||||
le_u8(header.stream_type),
|
||||
le_u16(header.msg_num),
|
||||
le_u16(header.response_code),
|
||||
le_u16(header.class),
|
||||
opt(header.bin_offset, le_u32),
|
||||
opt(header.payload_offset, le_u32),
|
||||
))
|
||||
}
|
||||
|
||||
fn bc_legacy<'a, W: Write>(legacy: &'a LegacyMsg) -> impl SerializeFn<W> + 'a {
|
||||
fn bc_legacy<W: Write>(legacy: &'_ LegacyMsg) -> impl SerializeFn<W> + '_ {
|
||||
move |out: WriteContext<W>| {
|
||||
use LegacyMsg::*;
|
||||
match legacy {
|
||||
@@ -146,13 +177,17 @@ fn do_nothing<W>() -> impl SerializeFn<W> {
|
||||
|
||||
#[test]
|
||||
fn test_legacy_login_roundtrip() {
|
||||
let mut context = BcContext::new();
|
||||
let encryption_protocol =
|
||||
std::sync::Arc::new(std::sync::Mutex::new(EncryptionProtocol::BCEncrypt));
|
||||
let mut context = BcContext::new(encryption_protocol);
|
||||
|
||||
// I don't want to make up a sample message; just load it
|
||||
let sample = include_bytes!("samples/model_sample_legacy_login.bin");
|
||||
let msg = Bc::deserialize::<&[u8]>(&mut context, &sample[..]).unwrap();
|
||||
|
||||
let ser_buf = msg.serialize(vec![]).unwrap();
|
||||
let ser_buf = msg
|
||||
.serialize(vec![], &EncryptionProtocol::BCEncrypt)
|
||||
.unwrap();
|
||||
let msg2 = Bc::deserialize::<&[u8]>(&mut context, ser_buf.as_ref()).unwrap();
|
||||
assert_eq!(msg, msg2);
|
||||
assert_eq!(&sample[..], ser_buf.as_slice());
|
||||
@@ -160,14 +195,18 @@ fn test_legacy_login_roundtrip() {
|
||||
|
||||
#[test]
|
||||
fn test_modern_login_roundtrip() {
|
||||
let mut context = BcContext::new();
|
||||
let encryption_protocol =
|
||||
std::sync::Arc::new(std::sync::Mutex::new(EncryptionProtocol::BCEncrypt));
|
||||
let mut context = BcContext::new(encryption_protocol);
|
||||
|
||||
// I don't want to make up a sample message; just load it
|
||||
let sample = include_bytes!("samples/model_sample_modern_login.bin");
|
||||
|
||||
let msg = Bc::deserialize::<&[u8]>(&mut context, &sample[..]).unwrap();
|
||||
|
||||
let ser_buf = msg.serialize(vec![]).unwrap();
|
||||
let ser_buf = msg
|
||||
.serialize(vec![], &EncryptionProtocol::BCEncrypt)
|
||||
.unwrap();
|
||||
let msg2 = Bc::deserialize::<&[u8]>(&mut context, ser_buf.as_ref()).unwrap();
|
||||
assert_eq!(msg, msg2);
|
||||
}
|
||||
+26
-12
@@ -11,16 +11,17 @@ use indoc::indoc;
|
||||
|
||||
#[derive(PartialEq, Eq, Debug, YaDeserialize)]
|
||||
#[yaserde(flatten)]
|
||||
pub(super) enum AllTopXmls {
|
||||
pub enum BcPayloads {
|
||||
#[yaserde(rename = "body")]
|
||||
BcXml(BcXml),
|
||||
Extension(Extension),
|
||||
#[yaserde(flatten)]
|
||||
Binary(Vec<u8>),
|
||||
}
|
||||
|
||||
// Required for YaDeserialize
|
||||
impl Default for AllTopXmls {
|
||||
impl Default for BcPayloads {
|
||||
fn default() -> Self {
|
||||
AllTopXmls::BcXml(Default::default())
|
||||
BcPayloads::Binary(Default::default())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,13 +46,16 @@ pub struct BcXml {
|
||||
pub norm: Option<Norm>,
|
||||
}
|
||||
|
||||
impl AllTopXmls {
|
||||
impl BcXml {
|
||||
pub fn try_parse(s: impl Read) -> Result<Self, String> {
|
||||
yaserde::de::from_reader(s)
|
||||
}
|
||||
pub fn serialize<W: Write>(&self, w: W) -> Result<W, String> {
|
||||
yaserde::ser::serialize_with_writer(self, w, &Config::default())
|
||||
}
|
||||
}
|
||||
|
||||
impl BcXml {
|
||||
impl Extension {
|
||||
pub fn try_parse(s: impl Read) -> Result<Self, String> {
|
||||
yaserde::de::from_reader(s)
|
||||
}
|
||||
@@ -130,7 +134,7 @@ pub struct Preview {
|
||||
pub version: String,
|
||||
|
||||
#[yaserde(rename = "channelId")]
|
||||
pub channel_id: u32,
|
||||
pub channel_id: u8,
|
||||
pub handle: u32,
|
||||
#[yaserde(rename = "streamType")]
|
||||
pub stream_type: String,
|
||||
@@ -138,8 +142,15 @@ pub struct Preview {
|
||||
|
||||
#[derive(PartialEq, Eq, Default, Debug, YaDeserialize, YaSerialize)]
|
||||
pub struct Extension {
|
||||
#[yaserde(attribute)]
|
||||
pub version: String,
|
||||
#[yaserde(rename = "binaryData")]
|
||||
pub binary_data: u32,
|
||||
pub binary_data: Option<u32>,
|
||||
#[yaserde(rename = "userName")]
|
||||
pub user_name: Option<String>,
|
||||
pub token: Option<String>,
|
||||
#[yaserde(rename = "channelId")]
|
||||
pub channel_id: Option<u8>,
|
||||
}
|
||||
|
||||
#[derive(PartialEq, Eq, Default, Debug, YaDeserialize, YaSerialize)]
|
||||
@@ -196,9 +207,9 @@ fn test_encryption_deser() {
|
||||
assert_eq!(enc.nonce, "9E6D1FCB9E69846D");
|
||||
assert_eq!(enc.type_, "md5");
|
||||
|
||||
let t = AllTopXmls::try_parse(sample.as_bytes()).unwrap();
|
||||
let t = BcXml::try_parse(sample.as_bytes()).unwrap();
|
||||
match t {
|
||||
AllTopXmls::BcXml(top_b) if top_b == b => assert!(true),
|
||||
top_b if top_b == b => assert!(true),
|
||||
_ => assert!(false),
|
||||
}
|
||||
}
|
||||
@@ -333,9 +344,12 @@ fn test_binary_deser() {
|
||||
</Extension>
|
||||
"#
|
||||
);
|
||||
let b = AllTopXmls::try_parse(sample.as_bytes()).unwrap();
|
||||
let b = Extension::try_parse(sample.as_bytes()).unwrap();
|
||||
match b {
|
||||
AllTopXmls::Extension(Extension { binary_data: 1 }) => assert!(true),
|
||||
Extension {
|
||||
binary_data: Some(1),
|
||||
..
|
||||
} => assert!(true),
|
||||
_ => assert!(false),
|
||||
}
|
||||
}
|
||||
+58
-10
@@ -1,11 +1,59 @@
|
||||
const XML_KEY: [u8; 8] = [0x1F, 0x2D, 0x3C, 0x4B, 0x5A, 0x69, 0x78, 0xFF];
|
||||
use super::model::EncryptionProtocol;
|
||||
use aes::Aes128;
|
||||
use cfb_mode::cipher::{NewStreamCipher, StreamCipher};
|
||||
use cfb_mode::Cfb;
|
||||
|
||||
pub fn crypt(offset: u32, buf: &[u8]) -> Vec<u8> {
|
||||
let key_iter = XML_KEY.iter().cycle().skip(offset as usize % 8);
|
||||
key_iter
|
||||
.zip(buf)
|
||||
.map(|(key, i)| *i ^ key ^ (offset as u8))
|
||||
.collect()
|
||||
const XML_KEY: [u8; 8] = [0x1F, 0x2D, 0x3C, 0x4B, 0x5A, 0x69, 0x78, 0xFF];
|
||||
const IV: &[u8] = b"0123456789abcdef";
|
||||
|
||||
pub fn decrypt(offset: u32, buf: &[u8], encryption_protocol: &EncryptionProtocol) -> Vec<u8> {
|
||||
match encryption_protocol {
|
||||
EncryptionProtocol::Unencrypted => buf.to_vec(),
|
||||
EncryptionProtocol::BCEncrypt => {
|
||||
let key_iter = XML_KEY.iter().cycle().skip(offset as usize % 8);
|
||||
key_iter
|
||||
.zip(buf)
|
||||
.map(|(key, i)| *i ^ key ^ (offset as u8))
|
||||
.collect()
|
||||
}
|
||||
EncryptionProtocol::Aes(key) => {
|
||||
// AES decryption
|
||||
if let Some(aeskey) = key {
|
||||
let mut decrypted = buf.to_vec();
|
||||
Cfb::<Aes128>::new(aeskey.into(), IV.into()).decrypt(&mut decrypted);
|
||||
decrypted
|
||||
} else {
|
||||
// Not yet ready to decrypt (still in login phase)
|
||||
// Use BCEncrypt
|
||||
decrypt(offset, buf, &EncryptionProtocol::BCEncrypt)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn encrypt(offset: u32, buf: &[u8], encryption_protocol: &EncryptionProtocol) -> Vec<u8> {
|
||||
match encryption_protocol {
|
||||
EncryptionProtocol::Unencrypted => {
|
||||
// Encrypt is the same as decrypt
|
||||
decrypt(offset, buf, encryption_protocol)
|
||||
}
|
||||
EncryptionProtocol::BCEncrypt => {
|
||||
// Encrypt is the same as decrypt
|
||||
decrypt(offset, buf, encryption_protocol)
|
||||
}
|
||||
EncryptionProtocol::Aes(key) => {
|
||||
// AES encryption
|
||||
if let Some(aeskey) = key {
|
||||
let mut encrypted = buf.to_vec();
|
||||
Cfb::<Aes128>::new(aeskey.into(), IV.into()).encrypt(&mut encrypted);
|
||||
encrypted
|
||||
} else {
|
||||
// Not yet ready to decrypt (still in login phase)
|
||||
// Use BCEncrypt
|
||||
encrypt(offset, buf, &EncryptionProtocol::BCEncrypt)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -13,7 +61,7 @@ fn test_xml_crypto() {
|
||||
let sample = include_bytes!("samples/xml_crypto_sample1.bin");
|
||||
let should_be = include_bytes!("samples/xml_crypto_sample1_plaintext.bin");
|
||||
|
||||
let decrypted = crypt(0, &sample[..]);
|
||||
let decrypted = decrypt(0, &sample[..], &EncryptionProtocol::BCEncrypt);
|
||||
assert_eq!(decrypted, &should_be[..]);
|
||||
}
|
||||
|
||||
@@ -21,7 +69,7 @@ fn test_xml_crypto() {
|
||||
fn test_xml_crypto_roundtrip() {
|
||||
let zeros: [u8; 256] = [0; 256];
|
||||
|
||||
let decrypted = crypt(0, &zeros[..]);
|
||||
let encrypted = crypt(0, &decrypted[..]);
|
||||
let decrypted = encrypt(0, &zeros[..], &EncryptionProtocol::BCEncrypt);
|
||||
let encrypted = decrypt(0, &decrypted[..], &EncryptionProtocol::BCEncrypt);
|
||||
assert_eq!(encrypted, &zeros[..]);
|
||||
}
|
||||
+70
-31
@@ -6,8 +6,10 @@ use crate::gst::GstOutputs;
|
||||
use adpcm::adpcm_to_pcm;
|
||||
use err_derive::Error;
|
||||
use log::*;
|
||||
use std::convert::TryInto;
|
||||
use std::io::Write;
|
||||
use std::net::{SocketAddr, ToSocketAddrs};
|
||||
use std::sync::atomic::{AtomicU16, Ordering};
|
||||
use std::time::Duration;
|
||||
|
||||
use Md5Trunc::*;
|
||||
@@ -19,8 +21,10 @@ mod time;
|
||||
|
||||
pub struct BcCamera {
|
||||
address: SocketAddr,
|
||||
channel_id: u8,
|
||||
connection: Option<BcConnection>,
|
||||
logged_in: bool,
|
||||
message_num: AtomicU16,
|
||||
}
|
||||
|
||||
use crate::Never;
|
||||
@@ -30,6 +34,7 @@ type Result<T> = std::result::Result<T, Error>;
|
||||
const RX_TIMEOUT: Duration = Duration::from_secs(5);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
pub enum Error {
|
||||
#[error(display = "Communication error")]
|
||||
CommunicationError(#[error(source)] std::io::Error),
|
||||
@@ -84,7 +89,7 @@ impl Drop for BcCamera {
|
||||
}
|
||||
|
||||
impl BcCamera {
|
||||
pub fn connect<T: ToSocketAddrs>(host: T) -> Result<BcCamera> {
|
||||
pub fn new_with_addr<T: ToSocketAddrs>(host: T, channel_id: u8) -> Result<Self> {
|
||||
let addr_iter = match host.to_socket_addrs() {
|
||||
Ok(iter) => iter,
|
||||
Err(_) => return Err(Error::AddrResolutionError),
|
||||
@@ -107,6 +112,8 @@ impl BcCamera {
|
||||
return Ok(Self {
|
||||
address: addr,
|
||||
connection: Some(conn),
|
||||
message_num: AtomicU16::new(0),
|
||||
channel_id,
|
||||
logged_in: false,
|
||||
});
|
||||
}
|
||||
@@ -114,6 +121,10 @@ impl BcCamera {
|
||||
Err(Error::Timeout)
|
||||
}
|
||||
|
||||
pub fn new_message_num(&self) -> u16 {
|
||||
self.message_num.fetch_add(1, Ordering::Relaxed)
|
||||
}
|
||||
|
||||
pub fn disconnect(&mut self) {
|
||||
if let Err(err) = self.logout() {
|
||||
warn!("Could not log out, ignoring: {}", err);
|
||||
@@ -145,8 +156,10 @@ impl BcCamera {
|
||||
let legacy_login = Bc {
|
||||
meta: BcMeta {
|
||||
msg_id: MSG_ID_LOGIN,
|
||||
client_idx: 0,
|
||||
encrypted: true,
|
||||
channel_id: self.channel_id,
|
||||
msg_num: self.new_message_num(),
|
||||
stream_type: 0,
|
||||
response_code: 0xdc03,
|
||||
class: 0x6514,
|
||||
},
|
||||
body: BcBody::LegacyMsg(LegacyMsg::LoginMsg {
|
||||
@@ -158,14 +171,15 @@ impl BcCamera {
|
||||
sub_login.send(legacy_login)?;
|
||||
|
||||
let legacy_reply = sub_login.rx.recv_timeout(RX_TIMEOUT)?;
|
||||
|
||||
let nonce;
|
||||
match legacy_reply.body {
|
||||
BcBody::ModernMsg(ModernMsg {
|
||||
xml:
|
||||
Some(BcXml {
|
||||
payload:
|
||||
Some(BcPayloads::BcXml(BcXml {
|
||||
encryption: Some(encryption),
|
||||
..
|
||||
}),
|
||||
})),
|
||||
..
|
||||
}) => {
|
||||
nonce = encryption.nonce;
|
||||
@@ -194,8 +208,10 @@ impl BcCamera {
|
||||
let modern_login = Bc::new_from_xml(
|
||||
BcMeta {
|
||||
msg_id: MSG_ID_LOGIN,
|
||||
client_idx: 0, // TODO
|
||||
encrypted: true,
|
||||
channel_id: self.channel_id,
|
||||
msg_num: self.new_message_num(),
|
||||
stream_type: 0,
|
||||
response_code: 0,
|
||||
class: 0x6414,
|
||||
},
|
||||
BcXml {
|
||||
@@ -216,11 +232,11 @@ impl BcCamera {
|
||||
let device_info;
|
||||
match modern_reply.body {
|
||||
BcBody::ModernMsg(ModernMsg {
|
||||
xml:
|
||||
Some(BcXml {
|
||||
payload:
|
||||
Some(BcPayloads::BcXml(BcXml {
|
||||
device_info: Some(info),
|
||||
..
|
||||
}),
|
||||
})),
|
||||
..
|
||||
}) => {
|
||||
// Login succeeded!
|
||||
@@ -228,8 +244,8 @@ impl BcCamera {
|
||||
device_info = info;
|
||||
}
|
||||
BcBody::ModernMsg(ModernMsg {
|
||||
xml: None,
|
||||
binary: None,
|
||||
extension: None,
|
||||
payload: None,
|
||||
}) => return Err(Error::AuthFailed),
|
||||
_ => {
|
||||
return Err(Error::UnintelligibleReply {
|
||||
@@ -239,12 +255,20 @@ impl BcCamera {
|
||||
}
|
||||
}
|
||||
|
||||
if let EncryptionProtocol::Aes(_) = connection.get_encrypted() {
|
||||
// We setup the data for the AES key now
|
||||
// as all subsequent communications will use it
|
||||
let passwd = password.unwrap_or("");
|
||||
let full_key = make_aes_key(&nonce, passwd);
|
||||
connection.set_encrypted(EncryptionProtocol::Aes(Some(full_key)));
|
||||
}
|
||||
|
||||
Ok(device_info)
|
||||
}
|
||||
|
||||
pub fn logout(&mut self) -> Result<()> {
|
||||
if self.logged_in {
|
||||
// TODO
|
||||
// TODO: Send message ID 2
|
||||
}
|
||||
self.logged_in = false;
|
||||
Ok(())
|
||||
@@ -260,9 +284,11 @@ impl BcCamera {
|
||||
let version = Bc {
|
||||
meta: BcMeta {
|
||||
msg_id: MSG_ID_VERSION,
|
||||
client_idx: 0,
|
||||
encrypted: true,
|
||||
class: 0x6414,
|
||||
channel_id: self.channel_id,
|
||||
msg_num: self.new_message_num(),
|
||||
stream_type: 0,
|
||||
response_code: 0,
|
||||
class: 0x6414, // IDK why
|
||||
},
|
||||
body: BcBody::ModernMsg(ModernMsg {
|
||||
..Default::default()
|
||||
@@ -275,11 +301,11 @@ impl BcCamera {
|
||||
let version_info;
|
||||
match modern_reply.body {
|
||||
BcBody::ModernMsg(ModernMsg {
|
||||
xml:
|
||||
Some(BcXml {
|
||||
payload:
|
||||
Some(BcPayloads::BcXml(BcXml {
|
||||
version_info: Some(info),
|
||||
..
|
||||
}),
|
||||
})),
|
||||
..
|
||||
}) => {
|
||||
version_info = info;
|
||||
@@ -302,8 +328,10 @@ impl BcCamera {
|
||||
let ping = Bc {
|
||||
meta: BcMeta {
|
||||
msg_id: MSG_ID_PING,
|
||||
client_idx: 0,
|
||||
encrypted: true,
|
||||
channel_id: self.channel_id,
|
||||
msg_num: self.new_message_num(),
|
||||
stream_type: 0,
|
||||
response_code: 0,
|
||||
class: 0x6414,
|
||||
},
|
||||
body: BcBody::ModernMsg(ModernMsg {
|
||||
@@ -318,29 +346,32 @@ impl BcCamera {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn start_video(
|
||||
&self,
|
||||
data_outs: &mut GstOutputs,
|
||||
stream_name: &str,
|
||||
channel_id: u32,
|
||||
) -> Result<Never> {
|
||||
pub fn start_video(&self, data_outs: &mut GstOutputs, stream_name: &str) -> Result<Never> {
|
||||
let connection = self
|
||||
.connection
|
||||
.as_ref()
|
||||
.expect("Must be connected to start video");
|
||||
let sub_video = connection.subscribe(MSG_ID_VIDEO)?;
|
||||
|
||||
let stream_num = match stream_name {
|
||||
"mainStream" => 0,
|
||||
"subStream" => 1,
|
||||
_ => 0,
|
||||
};
|
||||
|
||||
let start_video = Bc::new_from_xml(
|
||||
BcMeta {
|
||||
msg_id: MSG_ID_VIDEO,
|
||||
client_idx: 0, // TODO
|
||||
encrypted: true,
|
||||
channel_id: self.channel_id,
|
||||
msg_num: self.new_message_num(),
|
||||
stream_type: stream_num,
|
||||
response_code: 0,
|
||||
class: 0x6414, // IDK why
|
||||
},
|
||||
BcXml {
|
||||
preview: Some(Preview {
|
||||
version: xml_ver(),
|
||||
channel_id,
|
||||
channel_id: self.channel_id,
|
||||
handle: 0,
|
||||
stream_type: stream_name.to_string(),
|
||||
}),
|
||||
@@ -400,6 +431,14 @@ fn md5_string(input: &str, trunc: Md5Trunc) -> String {
|
||||
md5
|
||||
}
|
||||
|
||||
pub fn make_aes_key(nonce: &str, passwd: &str) -> [u8; 16] {
|
||||
let key_phrase = format!("{}-{}", nonce, passwd);
|
||||
let key_phrase_hash = format!("{:X}\0", md5::compute(&key_phrase))
|
||||
.to_uppercase()
|
||||
.into_bytes();
|
||||
key_phrase_hash[0..16].try_into().unwrap()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_md5_string() {
|
||||
// Note that these literals are only 31 characters long - see explanation above.
|
||||
|
||||
@@ -5,6 +5,7 @@ use log::*;
|
||||
use socket2::{Domain, Socket, Type};
|
||||
use std::collections::btree_map::Entry;
|
||||
use std::collections::BTreeMap;
|
||||
use std::error::Error as StdErr; // Just need the traits
|
||||
use std::net::{Shutdown, SocketAddr, TcpStream};
|
||||
use std::sync::mpsc::{channel, Receiver, Sender};
|
||||
use std::sync::{Arc, Mutex};
|
||||
@@ -20,6 +21,9 @@ pub struct BcConnection {
|
||||
connection: Arc<Mutex<TcpStream>>,
|
||||
subscribers: Arc<Mutex<BTreeMap<u32, Sender<Bc>>>>,
|
||||
rx_thread: Option<JoinHandle<()>>,
|
||||
// Arc<Mutex<EncryptionProtocol>> because it is shared between context
|
||||
// and connection for deserialisation and serialistion respectivly
|
||||
encryption_protocol: Arc<Mutex<EncryptionProtocol>>,
|
||||
}
|
||||
|
||||
pub struct BcSubscription<'a> {
|
||||
@@ -53,20 +57,29 @@ impl BcConnection {
|
||||
let mut subs = subscribers.clone();
|
||||
let conn = tcp_conn.try_clone()?;
|
||||
|
||||
let encryption_protocol = Arc::new(Mutex::new(EncryptionProtocol::Unencrypted));
|
||||
let connections_encryption_protocol = encryption_protocol.clone();
|
||||
let rx_thread = std::thread::spawn(move || {
|
||||
let mut context = BcContext::new();
|
||||
let mut context = BcContext::new(connections_encryption_protocol);
|
||||
let mut result;
|
||||
while {
|
||||
result = BcConnection::poll(&mut context, &conn, &mut subs);
|
||||
result.is_ok()
|
||||
} {}
|
||||
error!("Deserialization error: {:?}", result.unwrap_err());
|
||||
let e = result.unwrap_err();
|
||||
error!("Deserialization error: {}", e);
|
||||
let mut cause = e.source();
|
||||
while let Some(e) = cause {
|
||||
error!("caused by: {}", e);
|
||||
cause = e.source();
|
||||
}
|
||||
});
|
||||
|
||||
Ok(BcConnection {
|
||||
connection: Arc::new(Mutex::new(tcp_conn)),
|
||||
subscribers,
|
||||
rx_thread: Some(rx_thread),
|
||||
encryption_protocol,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -115,6 +128,14 @@ impl BcConnection {
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn set_encrypted(&self, value: EncryptionProtocol) {
|
||||
*(self.encryption_protocol.lock().unwrap()) = value;
|
||||
}
|
||||
|
||||
pub fn get_encrypted(&self) -> EncryptionProtocol {
|
||||
(*self.encryption_protocol.lock().unwrap()).clone()
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for BcConnection {
|
||||
@@ -141,7 +162,10 @@ impl<'a> BcSubscription<'a> {
|
||||
pub fn send(&self, bc: Bc) -> Result<()> {
|
||||
assert!(bc.meta.msg_id == self.msg_id);
|
||||
|
||||
bc.serialize(&*self.conn.connection.lock().unwrap())?;
|
||||
bc.serialize(
|
||||
&*self.conn.connection.lock().unwrap(),
|
||||
&self.conn.get_encrypted(),
|
||||
)?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -216,7 +216,7 @@ impl<'a> MediaDataSubscriber<'a> {
|
||||
loop {
|
||||
let msg = self.bc_sub.rx.recv_timeout(RX_TIMEOUT)?;
|
||||
if let BcBody::ModernMsg(ModernMsg {
|
||||
binary: Some(binary),
|
||||
payload: Some(BcPayloads::Binary(binary)),
|
||||
..
|
||||
}) = msg.body
|
||||
{
|
||||
|
||||
+11
-7
@@ -12,8 +12,10 @@ impl BcCamera {
|
||||
let get = Bc {
|
||||
meta: BcMeta {
|
||||
msg_id: MSG_ID_GET_GENERAL,
|
||||
client_idx: 0,
|
||||
encrypted: true,
|
||||
channel_id: self.channel_id,
|
||||
msg_num: self.new_message_num(),
|
||||
response_code: 0,
|
||||
stream_type: 0,
|
||||
class: 0x6414,
|
||||
},
|
||||
body: BcBody::ModernMsg(ModernMsg::default()),
|
||||
@@ -23,8 +25,8 @@ impl BcCamera {
|
||||
let msg = sub_get_general.rx.recv_timeout(RX_TIMEOUT)?;
|
||||
|
||||
if let BcBody::ModernMsg(ModernMsg {
|
||||
xml:
|
||||
Some(BcXml {
|
||||
payload:
|
||||
Some(BcPayloads::BcXml(BcXml {
|
||||
system_general:
|
||||
Some(SystemGeneral {
|
||||
time_zone: Some(time_zone),
|
||||
@@ -37,7 +39,7 @@ impl BcCamera {
|
||||
..
|
||||
}),
|
||||
..
|
||||
}),
|
||||
})),
|
||||
..
|
||||
}) = msg.body
|
||||
{
|
||||
@@ -82,8 +84,10 @@ impl BcCamera {
|
||||
let set = Bc::new_from_xml(
|
||||
BcMeta {
|
||||
msg_id: MSG_ID_SET_GENERAL,
|
||||
client_idx: 0,
|
||||
encrypted: true,
|
||||
channel_id: self.channel_id,
|
||||
msg_num: self.new_message_num(),
|
||||
response_code: 0,
|
||||
stream_type: 0,
|
||||
class: 0x6414,
|
||||
},
|
||||
BcXml {
|
||||
|
||||
+2
-2
@@ -67,7 +67,7 @@ pub struct CameraConfig {
|
||||
|
||||
#[validate(range(min = 0, max = 31, message = "Invalid channel", code = "channel_id"))]
|
||||
#[serde(default = "default_channel_id")]
|
||||
pub channel_id: u32,
|
||||
pub channel_id: u8,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, Validate, Clone)]
|
||||
@@ -100,7 +100,7 @@ fn default_tls_client_auth() -> String {
|
||||
"none".to_string()
|
||||
}
|
||||
|
||||
fn default_channel_id() -> u32 {
|
||||
fn default_channel_id() -> u8 {
|
||||
0
|
||||
}
|
||||
|
||||
|
||||
+1
-5
@@ -13,7 +13,6 @@ use gstreamer_rtsp_server::{
|
||||
RTSP_PERM_MEDIA_FACTORY_ACCESS, RTSP_PERM_MEDIA_FACTORY_CONSTRUCT,
|
||||
RTSP_TOKEN_MEDIA_FACTORY_ROLE,
|
||||
};
|
||||
use itertools::Itertools;
|
||||
use log::*;
|
||||
use std::collections::HashSet;
|
||||
use std::fs;
|
||||
@@ -142,10 +141,7 @@ impl RtspServer {
|
||||
debug!(
|
||||
"Permitting {} to access {}",
|
||||
// This is hashmap or (iter) equivalent of join, it requres itertools
|
||||
permitted_users
|
||||
.iter()
|
||||
.cloned()
|
||||
.intersperse(", ")
|
||||
itertools::Itertools::intersperse(permitted_users.iter().cloned(), ", ")
|
||||
.collect::<String>(),
|
||||
paths.join(", ")
|
||||
);
|
||||
|
||||
+3
-3
@@ -19,6 +19,7 @@ use cmdline::Opt;
|
||||
use config::{CameraConfig, Config, UserConfig};
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
pub enum Error {
|
||||
#[error(display = "Configuration parsing error")]
|
||||
ConfigError(#[error(source)] toml::de::Error),
|
||||
@@ -198,6 +199,7 @@ fn camera_main(
|
||||
) -> Result<Never, CameraErr> {
|
||||
let mut connected = false;
|
||||
(|| {
|
||||
let mut camera = BcCamera::new_with_addr(&camera_config.camera_addr, camera_config.channel_id)?;
|
||||
if camera_config.timeout.is_some() {
|
||||
warn!("The undocumented `timeout` config option has been removed and is no longer needed.");
|
||||
warn!("Please update your config file.");
|
||||
@@ -208,8 +210,6 @@ fn camera_main(
|
||||
camera_config.name, camera_config.camera_addr
|
||||
);
|
||||
|
||||
let mut camera = BcCamera::connect(&camera_config.camera_addr)?;
|
||||
|
||||
camera.login(&camera_config.username, camera_config.password.as_deref())?;
|
||||
|
||||
connected = true;
|
||||
@@ -223,7 +223,7 @@ fn camera_main(
|
||||
"{}: Starting video stream {}",
|
||||
camera_config.name, stream_name
|
||||
);
|
||||
camera.start_video(outputs, stream_name, camera_config.channel_id)
|
||||
camera.start_video(outputs, stream_name)
|
||||
})()
|
||||
.map_err(|err| CameraErr { connected, err })
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user