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

LocalIp: support get interface flags #1315

Merged
merged 1 commit into from
Oct 5, 2024

Conversation

apocelipes
Copy link
Contributor

Each net interface has its flags. These flags show the interface and its IP's status/capabilities.

Flags have already been reported by 'ifconfig' and 'ip addr' commands:

ifconfig

Add the same capability to fastfetch:

Snipaste_2024-10-04_19-49-37
Snipaste_2024-10-04_20-42-56

I also added a new option '--localip-show-flags' to control whether getting interface flags (the default value is FALSE).

@apocelipes
Copy link
Contributor Author

Spellcheck's error is a noise.
image

This is just a flag name, we can do nothing about it.

{
.flag = IFF_UP,
.name = "UP",
},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer { IFF_UP, "UP" } so that they take less spaces.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

{
if (ioctl(sockfd, SIOCGIFFLAGS, &ifr) == 0)
writeNIFlagsToStrBuf(&iface->flags, ifr.ifr_flags, nicFlags);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't it ifa->ifa_flags?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getifaddrs will return all interfaces in the local system which we already got. It might be heavier than creating a socket then calling a ioctl.
And manpages say this function is not a part of the standard, it could be different on other systems.
So, I think using ioctl and ifreq here may be enough.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But we have already called getifaddrs. Why not reuse its result?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, getifaddrs already called.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this advice, I'll change to reuse its result.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@CarterLi
Copy link
Member

CarterLi commented Oct 4, 2024

This is just a flag name, we can do nothing about it.

You should add it to .codespellrc. You should also add this flag to json_schema.json

@apocelipes
Copy link
Contributor Author

This is just a flag name, we can do nothing about it.

You should add it to .codespellrc. You should also add this flag to json_schema.json

Done.

@CarterLi CarterLi merged commit 40ab735 into fastfetch-cli:dev Oct 5, 2024
16 checks passed
@apocelipes apocelipes deleted the feat/nic-flags branch October 5, 2024 07:13
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.

2 participants