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

feat(config): wildcard interface name support & refactor lazybind #758

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

LostAttractor
Copy link
Contributor

@LostAttractor LostAttractor commented Feb 20, 2025

Background

#724
该PR抽象了lazybind的能力以便后续其他功能使用(主要是后续在routing中过滤interface需要)
该PR实现的功能与 #729 类似
此外,为wan也加入了lazybind

Checklist

Full Changelogs

  • interface name now support wildcard
  • wan interface now support lazybind

Issue Reference

Closes #724
Closes #729

Test Result

@mzz2017
Copy link
Contributor

mzz2017 commented Feb 20, 2025

#724是个issue,不是pr

@mzz2017
Copy link
Contributor

mzz2017 commented Feb 20, 2025

Closes #724
Closes #729

@@ -0,0 +1,117 @@
package control
Copy link
Contributor

Choose a reason for hiding this comment

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

把这个 interface manager 组件放到 components 里?

callbacks []callbackSet
}

func newInterfaceManager(log *logrus.Logger, closed context.Context) *InterfaceManager {
Copy link
Contributor

Choose a reason for hiding this comment

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

按照约定,ctx 应该放到第一个参数,就叫 ctx 就好,代表生命周期。不过我建议不是传入 ctx(因为有歧义,也可能代表这个函数的生命周期),而是可以在 newXXX 函数里 context.WithCancel 并对该 struct 实现 Close() error 接口。

}

switch update.Header.Type {
case unix.RTM_NEWLINK:
Copy link
Contributor

Choose a reason for hiding this comment

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

根据 #729,NEWLINK 事件可能会由多种事件触发,是否要判断 UpFlag == 0?或者在 cb 函数里自己判断
这里需要测试一下用户说的 pppoe 断开重连场景

return err
}
newlinkCallback := func(link netlink.Link) {
if link.Attrs().Name == "dae0" {
Copy link
Contributor

Choose a reason for hiding this comment

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

dae0 是否有对应的 const?能否对所有出现的 dae0 string 统一抽象出 const?

if link.Attrs().Name == "dae0" {
return
}
c.log.Warnf("New link creation of '%v' is detected. Bind LAN program to it.", link.Attrs().Name)
Copy link
Contributor

@woshikedayaa woshikedayaa Feb 21, 2025

Choose a reason for hiding this comment

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

日志应该打 Bind WAN ,包括下面也有一行日志错误。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature Request] Wildcard / Regexp support for LAN interface name
3 participants