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

Regex support for interfaces in network module #2853

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

madhavpcm
Copy link
Contributor

@madhavpcm madhavpcm commented Oct 28, 2022

What type of PR is this? (check all applicable)

  • Refactor
  • Feature
  • Bug Fix
  • Optimization
  • Documentation Update
  • Other: Replace this with a description of the type of this PR

Description

network module interface now supports regex
interface = wl.* will match any adapter named wlan0 wlan1 etc..

Related Issues & Documents

#2551

Documentation (check all applicable)

  • This PR requires changes to the Wiki documentation (describe the changes)
  • This PR requires changes to the documentation inside the git repo (please add them to the PR).
  • Does not require documentation changes

@codecov
Copy link

codecov bot commented Oct 28, 2022

Codecov Report

Merging #2853 (21bf433) into master (10cdec3) will decrease coverage by 0.02%.
The diff coverage is 0.00%.

@@            Coverage Diff             @@
##           master    #2853      +/-   ##
==========================================
- Coverage   13.17%   13.14%   -0.03%     
==========================================
  Files         162      162              
  Lines       11509    11532      +23     
==========================================
  Hits         1516     1516              
- Misses       9993    10016      +23     
Flag Coverage Δ
unittests 13.14% <0.00%> (-0.03%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
include/adapters/net.hpp 0.00% <ø> (ø)
src/adapters/net.cpp 0.00% <0.00%> (ø)
src/modules/network.cpp 0.00% <0.00%> (ø)
include/modules/meta/base.inl 0.00% <0.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

src/modules/network.cpp Outdated Show resolved Hide resolved
src/modules/network.cpp Outdated Show resolved Hide resolved
* Added warning message

* Fixed memory Leak

* Running adapters get preference
Copy link
Member

@patrick96 patrick96 left a comment

Choose a reason for hiding this comment

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

Please also run clang-format on the files you changed.

struct ifaddrs* ifaddrs;

if (regexpr.empty())
return "";
Copy link
Member

Choose a reason for hiding this comment

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

missing braces

m_interface = net::find_interface_regex(m_interface);

if (!m_interface.empty())
m_log.notice("%s: Matched regex %s with interface %s", name(), regexpr, m_interface);
Copy link
Member

Choose a reason for hiding this comment

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

Missing braces

m_interface = net::find_interface_regex(m_interface);

if (!m_interface.empty())
m_log.notice("%s: Matched regex %s with interface %s", name(), regexpr, m_interface);

if (m_interface.empty()) {
Copy link
Member

Choose a reason for hiding this comment

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

If the regex doesn't match any interface, the module will shut down with the message Missing parameter "module/wireless.interface-type" because m_interface is empty again here.

If we tried to match using regex, we shouldn't try to use interface-type, so something like this:

if (!m_interface.empty()) {
  // match regex
} else {
  // find interface type
}

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

2 participants