@@ -482,7 +482,8 @@ func (c *ConnectionManager) isLocalTarget(pair *ip.SocketPair) addressProcessTyp
482
482
483
483
func (c * ConnectionManager ) AddNewProcess (pid int32 , entities []api.ProcessInterface ) {
484
484
// filtering the namespace
485
- if c .shouldExcludeTheProcess (entities ) {
485
+ monitorProcesses := c .shouldMonitorProcesses (entities )
486
+ if len (monitorProcesses ) == 0 {
486
487
c .RemoveProcess (pid , entities )
487
488
return
488
489
}
@@ -491,9 +492,9 @@ func (c *ConnectionManager) AddNewProcess(pid int32, entities []api.ProcessInter
491
492
defer c .monitoringProcessLock .Unlock ()
492
493
493
494
// adding monitoring process and IP addresses
494
- c .monitoringProcesses [pid ] = entities
495
+ c .monitoringProcesses [pid ] = monitorProcesses
495
496
c .updateMonitorStatusForProcess (pid , true )
496
- for _ , entity := range entities {
497
+ for _ , entity := range monitorProcesses {
497
498
for _ , host := range entity .ExposeHosts () {
498
499
c .localIPWithPid [host ] = pid
499
500
}
@@ -529,8 +530,8 @@ func (c *ConnectionManager) printTotalAddressesWithPid(prefix string) {
529
530
log .Debugf ("----------------------------" )
530
531
}
531
532
532
- func (c * ConnectionManager ) shouldExcludeTheProcess (entities []api.ProcessInterface ) bool {
533
- return c .monitorFilter .ShouldExclude (entities )
533
+ func (c * ConnectionManager ) shouldMonitorProcesses (entities []api.ProcessInterface ) []api. ProcessInterface {
534
+ return c .monitorFilter .ShouldIncludeProcesses (entities )
534
535
}
535
536
536
537
func (c * ConnectionManager ) RemoveProcess (pid int32 , entities []api.ProcessInterface ) {
@@ -549,10 +550,11 @@ func (c *ConnectionManager) RemoveProcess(pid int32, entities []api.ProcessInter
549
550
func (c * ConnectionManager ) RecheckAllProcesses (processes map [int32 ][]api.ProcessInterface ) {
550
551
shouldMonitoringProcesses := make (map [int32 ][]api.ProcessInterface )
551
552
for pid , p := range processes {
552
- if c .shouldExcludeTheProcess (p ) {
553
+ monitorProcesses := c .shouldMonitorProcesses (p )
554
+ if len (monitorProcesses ) == 0 {
553
555
continue
554
556
}
555
- shouldMonitoringProcesses [pid ] = p
557
+ shouldMonitoringProcesses [pid ] = monitorProcesses
556
558
}
557
559
// checking the monitoring process
558
560
c .monitoringProcesses = shouldMonitoringProcesses
0 commit comments