@@ -37,7 +37,7 @@ func (m *NetstatModule) Name() string {
37
37
}
38
38
39
39
func (m * NetstatModule ) Dependencies () []string {
40
- return []string {"host-basic" }
40
+ return []string {"host-basic" , "host-network" }
41
41
}
42
42
43
43
func flowFilter (state netstat.SkState ) bool {
@@ -58,12 +58,15 @@ func flowFilter(state netstat.SkState) bool {
58
58
59
59
// portFilter returns true when the connection is listening, established or close-wait
60
60
func portFilter (e * netstat.SockTabEntry ) bool {
61
- if e .LocalAddr .IP .IsLoopback () && ! e .RemoteAddr .IP .IsLoopback () {
62
- return false
63
- }
61
+ // accept everything
64
62
if e .State == netstat .Listen || flowFilter (e .State ) {
65
63
return true
66
64
}
65
+ // fmt.Println(e.LocalAddr.IP, ":", e.LocalAddr.Port, " -> ", e.RemoteAddr.IP, ":", e.RemoteAddr.Port)
66
+ // if e.LocalAddr.IP.IsLoopback() && !e.RemoteAddr.IP.IsLoopback() {
67
+ // return false
68
+ // }
69
+
67
70
return false
68
71
}
69
72
@@ -99,11 +102,6 @@ func (m *NetstatModule) Run() error {
99
102
continue
100
103
}
101
104
102
- // (NEW!) create localhost if needed (localhost communication)
103
- if entry .LocalAddr .IP .IsLoopback () && entry .RemoteAddr .IP .IsLoopback () {
104
- machine .GetOrCreateHostLoopback (entry .LocalAddr .IP )
105
- }
106
-
107
105
name := entry .Process .Name
108
106
args , err := utils .GetCmd (entry .Process .Pid )
109
107
if err == nil && len (args ) > 0 {
@@ -146,21 +144,23 @@ func (m *NetstatModule) Run() error {
146
144
soft .Args = args
147
145
}
148
146
149
- endpoint , created := soft .AddEndpoint (
150
- entry .LocalAddr .IP ,
151
- entry .LocalAddr .Port ,
152
- protocols [k ])
153
- // fmt.Printf("%+v\n", soft)
154
- // fmt.Printf("len: %v, cap: %v, %v\n",
155
- // len(soft.Endpoints), cap(soft.Endpoints), soft.Endpoints)
156
- if created {
157
- // fmt.Println(len(soft.Endpoints))
158
- // logging
159
- l := logger .WithField ("app" , soft .Name )
160
- l = l .WithField ("ip" , endpoint .Addr )
161
- l = l .WithField ("port" , endpoint .Port )
162
- l = l .WithField ("proto" , endpoint .Protocol )
163
- l .Info ("Endpoint found" )
147
+ if entry .State == netstat .Listen {
148
+ endpoint , created := soft .AddEndpoint (
149
+ entry .LocalAddr .IP ,
150
+ entry .LocalAddr .Port ,
151
+ protocols [k ])
152
+ // fmt.Printf("%+v\n", soft)
153
+ // fmt.Printf("len: %v, cap: %v, %v\n",
154
+ // len(soft.Endpoints), cap(soft.Endpoints), soft.Endpoints)
155
+ if created {
156
+ // fmt.Println(len(soft.Endpoints))
157
+ // logging
158
+ l := logger .WithField ("app" , soft .Name )
159
+ l = l .WithField ("ip" , endpoint .Addr )
160
+ l = l .WithField ("port" , endpoint .Port )
161
+ l = l .WithField ("proto" , endpoint .Protocol )
162
+ l .Info ("Endpoint found" )
163
+ }
164
164
}
165
165
}
166
166
}
0 commit comments