use dns-sd instead of mdns for discovery

This commit is contained in:
awiouy 2018-01-26 19:35:21 +01:00
parent a82af966b4
commit 0eec0bd170
4 changed files with 22 additions and 30 deletions

29
Cargo.lock generated
View file

@ -106,6 +106,15 @@ dependencies = [
"quick-error 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "quick-error 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]]
name = "dns-sd"
version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)",
"pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]] [[package]]
name = "dtoa" name = "dtoa"
version = "0.4.2" version = "0.4.2"
@ -283,7 +292,7 @@ dependencies = [
"librespot-metadata 0.1.0", "librespot-metadata 0.1.0",
"librespot-protocol 0.1.0", "librespot-protocol 0.1.0",
"log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
"mdns 0.2.0 (git+https://github.com/plietar/rust-mdns)", "dns-sd 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"num-bigint 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)", "num-bigint 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)",
"portaudio-rs 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "portaudio-rs 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"protobuf 1.4.3 (registry+https://github.com/rust-lang/crates.io-index)", "protobuf 1.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
@ -395,23 +404,6 @@ name = "matches"
version = "0.1.6" version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "mdns"
version = "0.2.0"
source = "git+https://github.com/plietar/rust-mdns#c0fc73502d7d752a4ffeb5268a017561405e218c"
dependencies = [
"byteorder 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"dns-parser 0.3.2 (git+https://github.com/plietar/dns-parser)",
"futures 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
"multimap 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"net2 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)",
"nix 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.3.20 (registry+https://github.com/rust-lang/crates.io-index)",
"tokio-core 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]] [[package]]
name = "memchr" name = "memchr"
version = "2.0.1" version = "2.0.1"
@ -1134,7 +1126,6 @@ dependencies = [
"checksum log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "e19e8d5c34a3e0e2223db8e060f9e8264aeeb5c5fc64a4ee9965c062211c024b" "checksum log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "e19e8d5c34a3e0e2223db8e060f9e8264aeeb5c5fc64a4ee9965c062211c024b"
"checksum log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "89f010e843f2b1a31dbd316b3b8d443758bc634bed37aabade59c686d644e0a2" "checksum log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "89f010e843f2b1a31dbd316b3b8d443758bc634bed37aabade59c686d644e0a2"
"checksum matches 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "100aabe6b8ff4e4a7e32c1c13523379802df0772b82466207ac25b013f193376" "checksum matches 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "100aabe6b8ff4e4a7e32c1c13523379802df0772b82466207ac25b013f193376"
"checksum mdns 0.2.0 (git+https://github.com/plietar/rust-mdns)" = "<none>"
"checksum memchr 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "796fba70e76612589ed2ce7f45282f5af869e0fdd7cc6199fa1aa1f1d591ba9d" "checksum memchr 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "796fba70e76612589ed2ce7f45282f5af869e0fdd7cc6199fa1aa1f1d591ba9d"
"checksum mime 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "e2e00e17be181010a91dbfefb01660b17311059dc8c7f48b9017677721e732bd" "checksum mime 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "e2e00e17be181010a91dbfefb01660b17311059dc8c7f48b9017677721e732bd"
"checksum mio 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)" = "75f72a93f046f1517e3cfddc0a096eb756a2ba727d36edc8227dee769a50a9b0" "checksum mio 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)" = "75f72a93f046f1517e3cfddc0a096eb756a2ba727d36edc8227dee769a50a9b0"

View file

@ -36,7 +36,7 @@ futures = "0.1.8"
getopts = "0.2.14" getopts = "0.2.14"
hyper = "0.11.2" hyper = "0.11.2"
log = "0.3.5" log = "0.3.5"
mdns = { git = "https://github.com/plietar/rust-mdns" } dns-sd = "0.1.3"
num-bigint = "0.1.35" num-bigint = "0.1.35"
protobuf = "1.1" protobuf = "1.1"
rand = "0.3.13" rand = "0.3.13"

View file

@ -6,7 +6,7 @@ use futures::sync::mpsc;
use futures::{Future, Stream, Poll}; use futures::{Future, Stream, Poll};
use hyper::server::{Service, Request, Response, Http}; use hyper::server::{Service, Request, Response, Http};
use hyper::{self, Get, Post, StatusCode}; use hyper::{self, Get, Post, StatusCode};
use mdns; use dns_sd::DNSService;
use num_bigint::BigUint; use num_bigint::BigUint;
use rand; use rand;
use std::collections::BTreeMap; use std::collections::BTreeMap;
@ -191,7 +191,7 @@ impl Service for Discovery {
pub struct DiscoveryStream { pub struct DiscoveryStream {
credentials: mpsc::UnboundedReceiver<Credentials>, credentials: mpsc::UnboundedReceiver<Credentials>,
_svc: mdns::Service, _svc: DNSService,
} }
pub fn discovery(handle: &Handle, config: ConnectConfig, device_id: String) pub fn discovery(handle: &Handle, config: ConnectConfig, device_id: String)
@ -203,7 +203,7 @@ pub fn discovery(handle: &Handle, config: ConnectConfig, device_id: String)
let http = Http::new(); let http = Http::new();
http.serve_addr_handle(&"0.0.0.0:0".parse().unwrap(), &handle, move || Ok(discovery.clone())).unwrap() http.serve_addr_handle(&"0.0.0.0:0".parse().unwrap(), &handle, move || Ok(discovery.clone())).unwrap()
}; };
let addr = serve.incoming_ref().local_addr(); let port = serve.incoming_ref().local_addr().port();
let server_future = { let server_future = {
let handle = handle.clone(); let handle = handle.clone();
serve.for_each(move |connection| { serve.for_each(move |connection| {
@ -214,12 +214,13 @@ pub fn discovery(handle: &Handle, config: ConnectConfig, device_id: String)
}; };
handle.spawn(server_future); handle.spawn(server_future);
let responder = mdns::Responder::spawn(&handle)?; let svc = DNSService::register(Some(&*config.name),
let svc = responder.register( "_spotify-connect._tcp",
"_spotify-connect._tcp".to_owned(), None,
config.name, None,
addr.port(), port,
&["VERSION=1.0", "CPath=/"]); &["VERSION=1.0", "CPath=/"])
.unwrap();
Ok(DiscoveryStream { Ok(DiscoveryStream {
credentials: creds_rx, credentials: creds_rx,

View file

@ -10,7 +10,7 @@ extern crate base64;
extern crate crypto; extern crate crypto;
extern crate futures; extern crate futures;
extern crate hyper; extern crate hyper;
extern crate mdns; extern crate dns_sd;
extern crate num_bigint; extern crate num_bigint;
extern crate protobuf; extern crate protobuf;
extern crate rand; extern crate rand;