mirror of
https://github.com/safing/portmaster
synced 2025-09-01 10:09:11 +00:00
Fix minor issues
This commit is contained in:
parent
f35872ec51
commit
7da7ebf183
6 changed files with 27 additions and 16 deletions
6
main.go
6
main.go
|
@ -71,16 +71,14 @@ func main() {
|
|||
fmt.Println("=== END STACK ===")
|
||||
}
|
||||
|
||||
go func() {
|
||||
modules.Shutdown()
|
||||
os.Exit(0)
|
||||
}()
|
||||
go func() {
|
||||
time.Sleep(3 * time.Second)
|
||||
fmt.Println("===== TAKING TOO LONG FOR SHUTDOWN - PRINTING STACK TRACES =====")
|
||||
pprof.Lookup("goroutine").WriteTo(os.Stdout, 2)
|
||||
os.Exit(1)
|
||||
}()
|
||||
modules.Shutdown()
|
||||
os.Exit(0)
|
||||
|
||||
case <-modules.ShuttingDown():
|
||||
}
|
||||
|
|
|
@ -9,9 +9,9 @@ import (
|
|||
)
|
||||
|
||||
var (
|
||||
cleanerTickDuration = 1 * time.Minute
|
||||
deadLinksTimeout = 5 * time.Minute
|
||||
thresholdDuration = 1 * time.Minute
|
||||
cleanerTickDuration = 10 * time.Second
|
||||
deadLinksTimeout = 3 * time.Minute
|
||||
thresholdDuration = 3 * time.Minute
|
||||
)
|
||||
|
||||
func cleaner() {
|
||||
|
@ -19,9 +19,9 @@ func cleaner() {
|
|||
time.Sleep(cleanerTickDuration)
|
||||
|
||||
cleanLinks()
|
||||
time.Sleep(10 * time.Second)
|
||||
time.Sleep(2 * time.Second)
|
||||
cleanConnections()
|
||||
time.Sleep(10 * time.Second)
|
||||
time.Sleep(2 * time.Second)
|
||||
cleanProcesses()
|
||||
}
|
||||
}
|
||||
|
@ -32,6 +32,9 @@ func cleanLinks() {
|
|||
now := time.Now().Unix()
|
||||
deleteOlderThan := time.Now().Add(-deadLinksTimeout).Unix()
|
||||
|
||||
// log.Tracef("network.clean: now=%d", now)
|
||||
// log.Tracef("network.clean: deleteOlderThan=%d", deleteOlderThan)
|
||||
|
||||
linksLock.RLock()
|
||||
defer linksLock.RUnlock()
|
||||
|
||||
|
@ -39,11 +42,15 @@ func cleanLinks() {
|
|||
for key, link := range links {
|
||||
|
||||
// delete dead links
|
||||
link.Lock()
|
||||
deleteThis := link.Ended > 0 && link.Ended < deleteOlderThan
|
||||
link.Unlock()
|
||||
if deleteThis {
|
||||
go link.Delete()
|
||||
if link.Ended > 0 {
|
||||
link.Lock()
|
||||
deleteThis := link.Ended < deleteOlderThan
|
||||
link.Unlock()
|
||||
if deleteThis {
|
||||
// log.Tracef("network.clean: deleted %s", link.DatabaseKey())
|
||||
go link.Delete()
|
||||
}
|
||||
|
||||
continue
|
||||
}
|
||||
|
||||
|
@ -59,6 +66,7 @@ func cleanLinks() {
|
|||
// mark end time
|
||||
if !found {
|
||||
link.Ended = now
|
||||
// log.Tracef("network.clean: marked %s as ended.", link.DatabaseKey())
|
||||
go link.Save()
|
||||
}
|
||||
|
||||
|
@ -73,6 +81,7 @@ func cleanConnections() {
|
|||
for _, conn := range connections {
|
||||
conn.Lock()
|
||||
if conn.FirstLinkEstablished < threshold && conn.LinkCount == 0 {
|
||||
// log.Tracef("network.clean: deleted %s", conn.DatabaseKey())
|
||||
go conn.Delete()
|
||||
}
|
||||
conn.Unlock()
|
||||
|
|
|
@ -268,6 +268,7 @@ func (conn *Connection) Delete() {
|
|||
conn.Meta().Delete()
|
||||
go dbController.PushUpdate(conn)
|
||||
conn.process.RemoveConnection()
|
||||
go conn.process.Save()
|
||||
}
|
||||
|
||||
// AddLink applies the connection to the link and increases sets counter and timestamps.
|
||||
|
|
|
@ -263,6 +263,7 @@ func (link *Link) Delete() {
|
|||
link.Meta().Delete()
|
||||
go dbController.PushUpdate(link)
|
||||
link.connection.RemoveLink()
|
||||
go link.connection.Save()
|
||||
}
|
||||
|
||||
// GetLink fetches a Link from the database from the default namespace for this object
|
||||
|
|
|
@ -9,6 +9,7 @@ var (
|
|||
6: "TCP",
|
||||
17: "UDP",
|
||||
27: "RDP",
|
||||
58: "ICMPv6",
|
||||
33: "DCCP",
|
||||
136: "UDPLite",
|
||||
}
|
||||
|
@ -20,6 +21,7 @@ var (
|
|||
"UDP": 17,
|
||||
"RDP": 27,
|
||||
"DCCP": 33,
|
||||
"ICMPv6": 58,
|
||||
"UDPLite": 136,
|
||||
}
|
||||
)
|
||||
|
|
|
@ -9,7 +9,7 @@ const (
|
|||
|
||||
var (
|
||||
UnknownDirectConnection = &Connection{
|
||||
Domain: "D",
|
||||
Domain: "PI",
|
||||
Direction: Outbound,
|
||||
Verdict: DROP,
|
||||
Reason: ReasonUnknownProcess,
|
||||
|
@ -17,7 +17,7 @@ var (
|
|||
}
|
||||
|
||||
UnknownIncomingConnection = &Connection{
|
||||
Domain: "I",
|
||||
Domain: "II",
|
||||
Direction: Inbound,
|
||||
Verdict: DROP,
|
||||
Reason: ReasonUnknownProcess,
|
||||
|
|
Loading…
Add table
Reference in a new issue