Git Product home page Git Product logo

rustcap's People

Contributors

ilya-epifanov avatar jmmk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

njeffords

rustcap's Issues

Cannot compile with latest pcap

I am trying to compile this MRE on Windows 11 Pro:

Cargo.toml

[package]
name = "findip"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
pnet = "0.34.0"
rustcap = { version = "0.1.2", features = ["pnet"] }

src/main.rs

use std::str::FromStr;

fn main() {
    println!("{}", discover_address_or_exit("0.0.0.0/0"));
}

#[must_use]
pub fn discover_address_or_exit(network: &str) -> std::net::IpAddr {
    discover_address(pnet::ipnetwork::IpNetwork::from_str(network).unwrap_or_else(|error| {
        eprintln!("{error}");
        std::process::exit(1)
    }))
    .unwrap_or_else(|| {
        eprintln!("No address found");
        std::process::exit(2);
    })
}

#[must_use]
pub fn discover_address(network: pnet::ipnetwork::IpNetwork) -> Option<std::net::IpAddr> {
    for iface in pnet::datalink::interfaces() {
        for ip in iface.ips {
            if network.contains(ip.ip()) {
                return Some(ip.ip());
            }
        }
    }

    None
}

Resulting in this error:

PS C:\Users\Richard Neumann\findip> cargo run
  Downloaded aho-corasick v1.0.3
  Downloaded log v0.4.20
  Downloaded 2 crates (206.7 KB) in 0.64s
   Compiling winapi-build v0.1.1
   Compiling libc v0.2.147
   Compiling memchr v2.5.0
   Compiling proc-macro2 v1.0.66
   Compiling winapi v0.2.8
   Compiling unicode-ident v1.0.11
   Compiling regex-syntax v0.7.4
   Compiling no-std-net v0.6.0
   Compiling log v0.4.20
   Compiling rustc-serialize v0.3.24
   Compiling unicode-xid v0.0.3
   Compiling bitflags v0.5.0
   Compiling pnet_base v0.34.0
   Compiling winapi v0.3.9
   Compiling glob v0.2.11
   Compiling serde v1.0.183
   Compiling kernel32-sys v0.2.2
   Compiling log v0.3.9
   Compiling ws2_32-sys v0.2.1
   Compiling pnet_base v0.21.0
   Compiling pnet_macros_support v0.21.0
   Compiling pkg-config v0.3.27
   Compiling pnet_macros_support v0.34.0
   Compiling ipnetwork v0.12.8
   Compiling pnet v0.21.0
   Compiling quote v1.0.32
   Compiling pnet v0.34.0
   Compiling bitflags v1.3.2
   Compiling syn v2.0.28
   Compiling pcap-sys v0.1.3
   Compiling syntex_pos v0.42.0
   Compiling pnet_sys v0.34.0
   Compiling ipnetwork v0.20.0
   Compiling pnet_datalink v0.34.0
   Compiling aho-corasick v1.0.3
   Compiling regex-automata v0.3.6
   Compiling regex v1.9.3
   Compiling pnet_macros v0.34.0
   Compiling pnet_packet v0.34.0
   Compiling pnet_sys v0.21.0
   Compiling term v0.4.6
   Compiling pnet_datalink v0.21.0
   Compiling syntex_errors v0.42.0
   Compiling syntex_syntax v0.42.0
   Compiling pnet_transport v0.34.0
   Compiling syntex v0.42.2
   Compiling pnet_packet v0.21.0
error[E0425]: cannot find function `register` in crate `pnet_macros`
  --> C:\Users\Richard Neumann\.cargo\registry\src\index.crates.io-6f17d22bba15001f\pnet_packet-0.21.0\build.rs:27:30
   |
27 |                 pnet_macros::register(&mut registry);
   |                              ^^^^^^^^ not found in `pnet_macros`

For more information about this error, try `rustc --explain E0425`.
error: could not compile `pnet_packet` (build script) due to previous error

It seems that register is no longer available in pnet_macros

Static compiling

Hello here,

can you help me, if there is anyway to compile all static ? I just made a test application but even with musl it compiles dynamic:

ldd target/x86_64-unknown-linux-musl/debug/hello_world
linux-vdso.so.1 (0x00007ffc2b15d000)
libpcap.so.0.8 => /usr/lib/x86_64-linux-gnu/libpcap.so.0.8 (0x00007f3596cb9000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f359691a000)
/lib/ld64.so.1 => /lib64/ld-linux-x86-64.so.2 (0x00007f3596efb000)

How to tell the rustcap or what should I set in the Cargo.toml to compile it static ?

[package]
name = "hello_world"
version = "0.0.1"
authors = [ "Your name <[email protected]>" ]

[build]
target = "x86_64-unknown-linux-musl"

[dependencies.rustcap]
version = "0.1.2"
feature = "static-libpcap"

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.