mirror of
https://github.com/librespot-org/librespot.git
synced 2025-10-05 19:42:03 +02:00
First working version of protocol handshake.
Key exchange and authentication is functional. Protocol definition has been moved to separate crate to speed up build time. Various cleanups. Take login info from command line, rather than hardcoded.
This commit is contained in:
parent
15f39607e7
commit
1ad62e6f18
19 changed files with 821 additions and 290 deletions
45
protocol/build.rs
Normal file
45
protocol/build.rs
Normal file
|
@ -0,0 +1,45 @@
|
|||
use std::env;
|
||||
use std::process::{Command, Stdio};
|
||||
use std::path::{Path,PathBuf};
|
||||
|
||||
#[derive(Debug)]
|
||||
enum ProtobufError {
|
||||
IoError(::std::io::Error),
|
||||
Other
|
||||
}
|
||||
|
||||
impl std::convert::From<::std::io::Error> for ProtobufError {
|
||||
fn from(e: ::std::io::Error) -> ProtobufError {
|
||||
ProtobufError::IoError(e)
|
||||
}
|
||||
}
|
||||
|
||||
fn compile(prefix : &Path, files : &[&Path]) -> Result<(),ProtobufError>{
|
||||
let mut c = Command::new("protoc");
|
||||
c.arg("--rust_out").arg(env::var("OUT_DIR").unwrap())
|
||||
.arg("--proto_path").arg(prefix.to_str().unwrap());
|
||||
|
||||
for f in files.iter() {
|
||||
c.arg(f.to_str().unwrap());
|
||||
}
|
||||
|
||||
//c.stdout(Stdio::inherit());
|
||||
c.stderr(Stdio::inherit());
|
||||
|
||||
let mut p = try!(c.spawn());
|
||||
let r = try!(p.wait());
|
||||
return match r.success() {
|
||||
true => Ok(()),
|
||||
false => Err(ProtobufError::Other),
|
||||
};
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let root = PathBuf::from(&env::var("CARGO_MANIFEST_DIR").unwrap());
|
||||
let proto = root.join("proto");
|
||||
compile(&proto, &[
|
||||
&proto.join("keyexchange.proto"),
|
||||
&proto.join("authentication.proto")
|
||||
]).unwrap();
|
||||
}
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue