in AWSIoTDeviceDefenderAgentSDK/metrics.py [0:0]
def add_listening_ports(self, protocol, ports):
"""
Add a sets of listening ports for a particular protocol.
Parameters
----------
protocol: string
TCP or UDP, all others invalid and will not be added
ports: list
List of Dictionaries, each dictionary should have a "port" and optionally an "interface" key.
Example Dictionary: {'port': 80, 'interface': 'eth0'}
"""
if protocol.upper() == "UDP":
for p in ports:
if p not in self.listening_udp_ports:
self.listening_udp_ports += ports
elif protocol.upper() == "TCP":
for p in ports:
if p not in self.listening_tcp_ports:
self.listening_tcp_ports += ports
else:
print(("Invalid Protocol: " + protocol))