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

Re-add serde support to NetworkInterface #462

Conversation

evanjs
Copy link
Contributor

@evanjs evanjs commented Sep 30, 2020

In #255, the ipnetwork crate was added.
IpNetwork did not yet support Serde, so (de)serialization support using such had to be removed.

As of achanda/ipnetwork@c9e25e1, IpNetwork includes feature-gated serde support

This snippet did not function prior to my changes, but seems to function
fine after re-implementing serde support for IpNetwork

pub fn get_network_interfaces() -> anyhow::Result<Value> {
    let raw_interfaces: Vec<NetworkInterface> = interfaces();
    Ok(json!(raw_interfaces))
}

Result:

[{"flags":65609,"index":1,"ips":["127.0.0.1/8","::1/128"],"mac":"00:00:00:00:00:00","name":"lo"},{"flags":69699,"index":2,"ips":["10.10.0.211/24","fe80::a9d:7071:53a:3da1/64"],"mac":"08:62:66:45:70:18","name":"eno1"},{"flags":4099,"index":3,"ips":["172.17.0.1/16"],"mac":"02:42:91:88:fa:1e","name":"docker0"}]

I understand there was question as to whether this feature was useful, but it seems appropriate to enable it in this case, especially since it is now supported upstream, and requires minimal effort in terms of maintenance for this repository (as far as I understand).

@kishiguro
Copy link
Contributor

Let me re-run the CI for figuring out CI failure root cause.

@mrmonday mrmonday closed this Oct 9, 2020
@mrmonday mrmonday reopened this Oct 9, 2020
In libpnet#255, the ipnetwork crate was added.
IpNetwork did not yet support Serde, so (de)serialization support using such had to be removed.

As of
achanda/ipnetwork@c9e25e1,
IpNetwork includes feature-gated serde support

This snippet did not function prior to my changes, but seems to function
fine after re-implementing serde support for IpNetwork

```rust
pub fn get_network_interfaces() -> anyhow::Result<Value> {
    let raw_interfaces: Vec<NetworkInterface> = interfaces();
    Ok(json!(raw_interfaces))
}
```

Since this is now supported upstream, it seems like a low-risk change.
@mrmonday mrmonday force-pushed the feature/pnet-datalink/NetworkInterface-serde-support branch from d618feb to 0f7754f Compare November 27, 2020 17:39
@mrmonday
Copy link
Contributor

Just rebased this, hopefully CI will pass now.

@mrmonday
Copy link
Contributor

CI is taking too long, gonna merge this and test locally.

@mrmonday mrmonday merged commit 55b19d9 into libpnet:master Nov 27, 2020
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

Successfully merging this pull request may close these issues.

None yet

3 participants