in pkg/profiling/task/network/analyze/base/traffic.go [407:435]
func (t *TrafficAnalyzer) findRemotePidWhenMeshEnvironment(con *ConnectionContext) uint32 {
// special handle for mesh application, when it could not match the process through address
if len(con.LocalProcesses) == 0 || !t.ipNotEmpty(con.RemoteIP, con.RemotePort) {
return 0
}
for _, localProcess := range con.LocalProcesses {
// match when the MESH data plane not found the MESH application
if localProcess.Entity().Layer == layerMeshDP {
addresses := t.localAddresses[con.RemoteIP]
if len(addresses) == 0 {
continue
}
if p := addresses[layerMeshApp]; p != nil {
log.Debugf("found in the mesh application, remote ip: %s", con.RemoteIP)
return uint32(p.Pid())
}
continue
}
// if current is mesh application, them it's must be sent to the MESH_DP
if localProcess.Entity().Layer == layerMeshApp &&
len(t.localAddresses[con.RemoteIP]) == 0 && !tools.IsLocalHostAddress(con.RemoteIP) {
if envoyPid := t.findSameInstanceMeshDP(localProcess.Entity()); envoyPid != 0 {
log.Debugf("found in the mesh data plane, remote ip: %s", con.RemoteIP)
return envoyPid
}
}
}
return 0
}