MCPcopy Create free account
hub / github.com/aaPanel/BaoTa / _get_ports_by_pid

Method _get_ports_by_pid

mod/project/python/serviceMod.py:286–294  ·  view source on GitHub ↗
(pid: int)

Source from the content-addressed store, hash-verified

284
285 @staticmethod
286 def _get_ports_by_pid(pid: int) -> List[int]:
287 try:
288 res = set()
289 for con in psutil.Process(pid).connections():
290 if con.status == 'LISTEN':
291 res.add(con.laddr.port)
292 return list(res)
293 except:
294 return []
295
296 def get_info(self) -> Dict[str, Any]:
297 if not self.env:

Callers 1

get_infoMethod · 0.95

Calls 2

setFunction · 0.50
addMethod · 0.45

Tested by

no test coverage detected