MCPcopy Create free account
hub / github.com/GoEdgeLab/EdgeNode / init

Function init

internal/firewalls/nftables/installer.go:20–53  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

18)
19
20func init() {
21 if !teaconst.IsMain {
22 return
23 }
24
25 events.On(events.EventReload, func() {
26 // linux only
27 if runtime.GOOS != "linux" {
28 return
29 }
30
31 nodeConfig, err := nodeconfigs.SharedNodeConfig()
32 if err != nil {
33 return
34 }
35
36 if nodeConfig == nil || !nodeConfig.AutoInstallNftables {
37 return
38 }
39
40 if os.Getgid() == 0 { // root user only
41 if len(NftExePath()) > 0 {
42 return
43 }
44 goman.New(func() {
45 err := NewInstaller().Install()
46 if err != nil {
47 // 不需要传到API节点
48 logs.Println("[NFTABLES]install nftables failed: " + err.Error())
49 }
50 })
51 }
52 })
53}
54
55// NftExePath 查找nftables可执行文件路径
56func NftExePath() string {

Callers

nothing calls this directly

Calls 6

OnFunction · 0.92
NewFunction · 0.92
NftExePathFunction · 0.85
NewInstallerFunction · 0.85
InstallMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected