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