def add_network_connection()

in AWSIoTDeviceDefenderAgentSDK/metrics.py [0:0]


    def add_network_connection(self, remote_addr, remote_port, interface, local_port):
        """
        Add network connection details.

        Parameters
        ----------
        remote_addr: string
            Ip address of the remote peer, can be ipv4 or ipv6
        remote_port: int
            Port of the remote peer
        interface: string
            Name of local network interface associated with the connection
        local_port: int
            Local port of the connection
        """
        ipAddress = remote_addr
        if type(ip_address(remote_addr)) is not IPv4Address:
            ipAddress = "[" + remote_addr + "]"
        new_conn = {self.t.remote_addr: ipAddress + ":" + str(remote_port),
                    self.t.local_interface: interface,
                    self.t.local_port: local_port}

        if new_conn not in self._net_connections:
            self._net_connections.append(new_conn)