Code Monkey home page Code Monkey logo

netdev's Introduction

shellrow

Languages and Tools

rust cplusplus csharp mssql mysql python

Stats

shellrow's GitHub stats

Support

ko-fi "Buy Me A Coffee"

netdev's People

Contributors

brainplot avatar dignifiedquire avatar flub avatar kingtous avatar link2xt avatar shellrow avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

netdev's Issues

Ideally `get_interfaces()` should return an `Iterator`

Returning some iterator type instead of the whole Vec directly would allow consumers to have more control over how memory is allocated.

This, however, would be a pretty major breaking change in the public API. If you agree with this change, I can attempt writing a PR.

Panic on macOS

Encountered this recently, unclear what exactly is going wrong, but sth doesn't seem to always work out.

thread 'main-runtime' panicked at 'assertion failed: `(left == right)`
  left: `0`,
 right: `5`', /Users/b5/.cargo/registry/src/index.crates.io-6f17d22bba15001f/default-net-0.16.2/src/gateway/macos.rs:293:9
stack backtrace:
   0: rust_begin_unwind
             at /rustc/5680fa18feaa87f3ff04063800aec256c3d4b4be/library/std/src/panicking.rs:593:5
   1: core::panicking::panic_fmt
             at /rustc/5680fa18feaa87f3ff04063800aec256c3d4b4be/library/core/src/panicking.rs:67:14
   2: core::panicking::assert_failed_inner
   3: core::panicking::assert_failed
             at /rustc/5680fa18feaa87f3ff04063800aec256c3d4b4be/library/core/src/panicking.rs:229:5
   4: default_net::gateway::macos::list_routes
             at /Users/b5/.cargo/registry/src/index.crates.io-6f17d22bba15001f/default-net-0.16.2/src/gateway/macos.rs:293:9
   5: default_net::gateway::macos::get_default_route
             at /Users/b5/.cargo/registry/src/index.crates.io-6f17d22bba15001f/default-net-0.16.2/src/gateway/macos.rs:412:11
   6: default_net::gateway::macos::get_default_gateway
             at /Users/b5/.cargo/registry/src/index.crates.io-6f17d22bba15001f/default-net-0.16.2/src/gateway/macos.rs:431:26
   7: default_net::interface::unix::interfaces
             at /Users/b5/.cargo/registry/src/index.crates.io-6f17d22bba15001f/default-net-0.16.2/src/interface/unix.rs:63:27
   8: iroh_net::net::interfaces::State::new::{{closure}}
             at ./iroh-net/src/net/interfaces.rs:194:22
   9: iroh_net::netcheck::reportgen::Actor::prepare_probes_task::{{closure}}
             at ./iroh-net/src/netcheck/reportgen.rs:570:49
  10: iroh_net::netcheck::reportgen::Actor::run_inner::{{closure}}
             at ./iroh-net/src/netcheck/reportgen.rs:236:53
  11: iroh_net::netcheck::reportgen::Actor::run::{{closure}}
             at ./iroh-net/src/netcheck/reportgen.rs:201:32
  12: iroh_net::netcheck::reportgen::Client::new::{{closure}}
             at ./iroh-net/src/netcheck/reportgen.rs:116:38
  13: <tracing::instrument::Instrumented<T> as core::future::future::Future>::poll
             at /Users/b5/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tracing-0.1.37/src/instrument.rs:272:9
  14: tokio::runtime::task::core::Core<T,S>::poll::{{closure}}
             at /Users/b5/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.32.0/src/runtime/task/core.rs:334:17
  15: tokio::loom::std::unsafe_cell::UnsafeCell<T>::with_mut
             at /Users/b5/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.32.0/src/loom/std/unsafe_cell.rs:16:9
  16: tokio::runtime::task::core::Core<T,S>::poll
             at /Users/b5/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.32.0/src/runtime/task/core.rs:323:13
  17: tokio::runtime::task::harness::poll_future::{{closure}}
             at /Users/b5/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.32.0/src/runtime/task/harness.rs:485:19
  18: <core::panic::unwind_safe::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
             at /rustc/5680fa18feaa87f3ff04063800aec256c3d4b4be/library/core/src/panic/unwind_safe.rs:271:9
  19: std::panicking::try::do_call
             at /rustc/5680fa18feaa87f3ff04063800aec256c3d4b4be/library/std/src/panicking.rs:500:40
  20: std::panicking::try
             at /rustc/5680fa18feaa87f3ff04063800aec256c3d4b4be/library/std/src/panicking.rs:464:19
  21: std::panic::catch_unwind
             at /rustc/5680fa18feaa87f3ff04063800aec256c3d4b4be/library/std/src/panic.rs:142:14
  22: tokio::runtime::task::harness::poll_future
             at /Users/b5/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.32.0/src/runtime/task/harness.rs:473:18
  23: tokio::runtime::task::harness::Harness<T,S>::poll_inner
             at /Users/b5/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.32.0/src/runtime/task/harness.rs:208:27
  24: tokio::runtime::task::harness::Harness<T,S>::poll
             at /Users/b5/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.32.0/src/runtime/task/harness.rs:153:15
  25: tokio::runtime::task::raw::RawTask::poll
             at /Users/b5/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.32.0/src/runtime/task/raw.rs:200:18
  26: tokio::runtime::task::LocalNotified<S>::run
             at /Users/b5/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.32.0/src/runtime/task/mod.rs:400:9
  27: tokio::runtime::scheduler::multi_thread::worker::Context::run_task::{{closure}}
             at /Users/b5/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.32.0/src/runtime/scheduler/multi_thread/worker.rs:639:22
  28: tokio::runtime::coop::with_budget
             at /Users/b5/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.32.0/src/runtime/coop.rs:107:5
  29: tokio::runtime::coop::budget
             at /Users/b5/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.32.0/src/runtime/coop.rs:73:5
  30: tokio::runtime::scheduler::multi_thread::worker::Context::run_task
             at /Users/b5/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.32.0/src/runtime/scheduler/multi_thread/worker.rs:575:9
  31: tokio::runtime::scheduler::multi_thread::worker::Context::run
             at /Users/b5/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.32.0/src/runtime/scheduler/multi_thread/worker.rs:526:24
  32: tokio::runtime::scheduler::multi_thread::worker::run::{{closure}}::{{closure}}
             at /Users/b5/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.32.0/src/runtime/scheduler/multi_thread/worker.rs:491:21
  33: tokio::runtime::context::scoped::Scoped<T>::set
             at /Users/b5/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.32.0/src/runtime/context/scoped.rs:40:9
  34: tokio::runtime::context::set_scheduler::{{closure}}
             at /Users/b5/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.32.0/src/runtime/context.rs:176:26
  35: std::thread::local::LocalKey<T>::try_with
             at /rustc/5680fa18feaa87f3ff04063800aec256c3d4b4be/library/std/src/thread/local.rs:270:16
  36: std::thread::local::LocalKey<T>::with
             at /rustc/5680fa18feaa87f3ff04063800aec256c3d4b4be/library/std/src/thread/local.rs:246:9
  37: tokio::runtime::context::set_scheduler
             at /Users/b5/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.32.0/src/runtime/context.rs:176:17
  38: tokio::runtime::scheduler::multi_thread::worker::run::{{closure}}
             at /Users/b5/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.32.0/src/runtime/scheduler/multi_thread/worker.rs:486:9
  39: tokio::runtime::context::runtime::enter_runtime
             at /Users/b5/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.32.0/src/runtime/context/runtime.rs:65:16
  40: tokio::runtime::scheduler::multi_thread::worker::run
             at /Users/b5/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.32.0/src/runtime/scheduler/multi_thread/worker.rs:478:5
  41: tokio::runtime::scheduler::multi_thread::worker::Launch::launch::{{closure}}
             at /Users/b5/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.32.0/src/runtime/scheduler/multi_thread/worker.rs:447:45
  42: <tokio::runtime::blocking::task::BlockingTask<T> as core::future::future::Future>::poll
             at /Users/b5/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.32.0/src/runtime/blocking/task.rs:42:21
  43: tokio::runtime::task::core::Core<T,S>::poll::{{closure}}
             at /Users/b5/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.32.0/src/runtime/task/core.rs:334:17
  44: tokio::loom::std::unsafe_cell::UnsafeCell<T>::with_mut
             at /Users/b5/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.32.0/src/loom/std/unsafe_cell.rs:16:9
  45: tokio::runtime::task::core::Core<T,S>::poll
             at /Users/b5/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.32.0/src/runtime/task/core.rs:323:13
  46: tokio::runtime::task::harness::poll_future::{{closure}}
             at /Users/b5/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.32.0/src/runtime/task/harness.rs:485:19
  47: <core::panic::unwind_safe::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
             at /rustc/5680fa18feaa87f3ff04063800aec256c3d4b4be/library/core/src/panic/unwind_safe.rs:271:9
  48: std::panicking::try::do_call
             at /rustc/5680fa18feaa87f3ff04063800aec256c3d4b4be/library/std/src/panicking.rs:500:40
  49: std::panicking::try
             at /rustc/5680fa18feaa87f3ff04063800aec256c3d4b4be/library/std/src/panicking.rs:464:19
  50: std::panic::catch_unwind
             at /rustc/5680fa18feaa87f3ff04063800aec256c3d4b4be/library/std/src/panic.rs:142:14
  51: tokio::runtime::task::harness::poll_future
             at /Users/b5/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.32.0/src/runtime/task/harness.rs:473:18
  52: tokio::runtime::task::harness::Harness<T,S>::poll_inner
             at /Users/b5/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.32.0/src/runtime/task/harness.rs:208:27
  53: tokio::runtime::task::harness::Harness<T,S>::poll
             at /Users/b5/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.32.0/src/runtime/task/harness.rs:153:15
  54: tokio::runtime::task::raw::RawTask::poll
             at /Users/b5/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.32.0/src/runtime/task/raw.rs:200:18
  55: tokio::runtime::task::UnownedTask<S>::run
             at /Users/b5/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.32.0/src/runtime/task/mod.rs:437:9
  56: tokio::runtime::blocking::pool::Task::run
             at /Users/b5/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.32.0/src/runtime/blocking/pool.rs:159:9
  57: tokio::runtime::blocking::pool::Inner::run
             at /Users/b5/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.32.0/src/runtime/blocking/pool.rs:513:17
  58: tokio::runtime::blocking::pool::Spawner::spawn_thread::{{closure}}
             at /Users/b5/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.32.0/src/runtime/blocking/pool.rs:471:13
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

First reported in n0-computer/iroh#1442

Announcement: Rebranding to netdev

About Rebranding

default-net is going to be rebranded as netdev starting from v0.23.0.
This rebranding reflects our commitment for future expansion, continuation, and better alignment with naming conventions.

As a part of this transition, v0.22.0 will be the final release under the default-net name.
All subsequent releases will be under the netdev name.

This rebranding will better align the library with its functionality and future development plans.
Thank you for your continued support and we look forward to bringing you more updates under the netdev brand.

Thank you.

Related release

default-net final release v0.22.0 changes

  • Notice for users. (Mainly for crates.io README)

netdev v0.23.0 changes

  • Support IPv6 gateway (route)
  • Support DNS Server
  • Support friendly_name for macOS
  • Replace Gateway to NetworkDevice
  • Fix MacOS bug in get route info
  • Some refactoring

Default Gateway not found on macos

Default gateway detection doesn't seem to work on macos, it fails with "Default Gateway not found" for me when calling
default_net::get_default_gateway().

Unexpected behaviour when no gateway is set

Tested on (raspbian) Linux.

Steps to reproduce:

  • Have a pi running on 192.168.1.101. In this case, file /etc/dhcpcd.conf (note this ends with cd.conf) contains a section,
interface wlan0
static ip_address=192.168.1.101
static routers=192.168.1.1
static domain_name_servers=8.8.8.8
static domain_search=

interface eth0
static ip_address=192.168.1.101
static routers=192.168.1.1
static domain_name_servers=8.8.8.8
static domain_search=
  • compile and run the example code
    This gives the following output, as expected:
Default Interface
	Index: 2
	Name: eth0
	Friendly Name: None
	Description: None
	Type: Ethernet
	MAC: e2:5f:21:41:11:b2
	IPv4: [Ipv4Net { addr: 192.168.1.101, prefix_len: 24, netmask: 255.255.255.0 }]
	IPv6: [Ipv6Net { addr: fe80::217f:fa11:4a86:38fa, prefix_len: 64, netmask: ffff:ffff:ffff:ffff:: }]
	Flags: 69699
	Transmit Speed: Some(1000000000)
	Receive Speed: Some(1000000000)
Default Gateway
	MAC: 8c:59:73:65:ba:d8
	IP: 192.168.1.1
  • Now we edit the above section to read,
interface eth0
static ip_address=192.168.1.101
static routers=
static domain_name_servers=
static domain_search=

(the wlan interface is removed altogether).
We then reboot the pi. The above is intended to create an air-gapped network environment.

Running the code again results in

Default Interface
	Index: 7
	Name: vethc3d719f
	Friendly Name: None
	Description: None
	Type: Ethernet
	MAC: 56:12:1f:7d:6f:98
	IPv4: [Ipv4Net { addr: 169.254.125.86, prefix_len: 16, netmask: 255.255.0.0 }]
	IPv6: [Ipv6Net { addr: fe80::e330:9b42:1990:d81a, prefix_len: 64, netmask: ffff:ffff:ffff:ffff:: }]
	Flags: 69699
	Transmit Speed: Some(10000000000)
	Receive Speed: Some(10000000000)
Default Gateway: (Not found)

While the transmit/receive speed of this interface is reportedly higher than eth0/wlan0, it's a virtual device (pointing to master br-ef67...49):

5: br-ef6764190849: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default 
    link/ether 02:32:16:c3:bd:6b brd ff:ff:ff:ff:ff:ff
    inet 172.19.0.1/16 brd 172.19.255.255 scope global br-ef6764190849
       valid_lft forever preferred_lft forever
    inet6 fe80::42:c6ff:fec3:ad6b/64 scope link 
       valid_lft forever preferred_lft forever
7: veth06ee6be@if6: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master br-ef6764190849 state UP group default 
    link/ether 5e:b1:24:aa:38:cf brd ff:ff:ff:ff:ff:ff link-netnsid 0
    inet 169.254.243.193/16 brd 169.254.255.255 scope global noprefixroute veth06ee6be
       valid_lft forever preferred_lft forever
    inet6 fe80::5cb1:14ff:fea8:f8cf/64 scope link 
       valid_lft forever preferred_lft forever

In the pi's GUI I have disabled all interfaces but eth0.
/etc/interfaces points to /etc/itnerfaces.d/ which is empty.
On login I get

Wi-Fi is currently blocked by rfkill.
Use raspi-config to set the country before use.

showing that the wlan interface has been switched off.

The actual hardware devices eth0, having been assigned 192.168.1.101, is still available for LAN traffic, however. What could be the reason it is not chosen as default once the gateway has been removed?

a strange bug?

sorry to bother you.
my environment:

Windows 11 21H2 22000.493
rustup 1.24.3 (ce5817a94 2021-05-31)
info: This is the version for the rustup toolchain manager, not the rustc compiler.
info: The currently active rustc version is rustc 1.58.1 (db9d1b20b 2022-01-20)
vscode
China mainland with proxy software.

detail:
when compiling my project, i find a strange bug from your project.
my code [example]:
mycode
always show:
error display
and I found your project level by level finally.
the code which may have problem in my PC as follows. but i can't find a problem.

OK:
图片
Failed:
图片

i change the "1.1.1.1:80" to other ip which is not polluted by gov, still compile failed.

Packet.lib needed

Compile fails if Packet.lib is not in library path. There may be other issues compiling the example. Please expand the Readme as necessary to compile on clean system. I will create a pull request if I figure it out on my own.

FYI Winpcap has ceased development so if the Packet.lib is from winpcap perhaps we need to look to a different library.

Thank you for the library.
Paul

Here is the error message I received when compiling.
= note: "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.29.30037\bin\HostX64\x64\link.exe" "/NOLOGO" "C:\Users\paul\Source\rust\netinfo\target\debug\deps\netinfo.1igodiqjgaoawuu9.rcgu.o" "C:\Users\paul\Source\rust\netinfo\target\debug\deps\netinfo.1pg9t9ql7fg0osqp.rcgu.o" "C:\Users\paul\Source\rust\netinfo\target\debug\deps\netinfo.2kw316jmo9acqzp1.rcgu.o" "C:\Users\paul\Source\rust\netinfo\target\debug\deps\netinfo.3aa76zcs7j6jo6kg.rcgu.o" "C:\Users\paul\Source\rust\netinfo\target\debug\deps\netinfo.40r240ybsdb7b1fl.rcgu.o" "C:\Users\paul\Source\rust\netinfo\target\debug\deps\netinfo.42991ni7oufsb6db.rcgu.o" "C:\Users\paul\Source\rust\netinfo\target\debug\deps\netinfo.4bfrclxrkvhnm0ab.rcgu.o" "C:\Users\paul\Source\rust\netinfo\target\debug\deps\netinfo.4em406slwu7ocilq.rcgu.o" "C:\Users\paul\Source\rust\netinfo\target\debug\deps\netinfo.4rfbv62pj6vvcywp.rcgu.o" "C:\Users\paul\Source\rust\netinfo\target\debug\deps\netinfo.hqg58zfik31b434.rcgu.o" "C:\Users\paul\Source\rust\netinfo\target\debug\deps\netinfo.429h0472lilcpk60.rcgu.o" "/LIBPATH:C:\Users\paul\Source\rust\netinfo\target\debug\deps" "/LIBPATH:C:\Users\paul\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\x86_64-pc-windows-msvc\lib" "C:\Users\paul\Source\rust\netinfo\target\debug\deps\libdefault_net-bda7b53030479e75.rlib" "C:\Users\paul\Source\rust\netinfo\target\debug\deps\libpnet_datalink-dca08bed085d0a8a.rlib" "C:\Users\paul\Source\rust\netinfo\target\debug\deps\libpnet_sys-91cb00b2b318454a.rlib" "C:\Users\paul\Source\rust\netinfo\target\debug\deps\libwinapi-47cc40cf81da0692.rlib" "C:\Users\paul\Source\rust\netinfo\target\debug\deps\liblibc-72f74b019795b39c.rlib" "C:\Users\paul\Source\rust\netinfo\target\debug\deps\libipnetwork-cfbeee74a5d63926.rlib" "C:\Users\paul\Source\rust\netinfo\target\debug\deps\libserde-5e823267d5146cc6.rlib" "C:\Users\paul\Source\rust\netinfo\target\debug\deps\libpnet_packet-fe834420d891dccd.rlib" "C:\Users\paul\Source\rust\netinfo\target\debug\deps\libpnet_macros_support-4ad153696a9ae314.rlib" "C:\Users\paul\Source\rust\netinfo\target\debug\deps\libpnet_base-5b282237a1301c1f.rlib" "C:\Users\paul\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\x86_64-pc-windows-msvc\lib\libstd-d993d47465b92f2a.rlib" "C:\Users\paul\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\x86_64-pc-windows-msvc\lib\libpanic_unwind-37c7849311f1d8d4.rlib" "C:\Users\paul\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\x86_64-pc-windows-msvc\lib\libstd_detect-fd48b10da935ab5c.rlib" "C:\Users\paul\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\x86_64-pc-windows-msvc\lib\librustc_demangle-5e024ec6c173f149.rlib" "C:\Users\paul\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\x86_64-pc-windows-msvc\lib\libhashbrown-3540b4805db710ba.rlib" "C:\Users\paul\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\x86_64-pc-windows-msvc\lib\librustc_std_workspace_alloc-637fbf9b0af4e593.rlib" "C:\Users\paul\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\x86_64-pc-windows-msvc\lib\libunwind-3da750ed88354bea.rlib" "C:\Users\paul\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\x86_64-pc-windows-msvc\lib\libcfg_if-5a35687d8624bf69.rlib" "C:\Users\paul\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\x86_64-pc-windows-msvc\lib\liblibc-5c6e234e3431724c.rlib" "C:\Users\paul\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\x86_64-pc-windows-msvc\lib\liballoc-332dac34332299ae.rlib" "C:\Users\paul\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\x86_64-pc-windows-msvc\lib\librustc_std_workspace_core-665ed95809278e59.rlib" "C:\Users\paul\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\x86_64-pc-windows-msvc\lib\libcore-c2100e40c13f915d.rlib" "C:\Users\paul\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\x86_64-pc-windows-msvc\lib\libcompiler_builtins-360663394438793f.rlib" "iphlpapi.lib" "Packet.lib" "advapi32.lib" "cfgmgr32.lib" "kernel32.lib" "user32.lib" "ws2_32.lib" "kernel32.lib" "ws2_32.lib" "bcrypt.lib" "advapi32.lib" "userenv.lib" "kernel32.lib" "msvcrt.lib" "/NXCOMPAT" "/LIBPATH:C:\Users\paul\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\x86_64-pc-windows-msvc\lib" "/OUT:C:\Users\paul\Source\rust\netinfo\target\debug\deps\netinfo.exe" "/OPT:REF,NOICF" "/DEBUG" "/NATVIS:C:\Users\paul\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\etc\intrinsic.natvis" "/NATVIS:C:\Users\paul\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\etc\liballoc.natvis" "/NATVIS:C:\Users\paul\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\etc\libcore.natvis" "/NATVIS:C:\Users\paul\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\etc\libstd.natvis"
= note: LINK : fatal error LNK1181: cannot open input file 'Packet.lib'

Replace deprecated _kSCNetworkInterfaceTypeBridge symbols

I'm writing to bring to your attention that Apple has deprecated the _kSCNetworkInterfaceTypeBridge symbols. This could potentially lead to issues or compatibility problems in the future. I would like to inquire if it's possible to replace these symbols with a more up-to-date alternative in your library.

Context

  • Symbol: _kSCNetworkInterfaceTypeBridge
  • Deprecated by Apple

Suggested Solution

It would be great if you could consider replacing the deprecated symbols with a suitable alternative to ensure long-term compatibility with the Apple ecosystem.

Additional Information

If you need any further information or assistance, please let me know. I'd be happy to help in any way possible.

Thank you for your attention to this matter, and for your continued work on this library!

Screenshot 2023-04-26 at 11 04 02 AM

Update `windows` dependency to 0.48.0

Current dependency is 0.32.0 which is outdated.

Maybe it should be listed as windows = "0" so the library does not force particular version on the user.

get_interfaces does'nt return gateway for all the interfaces

When I call get_interfaces to list all the interfaces my computer has, it shows all them BUT the only interface that has a gateway listed is the default one. The remaining WAN ports doesn't show a gateway, although OpenWRT interface shows one for them.

[Feature Request] dhcp

Maybe it is nice to check the interface configured dhcp client or not for all platform

/dev/bpf* requires elevated permissions?

On macOS Monterey I have numeric interfaces

$ ls /dev/bpf*
/dev/bpf0	/dev/bpf1	/dev/bpf2	/dev/bpf3

But opening them gives a

Permission denied (os error 13)
-1 Permission denied (os error 13)         
-1 Permission denied (os error 13)       
-1 Permission denied (os error 13) 

Is that expected? Would you be open to a different implementation that doesn't require elevated privs?

Slow execution

default_net::get_interfaces() takes 3 seconds on my ryzen 9 3900x cpu on windows 11.
Seems like an extremely long time for such info?

Fails to build on FreeBSD

Hello,

When I try to build the crate on FreeBSD 13.2 this error pops up(it works just fine on Linux):

default-net-0.20.0/src/bpf/binding.rs:82:1
   |
69 | pub struct bpf_hdr {
   | ------------------ previous definition of the type `bpf_hdr` here
...
82 | pub struct bpf_hdr {
   | ^^^^^^^^^^^^^^^^^^ `bpf_hdr` redefined here
   |
   = note: `bpf_hdr` must be defined only once in the type namespace of this module

There's two distinct definitions of that struct so I assume one applies to some OS(es) but not others

One idea would be to remove

pub struct bpf_hdr {
    pub bh_tstamp: libc::timeval,
    pub bh_caplen: u32,
    pub bh_datalen: u32,
    pub bh_hdrlen: libc::c_ushort,
}

and to add something like this?

#[repr(C)]
pub struct bpf_hdr {
    #[cfg(any(target_os = "freebsd", target_os = "netbsd"))]
    pub bh_tstamp: libc::timeval,
    #[cfg(not(any(target_os = "freebsd", target_os = "netbsd")))]
    pub bh_tstamp: timeval32,
    pub bh_caplen: u32,
    pub bh_datalen: u32,
    pub bh_hdrlen: libc::c_ushort,
}

or maybe the cfg for the struct fields should be the other way around.

thanks very much!

MacOs panic

We have observed an assertion failure in the version assertion in gateway/macos.rs as follows:

thread '<unnamed>' panicked at /Users/andyduplain/.cargo/registry/src/index.crates.io-6f17d22bba15001f/default-net-0.17.0/src/gateway/macos.rs:293:9:
assertion `left == right` failed
  left: 0
 right: 5
stack backtrace:
   0: rust_begin_unwind
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:645:5
   1: core::panicking::panic_fmt
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/panicking.rs:72:14
   2: core::panicking::assert_failed_inner
   3: core::panicking::assert_failed
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/panicking.rs:279:5
   4: default_net::gateway::macos::list_routes
             at /Users/andyduplain/.cargo/registry/src/index.crates.io-6f17d22bba15001f/default-net-0.17.0/src/gateway/macos.rs:293:9
   5: default_net::gateway::macos::get_default_route
             at /Users/andyduplain/.cargo/registry/src/index.crates.io-6f17d22bba15001f/default-net-0.17.0/src/gateway/macos.rs:412:11
   6: default_net::gateway::macos::get_default_gateway
             at /Users/andyduplain/.cargo/registry/src/index.crates.io-6f17d22bba15001f/default-net-0.17.0/src/gateway/macos.rs:431:26
   7: default_net::interface::unix::interfaces
             at /Users/andyduplain/.cargo/registry/src/index.crates.io-6f17d22bba15001f/default-net-0.17.0/src/interface/unix.rs:63:27
   8: default_net::interface::get_default_interface
             at /Users/andyduplain/.cargo/registry/src/index.crates.io-6f17d22bba15001f/default-net-0.17.0/src/interface/mod.rs:134:38

There is only one assert in the macos.rs code,

        assert_eq!(rt_hdr.rtm_version as u32, RTM_VERSION);

which is called after the error check:

        let rt_hdr = unsafe { std::mem::transmute::<_, &rt_msghdr>(buf.as_ptr()) };
        assert_eq!(rt_hdr.rtm_version as u32, RTM_VERSION);
        if rt_hdr.rtm_errno != 0 {
            return Err(code_to_error(rt_hdr.rtm_errno));
        }

Perhaps the error check should go before the assertion?

Before jumping in, note we're currently using 0.17.0.
As a version 0.21.0 is available at the time of this writing, we'll try with the most recent version of the crate and report back.

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.