Skip to content

Commit

Permalink
Initial commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
plietar committed Apr 25, 2015
0 parents commit a993b60
Show file tree
Hide file tree
Showing 17 changed files with 872 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
target
Cargo.lock
.cargo
107 changes: 107 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 28 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
[package]
name = "librespot"
version = "0.1.0"
authors = ["Paul Liétar <paul@lietar.net>"]
build = "build.rs"
links = "gmp"

#[[bin]]
#name = "librespot"
#path = "src/main.rs"

[dependencies]
mod_path = "*"
byteorder = "*"
num = "*"
rand = "*"
lazy_static = "0.1.*"
rust-crypto = "*"

[dependencies.protobuf]
git = "https://github.com/plietar/rust-protobuf.git"

[dependencies.protobuf_macros]
git = "https://github.com/plietar/rust-protobuf-macros.git"

[dependencies.rust-gmp]
git = "https://github.com/plietar/rust-gmp.git"

21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2015 Paul Lietar

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
43 changes: 43 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
use std::env;
use std::process::{Command, Stdio};
use std::path::Path;

#[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 prefix = Path::new("protocol");
compile(&prefix, &[
&prefix.join("keyexchange.proto"),
&prefix.join("authentication.proto")
]).unwrap();
}

51 changes: 51 additions & 0 deletions protocol/authentication.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
message AuthRequest {
enum LoginMethod {
PASSWORD = 0x0;
TOKEN = 0x3;
}

message Credentials {
optional string username = 0x0a;
required LoginMethod method = 0x14;
required bytes password = 0x1e;
}
required Credentials credentials = 0x0a;

message Data1 {
required uint32 data0 = 0x0a;
required uint32 data1 = 0x3c;
required string partner = 0x5a; // "Partner %s %s;%s" % ("lenbrook_bluesound", brand, model)
required string deviceid = 0x64; // sha1(os_device_id).hexdigest()
}
required Data1 data1 = 0x32;

required string version = 0x46;

message Data3 {
required uint32 data0 = 0x01;
required bytes appkey1 = 0x02;
required bytes appkey2 = 0x03;
required string data3 = 0x04;
required bytes data4 = 0x05;
}
required Data3 data3 = 0x50;
}

message AuthSuccess {
required string username = 0x0a;
required uint32 data1 = 0x14;
required uint32 data2 = 0x19;
required uint32 data3 = 0x1e;
required bytes data4 = 0x28;
required bytes data5 = 0x32;
}

message AuthFailure {
required uint32 code = 0x0a;
required Data1 data1 = 0x32;

message Data1 {
required string data0 = 0x01;
}
}

61 changes: 61 additions & 0 deletions protocol/keyexchange.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
message Request {
message Data0 {
required uint32 data0 = 0x0a; // 05
required uint32 data1 = 0x1e; // 02
required uint64 data2 = 0x28; // 10800000000
}

message Data2 {
message Data0 {
required bytes data0 = 0x0a; // 60
required uint32 data1 = 0x14; // 01
}
required Data0 data0 = 0x0a; // 65
}

required Data0 data0 = 0x0a; // 0d
required uint32 data1 = 0x1e; // 00
required Data2 data2 = 0x32; // 67
required bytes random = 0x3c; // 10
required bytes data4 = 0x46; // 01
required bytes data5 = 0x50; // 02

}

message Response {
message Data {
message Data0 {
message Data0 {
required bytes data0 = 0x0a; // 60
required uint32 data1 = 0x14;
required bytes data2 = 0x1e; // 100
}
required Data0 data0 = 0x0a;
}
message Data3 {
required bytes data0 = 0x0a;
}

required Data0 data0 = 0x0a;
required bytes data1 = 0x14;
required bytes data2 = 0x1e;
required Data3 data3 = 0x28;
required bytes data4 = 0x32;
required bytes data5 = 0x3c;
}

required Data data = 0x0a;
}

message ChallengePacket {
message Data0 {
message Data0 {
required bytes data0 = 0x0a;
}
required Data0 data0 = 0x0a;
}
required Data0 data0 = 0x0a;
required bytes data1 = 0x14;
required bytes data2 = 0x1e;
}

49 changes: 49 additions & 0 deletions protocol/mercury.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
message MercuryRequest {
required string url = 0x01;
optional string mime = 0x02;
required string method = 0x03;
}

message MercuryReply {
required string url = 0x01;
required string mime = 0x02;
required sint32 code = 0x04;
repeated Header header = 0x06;

message Header {
required string key = 0x01;
required bytes value = 0x02;
}
}

message MercuryGetRequest {
required string url = 0x01;
optional string method = 0x03;
}

message MercuryMultiGetRequest {
repeated MercuryGetRequest request = 0x01;
}

message MercuryGetReply {
enum CachePolicy {
CACHE_NO = 1;
CACHE_PRIVATE = 2;
CACHE_PUBLIC = 3;
}
optional sint32 code = 0x01;
optional CachePolicy cache_policy = 0x03;
optional uint32 ttl = 0x04;
optional bytes etag = 0x05;
optional string mime = 0x06;
optional bytes body = 0x07;
}

message MercuryMultiGetReply {
repeated MercuryGetReply reply = 0x1;
}

message MercurySubscribed {
required string url = 0x1;
}

Loading

0 comments on commit a993b60

Please sign in to comment.