diff --git a/.travis.yml b/.travis.yml index 9ea4350..b011330 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,3 +1,5 @@ +language: rust + addons: apt: packages: @@ -5,7 +7,7 @@ addons: - libcurl4-openssl-dev - libelf-dev - libdw-dev -language: rust + - libudev-dev rust: - nightly - beta @@ -20,24 +22,19 @@ matrix: allow_failures: - rust: beta - rust: nightly -cache: - apt: true - rust-download: true - directories: - - $TRAVIS_BUILD_DIR/target - - ~/.cargo notifications: email: on_success: never -# This requires the old travis -#after_success: | -# wget https://github.com/SimonKagstrom/kcov/archive/master.tar.gz && -# tar xzf master.tar.gz && -# mkdir kcov-master/build && -# cd kcov-master/build && -# cmake .. && -# make && -# sudo make install && -# cd ../.. && -# kcov --coveralls-id=$TRAVIS_JOB_ID --exclude-pattern=/.cargo target/kcov target/debug/decode_ceph--*; +before_script: + - pip install 'travis-cargo<0.2' --user && export PATH=$HOME/.local/bin:$PATH + +script: + - | + travis-cargo build && + travis-cargo test + +after_success: + - travis-cargo coveralls --no-sudo + +sudo: false diff --git a/Cargo.lock b/Cargo.lock index b6c7517..101def5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -47,7 +47,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "ceph" version = "0.3.2" -source = "git+https://github.com/ChrisMacNaughton/ceph-rs.git#b7479558035d0a11bb1037800a01e3e72f532298" +source = "git+https://github.com/ChrisMacNaughton/ceph-rs.git#7c86e718746198755978bd0b06899f80ac18c80d" dependencies = [ "bitflags 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -55,9 +55,9 @@ dependencies = [ "enum_primitive 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", "nom 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "num 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", + "num 0.1.30 (registry+https://github.com/rust-lang/crates.io-index)", "pcap 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.3.12 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)", "regex 0.1.46 (registry+https://github.com/rust-lang/crates.io-index)", "rust-crypto 0.2.34 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)", @@ -108,7 +108,7 @@ name = "enum_primitive" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "num 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", + "num 0.1.30 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -237,10 +237,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "num" -version = "0.1.29" +version = "0.1.30" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "rand 0.3.12 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -309,7 +309,7 @@ dependencies = [ [[package]] name = "rand" -version = "0.3.12" +version = "0.3.13" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "advapi32-sys 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -339,7 +339,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "gcc 0.3.21 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.3.12 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.34 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -367,7 +367,7 @@ name = "serde" version = "0.6.7" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "num 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", + "num 0.1.30 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -398,7 +398,7 @@ name = "tempdir" version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "rand 0.3.12 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -461,7 +461,7 @@ name = "uuid" version = "0.1.18" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "rand 0.3.12 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)", ] diff --git a/src/main.rs b/src/main.rs index 247e4e3..76332f4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -10,11 +10,6 @@ extern crate time; extern crate users; use ceph::sniffer::*; -// use ceph::sniffer::serial::*; -// use ceph::sniffer::crypto::*; -// use ceph::sniffer::mon_decode::*; -// use ceph::sniffer::common_decode::*; -// use ceph::sniffer::osd_decode::*; use pcap::{Capture, Device}; @@ -32,40 +27,36 @@ use output_args::*; mod tests{ extern crate output_args; extern crate pcap; + extern crate log; - // use std::io::Cursor; - // use std::net::Ipv4Addr; use std::path::Path; use pcap::Capture; - // use output_args::*; - // use super::serial; + use super::ceph::sniffer::*; #[test] fn test_pcap_parsing(){ - // let args = output_args::Args { - // carbon: None, - // elasticsearch: None, - // stdout: Some("stdout".to_string()), - // influx: None, - // outputs: vec!["elasticsearch".to_string(), "carbon".to_string(), "stdout".to_string()], - // config_path: "".to_string(), - // log_level: log::LogLevel::Info - // }; + let args = output_args::Args { + carbon: None, + elasticsearch: None, + stdout: Some("stdout".to_string()), + influx: None, + outputs: vec!["stdout".to_string()], + config_path: "".to_string(), + log_level: log::LogLevel::Info + }; //Set the cursor so the parsing doesn't fail let mut cap = Capture::from_file(Path::new("ceph.pcap")).unwrap(); - /* + //We received a packet while let Ok(packet) = cap.next() { match serial::parse_ceph_packet(&packet.data) { - nom::IResult::Done(_, result) => { - println!("logging {:?}", result); - // let _ = super::process_packet(&result.header, &result.ceph_message, &args); + Some(result) => { + trace!("logging {:?}", result); + let _ = super::process_packet(&result.header, &result.ceph_message, &args); }, - nom::IResult::Incomplete(i) => println!("Incomplete: {:?}: {:?}", i, packet), - nom::IResult::Error(e) => println!("Error parsing; {:?}", e), - // _ => trace!("Error while parsing packet") - } + _ => {}, + }; + // break } - */ } } @@ -244,7 +235,7 @@ fn log_msg_to_influx(header: &serial::PacketHeader, msg: &serial::Message, outpu let client = create_client(credentials, hosts); let src_addr = header.src_addr.ip_address(); - + let dst_addr = header.dst_addr.ip_address(); let _ = match *msg{