节点状态记录是否检查到本地防火墙

This commit is contained in:
GoEdgeLab
2022-04-21 18:14:53 +08:00
parent 8d57efee7e
commit e9055a6b60
4 changed files with 17 additions and 1 deletions

View File

@@ -60,6 +60,11 @@ func (this *Firewalld) IsReady() bool {
return this.isReady return this.isReady
} }
// IsMock 是否为模拟
func (this *Firewalld) IsMock() bool {
return false
}
func (this *Firewalld) AllowPort(port int, protocol string) error { func (this *Firewalld) AllowPort(port int, protocol string) error {
if !this.isReady { if !this.isReady {
return nil return nil

View File

@@ -10,6 +10,9 @@ type FirewallInterface interface {
// IsReady 是否已准备被调用 // IsReady 是否已准备被调用
IsReady() bool IsReady() bool
// IsMock 是否为模拟
IsMock() bool
// AllowPort 允许端口 // AllowPort 允许端口
AllowPort(port int, protocol string) error AllowPort(port int, protocol string) error

View File

@@ -20,6 +20,11 @@ func (this *MockFirewall) IsReady() bool {
return true return true
} }
// IsMock 是否为模拟
func (this *MockFirewall) IsMock() bool {
return true
}
// AllowPort 允许端口 // AllowPort 允许端口
func (this *MockFirewall) AllowPort(port int, protocol string) error { func (this *MockFirewall) AllowPort(port int, protocol string) error {
_ = port _ = port

View File

@@ -7,6 +7,7 @@ import (
"github.com/TeaOSLab/EdgeNode/internal/caches" "github.com/TeaOSLab/EdgeNode/internal/caches"
teaconst "github.com/TeaOSLab/EdgeNode/internal/const" teaconst "github.com/TeaOSLab/EdgeNode/internal/const"
"github.com/TeaOSLab/EdgeNode/internal/events" "github.com/TeaOSLab/EdgeNode/internal/events"
"github.com/TeaOSLab/EdgeNode/internal/firewalls"
"github.com/TeaOSLab/EdgeNode/internal/monitor" "github.com/TeaOSLab/EdgeNode/internal/monitor"
"github.com/TeaOSLab/EdgeNode/internal/remotelogs" "github.com/TeaOSLab/EdgeNode/internal/remotelogs"
"github.com/TeaOSLab/EdgeNode/internal/rpc" "github.com/TeaOSLab/EdgeNode/internal/rpc"
@@ -62,7 +63,7 @@ func (this *NodeStatusExecutor) update() {
var tr = trackers.Begin("UPLOAD_NODE_STATUS") var tr = trackers.Begin("UPLOAD_NODE_STATUS")
defer tr.End() defer tr.End()
status := &nodeconfigs.NodeStatus{} var status = &nodeconfigs.NodeStatus{}
status.BuildVersion = teaconst.Version status.BuildVersion = teaconst.Version
status.BuildVersionCode = utils.VersionToLong(teaconst.Version) status.BuildVersionCode = utils.VersionToLong(teaconst.Version)
status.OS = runtime.GOOS status.OS = runtime.GOOS
@@ -74,6 +75,8 @@ func (this *NodeStatusExecutor) update() {
status.CacheTotalMemorySize = caches.SharedManager.TotalMemorySize() status.CacheTotalMemorySize = caches.SharedManager.TotalMemorySize()
status.TrafficInBytes = teaconst.InTrafficBytes status.TrafficInBytes = teaconst.InTrafficBytes
status.TrafficOutBytes = teaconst.OutTrafficBytes status.TrafficOutBytes = teaconst.OutTrafficBytes
var localFirewall = firewalls.Firewall()
status.HasLocalFirewall = localFirewall != nil && !localFirewall.IsMock()
// 记录监控数据 // 记录监控数据
monitor.SharedValueQueue.Add(nodeconfigs.NodeValueItemConnections, maps.Map{ monitor.SharedValueQueue.Add(nodeconfigs.NodeValueItemConnections, maps.Map{