fix ip report bug

This commit is contained in:
yuzuki999 2022-08-19 22:42:51 +08:00
parent 27b97927c1
commit ca2669a575

View File

@ -108,10 +108,12 @@ func (c *Node) Start() error {
time.Sleep(time.Duration(c.config.UpdatePeriodic) * time.Second)
_ = c.userReportPeriodic.Start()
}()
if c.config.EnableIpRecorder {
c.onlineIpReportPeriodic = &task.Periodic{
Interval: time.Duration(c.config.UpdatePeriodic) * 30,
Interval: time.Duration(c.config.IpRecorderConfig.Periodic) * time.Second,
Execute: c.onlineIpReport,
}
}
log.Printf("[%s: %d] Start report online ip", c.nodeInfo.NodeType, c.nodeInfo.NodeId)
// delay to start onlineIpReport
go func() {
@ -381,12 +383,14 @@ func (c *Node) userInfoMonitor() (err error) {
}
}
userTraffic = nil
if !c.config.EnableIpRecorder {
c.server.ClearOnlineIps(c.Tag)
}
runtime.GC()
return nil
}
func (c *Node) onlineIpReport() (err error) {
if c.config.EnableIpRecorder {
onlineIp, err := c.server.GetOnlineIps(c.Tag)
if err != nil {
log.Print(err)
@ -417,9 +421,6 @@ func (c *Node) onlineIpReport() (err error) {
} else {
c.server.ClearOnlineIps(c.Tag)
}
} else {
c.server.ClearOnlineIps(c.Tag)
}
return nil
}