use mdns 1.1

This commit is contained in:
Robin Appelman 2020-01-31 22:19:16 +01:00
commit cf0a704f21
6 changed files with 124 additions and 167 deletions

65
Cargo.lock generated
View file

@ -15,16 +15,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]] [[package]]
name = "async-stream" name = "async-stream"
version = "0.2.0" version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"async-stream-impl 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "async-stream-impl 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"futures-core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "futures-core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]] [[package]]
name = "async-stream-impl" name = "async-stream-impl"
version = "0.2.0" version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"proc-macro2 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)",
@ -276,7 +276,7 @@ dependencies = [
"indexmap 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "indexmap 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
"slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
"tokio 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", "tokio 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
"tokio-util 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-util 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
@ -344,9 +344,9 @@ dependencies = [
"itoa 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "itoa 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
"net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", "net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)",
"pin-project 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "pin-project 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
"time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)",
"tokio 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", "tokio 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
"tower-service 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "tower-service 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"want 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "want 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
@ -362,7 +362,7 @@ dependencies = [
"hyper 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)", "hyper 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)",
"rustls 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)", "rustls 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rustls-native-certs 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "rustls-native-certs 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"tokio 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", "tokio 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
"tokio-rustls 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-rustls 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)",
"webpki 0.21.0 (registry+https://github.com/rust-lang/crates.io-index)", "webpki 0.21.0 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
@ -375,7 +375,7 @@ dependencies = [
"bytes 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)",
"hyper 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)", "hyper 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)",
"native-tls 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "native-tls 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
"tokio 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", "tokio 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
"tokio-tls 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-tls 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
@ -462,16 +462,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]] [[package]]
name = "mdns" name = "mdns"
version = "1.0.0" version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"async-stream 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "async-stream 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"dns-parser 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "dns-parser 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"err-derive 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "err-derive 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"futures-core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "futures-core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"futures-util 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "futures-util 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", "net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)",
"tokio 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", "tokio 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]] [[package]]
@ -595,15 +595,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]] [[package]]
name = "pin-project" name = "pin-project"
version = "0.4.7" version = "0.4.8"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"pin-project-internal 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "pin-project-internal 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]] [[package]]
name = "pin-project-internal" name = "pin-project-internal"
version = "0.4.7" version = "0.4.8"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"proc-macro2 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)",
@ -681,13 +681,13 @@ dependencies = [
[[package]] [[package]]
name = "prometheus-edge-detector" name = "prometheus-edge-detector"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/icewind1991/prometheus-edge-detector#67e25175e20e6ebf452cb1879fa8fcf780d959a8" source = "git+https://github.com/icewind1991/prometheus-edge-detector#5a566f0197f3454da4e349e3b282d325051c4602"
dependencies = [ dependencies = [
"err-derive 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "err-derive 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"futures-util 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "futures-util 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"reqwest 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", "reqwest 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)",
"tokio 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", "tokio 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]] [[package]]
@ -700,12 +700,12 @@ dependencies = [
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
"main_error 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "main_error 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"maplit 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "maplit 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
"mdns 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "mdns 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"prometheus-edge-detector 0.1.0 (git+https://github.com/icewind1991/prometheus-edge-detector)", "prometheus-edge-detector 0.1.0 (git+https://github.com/icewind1991/prometheus-edge-detector)",
"reqwest 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", "reqwest 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_json 1.0.45 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.45 (registry+https://github.com/rust-lang/crates.io-index)",
"tokio 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", "tokio 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
"toml 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)", "toml 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
@ -816,7 +816,7 @@ dependencies = [
"serde_json 1.0.45 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.45 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_urlencoded 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "serde_urlencoded 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)",
"time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)",
"tokio 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", "tokio 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
"tokio-rustls 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-rustls 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)",
"tokio-tls 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-tls 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"url 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "url 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
@ -1047,7 +1047,7 @@ dependencies = [
[[package]] [[package]]
name = "tokio" name = "tokio"
version = "0.2.10" version = "0.2.11"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"bytes 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)",
@ -1059,14 +1059,15 @@ dependencies = [
"mio 0.6.21 (registry+https://github.com/rust-lang/crates.io-index)", "mio 0.6.21 (registry+https://github.com/rust-lang/crates.io-index)",
"pin-project-lite 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "pin-project-lite 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
"slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
"tokio-macros 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-macros 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]] [[package]]
name = "tokio-macros" name = "tokio-macros"
version = "0.2.3" version = "0.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"proc-macro2 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)",
"quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
"syn 1.0.14 (registry+https://github.com/rust-lang/crates.io-index)", "syn 1.0.14 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
@ -1078,7 +1079,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"futures-core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "futures-core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"rustls 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)", "rustls 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)",
"tokio 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", "tokio 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
"webpki 0.21.0 (registry+https://github.com/rust-lang/crates.io-index)", "webpki 0.21.0 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
@ -1088,7 +1089,7 @@ version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"native-tls 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "native-tls 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
"tokio 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", "tokio 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]] [[package]]
@ -1101,7 +1102,7 @@ dependencies = [
"futures-sink 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "futures-sink 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
"pin-project-lite 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "pin-project-lite 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
"tokio 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", "tokio 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]] [[package]]
@ -1371,8 +1372,8 @@ dependencies = [
[metadata] [metadata]
"checksum aho-corasick 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)" = "58fb5e95d83b38284460a5fda7d6470aa0b8844d283a0b614b8535e880800d2d" "checksum aho-corasick 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)" = "58fb5e95d83b38284460a5fda7d6470aa0b8844d283a0b614b8535e880800d2d"
"checksum anyhow 1.0.26 (registry+https://github.com/rust-lang/crates.io-index)" = "7825f6833612eb2414095684fcf6c635becf3ce97fe48cf6421321e93bfbd53c" "checksum anyhow 1.0.26 (registry+https://github.com/rust-lang/crates.io-index)" = "7825f6833612eb2414095684fcf6c635becf3ce97fe48cf6421321e93bfbd53c"
"checksum async-stream 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "58982858be7540a465c790b95aaea6710e5139bf8956b1d1344d014fa40100b0" "checksum async-stream 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "22068c0c19514942eefcfd4daf8976ef1aad84e61539f95cd200c35202f80af5"
"checksum async-stream-impl 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "393356ed99aa7bff0ac486dde592633b83ab02bd254d8c209d5b9f1d0f533480" "checksum async-stream-impl 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "25f9db3b38af870bf7e5cc649167533b493928e50744e2c30ae350230b414670"
"checksum atty 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)" = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" "checksum atty 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)" = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8"
"checksum autocfg 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "1d49d90015b3c36167a20fe2810c5cd875ad504b39cff3d4eae7977e6b7c1cb2" "checksum autocfg 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "1d49d90015b3c36167a20fe2810c5cd875ad504b39cff3d4eae7977e6b7c1cb2"
"checksum autocfg 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f8aac770f1885fd7e387acedd76065302551364496e46b3dd00860b2f8359b9d" "checksum autocfg 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f8aac770f1885fd7e387acedd76065302551364496e46b3dd00860b2f8359b9d"
@ -1427,7 +1428,7 @@ dependencies = [
"checksum main_error 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3516df0fb44d98fe6d6e859d224adfb7b6686447937e5b96308d6061595eed04" "checksum main_error 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3516df0fb44d98fe6d6e859d224adfb7b6686447937e5b96308d6061595eed04"
"checksum maplit 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "3e2e65a1a2e43cfcb47a895c4c8b10d1f4a61097f9f254f183aee60cad9c651d" "checksum maplit 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "3e2e65a1a2e43cfcb47a895c4c8b10d1f4a61097f9f254f183aee60cad9c651d"
"checksum matches 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08" "checksum matches 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08"
"checksum mdns 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d1d1e461d374d1e092612bd6087031f55c03dd10a38e680dce380181ba0aabf0" "checksum mdns 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "caccbabad4e71a1a261c872ac0bb94ce9958098a1ef4c637f2b4de4f6835ce7e"
"checksum memchr 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3197e20c7edb283f87c071ddfc7a2cca8f8e0b888c242959846a6fce03c72223" "checksum memchr 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3197e20c7edb283f87c071ddfc7a2cca8f8e0b888c242959846a6fce03c72223"
"checksum mime 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)" = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d" "checksum mime 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)" = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d"
"checksum mime_guess 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1a0ed03949aef72dbdf3116a383d7b38b4768e6f960528cd6a6044aa9ed68599" "checksum mime_guess 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1a0ed03949aef72dbdf3116a383d7b38b4768e6f960528cd6a6044aa9ed68599"
@ -1440,8 +1441,8 @@ dependencies = [
"checksum openssl-probe 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "77af24da69f9d9341038eba93a073b1fdaaa1b788221b00a69bce9e762cb32de" "checksum openssl-probe 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "77af24da69f9d9341038eba93a073b1fdaaa1b788221b00a69bce9e762cb32de"
"checksum openssl-sys 0.9.53 (registry+https://github.com/rust-lang/crates.io-index)" = "465d16ae7fc0e313318f7de5cecf57b2fbe7511fd213978b457e1c96ff46736f" "checksum openssl-sys 0.9.53 (registry+https://github.com/rust-lang/crates.io-index)" = "465d16ae7fc0e313318f7de5cecf57b2fbe7511fd213978b457e1c96ff46736f"
"checksum percent-encoding 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" "checksum percent-encoding 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e"
"checksum pin-project 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)" = "75fca1c4ff21f60ca2d37b80d72b63dab823a9d19d3cda3a81d18bc03f0ba8c5" "checksum pin-project 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "7804a463a8d9572f13453c516a5faea534a2403d7ced2f0c7e100eeff072772c"
"checksum pin-project-internal 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)" = "6544cd4e4ecace61075a6ec78074beeef98d58aa9a3d07d053d993b2946a90d6" "checksum pin-project-internal 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "385322a45f2ecf3410c68d2a549a4a2685e8051d0f278e39743ff4e451cb9b3f"
"checksum pin-project-lite 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "237844750cfbb86f67afe27eee600dfbbcb6188d734139b534cbfbf4f96792ae" "checksum pin-project-lite 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "237844750cfbb86f67afe27eee600dfbbcb6188d734139b534cbfbf4f96792ae"
"checksum pin-utils 0.1.0-alpha.4 (registry+https://github.com/rust-lang/crates.io-index)" = "5894c618ce612a3fa23881b152b608bafb8c56cfc22f434a3ba3120b40f7b587" "checksum pin-utils 0.1.0-alpha.4 (registry+https://github.com/rust-lang/crates.io-index)" = "5894c618ce612a3fa23881b152b608bafb8c56cfc22f434a3ba3120b40f7b587"
"checksum pkg-config 0.3.17 (registry+https://github.com/rust-lang/crates.io-index)" = "05da548ad6865900e60eaba7f589cc0783590a92e940c26953ff81ddbab2d677" "checksum pkg-config 0.3.17 (registry+https://github.com/rust-lang/crates.io-index)" = "05da548ad6865900e60eaba7f589cc0783590a92e940c26953ff81ddbab2d677"
@ -1487,8 +1488,8 @@ dependencies = [
"checksum termcolor 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bb6bfa289a4d7c5766392812c0a1f4c1ba45afa1ad47803c11e1f407d846d75f" "checksum termcolor 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bb6bfa289a4d7c5766392812c0a1f4c1ba45afa1ad47803c11e1f407d846d75f"
"checksum thread_local 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d40c6d1b69745a6ec6fb1ca717914848da4b44ae29d9b3080cbee91d72a69b14" "checksum thread_local 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d40c6d1b69745a6ec6fb1ca717914848da4b44ae29d9b3080cbee91d72a69b14"
"checksum time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)" = "db8dcfca086c1143c9270ac42a2bbd8a7ee477b78ac8e45b19abfb0cbede4b6f" "checksum time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)" = "db8dcfca086c1143c9270ac42a2bbd8a7ee477b78ac8e45b19abfb0cbede4b6f"
"checksum tokio 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)" = "c1fc73332507b971a5010664991a441b5ee0de92017f5a0e8b00fd684573045b" "checksum tokio 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "8fdd17989496f49cdc57978c96f0c9fe5e4a58a8bddc6813c449a4624f6a030b"
"checksum tokio-macros 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "50a61f268a3db2acee8dcab514efc813dc6dbe8a00e86076f935f94304b59a7a" "checksum tokio-macros 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "f4b1e7ed7d5d4c2af3d999904b0eebe76544897cdbfb2b9684bed2174ab20f7c"
"checksum tokio-rustls 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)" = "141afec0978abae6573065a48882c6bae44c5cc61db9b511ac4abf6a09bfd9cc" "checksum tokio-rustls 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)" = "141afec0978abae6573065a48882c6bae44c5cc61db9b511ac4abf6a09bfd9cc"
"checksum tokio-tls 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7bde02a3a5291395f59b06ec6945a3077602fac2b07eeeaf0dee2122f3619828" "checksum tokio-tls 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7bde02a3a5291395f59b06ec6945a3077602fac2b07eeeaf0dee2122f3619828"
"checksum tokio-util 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "571da51182ec208780505a32528fc5512a8fe1443ab960b3f2f3ef093cd16930" "checksum tokio-util 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "571da51182ec208780505a32528fc5512a8fe1443ab960b3f2f3ef093cd16930"

View file

@ -6,7 +6,7 @@ edition = "2018"
[dependencies] [dependencies]
prometheus-edge-detector = { version = "0.1", git = "https://github.com/icewind1991/prometheus-edge-detector", default-features = false } prometheus-edge-detector = { version = "0.1", git = "https://github.com/icewind1991/prometheus-edge-detector", default-features = false }
mdns = "1.0" mdns = "1.1"
tokio = { version = "0.2.4", features = ["macros", "time", "fs"] } tokio = { version = "0.2.4", features = ["macros", "time", "fs"] }
main_error = "0.1.0" main_error = "0.1.0"
futures-util = "0.3.1" futures-util = "0.3.1"

View file

@ -1,6 +1,6 @@
use serde::Deserialize;
use err_derive::Error;
use crate::mdns::resolve_mdns; use crate::mdns::resolve_mdns;
use err_derive::Error;
use serde::Deserialize;
use std::collections::HashMap; use std::collections::HashMap;
#[derive(Debug, Error)] #[derive(Debug, Error)]
@ -38,27 +38,25 @@ pub enum Parameter {
impl Parameter { impl Parameter {
pub async fn get_value(&self) -> Result<String, ParameterError> { pub async fn get_value(&self) -> Result<String, ParameterError> {
match self { match self {
Parameter::Mdns { Parameter::Mdns { service, host } => match resolve_mdns(service, host).await? {
service, Some(service) => Ok(service.to_string()),
host None => Err(ParameterError::MdnsHostNotFound),
} => { },
match resolve_mdns(service, host).await? {
Some(service) => Ok(format!("{}:{}", service.addr, service.port)),
None => Err(ParameterError::MdnsHostNotFound)
}
}
Parameter::Value { value } => Ok(value.clone()), Parameter::Value { value } => Ok(value.clone()),
Parameter::Service { Parameter::Service { file, key, value } => {
file, key, value
} => {
let content = tokio::fs::read(file).await?; let content = tokio::fs::read(file).await?;
let services: Vec<Service> = serde_json::from_slice(&content)?; let services: Vec<Service> = serde_json::from_slice(&content)?;
services.into_iter().find_map(|service| { services
service.labels.get(key) .into_iter()
.find_map(|service| {
service
.labels
.get(key)
.filter(|val| *val == value) .filter(|val| *val == value)
.and_then(|_| service.targets.get(0)) .and_then(|_| service.targets.get(0))
.cloned() .cloned()
}).ok_or(ParameterError::ServiceNotFound) })
.ok_or(ParameterError::ServiceNotFound)
} }
} }
} }
@ -88,7 +86,7 @@ pub struct Config {
#[derive(Debug, Clone, Deserialize)] #[derive(Debug, Clone, Deserialize)]
pub struct PrometheusConfig { pub struct PrometheusConfig {
pub url: String pub url: String,
} }
#[derive(Debug, Clone, Deserialize)] #[derive(Debug, Clone, Deserialize)]

View file

@ -1,7 +1,7 @@
use main_error::MainError;
use tokio::fs::File;
use crate::config::Config; use crate::config::Config;
use crate::trigger::TriggerManager; use crate::trigger::TriggerManager;
use main_error::MainError;
use tokio::fs::File;
use tokio::prelude::*; use tokio::prelude::*;
mod config; mod config;

View file

@ -1,87 +1,15 @@
use tokio::time::timeout; use std::net::SocketAddr;
use futures_util::{pin_mut, stream::StreamExt}; use std::time::Duration;
use mdns::{Record, RecordKind};
use std::{net::IpAddr, time::Duration};
const INTERVAL: Duration = Duration::from_secs(3); pub async fn resolve_mdns(
service: &str,
#[derive(Debug)] search_name: &str,
pub struct MdnsService { ) -> Result<Option<SocketAddr>, mdns::Error> {
pub id: String, Ok(mdns::resolve::one(
pub name: String, service,
pub addr: IpAddr, &format!("{}.{}", search_name, service),
pub port: u16, Duration::from_secs(15),
} )
.await?
pub async fn resolve_mdns(service: &str, search_name: &str) -> Result<Option<MdnsService>, mdns::Error> { .and_then(|response| response.socket_address()))
let stream = mdns::discover::all(service, INTERVAL)?.listen();
pin_mut!(stream);
let process = async move {
while let Some(Ok(response)) = stream.next().await {
let id = response.records().find_map(to_id);
let addr = response.records().find_map(to_ip_addr);
let port = response.records().find_map(to_port);
let name = response.records().find_map(to_name);
if let (Some(id), Some(addr), Some(name), Some(port)) = (id, addr, name, port) {
let service = MdnsService {
id,
name,
addr,
port,
};
if service.id == search_name {
return Some(service);
}
}
}
None
};
match timeout(Duration::from_secs(5), process).await {
Err(_) => Ok(None),
Ok(res) => Ok(res)
}
}
fn to_id(record: &Record) -> Option<String> {
match &record.kind {
RecordKind::PTR(id) => {
id.split('.').next().map(|s| s.to_string())
}
_ => None,
}
}
fn to_ip_addr(record: &Record) -> Option<IpAddr> {
match record.kind {
RecordKind::A(addr) => Some(addr.into()),
RecordKind::AAAA(addr) => Some(addr.into()),
_ => None,
}
}
fn to_port(record: &Record) -> Option<u16> {
match record.kind {
RecordKind::SRV { port, .. } => Some(port),
_ => None,
}
}
fn to_name(record: &Record) -> Option<String> {
if let RecordKind::TXT(txt) = &record.kind {
txt.iter()
.find_map(|pair| {
let mut parts = pair.split('=');
if let (Some("name"), Some(value)) = (parts.next(), parts.next()) {
Some(value.to_string())
} else {
None
}
})
} else {
None
}
} }

View file

@ -1,13 +1,13 @@
use main_error::MainError; use crate::config::{Action, Condition, Config, Method, Parameter, ParameterError, Trigger};
use std::collections::HashMap;
use crate::config::{Parameter, ParameterError, Trigger, Config, Action, Method, Condition};
use prometheus_edge_detector::EdgeDetector;
use futures_util::future::try_join_all;
use std::time::{Duration, SystemTime};
use reqwest::Client;
use tokio::time::delay_for;
use log::{info, error};
use err_derive::Error; use err_derive::Error;
use futures_util::future::try_join_all;
use log::{error, info};
use main_error::MainError;
use prometheus_edge_detector::EdgeDetector;
use reqwest::Client;
use std::collections::HashMap;
use std::time::{Duration, SystemTime};
use tokio::time::delay_for;
pub struct TriggerManager { pub struct TriggerManager {
http_client: Client, http_client: Client,
@ -16,7 +16,10 @@ pub struct TriggerManager {
} }
fn now() -> u64 { fn now() -> u64 {
SystemTime::now().duration_since(SystemTime::UNIX_EPOCH).unwrap().as_secs() SystemTime::now()
.duration_since(SystemTime::UNIX_EPOCH)
.unwrap()
.as_secs()
} }
fn since(time: u64) -> u64 { fn since(time: u64) -> u64 {
@ -45,9 +48,12 @@ impl TriggerManager {
} }
pub async fn run_triggers(&self) -> Result<(), MainError> { pub async fn run_triggers(&self) -> Result<(), MainError> {
try_join_all(self.triggers.iter().map(|trigger| { try_join_all(
self.run_trigger(trigger) self.triggers
})).await?; .iter()
.map(|trigger| self.run_trigger(trigger)),
)
.await?;
Ok(()) Ok(())
} }
@ -61,7 +67,10 @@ impl TriggerManager {
Ok(Some(edge)) => { Ok(Some(edge)) => {
let elapsed = since(edge); let elapsed = since(edge);
let wait = delay.saturating_sub(elapsed); let wait = delay.saturating_sub(elapsed);
info!("[{}] Found edge, {}s ago, waiting {}s before triggering", trigger.name, elapsed, wait); info!(
"[{}] Found edge, {}s ago, waiting {}s before triggering",
trigger.name, elapsed, wait
);
let wait_delay = Duration::from_secs(wait); let wait_delay = Duration::from_secs(wait);
delay_for(wait_delay).await; delay_for(wait_delay).await;
@ -84,7 +93,10 @@ impl TriggerManager {
} }
} }
Ok(None) => { Ok(None) => {
info!("[{}] No edge found, waiting {}s before looking for new edge", trigger.name, delay); info!(
"[{}] No edge found, waiting {}s before looking for new edge",
trigger.name, delay
);
delay_for(delay_duration).await; delay_for(delay_duration).await;
} }
Err(e) => { Err(e) => {
@ -95,16 +107,31 @@ impl TriggerManager {
} }
} }
async fn get_edge(&self, condition: &Condition, delay: u64) -> Result<Option<u64>, TriggerError> { async fn get_edge(
&self,
condition: &Condition,
delay: u64,
) -> Result<Option<u64>, TriggerError> {
let query = interpolate_params(&condition.query, &condition.params).await?; let query = interpolate_params(&condition.query, &condition.params).await?;
Ok(self.edge_detector.get_last_edge(&query, condition.from, condition.to, Duration::from_secs(delay + 60)).await?) Ok(self
.edge_detector
.get_last_edge(
&query,
condition.from,
condition.to,
Duration::from_secs(delay + 60),
)
.await?)
} }
} }
async fn interpolate_params(input: &str, params: &HashMap<String, Parameter>) -> Result<String, ParameterError> { async fn interpolate_params(
let futures = params.values().map(|definition| { input: &str,
Box::pin(definition.get_value()) params: &HashMap<String, Parameter>,
}); ) -> Result<String, ParameterError> {
let futures = params
.values()
.map(|definition| Box::pin(definition.get_value()));
let resolved_params: Vec<String> = try_join_all(futures).await?; let resolved_params: Vec<String> = try_join_all(futures).await?;
let mut result = input.to_string(); let mut result = input.to_string();
@ -120,13 +147,16 @@ async fn interpolate_params(input: &str, params: &HashMap<String, Parameter>) ->
async fn test_interpolate() { async fn test_interpolate() {
use maplit::hashmap; use maplit::hashmap;
let result = interpolate_params("foo_$param", &hashmap! { let result = interpolate_params(
"foo_$param",
&hashmap! {
"param".to_string() => Parameter::Value{value: "bar".to_string()} "param".to_string() => Parameter::Value{value: "bar".to_string()}
}).await; },
)
.await;
assert_eq!("foo_bar".to_string(), result.unwrap()); assert_eq!("foo_bar".to_string(), result.unwrap());
} }
async fn run_action(action: &Action, client: &Client) -> Result<(), TriggerError> { async fn run_action(action: &Action, client: &Client) -> Result<(), TriggerError> {
let url = interpolate_params(&action.url, &action.params).await?; let url = interpolate_params(&action.url, &action.params).await?;