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: allow group override global node connectivity check #623

Merged
merged 7 commits into from
Sep 8, 2024

Conversation

KagurazakaNyaa
Copy link
Contributor

@KagurazakaNyaa KagurazakaNyaa commented Sep 7, 2024

Background

此Pull Request允许group配置覆盖global配置中的节点联通性检查以支持更加灵活的场景

Checklist

Full Changelogs

  • 允许group段中的配置覆盖global的节点联通性检查配置
  • 当group中未定义这些新的配置时,行为应当和之前完全一致
  • 当group中存在这些新配置时,所有此group的dialer将会被克隆并修改联通性检查配置

Issue Reference

Closes #619

Test Result

测试环境

Archlinux

$ uname -a
Linux secops 6.10.8-zen1-1-zen #1 ZEN SMP PREEMPT_DYNAMIC Wed, 04 Sep 2024 15:18:31 +0000 x86_64 GNU/Linux

构建

$ make
git submodule update --init --recursive -- trace/kern/headers && \
touch trace/kern/headers
-no-strip
Compiled /home/kagurazakanyaa/src/dae/control/bpf_bpfel.o
Wrote /home/kagurazakanyaa/src/dae/control/bpf_bpfel.go
Compiled /home/kagurazakanyaa/src/dae/control/bpf_bpfeb.o
Wrote /home/kagurazakanyaa/src/dae/control/bpf_bpfeb.go
Compiled /home/kagurazakanyaa/src/dae/trace/bpf_bpfel_x86.o
Wrote /home/kagurazakanyaa/src/dae/trace/bpf_bpfel_x86.go
-DMAX_MATCH_SET_LEN=64 -O2 -Wall -Werror
go build -tags=trace -o dae -trimpath -ldflags "-s -w -X github.com/daeuniverse/dae/cmd.Version=unstable-20240907.r731.b03348d -X github.com/daeuniverse/dae/common/consts.MaxMatchSetLen_=64"  .
$ sudo cp ./dae /usr/bin/dae

测试

未更改原有配置的情况下,systemd启动服务正常运行
执行sudo /usr/bin/dae validate -c /etc/dae/config.dae返回值0

修改配置后,systemctl restart dae.service
主要变更的配置

global {
  tcp_check_url: 'https://cp.cloudflare.com'
}
group {
  proxy {
    filter: subtag([redacted]) && name(keyword: '日本', keyword: '新加坡' , keyword: '美国' , keyword: '台湾')
    filter: subtag([redacted]) && name(keyword: '[redacted]')
    filter: subtag([redacted]) && name(keyword: 'AnyPath', keyword: 'PVCC', keyword: '日本', keyword: '新加坡', keyword: 'IPLC' , keyword: 'IEPL') && !name(keyword: '香港', keyword: '印度')
    policy: min_moving_avg
  }
aur {
    filter: subtag([redacted]) && name(keyword: '日本', keyword: '新加坡' , keyword: '美国' , keyword: '台湾')
    filter: subtag([redacted]) && name(keyword: '[redacted]')
	policy: min_moving_avg
    tcp_check_url: 'https://aur.archlinux.org'
  }
}

routing {
  domain(suffix:archlinux.org) -> aur
  fallback: proxy
}

检查日志

level=info msg="Group "aur"'s check option has been override."

且proxy组没有此日志
代理正常运行

内存使用情况

$ systemctl status dae
● dae.service - dae Service
     Loaded: loaded (/usr/lib/systemd/system/dae.service; enabled; preset: disabled)
    Drop-In: /etc/systemd/system/dae.service.d
             └─override.conf
     Active: active (running) since Sat 2024-09-07 11:00:20 CST; 6min ago
 Invocation: 086a390b131e41c4932c65be943bf4c8
       Docs: https://github.com/daeuniverse/dae
    Process: 711204 ExecStartPre=/usr/bin/dae validate -c /etc/dae/config.dae (code=exited, status=0/SUCCESS)
   Main PID: 711258 (dae)
      Tasks: 22 (limit: 56940)
     Memory: 234.4M (peak: 248.1M)
        CPU: 5.856s
     CGroup: /system.slice/dae.service
             └─711258 /usr/bin/dae run --disable-timestamp -c /etc/dae/config.dae

9月 07 11:00:11 secops systemd[1]: Starting dae Service...
9月 07 11:00:20 secops systemd[1]: Started dae Service.

修改配置添加

group {
  steam {
    filter: subtag([redacted]) && name(keyword: '日本', keyword: '新加坡' , keyword: '美国' , keyword: '台湾')
    filter: subtag([redacted]) && name(keyword: '[redacted]')
    policy: min_moving_avg
    tcp_check_url: 'http://test.steampowered.com'
  }
}
routing {
  domain(suffix:steampowered.com) -> steam
  domain(suffix:steamcommunity.com) -> steam
  domain(suffix:steamserver.net) -> steam
  domain(suffix:steam-chat.com) -> steam
}

重启后内存使用没有显著增加

$ systemctl status dae
● dae.service - dae Service
     Loaded: loaded (/usr/lib/systemd/system/dae.service; enabled; preset: disabled)
    Drop-In: /etc/systemd/system/dae.service.d
             └─override.conf
     Active: active (running) since Sat 2024-09-07 11:12:23 CST; 3min 12s ago
 Invocation: 68cc1e49dcfb42e2a7081b0561fefc99
       Docs: https://github.com/daeuniverse/dae
    Process: 766530 ExecStartPre=/usr/bin/dae validate -c /etc/dae/config.dae (code=exited, status=0/SUCCESS)
   Main PID: 766579 (dae)
      Tasks: 22 (limit: 56940)
     Memory: 240.8M (peak: 242.5M)
        CPU: 4.279s
     CGroup: /system.slice/dae.service
             └─766579 /usr/bin/dae run --disable-timestamp -c /etc/dae/config.dae

9月 07 11:12:15 secops systemd[1]: Starting dae Service...
9月 07 11:12:23 secops systemd[1]: Started dae Service.

control/control_plane.go Show resolved Hide resolved
control/control_plane.go Outdated Show resolved Hide resolved
example.dae Outdated Show resolved Hide resolved
example.dae Outdated Show resolved Hide resolved
control/control_plane.go Outdated Show resolved Hide resolved
@mzz2017
Copy link
Contributor

mzz2017 commented Sep 7, 2024

非常感谢你的贡献,代码质量看起来很不错

@KagurazakaNyaa
Copy link
Contributor Author

@mzz2017 上述提及的代码均已按建议修改,请再次review

mzz2017
mzz2017 previously approved these changes Sep 8, 2024
Copy link
Contributor

@mzz2017 mzz2017 left a comment

Choose a reason for hiding this comment

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

LGTM!

@mzz2017
Copy link
Contributor

mzz2017 commented Sep 8, 2024

等待第三方测试后合入

Copy link
Contributor

@dae-prow dae-prow bot left a comment

Choose a reason for hiding this comment

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

🧪 Since the PR has been fully tested, please consider merging it.

@mzz2017
Copy link
Contributor

mzz2017 commented Sep 8, 2024

测试一切正常,能正常工作

@mzz2017 mzz2017 merged commit 9f04adf into daeuniverse:main Sep 8, 2024
26 checks passed
@QiuSimons
Copy link

@mzz2017 @KagurazakaNyaa 应用这个pr后编译基于此版本dae的daed,会导致daed更新订阅出错,无法获取到节点
报错如下
https://pastebin.com/RMCGjJad

@KagurazakaNyaa
Copy link
Contributor Author

@mzz2017 @KagurazakaNyaa 应用这个pr后编译基于此版本dae的daed,会导致daed更新订阅出错,无法获取到节点 报错如下 https://pastebin.com/RMCGjJad

看了一下报错在 https://github.com/KagurazakaNyaa/dae/blob/d8fad755979e87fdb448eead497a650a18a23cf1/component/outbound/dialer/dialer.go#L101 似乎是打日志的时候引用了空指针
@mzz2017 请确认一下d.Property().Namedialer有这个属性吗,我好像没有找到,也许不应该使用这个字段来在日志中区分dialer?

@mzz2017
Copy link
Contributor

mzz2017 commented Sep 12, 2024

@KagurazakaNyaa 应该是 daed 在 new dialer 的时候没有传入 property,而是传的空指针导致的,要改一下 dae-wing

mnixry pushed a commit to mnixry/dae that referenced this pull request Sep 18, 2024
@wanlce
Copy link
Contributor

wanlce commented Sep 20, 2024

@mzz2017
daed 这边报错是因为 option.Log 为 nil

option.Log.WithField("dialer", d.Property().Name).

@mzz2017
Copy link
Contributor

mzz2017 commented Sep 20, 2024

@wanlce 可否帮忙修一下?

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.

[Enhancement] 对每个group支持配置单独的节点连通性检查策略
4 participants