Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

provide better examples #5

Open
dvc94ch opened this issue May 9, 2021 · 0 comments
Open

provide better examples #5

dvc94ch opened this issue May 9, 2021 · 0 comments

Comments

@dvc94ch
Copy link

dvc94ch commented May 9, 2021

compiled all the tools pcap-analyzer test-analyzer etc. but not much happens when running them on a pcap file (other than displaying some simple stats about the pcap file itself).

Maybe something like this would be helpful to get started:

use anyhow::Result;
use libpcap_analyzer::{Analyzer, PluginRegistry};
use libpcap_analyzer::plugins::flows::FlowsInfo;
use libpcap_tools::{Config, PcapDataEngine, PcapEngine};
use std::fs::File;
use std::sync::{Arc, Mutex};

fn main() -> Result<()> {
    env_logger::init();
    let config = Config::default();
    let mut registry = PluginRegistry::new();
    let flows = Arc::new(Mutex::new(FlowsInfo::default()));
    registry.add_plugin(flows.clone());
    let analyzer = Analyzer::new(Arc::new(registry), &config);
    let mut engine = PcapDataEngine::new(analyzer, &config);
    let mut f = File::open("/home/dvc/ipld/quinn-noise-dissector/libp2p-quic.pcap")?;
    engine.run(&mut f)?;
    let json = flows.lock().unwrap().get_results_json();
    println!("{}", serde_json::to_string(&json)?);
    Ok(())
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant